Asset API changing the properties with namespace dc: to jcr - AEM 6.3.3.3 | Community
Skip to main content
Community Advisor
December 17, 2019
Solved

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

  • December 17, 2019
  • 4 replies
  • 3446 views

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

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 AlbinIs1

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

4 replies

kautuk_sahni
Community Manager
Community Manager
August 27, 2020
AlbinIs1Community AdvisorAuthor
Community Advisor
August 27, 2020

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

Nikhil-Kumar
Community Advisor
Community Advisor
August 27, 2020

@albinis1 -

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

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

Nikhil-Kumar
Community Advisor
Community Advisor
August 27, 2020

@albinis1 - Or try using JAVA AssetManager API.

AlbinIs1Community AdvisorAuthorAccepted solution
Community Advisor
August 28, 2020

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