Search in sources :

Example 1 with PostValidationHook

use of org.apache.jackrabbit.oak.spi.commit.PostValidationHook in project jackrabbit-oak by apache.

the class MutableRoot method getCommitHook.

/**
     * Combine the globally defined commit hook(s) and the hooks and validators defined by the
     * various security related configurations.
     *
     * @return A commit hook combining repository global commit hook(s) with the pluggable hooks
     *         defined with the security modules and the padded {@code hooks}.
     */
private CommitHook getCommitHook() {
    List<CommitHook> hooks = newArrayList();
    hooks.add(ResetCommitAttributeHook.INSTANCE);
    hooks.add(hook);
    List<CommitHook> postValidationHooks = new ArrayList<CommitHook>();
    for (SecurityConfiguration sc : securityProvider.getConfigurations()) {
        for (CommitHook ch : sc.getCommitHooks(workspaceName)) {
            if (ch instanceof PostValidationHook) {
                postValidationHooks.add(ch);
            } else if (ch != EmptyHook.INSTANCE) {
                hooks.add(ch);
            }
        }
        List<? extends ValidatorProvider> validators = sc.getValidators(workspaceName, subject.getPrincipals(), moveTracker);
        if (!validators.isEmpty()) {
            hooks.add(new EditorHook(CompositeEditorProvider.compose(validators)));
        }
    }
    hooks.addAll(postValidationHooks);
    return CompositeHook.compose(hooks);
}
Also used : CommitHook(org.apache.jackrabbit.oak.spi.commit.CommitHook) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) ArrayList(java.util.ArrayList) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) PostValidationHook(org.apache.jackrabbit.oak.spi.commit.PostValidationHook) SecurityConfiguration(org.apache.jackrabbit.oak.spi.security.SecurityConfiguration)

Aggregations

Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 ArrayList (java.util.ArrayList)1 CommitHook (org.apache.jackrabbit.oak.spi.commit.CommitHook)1 EditorHook (org.apache.jackrabbit.oak.spi.commit.EditorHook)1 PostValidationHook (org.apache.jackrabbit.oak.spi.commit.PostValidationHook)1 SecurityConfiguration (org.apache.jackrabbit.oak.spi.security.SecurityConfiguration)1