Expand my Community achievements bar.

tagmanager.findByTitle() not working for special characters like "&"

Avatar

Level 3

Hi,

I am writing a piece of code that uses the title to fetch the corresponding Tag. I am facing issues for tags with & sign.

 

Example:

        String tagTtitle = "Celebrations & Holidays";
        FindResults result = tagManager.findByTitle(tagTtitle)

       Tag[] tagArr = result.tags;

        for(Tag tag : tagArr){
               tagList.add(tag);
         }
 

This is a title under Stock Photography, but returns an empty result. Works fine for tags with regular titles. 

 

Thanks

12 Replies

Avatar

Administrator

Hi

-----------------------------------

Not Sure but you can try

------------------------------------

You can try %encoding the string.

Eg. let say for "admin@123" we could write admin%40123. //@ has hex value of 40 so we escaped it as %40. This is the technique use by many browsers for handling Unicode characters.

So for, 

&=> %26

Thanks and Regards

Kautuk Sahni



Kautuk Sahni

Avatar

Level 3

Hi Kautuk,

Thanks for the help. But even this is not working.

Avatar

Level 10

You are correct - i was able to reproduce your results: 

  TagManager tMgr = tmf.getTagManager(session);
  //String myTag =  "properties:style/color"; 
  String myTag =  "Celebrations & Holidays"; 
                      
 log.info("**** ABOUT TO FIND TAGS");
 RangeIterator<Resource> tagsIt = tMgr.findByTitle(myTag).resources;

Special chars seem to be an issue.

This is a bug.  Please log a  ticket here so Eng and SUpport are made aware: 

https://helpx.adobe.com/marketing-cloud/contact-support.html

Avatar

Level 1

scott i am trying to find the dam asset path with below sample code in 6.3 and getting null value

Map<String, Object> param = new HashMap<String, Object>();

        param.put(ResourceResolverFactory.SUBSERVICE, "allegionCorpService");   

        ResourceResolver resolver = null;

        Session session = null;

try {

//ResourceResolver resourceResolver = resolverFactory.getAdministrativeResourceResolver(null);

//session = repository.loginService("allegionCorpService", null);       

        resolver = resolverFactory.getServiceResourceResolver(param);

            session = resolver.adaptTo(Session.class);            

            log.error("####### session ######### : " + session.getUserID());

TagManager tMgr = tmf.getTagManager(session);

String myTag = tagID; //

RangeIterator<Resource> tagsIt = tMgr.find(myTag); - getting null pointer exception means tagIt is null

error log

28.11.2017 16:43:05.694 *ERROR* [198.102.128.6 [1511905385664] GET /content/allegion-us-2/en/home/products/detail.html HTTP/1.1] com.allegionus2.americas.serviceImpl.HelloServiceImpl ####### session ######### : allesysuser

28.11.2017 16:43:05.695 *ERROR* [198.102.128.6 [1511905385664] GET /content/allegion-us-2/en/home/products/detail.html HTTP/1.1] com.allegionus2.americas.serviceImpl.HelloServiceImpl ####### Before Tag ID ######### : allegion-us-2:Products::com.day.cq.tagging.impl.JcrTagManagerImpl@7ec199dc

28.11.2017 16:43:05.696 *ERROR* [198.102.128.6 [1511905385664] GET /content/allegion-us-2/en/home/products/detail.html HTTP/1.1] com.allegionus2.americas.serviceImpl.HelloServiceImpl ####### After Tag ID ######### : null

28.11.2017 16:43:05.696 *ERROR* [198.102.128.6 [1511905385664] GET /content/allegion-us-2/en/home/products/detail.html HTTP/1.1] com.allegionus2.americas.serviceImpl.HelloServiceImpl *** COUNT ERROR: java.lang.NullPointerException

Avatar

Level 3

Hi,

 

Can anyone please explain why tagManager.resolveByTitle("Celebrations & Holidays"); not working? The API states that it uses Title Path property. Can you please explain what it is?

 

Thanks in advance.

Avatar

Level 10

Hi,

I too agree with Scott statement. Special character might cause the issue. Otherwise it should work.

This is a bug. Create support ticket here for the same: https://helpx.adobe.com/marketing-cloud/contact-support.html

Thanks,
Ratna Kumar.

Avatar

Administrator

Ratna Kumar wrote...

Hi,

I too agree with Scott statement. Special character might cause the issue. Otherwise it should work.

This is a bug. Create support ticket here for the same: https://helpx.adobe.com/marketing-cloud/contact-support.html

Thanks,
Ratna Kumar.

 

The argument of the Function is String Type (resolveByTitle(String tagTitlePath) ), i doubt that this would be a bug. It could be asDesigned, that these special characters need some Escaping.

I would Recommend you to Create support ticket here for the same: https://helpx.adobe.com/marketing-cloud/contact-support.html 

Whenever you get the answer, please share it with the community for community's benefit.

 

Thanks and Regards

Kautuk Sahni



Kautuk Sahni

Avatar

Level 10

There is a bug somewhere - either the function call or the lack of documentation. 

Avatar

Level 3

Hi All,

I have raised a bug for TagManager.FindResults findByTitle(String title) method and it has been escalated.

While trying another approach I came through Tag resolveByTitle(String tagTitlePath) method. I tried using this but method but this returns null for any Tag title I use. On going through the API I found that the method required Tag's title path. So in the scenario mentioned above, I would require to use the method as:

String myTag = "Stock Photography: Celebrations & Holiday"

Tag tag = tagManager.resolveByTitle(myTag);\

However in the implementation I am trying, there are various tags belonging to different namespaces. So is there any other approach i might try.

 

Once again I thank all of you for the help.

Avatar

Administrator

Har.Khandelwal wrote...

Hi All,

I have raised a bug for TagManager.FindResults findByTitle(String title) method and it has been escalated.

While trying another approach I came through Tag resolveByTitle(String tagTitlePath) method. I tried using this but method but this returns null for any Tag title I use. On going through the API I found that the method required Tag's title path. So in the scenario mentioned above, I would require to use the method as:

String myTag = "Stock Photography: Celebrations & Holiday"

Tag tag = tagManager.resolveByTitle(myTag);\

However in the implementation I am trying, there are various tags belonging to different namespaces. So is there any other approach i might try.

 

Once again I thank all of you for the help.

 

Hi 

Information from Internal Team:-

"this is happening only on 6.0 SP3 and not on 6.1 SP1. I could successfully fetch the tag with special character on 6.1 SP1 using a similar code snippet."

I hope this would be of some help to you.

Thanks and Regards

Kautuk Sahni



Kautuk Sahni

Avatar

Level 3

Hi,

 

I received an update from Adobe. The tags are fetched using:

String myTag = "\"Celebreations & Holidays\"";

 

Thanks,

Harshit

Avatar

Administrator

I have asked internally.

Would get back to you soon.

 

Thanks and Regards

Kautuk Sahni



Kautuk Sahni