How do I schedule a JBoss task? - jboss

I have scheduled task in JBoss:
<?xml version="1.0" encoding="UTF-8"?>
<server>
<mbean code="org.jboss.varia.scheduler.Scheduler" name="acme:service=Scheduler">
<attribute name="...">...</attribute>
.....
</mbean>
</server>
How to write this task, that will execute at 1:00 AM on the first day of every month?
Thank You!

You'll need to create a scheduling class. org.jboss.varia.scheduler.Scheduler
Since you want to perform monthly and cannot state this as a attribute. You'll need to have another Class which handles setting the next interval. Java Monthly Timer
Have the scheduler class call the monthly timer to get the next interval and set it. Maybe pass some values at initial start.
<mbean code="org.jboss.varia.scheduler.Scheduler"
name="jboss.docs:service=Scheduler">
<attribute name="StartAtStartup">true</attribute>
<attribute name="SchedulableClass">org.jboss.book.misc.ex2.ExSchedulable</attribute>
<attribute name="SchedulableArguments">01:00</attribute> <!-- 24hr time hh:mm -->
<attribute name="SchedulableArgumentTypes">java.lang.String</attribute>
</mbean>
ExSchedulable (this is just pseudo-code)
public ExSchedulable(String time) {
Date tDate = new Date();
tDate.setTime(time);
Monthly monthyObj = Monthly(1); //Day of the month
//Gets the next interval date specified from the day of the month
Date nextInterval = monthyObj .getNextInterval(tDate);
}

Related

CalDAV finds recurring event outside of search range

I am trying to retrieve all events (recurring or not) between 2 date-times from a Synology calendar via CalDAV:
curl --user "user:password" -X REPORT --data '<?xml version="1.0" encoding="UTF-8"?>
<C:calendar-query xmlns:C="urn:ietf:params:xml:ns:caldav" xmlns:D="DAV:">
<D:prop>
<C:calendar-data>
<C:expand start="20230207T100000Z" end="20230207T110000Z" />
</C:calendar-data>
</D:prop>
<C:filter>
<C:comp-filter name="VCALENDAR">
<C:comp-filter name="VEVENT">
<C:time-range start="20230207T100000Z" end="20230207T110000Z" />
</C:comp-filter>
</C:comp-filter>
</C:filter>
</C:calendar-query>' https://server/caldav.php/user/calid/
The query above finds the following all day recurring event. The event is recurring weekly before and after the queried date-time, but not within the time-range.
<?xml version="1.0" encoding="utf-8" ?>
<multistatus xmlns="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
<response>
<href>/caldav.php/user/calid/eventid.ics</href>
<propstat>
<prop>
<C:calendar-data>BEGIN:VCALENDAR
CALSCALE:GREGORIAN
PRODID:xxx
VERSION:2.0
BEGIN:VEVENT
CREATED:20230201T210000Z
DTSTAMP:20230201T210000Z
LAST-MODIFIED:20230201T210000Z
SEQUENCE:0
SUMMARY:My Weekly Monday Event
TRANSP:OPAQUE
UID:xxx-xxx-xxx-xxx-xxx
URL;VALUE=URI:
DTSTART;VALUE=DATE:20230206
DURATION:P1D
RECURRENCE-ID;VALUE=DATE:20230206
END:VEVENT
END:VCALENDAR
</C:calendar-data>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
</multistatus>
Notice I am looking for events on February 7th while the event happens on February 6th. If I change the search range to February 8th the event is no longer included.
Any idea why the event is included in the result? The recurring event does show correctly in Evolution, iOS, and Synology, so I am probably doing something wrong.

Adobe AEM CQ XSS filter

In my author I am editing a text component and adding the following html:
<li><span>test text</span></li>
However, When I switch to preview mode the html that render is:
<li><span><a class="tt" href="#">Test text</a></span></li>
It looks like AEM is stripping out some attributes. Any ideas why?
MORE INFO
After more reading, I think I narrowed it down to adding the attributes to /libs/cq/xssprotection/config.xml. However, pages stop loading when I add this:
<tag name="div" action="validate">
<attribute name="align"/>
<attribute name="data-toggle">
<regexp-list>
<regexp name="data-toggle"/>
</regexp-list>
</attribute>
<attribute name="data-html">
<regexp-list>
<regexp name="data-html"/>
</regexp-list>
</attribute>
<attribute name="data-placement">
<regexp-list>
<regexp name="data-placement"/>
</regexp-list>
</attribute>
<attribute name="data-content">
<regexp-list>
<regexp name="data-content"/>
</regexp-list>
</attribute>
</tag>
Do I have the incorrect syntax?
This is because you are using the OOTB text component and the OOTB text component uses <cq:text> tag to display the text configured in the component. Something similar to the one shown below.
<cq:text property="text" escapeXml="true" ... />
Behind the scenes, when the escapeXml attribute is set to true, it internally calls the #filterHTML method of XSSAPI, the output of which stripped all your data attributes.
You can overlay the text component and remove the escapeXml attribute if required or implement your logic after overlaying as per the requirements.

What kind of a date format is this? 437432903.96807599067687988281

Somehow 437432903.96807599067687988281 translates to November 11, 2014, 4:08pm, but I'm not sure how.
Edit: The context is I'm trying to export data from Thyme, a menubar timer for Mac. It's recorded in an XML file called storedata. For example:
<object type="SESSION" id="z102">
<attribute name="seconds" type="int32">43</attribute>
<attribute name="minutes" type="int32">10</attribute>
<attribute name="hours" type="int32">4</attribute>
<attribute name="date" type="date">437432903.96807599067687988281</attribute>
</object>
Apple's OS X Objective C application framework Cocoa has a date/time class NSDate which uses an epoch date of January 1st 2001. So a timestamp of 437432903.96807599067687988281 seconds, when added to January 1st 2001, gives you the correct date and time: 9:08:23 pm GMT | Tuesday, November 11, 2014

Microsoft Dynamics CRM 2011 PlugIn RetrieveMultiple Does not return custom attribute on pricelist

I am writing a simple PlugIn for Dynamics CRM 2011 which should retrieve a custom attribute which I customized in the pricelist entity.
When I execute the following code, all standard attributes are returned, but not the one custom attribute which I customized (and published of course). I don't get an error, but simply the attribute 'axi_submarketid' is not returned. If I read data from a completely custom entity, I have no problem.
string fetch = string.Format(#"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
<entity name='pricelevel'>
<attribute name='name' />
<attribute name='transactioncurrencyid' />
<attribute name='enddate' />
<attribute name='begindate' />
<attribute name='statecode' />
<attribute name='pricelevelid' />
<attribute name='axi_submarketid' />
<order attribute='name' descending='false' />
<filter type='and'>
<condition attribute='pricelevelid' operator='eq' uiname='10 Stromlieferung' uitype='pricelevel' value='{0}' />
</filter>
</entity>
</fetch>", pricelevelid);
EntityCollection pricelevel = _service.RetrieveMultiple(new FetchExpression(fetch));
What am I doing wrong?
Thanks for help,
Peter
I solved my issue myself and it is a bit embarassing :-)
The expected attribute was not deliverd, because it had no content. Meaning, not only in the direct context of a PlugIn, but also when requesting data in general: if in an attribute there is no data, the attribute is not sent back, for example if the attribute is NULL or has no value in it.
Thanks anyway, hope this question and answer helps someone else.
Regards,
Peter

How to use OrganizationServiceProxy on my Plugin - CRM 2011?

I need to use fetch xml in a CRM plugin, and I found here an example on how to do that:
string groupby1 = #"
<fetch distinct='false' mapping='logical' aggregate='true'>
<entity name='opportunity'>
<attribute name='name' alias='opportunity_count' aggregate='countcolumn' />
<attribute name='ownerid' alias='ownerid' groupby='true' />
<attribute name='createdon' alias='createdon' />
<attribute name='customerid' alias='customerid' />
</entity>
</fetch>";
EntityCollection groupby1_result = orgProxy.RetrieveMultiple(new FetchExpression(groupby1));
but there's something else I don't know how to use, or where is it to use.. it's the part which says:
orgProxy.RetrieveMultiple(new FetchExpression(groupby1));
I Know it's an object of the OrganizationServiceProxy, but where is it in the plugin class? I couldn't find out.
In the politest way possible, you probably need to take a few steps backwards to go forwards.
So to write a plugin, you need to implement IPlugin, which has just the one method
public void Execute(IServiceProvider serviceProvider)
The IServiceProvider is your window into CRM and the context of the event that you are hooking into.
Typically, you would do something like:
var context = (IPluginExecutionContext) serviceProvider.GetService(typeof (IPluginExecutionContext));
var factory = (IOrganizationServiceFactory) serviceProvider.GetService(typeof (IOrganizationServiceFactory));
var service = factory.CreateOrganizationService(context.UserId);
In the example above, service is of type IOrganizationService. This gives you all the methods you would expect
service.Execute(foo);
service.RetrieveMultiple(bar);
service.Update(... /* etc
Might be worth reviewing some of the guides around this - as I've given in a previous answer here