Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events
SOLVED

Configure a tag path selector in Scheduler service in AEM6.5

Avatar

Level 7

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.

anasustic_0-1697109110570.png

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor
7 Replies

Avatar

Community Advisor

Hi @anasustic 
Could you please share more detail about the use case?



Arun Patidar

Avatar

Level 7

Thank you. I appologise for the lack of explanation @arunpatidar and @aanchal-sikka which I updated.

Avatar

Correct answer by
Community Advisor

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/... 



Arun Patidar

Avatar

Level 7

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"};

 

Avatar

Community Advisor

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;
		}
	}

 


Aanchal Sikka

Avatar

Community Advisor

Hello @anasustic 

 

Need some help understanding how tag paths is related to Scheduler.

 


Aanchal Sikka