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();
}
Other way around
String damPath = "/content/dam/geometrixx/offices/basel kitchen.jpg";
for (ReferenceSearch.Info info: new ReferenceSearch().search(resourceResolver, damPath).values()) {
for (String p: info.getProperties()) {
out.println("Path is "+info.getPage().getPath());
}
//See all methods available in info. For example to get replication status of ref page
final ReplicationStatus replStatus = info.getPage().adaptTo(ReplicationStatus.class);
if (replStatus != null) {
//replStatus.isActivated() will give you activation status ...
}
}
No comments:
Post a Comment
If you have any doubts or questions, please let us know.