Expand my Community achievements bar.

SOLVED

Relationship between JCR and DAM - Is the DAM part of the JCR

Avatar

Level 6

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

1 Accepted Solution

Avatar

Correct answer by
Level 10

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. 

View solution in original post

4 Replies

Avatar

Level 9

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.

Avatar

Level 6

Thank you for this answer. This is also very helpful to me.

Regards
Clive Stewart

Avatar

Correct answer by
Level 10

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. 

Avatar

Level 6

Thank you for such a comprehensive answer.

This will help my understanding a lot.

 

Regards

Clive Stewart