Extend Assets Metadata Editor | Community
Skip to main content
Level 2
March 17, 2023
Solved

Extend Assets Metadata Editor

  • March 17, 2023
  • 2 replies
  • 970 views

While using the below code to get the asset path getting null pointer . Can anybody help me is there any other way to get the asset path?

 

public class ExamplePostProcessor implements SlingPostProcessor {
@Override
public void process(final SlingHttpServletRequest request, final List<Modification> modifications){
try {
final String assetPath = request.getRequestURI();// this method not giving the required assetPath.It is giving content/dam.html
final Resource rr = request.getResourceResolver().getResource(assetPath);
.......
}
}

Requirement is onclick of save&close button in metada editor it should save all the metadat in a external DB.



 

 

 

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 SivakumarKanoori

@divanshjohndigital :

You can develop a sling servlet where you can write your logic connect to External DB.

one of the way is, you can create a clinet lib with categories as "dam.gui.coral.propertieseditor" and 

in java script you can write the below click event 

$('.granite-form-saveactivator' ).on( "click", trigger);

function trigger(){

// You can make ajax call to your servlet by passing the data. or you can pass the asset url to your servlet, from servlet you can read metadata values and pass to DB.

 

}

 

Thansk,
Siva

Thanks,

Siva

2 replies

SivakumarKanoori
Community Advisor
SivakumarKanooriCommunity AdvisorAccepted solution
Community Advisor
March 17, 2023

@divanshjohndigital :

You can develop a sling servlet where you can write your logic connect to External DB.

one of the way is, you can create a clinet lib with categories as "dam.gui.coral.propertieseditor" and 

in java script you can write the below click event 

$('.granite-form-saveactivator' ).on( "click", trigger);

function trigger(){

// You can make ajax call to your servlet by passing the data. or you can pass the asset url to your servlet, from servlet you can read metadata values and pass to DB.

 

}

 

Thansk,
Siva

Thanks,

Siva

Thanks,Siva
Level 2
March 21, 2023

@sivakumarkanoori Thanks a lot this approach working as expected.

 

aanchal-sikka
Community Advisor
Community Advisor
March 21, 2023

@divanshjohndigital 

 

In my opinion, you should rather capture Asset update event and create sling jobs to push data to external DB.

 

By executing it from frontend, we might loose data in case of unavailability of services. Tracking such discrepancies in long term will be an additional task.

 

 

Aanchal Sikka