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

Avatar

Avatar

Albin_Issac

MVP

Avatar

Albin_Issac

MVP

Albin_Issac
MVP

17-12-2019

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

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

Albin_Issac

MVP

Avatar

Albin_Issac

MVP

Albin_Issac
MVP

27-08-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

Answers (3)

Answers (3)

Avatar

Avatar

Nikhil-Kumar

MVP

Avatar

Nikhil-Kumar

MVP

Nikhil-Kumar
MVP

27-08-2020

@Albin_Issac - Or try using JAVA AssetManager API.

Avatar

Avatar

Nikhil-Kumar

MVP

Avatar

Nikhil-Kumar

MVP

Nikhil-Kumar
MVP

27-08-2020

@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

Avatar

kautuk_sahni

Community Manager

Total Posts

5.6K

Likes

961

Correct Answer

1.1K

Avatar

kautuk_sahni

Community Manager

Total Posts

5.6K

Likes

961

Correct Answer

1.1K
kautuk_sahni
Community Manager

26-08-2020