Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

how to resolve a path in java like we do in JS with the help of granite.resource.resolve

amangoyal15
Level 3
Level 3

I need to acces page properties of a given page in JAVA as i want to make servlet.

I can do it in JS. But i dont know how to do in JAVA.

In js - i did this way

ResourceUtils.getResource(pageResource.path + "/jcr:content")
            .then(function (pageContentResource){
        if (pageContentResource.properties["fileReference"]) {
             log.error("@@@'pageContentResource.properties['fileReference']'"+pageContentResource.properties["fileReference"]);
                   imagePathPromise.resolve(pageContentResource.properties["fileReference"]);
                    
                } else {
                    ResourceUtils.getResource(pageContentResource.path + "/image")
                        .then(function (imageChildResource) {
                            if (imageChildResource.properties["fileReference"]) {
                                log.error("@@@'imageChildResource.properties['fileReference']'"+imageChildResource.properties["fileReference"]);
                                imagePathPromise.resolve(imageChildResource.properties["fileReference"]);
                            } else {
                                ResourceUtils.getResource(imageChildResource.path + "/file")
                                    .then(function (imageFileResource) {
                                        log.error("@@@'imageChildResource.path '/file''     " +imageChildResource.path + "/file");
                                        imagePathPromise.resolve(imageChildResource.path + "/file");
                                    }, function () {
                                        imagePathPromise.resolve("");
                                    });
                            }
                        }, function () {
                            imagePathPromise.resolve("");
                        });
                }

            }, function () {
                imagePathPromise.resolve("");
          });

 

 

Now for JAVA , which all functions i have to use.. Kindly assist me

1 Accepted Solution
Feike_Visser1
Correct answer by
Employee
Employee

Use getResourceResolver() to resolve path. 

You can use resource.getResourceResolver()

View solution in original post

1 Reply
Feike_Visser1
Correct answer by
Employee
Employee

Use getResourceResolver() to resolve path. 

You can use resource.getResourceResolver()

View solution in original post