Niveau 1
Niveau 2
Se connecter à la communauté
Connectez-vous pour voir tous les badges
I just want to call aem ootp api like '/libs/wcm/core/content/reference.json' by java code in author. Are there any convenient ways to do this?
Les sujets facilitent la catégorisation du contenu de la Communauté et vous aident à retrouver le contenu le plus pertinent.
Vues
Réponses
Nombre de J’aime
But when I call author apis, it needs account and password, I just want some convenient ways to call these api.
Hi @Johann_Lu
Usually in publish environment, for the anonymous user: user has restricted permissions only. ie /content /bin. In your case, you need to give read permission to the path "/libs/wcm/core/content/" for the anonymous user. Is this the right way?? Not sure.
Or else, you need to create some proxy servlet, that will internally call /libs/wcm/core/content/.
Vues
Réponses
Nombre de J’aime
Or may be you can tell me that how can I get the resources refferenced by the page? I have tried several apis like 'ReferenceProvider' which didn't work.
@Johann_Lu : Have you tried invoking this from your backend ie. java?
The request to your backend system would already have the session details coming through cookie from original backend request.
Please try and see if it already works as-is. If not, please identify (i.e login-token) what is needed for reference.json to work in author and retrieve the same from original request's cookie.
thanks.
How should I do? Like call 3rd party API?
@Johann_Lu : Please refer:
Yes, I know this method, I am just looking for a more convenient way to call this api. In fact, I just need all resources referenced by the page,like this api '/libs/wcm/core/content/reference.json' do.
You can use AssetReferenceSearch get the resources referenced by the page. It's constructor takes the node (content node of the page ) to search under, path where the assets are stored (can be /content/dam ) and Resource Resolver.
String Pagepath = "/content/we-retail/en"; //This would be your page path
Resource r = resourceResolver.getResource(Pagepath + "/" + JcrConstants.JCR_CONTENT);
Node n = r.adaptTo(Node.class);
AssetReferenceSearch ref = new AssetReferenceSearch
(n, DamConstants.MOUNTPOINT_ASSETS, resourceResolver);
Map<String,Asset> allref = new HashMap<String,Asset>();
allref.putAll(ref.search());
for (Map.Entry<String, Asset> entry : allref.entrySet()) {
String val = entry.getKey();
out.println(val+"<br>"); // Path of all Asset ref in page
Asset asset = entry.getValue();
}
What about template and policy?
I have checked it before, it didn't work, the result is null
Hi @Johann_Lu
Here is the working example from ACS Common project :
@Johann_Lu Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.
Vues
Réponses
Nombre de J’aime
What they said I have tried before, but those didn't work.
I have the same requirement as yours, I stumbled upon this article it might help
https://kiransg.com/2023/05/16/sling-servlet-helpers/
Vues
Réponses
Nombre de J’aime
Vues
Likes
Réponses
Vues
Likes
Réponses
Vues
Likes
Réponses
Vues
Like
Réponses