in src/main/java/org/apache/sling/servlets/post/impl/SlingPostServlet.java [254:313]
protected void doPost(final SlingJakartaHttpServletRequest request, final SlingJakartaHttpServletResponse response)
throws IOException {
final VersioningConfiguration localVersioningConfig = createRequestVersioningConfiguration(request);
request.setAttribute(VersioningConfiguration.class.getName(), localVersioningConfig);
// prepare the response
final JakartaPostResponse htmlResponse = createPostResponse(request);
htmlResponse.setReferer(request.getHeader("referer"));
final JakartaPostOperation operation = getSlingPostOperation(request);
if (operation == null) {
htmlResponse.setStatus(
HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Invalid operation specified for POST request");
} else {
request.getRequestProgressTracker()
.log("Calling PostOperation: {0}", operation.getClass().getName());
final SlingJakartaPostProcessor[] processors = this.cachedPostProcessors;
try {
operation.run(request, htmlResponse, processors);
} catch (ResourceNotFoundException rnfe) {
htmlResponse.setStatus(HttpServletResponse.SC_NOT_FOUND, rnfe.getMessage());
} catch (final PreconditionViolatedPersistenceException e) {
logPersistenceException(request, operation, e);
if (backwardsCompatibleStatuscode) {
htmlResponse.setError(e);
} else {
htmlResponse.setStatus(422, "invalid payload");
}
} catch (final PersistenceException e) {
// also catches the RetryableOperationException, as the handling is the same
logPersistenceException(request, operation, e);
if (backwardsCompatibleStatuscode) {
htmlResponse.setError(e);
} else {
htmlResponse.setStatus(
HttpServletResponse.SC_CONFLICT, "repository state conflicting with request");
}
} catch (final Exception e) {
log.warn(
"Exception while handling POST on path [{}] with operation [{}]",
request.getResource().getPath(),
operation.getClass().getName(),
e);
htmlResponse.setError(e);
}
}
// check for redirect URL if processing succeeded
if (htmlResponse.isSuccessful()) {
if (redirectIfNeeded(request, htmlResponse, response)) {
return;
}
}
// create a html response and send if unsuccessful or no redirect
htmlResponse.send(response, isSetStatus(request));
}