0

I'm pretty new to Java so bear with me. I can't for the life of me figure out why I'm getting a cannot find symbol error on resourceResolver.resolve. When on the line above it I'm defining the variable. Maybe this is something simple I'm missing but I can't figure this out and I feel like I've stared at this way to long.

private static final String ROOTCHILD = "rootChild";

public void setResource(Resource resource) {
   this.resource = resource;
}

public void setProperties(ValueMap properties) {
   this.properties = properties;
}

public Page getRootPage() {
   ResourceResolver resourceResolver = getResource().getResourceResolver();
   return (this.properties != null)
      ? resourceResolver.resolve(
           properties.get( ROOTCHILD,currentPage.getPath())).adaptTo(Page.class)
      : null;
}
Aubin
  • 14,617
  • 9
  • 61
  • 84
Delmon Young
  • 2,013
  • 5
  • 39
  • 51

2 Answers2

0

My guess here (never worked with sling and haven't used Java for a while):

I think the problem is you initialized the ValueMap properties so that it doesn't contain Strings or HttpServletRequests, but something else. The .resolve() method only accepts either a String or an HttpServletRequest. (Or two parameters, but you're only passing one, so that one can't be the case.) There is no .resolve() method found accepting the parameters you try to give it, so that symbol is not found!

11684
  • 7,356
  • 12
  • 48
  • 71
0

To see the true error, rewrite your code and compile it:

public Page getRootPage() {
   if( properties == null ) {
      return null;
   }
   YYYYYY resource = getResource();
   ResourceResolver resourceResolver = resource.getResourceResolver();
   String path = currentPage.getPath();
   String rootChild = properties.get( ROOTCHILD, path );
   XXXXXX rc = resourceResolver.resolve( rootChild );
   return rc.adaptTo( Page.class );
}
Aubin
  • 14,617
  • 9
  • 61
  • 84