use of org.apache.jackrabbit.oak.spi.state.ApplyDiff in project jackrabbit-oak by apache.
the class PrivilegeInitializer method initialize.
@Override
public void initialize(@Nonnull NodeBuilder builder) {
NodeBuilder system = builder.child(JcrConstants.JCR_SYSTEM);
system.setProperty(JcrConstants.JCR_PRIMARYTYPE, NodeTypeConstants.NT_REP_SYSTEM, Type.NAME);
if (!system.hasChildNode(REP_PRIVILEGES)) {
NodeBuilder privileges = system.child(REP_PRIVILEGES);
privileges.setProperty(JcrConstants.JCR_PRIMARYTYPE, NT_REP_PRIVILEGES, Type.NAME);
// squeeze node state before it is passed to store (OAK-2411)
NodeState base = squeeze(builder.getNodeState());
NodeStore store = new MemoryNodeStore(base);
try {
Root systemRoot = rootProvider.createSystemRoot(store, null);
new PrivilegeDefinitionWriter(systemRoot).writeBuiltInDefinitions();
} catch (RepositoryException e) {
log.error("Failed to register built-in privileges", e);
throw new RuntimeException(e);
}
NodeState target = store.getRoot();
target.compareAgainstBaseState(base, new ApplyDiff(builder));
}
}
Aggregations