Accessing predecessor binary in DAM with URL without restoring | Community
Skip to main content
cfredman
October 16, 2015
Solved

Accessing predecessor binary in DAM with URL without restoring

  • October 16, 2015
  • 1 reply
  • 721 views

Hi,

Is it possible to access/download a previous version of a file in CQ5.4 DAM without first restoring the file with a URL?

Something like: /content/dam/photos/image1.tif/jcr:version/1.0/jcr:frozenNode/jcr:content/renditions/original/jcr:content/jcr:data

We need to extract older versions of images for reprint of legacy publications.

Thanks in advance,

Charles

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

In the CQ doc topic:  -- http://wem.help.adobe.com/enterprise/en_US/10-0/wem/dam/cq5_dam_version_management.html -- it states that all versions of an asset are store. Therefore because it is still stored -- you can retrieve the asset using the Query Builder API. This API lets you search and get assets in the CQ DAM. 

Here is Query Builder API code that searches the CQ DAM and gets assets.

In your situation- make sure that you setup the search in order to get the correct digital asset version.
 

<%@include file="/libs/foundation/global.jsp"%>

<%@page session="false" %>

<%@page import="com.day.cq.tagging.*,com.day.cq.wcm.api.*"%>

 

<%@ page import="java.util.*,

    javax.jcr.*,

    org.apache.sling.api.resource.*,

    org.apache.sling.api.scripting.*,

    org.apache.sling.jcr.api.*,

    com.day.cq.search.*,

    com.day.cq.search.result.*"

 

 %>

 

<%@page import="com.day.cq.dam.api.Asset"%>

 

<%

SlingRepository slingRep = sling.getService(SlingRepository.class);

Session session = slingRep.loginAdministrative(null);

QueryBuilder qb ;

Map<String, String> map = new HashMap<String,String>();

map.put("type", "dam.Asset");

map.put("property", "jcr:content/metadata/dc:format");

map.put("property.value", "image/jpeg");

qb=resource.getResourceResolver().adaptTo(QueryBuilder.class);

Query query = qb.createQuery(PredicateGroup.create(map), session);

 

SearchResult sr= query.getResult();

String assetPath=null;

 

 // iterating over the results

  for (Hit hit : sr.getHits()) {

      String path = hit.getPath();

      Resource rs = resourceResolver.getResource(path);

      Asset asset = rs.adaptTo(Asset.class);    

     assetPath = asset.getPath();

%>

<img src = "<%= asset.getRendition("cq5dam.thumbnail.140.100.png").getPath()%>" ></img>

<%

}

%>

1 reply

smacdonald2008
smacdonald2008Accepted solution
Level 10
October 16, 2015

In the CQ doc topic:  -- http://wem.help.adobe.com/enterprise/en_US/10-0/wem/dam/cq5_dam_version_management.html -- it states that all versions of an asset are store. Therefore because it is still stored -- you can retrieve the asset using the Query Builder API. This API lets you search and get assets in the CQ DAM. 

Here is Query Builder API code that searches the CQ DAM and gets assets.

In your situation- make sure that you setup the search in order to get the correct digital asset version.
 

<%@include file="/libs/foundation/global.jsp"%>

<%@page session="false" %>

<%@page import="com.day.cq.tagging.*,com.day.cq.wcm.api.*"%>

 

<%@ page import="java.util.*,

    javax.jcr.*,

    org.apache.sling.api.resource.*,

    org.apache.sling.api.scripting.*,

    org.apache.sling.jcr.api.*,

    com.day.cq.search.*,

    com.day.cq.search.result.*"

 

 %>

 

<%@page import="com.day.cq.dam.api.Asset"%>

 

<%

SlingRepository slingRep = sling.getService(SlingRepository.class);

Session session = slingRep.loginAdministrative(null);

QueryBuilder qb ;

Map<String, String> map = new HashMap<String,String>();

map.put("type", "dam.Asset");

map.put("property", "jcr:content/metadata/dc:format");

map.put("property.value", "image/jpeg");

qb=resource.getResourceResolver().adaptTo(QueryBuilder.class);

Query query = qb.createQuery(PredicateGroup.create(map), session);

 

SearchResult sr= query.getResult();

String assetPath=null;

 

 // iterating over the results

  for (Hit hit : sr.getHits()) {

      String path = hit.getPath();

      Resource rs = resourceResolver.getResource(path);

      Asset asset = rs.adaptTo(Asset.class);    

     assetPath = asset.getPath();

%>

<img src = "<%= asset.getRendition("cq5dam.thumbnail.140.100.png").getPath()%>" ></img>

<%

}

%>