Can we get full page path in Preprocessor java class ?
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @Nusrat_Jahan,
When publishing a page in AEM, the process involves publishing various associated nodes, including the template policy (/conf), assets (/content/dam), content (/content), and more. To exclusively target content pages within this process, you can incorporate a filter in your code.
public class ReplicationPreprocessor implements Preprocessor {
@Override
public void preprocess(ReplicationAction action, ReplicationOptions options) throws ReplicationException {
final String path = action.getPath();
if (path.contains(CONTENT_PATH)) {
// Place your logic for content pages here
if(inValid) {
throw new ReplicationException("ERROR_MESSAGE");
}
}
}
}
By using this filter, you guarantee that your logic is executed solely on nodes residing under any path specified by CONTENT_PATH.
@Nusrat_Jahan Below is the sample code that gets the full page path
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
import org.apache.sling.engine.servlets.preprocessor.SlingRequestPreprocessor;
public class MyPreprocessor extends SlingSafeMethodsServlet implements SlingRequestPreprocessor {
@Override
public void preprocess(SlingHttpServletRequest request, SlingHttpServletResponse response) {
// Your preprocessing logic here
String fullPagePath = request.getRequestPathInfo().getSuffix();
// Now, fullPagePath contains the full page path
}
}
Hi @Nusrat_Jahan,
When publishing a page in AEM, the process involves publishing various associated nodes, including the template policy (/conf), assets (/content/dam), content (/content), and more. To exclusively target content pages within this process, you can incorporate a filter in your code.
public class ReplicationPreprocessor implements Preprocessor {
@Override
public void preprocess(ReplicationAction action, ReplicationOptions options) throws ReplicationException {
final String path = action.getPath();
if (path.contains(CONTENT_PATH)) {
// Place your logic for content pages here
if(inValid) {
throw new ReplicationException("ERROR_MESSAGE");
}
}
}
}
By using this filter, you guarantee that your logic is executed solely on nodes residing under any path specified by CONTENT_PATH.
Views
Likes
Replies
Views
Likes
Replies