Is there a way to access OOTB Sling service or servlet from an custom sling servlet? For instance, if I want to access OOTB servlet - http://localhost:4502/bin/wcm/contentfinder/asset/view.json/content/dam from an Sling servlet and process results on top of that, how to access the service by path itself?
Note: Looking for a solution without using HttpClient (in a REST way) ot by @Reference as I need to access through Path only.
Solved! Go to Solution.
This would work -- Invoking a servlet from a java class - Stack Overflow
And yes - we did write this -- Scott's Digital Community: Invoking AEM Sling Servlets using Apache HTTP APIs
Views
Replies
Total Likes
To invoke another AEM Service from a Sling Servlet - you use @Reference.
Views
Replies
Total Likes
smacdonald2008 Thanks for the reply but I will not be able to use @Reference because I know only the path by which we can access the service (/bin/wcm/contentfinder/asset/view.json/content/dam). There should be some way to access the service right?
Views
Replies
Total Likes
If you only know the path to a servlet - only possible way is to invoke it using HTTP.
Views
Replies
Total Likes
The concerns I see with HTTP approach is authorization i.e., to access it on author environment.
Below is the requirement we are trying to fulfill - By OOTB, content finder images are loaded from /content/dam but the requirement is to filter this. We need to load the images only 2 folders with in /content/dam.
By analyzing the ootb code, we realized that we can read images only from one folder by modifying /libs/wcm/extensions/contentfinder/images.js file.
We can update URL at "url": "/bin/wcm/contentfinder/asset/view.json/content/dam{/appspecfolder}" to the desired folder but we are unable to provide multiple folder paths here.
So our approach is to replace this service with a custom servlet and internally call the OOTB service twice and merge the results and use that to populate content finder.
Please let me know if there is a better way to solve this. Thanks in advance.
Views
Replies
Total Likes
Creating custom Sling Servets in a valid approach. Most of the examples we have of Servlets - we use AJAX to invoke the servlet. BUt you can invoke it using supported HTTP methods.
Cool smacdonald2008, Is there any community article reference where service is being called from servlet through "path" but not by @Reference? and works in author environment seamlessly?
Views
Replies
Total Likes
This would work -- Invoking a servlet from a java class - Stack Overflow
And yes - we did write this -- Scott's Digital Community: Invoking AEM Sling Servlets using Apache HTTP APIs
Views
Replies
Total Likes
try this-
RequestDispatcher dispatcher = request.getRequestDispatcher("/bin/wcm/contentfinder/asset/view.json/content/dam", opts);
dispatcher.include(request, response);
Views
Replies
Total Likes