[
https://issues.apache.org/jira/browse/SLING-12737?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Mircea Stan updated SLING-12737:
--------------------------------
Description:
I am using the method findJobs in JobManager to iterate through all Sling jobs.
I would like to find all history jobs with a finished date before a certain
date specified by a user.
First of all, there are no tests that test templates with operators, so I had
to reverse engineer how should I build the template.
In the end, I created a template like this:
{code:java}
Map<String, Object> templateBefore = Map.of("<" +
JobImpl.PROPERTY_FINISHED_DATE,"2026-04-03T11:38:25.360+03:00"); {code}
The template is not working though because the key is encoded before extracting
the first character and the first character is no longer '<'.
{code:java}
final String key = ISO9075.encode(current.getKey());
final char firstChar = key.length() > 0 ? key.charAt(0) : 0;
final String propName;
final Operation op;
if ( firstChar == '=' ) {
propName = key.substring(1);
op = Operation.EQUALS;
} else if ( firstChar == '<' ) {
final char secondChar = key.length() > 1 ? key.charAt(1) : 0;
if ( secondChar == '=' ) {
op = Operation.LESS_OR_EQUALS;
propName = key.substring(2);
} else {
op = Operation.LESS;
propName = key.substring(1);
}
} {code}
Could you confirm the bug and if it is not a bug, share a template that can
work in the scenario I described?
Thanks!
was:
I am using the method findJobs in JobManager to iterate through all Sling jobs.
I would like to find all history jobs with a finished date before a certain
date specified by a user.
First of all, there are no tests that test templates with operators, so I had
to reverse engineer how should I build the template.
In the end, I created a template like this:
{code:java}
Map<String, Object> templateBefore = Map.of("<" +
JobImpl.PROPERTY_FINISHED_DATE,"2026-04-03T11:38:25.360+03:00"); {code}
The template is not working though because the key is encoded before extracting
the first character and the first character is no longer '<'.
Could you confirm the bug and if it is not a bug, share a template that can
work in the scenario I described?
Thanks!
> The method findJobs in JobManagerImpl does not accept a template containing
> an operation
> ----------------------------------------------------------------------------------------
>
> Key: SLING-12737
> URL: https://issues.apache.org/jira/browse/SLING-12737
> Project: Sling
> Issue Type: Bug
> Components: Event
> Affects Versions: Event 4.3.14
> Reporter: Mircea Stan
> Priority: Major
>
> I am using the method findJobs in JobManager to iterate through all Sling
> jobs.
> I would like to find all history jobs with a finished date before a certain
> date specified by a user.
> First of all, there are no tests that test templates with operators, so I had
> to reverse engineer how should I build the template.
> In the end, I created a template like this:
> {code:java}
> Map<String, Object> templateBefore = Map.of("<" +
> JobImpl.PROPERTY_FINISHED_DATE,"2026-04-03T11:38:25.360+03:00"); {code}
> The template is not working though because the key is encoded before
> extracting the first character and the first character is no longer '<'.
> {code:java}
> final String key = ISO9075.encode(current.getKey());
> final char firstChar = key.length() > 0 ? key.charAt(0) : 0;
> final String propName;
> final Operation op;
> if ( firstChar == '=' ) {
> propName = key.substring(1);
> op = Operation.EQUALS;
> } else if ( firstChar == '<' ) {
> final char secondChar = key.length() > 1 ? key.charAt(1) : 0;
> if ( secondChar == '=' ) {
> op = Operation.LESS_OR_EQUALS;
> propName = key.substring(2);
> } else {
> op = Operation.LESS;
> propName = key.substring(1);
> }
> } {code}
> Could you confirm the bug and if it is not a bug, share a template that can
> work in the scenario I described?
> Thanks!
--
This message was sent by Atlassian Jira
(v8.20.10#820010)