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

Avatar

Avatar
Validate 1
Level 1
annyreddy
Level 1

Like

1 like

Total Posts

19 posts

Correct reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 1
annyreddy
Level 1

Like

1 like

Total Posts

19 posts

Correct reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile
annyreddy
Level 1

29-10-2020

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.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Establish
MVP
Anudeep_Garnepudi
MVP

Likes

275 likes

Total Posts

320 posts

Correct reply

87 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile

Avatar
Establish
MVP
Anudeep_Garnepudi
MVP

Likes

275 likes

Total Posts

320 posts

Correct reply

87 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile
Anudeep_Garnepudi
MVP

29-10-2020

Hi @annyreddy 

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

Answers (2)

Answers (2)

Avatar

Avatar
Give Back 3
MVP
Manjunath_K
MVP

Likes

140 likes

Total Posts

188 posts

Correct reply

61 solutions
Top badges earned
Give Back 3
Give Back
Boost 50
Boost 5
Boost 3
View profile

Avatar
Give Back 3
MVP
Manjunath_K
MVP

Likes

140 likes

Total Posts

188 posts

Correct reply

61 solutions
Top badges earned
Give Back 3
Give Back
Boost 50
Boost 5
Boost 3
View profile
Manjunath_K
MVP

29-10-2020

Hi @annyreddy 

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!

Avatar

Avatar
Establish
MVP
santhosh_kumark
MVP

Likes

99 likes

Total Posts

111 posts

Correct reply

38 solutions
Top badges earned
Establish
Validate 1
Give Back 3
Give Back
Boost 50
View profile

Avatar
Establish
MVP
santhosh_kumark
MVP

Likes

99 likes

Total Posts

111 posts

Correct reply

38 solutions
Top badges earned
Establish
Validate 1
Give Back 3
Give Back
Boost 50
View profile
santhosh_kumark
MVP

29-10-2020

Hi @annyreddy ,

 

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

 

Thanks,

Santosh