Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
Servlets Post 2.0.2
-
None
Description
Currently during a post, a SlingPostOperation is selected and then executed. The post operation does "everything", performing the changes and saving them.
I think we could reintroduce a Changes interface with several implementations like Add, Remove, Copy etc. This interface has all knowledge of what to change.
The SlingPostOperation would then return a list of changes:
interface SlingPostOperation {
List <Change> prepare(SlingHttpServletRequest);
}
So the first step when a post comes in, is still to select the post operation, but then this operation just generates a list of changes without changing anything in the repository.
We then introduce pre and post processor interfaces (these are no final names yet
interface PreProcessor {
void process(SlingHttpServletRequest, List<Change>);
}
interface PostProcessor {
void process(SlingHttpServletRequest, List<Change>);
}
There can be several pre and post processor registered, a property of a processor is used to order them and guarantee an ordered execution.
A pre processor can alter the list of changes.
When all pre processors are run, the changes are applied to the repository by Sling, then all post processors are executed.
Finally all changes are saved.