Skip to main content
Level 6
Oct 16, 2015 2:27 AM UTC
Solved

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

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
smacdonald2008
smacdonald2008Accepted solution
Level 10
Oct 16, 2015 2:27 AM UTC

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. 

4 replies

Level 6
Oct 16, 2015 2:27 AM UTC

Thank you for such a comprehensive answer.

This will help my understanding a lot.

 

Regards

Clive Stewart

Translate
smacdonald2008
smacdonald2008Accepted solution
Level 10
Oct 16, 2015 2:27 AM UTC

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. 

Translate
Level 6
Oct 16, 2015 2:27 AM UTC

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

Regards
Clive Stewart

Translate
Community Advisor
Oct 16, 2015 2:27 AM UTC

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.

Translate