Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Asset API changing the properties with namespace dc: to jcr - AEM 6.3.3.3

Avatar

Community Advisor

We are trying to use the AEM Asset API to upload the asset from external system and update the asset meta data:

PUT - http://localhost:4502/api/assets/we-retail/647401-ABTestSmithAsset-FINALCORRECTED.pdf

Content-Type - application/json

{"properties":{"metadata":{"dc:description":"test desc","dc:language":"English","dc:title":"Test Activity - DAM UAT 2019-12-111259 - Test","pdf:title":"Test Activity - DAM UAT 2019-12-111259 - Test"}}}

Response:

{
"class": [
"core/response"
],
"properties": {
"path": "/api/assets/we-retail/647401-ABTestSmithAsset-FINALCORRECTED.pdf",
"parentLocation": "/api/assets/we-retail.json",
"referer": "",
"changes": [
{
"argument": "/api/assets/we-retail/647401-ABTestSmithAsset-FINALCORRECTED.pdf",
"type": "modified"
}
],
"location": "/api/assets/we-retail/647401-ABTestSmithAsset-FINALCORRECTED.pdf.json",
"status.message": "OK",
"title": "Content modified /api/assets/we-retail/647401-ABTestSmithAsset-FINALCORRECTED.pdf",
"status.code": 200
}
}

the name space was changed from dc to jcr post update

dc:description --> jcr:description
dc:language --> jcr:language
dc:title-->jcr:title

The asset folders are associated with custom Metadata Schema that supports the fields with namespace dc - the fields are empty in the UI as the metadata fields are now updated with jcr namespace

Let me know if you have some insight on this

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Thanks for the update We came to know from Adobe Engineering team, the namespace changing - dc to jcr was the expected behavior for the ASET HTTP API, one solution is building custom services through Asset Manager API to handle the assets and metadata - this require additional dev effort.

 

As a quick workaround, we have enabled a workflow launcher that will be triggered only on the modification of specific jcr property(excluded for all other namespaces) and a model that will copy the jcr property e.g jcr:title received from the HTTP API to the corresponding dc:title property - refer https://www.albinsblog.com/2020/01/aem-workflow-launcher-exclude-list.html#.X0f9QshKg2w for more details

 

But it should be great if we are able to get some insight from the product team on this behavior and the alternate option to handle this scenario

 

Regards

Albin I

View solution in original post

5 Replies

Avatar

Community Advisor

Thanks for the update We came to know from Adobe Engineering team, the namespace changing - dc to jcr was the expected behavior for the ASET HTTP API, one solution is building custom services through Asset Manager API to handle the assets and metadata - this require additional dev effort.

 

As a quick workaround, we have enabled a workflow launcher that will be triggered only on the modification of specific jcr property(excluded for all other namespaces) and a model that will copy the jcr property e.g jcr:title received from the HTTP API to the corresponding dc:title property - refer https://www.albinsblog.com/2020/01/aem-workflow-launcher-exclude-list.html#.X0f9QshKg2w for more details

 

But it should be great if we are able to get some insight from the product team on this behavior and the alternate option to handle this scenario

 

Regards

Albin I

Avatar

Community Advisor

@Albin_Issac -

Try this out grammatically, as mentioned by @smacdonald2008  in https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/assets-api-http-not-workin... 

Try using the below code to update the props that you want to update:

@Reference
private ResourceResolverFactory resolverFactory;

ResourceResolver resourceResolver =null;
try
{
String resourcePath = "/content/dam/we-retail/647401-ABTestSmithAsset-FINALCORRECTED.pdf";
Map<String, Object> param = new HashMap<>();
param.put(ResourceResolverFactory.SUBSERVICE, "sysUser");

resourceResolver= resolverFactory.getServiceResourceResolver(param);

    Resource res = resourceResolver.getResource(resourcePath);
    
    Resource metadataRes =res.getChild("jcr:content/metadata");
    ModifiableValueMap map = metadataRes.adaptTo(ModifiableValueMap.class);
      
    //set metadata
    map.put("dc:samplemetadata", "sample metadata");
    resourceResolver.commit();
      
    //get metadata   

    String metadata=map.get("dc:samplemetadata").toString();   
      
}catch(Exception e)
{

}finally
{
resourceResolver.close();
}


But if you want to go ahead with Asset API only then follow the above thread once.

Thanks,
Nikhil

Avatar

Correct answer by
Community Advisor

Thanks for the update We came to know from Adobe Engineering team, the namespace changing - dc to jcr was the expected behavior for the ASET HTTP API, one solution is building custom services through Asset Manager API to handle the assets and metadata - this require additional dev effort.

 

As a quick workaround, we have enabled a workflow launcher that will be triggered only on the modification of specific jcr property(excluded for all other namespaces) and a model that will copy the jcr property e.g jcr:title received from the HTTP API to the corresponding dc:title property - refer https://www.albinsblog.com/2020/01/aem-workflow-launcher-exclude-list.html#.X0f9QshKg2w for more details

 

But it should be great if we are able to get some insight from the product team on this behavior and the alternate option to handle this scenario

 

Regards

Albin I