in src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractPostOperation.java [84:209]
public void run(
final SlingJakartaHttpServletRequest request,
final JakartaPostResponse response,
final SlingJakartaPostProcessor[] processors)
throws PreconditionViolatedPersistenceException, TemporaryPersistenceException, PersistenceException {
final VersioningConfiguration versionableConfiguration = getVersioningConfiguration(request);
try {
// calculate the paths
String path = this.getResourcePath(request);
response.setPath(path);
// location
response.setLocation(externalizePath(request, path));
// parent location
path = ResourceUtil.getParent(path);
if (path != null) {
response.setParentLocation(externalizePath(request, path));
}
final List<Modification> changes = new ArrayList<>();
doRun(request, response, changes);
// invoke processors
try {
if (processors != null) {
for (SlingJakartaPostProcessor processor : processors) {
request.getRequestProgressTracker()
.log(
"Calling Sling Post Processor {0}",
processor.getClass().getName());
processor.process(request, changes);
}
}
} catch (PreconditionViolatedPersistenceException | TemporaryPersistenceException e) {
throw e;
} catch (Exception e) {
throw new PersistenceException("Exception during response processing", e);
}
// check modifications for remaining postfix and store the base path
final Map<String, String> modificationSourcesContainingPostfix = new HashMap<>();
final Set<String> allModificationSources = new HashSet<>(changes.size());
for (final Modification modification : changes) {
final String source = modification.getSource();
if (source != null) {
allModificationSources.add(source);
final int atIndex = source.indexOf('@');
if (atIndex > 0) {
modificationSourcesContainingPostfix.put(source.substring(0, atIndex), source);
}
}
}
// fail if any of the base paths (before the postfix) which had a postfix are contained in the modification
// set
if (modificationSourcesContainingPostfix.size() > 0) {
for (final Map.Entry<String, String> sourceToCheck : modificationSourcesContainingPostfix.entrySet()) {
if (allModificationSources.contains(sourceToCheck.getKey())) {
throw new PersistenceException("Postfix-containing path " + sourceToCheck.getValue()
+ " contained in the modification list. Check configuration.");
}
}
}
final Set<String> nodesToCheckin = new LinkedHashSet<>();
// set changes on html response
for (Modification change : changes) {
switch (change.getType()) {
case MODIFY:
response.onModified(change.getSource());
break;
case DELETE:
response.onDeleted(change.getSource());
break;
case MOVE:
response.onMoved(change.getSource(), change.getDestination());
break;
case COPY:
response.onCopied(change.getSource(), change.getDestination());
break;
case CREATE:
response.onCreated(change.getSource());
if (versionableConfiguration.isCheckinOnNewVersionableNode()) {
nodesToCheckin.add(change.getSource());
}
break;
case ORDER:
response.onChange("ordered", change.getSource(), change.getDestination());
break;
case CHECKOUT:
response.onChange("checkout", change.getSource());
nodesToCheckin.add(change.getSource());
break;
case CHECKIN:
response.onChange("checkin", change.getSource());
nodesToCheckin.remove(change.getSource());
break;
case RESTORE:
response.onChange("restore", change.getSource());
break;
}
}
if (isResourceResolverCommitRequired(request)) {
request.getResourceResolver().commit();
}
if (!isSkipCheckin(request)) {
// now do the checkins
for (String checkinPath : nodesToCheckin) {
if (this.jcrSupport.checkin(request.getResourceResolver().getResource(checkinPath))) {
response.onChange("checkin", checkinPath);
}
}
}
} finally {
if (isResourceResolverCommitRequired(request)) {
request.getResourceResolver().revert();
}
}
}