Is it possible to configure a tag path selector in Scheduler service in AEM6.5?
I would like to configure a tag location that I then use in the Scheduler:
Example:
/content/cq:tags/blog
/content/cq:tags/zkb/content/blog
I tried to configure it like this:
@AttributeDefinition(name = "tagPath", description = "Enter content paths for tags used in Blog Articles.")
String[] getTagPaths() default {"/content/cq:tags/blog", "/content/cq:tags/zkb/content/blog"};
@Activate
protected void activate(final Config config) {
tagPaths = config.getTagPaths();
}
The result is that I by default get an String array with one element with value /content/cq:tags/blog, /content/cq:tags/zkb/content/blog
I can go in /system/console/configMgr and manually add tagPaths but I am not able to configure it like that programatically.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
This is possible,
Example for osgi service with multiple values
https://github.com/arunpatidar02/aemaacs-aemlab/blob/master/core/src/main/java/com/community/aemlab/...
Hi @anasustic
Could you please share more detail about the use case?
Thank you. I appologise for the lack of explanation @arunpatidar and @aanchal-sikka which I updated.
Hi,
This is possible,
Example for osgi service with multiple values
https://github.com/arunpatidar02/aemaacs-aemlab/blob/master/core/src/main/java/com/community/aemlab/...
Thanks so much @arunpatidar
I was able to configure it correctly using your example:
@AttributeDefinition(name = "tagPath", description = "Enter content paths for tags used in Blog Articles.")
String[] getTagPaths() default {"/content/cq:tags/blog","/content/cq:tags/zkb/content/blog"};
Hello @anasustic
I guess you are having issue while retrieving Info.
You can convert it into an array of primitive type.
Code sample is available on https://techrevel.blog/2017/11/13/ds-annotations-component-property-and-configurations/
static Object[] convertToObjectArray(Object array) {
Class ofArray = array.getClass().getComponentType();
if (ofArray.isPrimitive()) {
List ar = new ArrayList();
int length = Array.getLength(array);
for (int i = 0; i < length; i++) {
ar.add(Array.get(array, i));
}
return ar.toArray();
} else {
return (Object[]) array;
}
}
Thank you so much @aanchal-sikka for your great resource.
Views
Likes
Replies