Getting null resource from the resolver - aem

I am getting a Resource object on a component JSP using resource.getResourceResolver().getResource(path)
but it is null. I have already made sure that the path exists. It's strange that when I am calling this method on any other component JSP it is working fine. But on the component that I have created, it is null. Any idea why?
Thanks in advance.

You may not have permissions to read the resource. For instance, all resources under /apps and /libs are unavailable for the anonymous user on the publish. You may check the current permissioning for given node in the Access Control tab in CRX DE.

From the API:
Returns:
The Resource object loaded from the path or null if the path does not resolve to a resource.
Sling API

Related

AEM servlet for a component that is not under /content?

My goal is to create a token whenever a page is rendered that contains a component called someTeaser. This someTeaser component renders in the template after the content and before the footer and is not editable. It is configured fixed in the template structure.
The problem appears when I want to create a servlet for someTeaser. This component is not in the Content Repository crxde.
#SlingServletResourceTypes(
resourceTypes = {Constants.ResourceTypes.SOME_TEASER},
selectors = {"token"},
extensions = Constants.Extensions.JSON
)
The resource for this component is /conf/xx/settings/wcm/templates/someTemplate/structure/jcr:content/root/main/container/someTeaser. This resource cannot be resolved in publish. It is not under content but rather under conf.
Request URL: https://publish_server/conf/xxx/settings/wcm/templates/someTemplate/structure/jcr:content/root/main/...
Request Method: GET
Status Code: 404 Not Found
An alternative solution would be to use define resourceTypes = {Constants.ResourceTypes.PAGE} in the servlet but then every page will be checked for the selector token.
Can someone suggest an alternative solution for the task?
I was able to request the token for the container that is avaliable in the JCR repository.
String containerPath = PathBuilder.with(currentPage.getPath())
.slash(AemConstants.JCR_CONTENT)
.slash("root/main/container")
.build();
and resolve the container url nicely using resourceResolver.map(path).

Angular developers need a path to call for the content from aem page

I generated the json file and gave the path /bin//filename.json . I am able to see the json file in author mode but not in publish. Our aem ops team says they cannot make bin as public. Tried to change the path, using js generated the json path file now at path /content//***/filename.json which I am able to see in author mode but not in publish.
My question is is there any other way that I can try . Please if any other ideas do comment.
Thank you.
Or just simple: Angular get content of page by call .infinity.json
Examp:
Your page is: /mysite/en/home.html
We change to : /mysite/en/home.infinity.json
For more detail: https://forums.adobe.com/thread/2337725
Good luck
We open using url under /bin/.. for SlingServlet
First create a slingSevlet
#SlingServlet(paths="/bin/filename.json", methods = "GET", metatype=true)
Then check the filter and make sure that /bin/filename.json accepts GET requests:
curl 'http://localhost:4502/system/console/configMgr'
Search for 'Apache Sling Referrer Filter'
Check the configuration

Import API not working in sisense

I was trying to use the dashboard import API from v1.0 which can be found in the REST API reference. I logged in to http://localhost:8083/dev/api/docs/#/ , gave the correct authorization token, and a dash file in the body, and a 24 character importFolder and hit the Run button to fire the API. It returns 201 as HTTP response, which means the request was successful. However, when I go back to the homepage, I don't see any new dashboard imported in to the said folder. I have tried both cases, where the importFolder exists (already created manually be me), and does not already exist, where I expect the API to create it for me. Neither of these, however, create/import the dashboard
A few comments that should help you resolve this:
When running the command from the interactive API reference (swagger) you don't need the authentication token, because you're already logged in with an active session.
Make sure the json of your dashboard is valid, by saving it as a .dash file and importing via the UI
The folder field is optional - if you leave the field blank, the dashboard is imported to the root of your navigation/folders panel.
If you'd like to import to a specific folder, you'll need to provide the folder ID, not its name, which can be found several ways such as using the /api/v1/folders endpoint, where you can provide a name filtering field and use the oid property of the returned object as the value for the folder field in the import endpoint.
If you can't get this to work still, use chrome's developer tools to look at the outgoing request when you import from the UI and compare the request (headers, body and path) to what you're doing via swagger in order to find the issue.

IceFaces and FileResource - delete after session expires

I'm using Icefaces. I generate reports for users and provide it using FileResource class. I do nothing with the file, since it should be available for download whenever user clicks on link to resource.
However, after user logs out, the report is no longer needed and should be deleted. Is there a build-in option in IceFaces to bind FileResource with session and automatically delete it when session expires?
Resource binds to a file which already exists when you are binding it to a Resource. It is expected that the file would be needed again, so there is probably no point in providing a method to delete the file.
The IceFaces tutorial on FileUpload talks about manually deleting files after session expiry using a session listener. So I guess IceFaces does not provide any method to delete files, whether or not they are binded to a Resource.

Need help with Zend Framework dynamic Namespaces

I want to make my system redirect unknown requests such as
www.address.com/a_company
to the adress
www.address.com/companies/company/ and display the company a_company if it exists in the database, otherwise throw the user to a 404 not found page.
So in detail, I want to make namespace that is as the first example dynamically, if the company exist in the database, I have no problem connecting to the database and retrieving information or finding a way to parse a company name, I just need help how to make my system check and run a function every time the address doesn't exist and show the second page (/companies/company/)..
I am using an Acl as well, but I think it should be fine if the page is /companies/company and then possibly add /?c=a_company or similar.
Thank you.
/Marcus
simply create a front controller plugin which checks the request params agains the database before the request is dispatched.