Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Extend Assets Metadata Editor

Avatar

Level 2

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.



 

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@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

View solution in original post

3 Replies

Avatar

Correct answer by
Community Advisor

@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

Avatar

Community Advisor

@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