Hi, I am uncertain as to what the relationship between the DAM and the JCR is. I had always assumed that the DAM was stored inside the JCR, but now I am uncertain.
Regards
Clive Stewart
Solved! Go to Solution.
Views
Replies
Total Likes
The DAM is certainly part of the AEM JCR and the structure of the DAM is nodes in the JCR:
[img]DAM.png[/img]
Like other JCR nodes - you can use various APIs - like QueryBuilder API to search for nodes.
// create query description as hash map (simplest way, same as form post)
Map<String, String> map = new HashMap<String, String>();
//set QueryBuilder search criteria
map.put("type", "dam:Asset");
map.put("path", "/content/dam/car");
map.put("property.value", "image/png");
builder= resourceResolver.adaptTo(QueryBuilder.class);
//Invoke the Search query
Query query = builder.createQuery(PredicateGroup.create(map), session);
SearchResult sr= query.getResult();
You can use AssetManager to create new nodes. For example:
ResourceResolver resourceResolver = resolverFactory.getAdministrativeResourceResolver(null);
//Use AssetManager to place the file into the AEM DAM
com.day.cq.dam.api.AssetManager assetMgr = resourceResolver.adaptTo(com.day.cq.dam.api.AssetManager.class);
String newFile = "/content/dam/travel/"+fileName ;
assetMgr.createAsset(newFile, is,"image/jpeg", true);
All content in AEM - including content in the DAM - are resources and part of the AEM JCR.
Views
Replies
Total Likes
Everything in JCR is a content, JCR is a node based repository. Each node is of a particular type called jcr:primaryType
All DAM assets are of type dam:Asset.
Views
Replies
Total Likes
Thank you for this answer. This is also very helpful to me.
Regards
Clive Stewart
Views
Replies
Total Likes
The DAM is certainly part of the AEM JCR and the structure of the DAM is nodes in the JCR:
[img]DAM.png[/img]
Like other JCR nodes - you can use various APIs - like QueryBuilder API to search for nodes.
// create query description as hash map (simplest way, same as form post)
Map<String, String> map = new HashMap<String, String>();
//set QueryBuilder search criteria
map.put("type", "dam:Asset");
map.put("path", "/content/dam/car");
map.put("property.value", "image/png");
builder= resourceResolver.adaptTo(QueryBuilder.class);
//Invoke the Search query
Query query = builder.createQuery(PredicateGroup.create(map), session);
SearchResult sr= query.getResult();
You can use AssetManager to create new nodes. For example:
ResourceResolver resourceResolver = resolverFactory.getAdministrativeResourceResolver(null);
//Use AssetManager to place the file into the AEM DAM
com.day.cq.dam.api.AssetManager assetMgr = resourceResolver.adaptTo(com.day.cq.dam.api.AssetManager.class);
String newFile = "/content/dam/travel/"+fileName ;
assetMgr.createAsset(newFile, is,"image/jpeg", true);
All content in AEM - including content in the DAM - are resources and part of the AEM JCR.
Views
Replies
Total Likes
Thank you for such a comprehensive answer.
This will help my understanding a lot.
Regards
Clive Stewart
Views
Replies
Total Likes
Views
Likes
Replies