6.4 tagmanagerobject.resolve(tagid) returning null

Avatar

Avatar

AdobeID24

Avatar

AdobeID24

AdobeID24

26-03-2020

 

tagmanagerobject.resolve(tagid) return ing null everytime.... I m using 6.4.1

 

Code is written inside active method and in class we are using wcmusepojo by extending it..... 

 

We got tag manager as getresourceresolver. Adapto(TagMAnager) 

Other points which I strict verified 

 

I m running my code in local...as admin...admin has all the access.......Where all tags are present.... 

 

Tagamanger obejvt is not null.... 

 

Tag I'd format is proper... Namesapce:fruits/apple kind...... 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

vanegi

Employee

Avatar

vanegi

Employee

vanegi
Employee

15-07-2020

As you know, tags are stored in the /etc paths in your JCR. When you logged out of  publisher as an admin, the resolver would NOT be able to access the tags object in /etc. Hence, it is returning nulls.

 

To solve this, you can create a new OSGI service like below:

public Class TagServiceImpl implements TagService {
 
  ResourceResolverFactory resolverFactory;
 
  public void init() {
    Map<String, Object> params = new HashMap<>();
    params.put(ResourceResolverFactory.SUBSERVICE, "companyServiceThread");
    ResourceResolver resourceResolver = resourceResolverFactory.getServiceResourceResolver(params);
  }
 
  public void kill() {
    resolver = null;
  }
  public Tag getTag(String tagID) {
 
    Tag myTag = resourceResolver.adaptTo(TagManager.class).resolve(tagID); //Now  works!!
    return myTag;
  }
 
 
This service-user has been given the appropriate read/write privileges to required paths. Hence, the tag (myTag) can be successfully resolved. 

Answers (0)