Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

DAM Asset- How to override dc:title metadata of an Asset

ArunaSurukunta
Level 5
Level 5

Hi All,

 

I am using  Asset api to create asset and assigning metadata propertiese  by adopting asset.

When I assign prperty to dc;title if any document has defined title on it is not able to assign my custom title.

 

Could you please suggest how to resolve this issue. Same thing is happening for dc:description field too. I need to override this with custom data.

1 Accepted Solution
Anudeep_Garnepudi
Correct answer by
Community Advisor
Community Advisor

Hi @ArunaSurukunta 

resource.getChild(String) will take relative path. Just see the below updated code. No need of "asset.getPath() +".

Resource resource = asset.adaptTo(Resource.class);
Resource metaResource = resource.getChild(DAMConstants.JCR_CONTENT_METADATA);
ModifiableValueMap modifiableValueMap = metaResource.adaptTo(ModifiableValueMap.class);
modifiableValueMap.put("dc:title", "Title");

resource.getResourceResolver().commit();

AG

View solution in original post

7 Replies
santhosh_kumark
Community Advisor
Community Advisor

Hi @ArunaSurukunta ,

 

Can you share the sample code how are you trying to override to understand it better.

 

Thanks,

Santosh

ArunaSurukunta
Level 5
Level 5

@santhosh_kumarkThank you for the response.

 

Please find the below code 

To create asset in AEM :

asset = AssetImportUtils.createAsset(assetManager, targetPath, fileInputStream, mimeType);

To update asset props

 

Resource resource = asset.adaptTo(Resource.class);
Resource metaResource = resource.getChild(asset.getPath() + DAMConstants.JCR_CONTENT_METADATA);
ModifiableValueMap modifiableValueMap = metaResource.adaptTo(ModifiableValueMap.class);
modifiableValueMap.put("dc:title", "Title");

resource.getResourceResolver().commit();

 

Manjunath_K
Community Advisor
Community Advisor

Hi @ArunaSurukunta 

I am able update asset meta data title using below code. check whether required permission is set for the service user which you are using. 

 

Resource metaResource = resourceResolver.getResource( "/content/dam/we-retail/en/products/apparel/gloves/Gloves.jpg/jcr:content/metadata");
ModifiableValueMap modifiableValueMap = metaResource.adaptTo(ModifiableValueMap.class);
modifiableValueMap.put("dc:title", "Title After Update");
if(resourceResolver.hasChanges()){
resourceResolver.commit();
}

 

Asset Before Update (with title configured) : 

metabefore.png

 

 

Asset After Update (using service resource resolver in backend) :

metaafter.png 

 

 

Hope this helps!

ArunaSurukunta
Level 5
Level 5

Thank you @Manjunath_K. Does your document has title property set?

 

before you upload document to DAm server please open with PDF and right click on the document CLick on Document Properties. Check if your document has properties set. if Not for me also it updating title.

If I have document propertiese set on asset file then it is not overriding.

 

annyreddy_0-1603999356326.png

 

Manjunath_K
Community Advisor
Community Advisor

Hi @ArunaSurukunta 

 

I tried the steps which you provided i.e. uploading pdf file with having title on DAM, i was able to update that pdf asset tile in backend & was not able to reproduce the issue which you are facing. try to check ModifiableValueMap in debug mode/printing in log after putting new title to it.

 

sample-doc.png

ArunaSurukunta
Level 5
Level 5

Thank you @Manjunath_K. I am using servlet and using request onject. still it is not updating title.

 

I am getting below error  com.adobe.xmp.worker.files.ncomm.XMPFilesNComm [XMPFilesProcessor.exe-4316] vcfoundation::ncomm::NCException: XMP Error 9: File could not be saved
race: 1 011330A0
2 01133128
3 011320A5
4 0113275E
5 01132572
6 0113166C

Anudeep_Garnepudi
Correct answer by
Community Advisor
Community Advisor

Hi @ArunaSurukunta 

resource.getChild(String) will take relative path. Just see the below updated code. No need of "asset.getPath() +".

Resource resource = asset.adaptTo(Resource.class);
Resource metaResource = resource.getChild(DAMConstants.JCR_CONTENT_METADATA);
ModifiableValueMap modifiableValueMap = metaResource.adaptTo(ModifiableValueMap.class);
modifiableValueMap.put("dc:title", "Title");

resource.getResourceResolver().commit();

AG

View solution in original post