Relationship between JCR and DAM - Is the DAM part of the JCR | Community
Skip to main content
New Participant
October 16, 2015
Solved

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

  • October 16, 2015
  • 4 replies
  • 1413 views

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.
Best answer by smacdonald2008

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

New Participant
October 16, 2015

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.

New Participant
October 16, 2015

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

Regards
Clive Stewart

smacdonald2008
smacdonald2008Accepted solution
New Participant
October 16, 2015

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. 

New Participant
October 16, 2015

Thank you for such a comprehensive answer.

This will help my understanding a lot.

 

Regards

Clive Stewart