use of javax.annotation.Nonnull in project jackrabbit-oak by apache.
the class CugPermissionProvider method getTreePermission.
@Nonnull
@Override
public TreePermission getTreePermission(@Nonnull Tree tree, @Nonnull TreePermission parentPermission) {
if (TreePermission.NO_RECOURSE == parentPermission) {
throw new IllegalStateException("Attempt to create tree permission for path '" + tree.getPath() + "', which is either not supported or doesn't contain any CUGs.");
}
Tree immutableTree = getImmutableTree(tree);
TreeType type = typeProvider.getType(immutableTree);
return getTreePermission(immutableTree, type, parentPermission);
}
use of javax.annotation.Nonnull in project jackrabbit-oak by apache.
the class RepoPolicyTreePermissionTest method getTreePermission.
@Nonnull
private TreePermission getTreePermission(@Nonnull ContentSession cs, @Nonnull String path) throws Exception {
Root r = cs.getLatestRoot();
PermissionProvider pp = config.getPermissionProvider(r, cs.getWorkspaceName(), cs.getAuthInfo().getPrincipals());
Tree t = r.getTree(PathUtils.ROOT_PATH);
TreePermission tp = pp.getTreePermission(t, TreePermission.EMPTY);
for (String name : PathUtils.elements(path)) {
t = t.getChild(name);
tp = pp.getTreePermission(t, tp);
}
return tp;
}
use of javax.annotation.Nonnull in project jackrabbit-oak by apache.
the class CommitContextTest method attributeAddedByCommitHook.
@Test
public void attributeAddedByCommitHook() throws Exception {
repository = new Oak(store).with(new OpenSecurityProvider()).with(observer).with(new CommitHook() {
@Nonnull
@Override
public NodeState processCommit(NodeState before, NodeState after, CommitInfo info) throws CommitFailedException {
CommitContext attrs = (CommitContext) info.getInfo().get(CommitContext.NAME);
assertNotNull(attrs);
attrs.set("foo", "bar");
return after;
}
}).createContentRepository();
session = newSession();
Root root = session.getLatestRoot();
Tree tree = root.getTree("/");
tree.setProperty("a", 1);
root.commit();
assertNotNull(observer.info);
CommitContext attrs = (CommitContext) observer.info.getInfo().get(CommitContext.NAME);
assertNotNull(attrs.get("foo"));
}
use of javax.annotation.Nonnull in project jackrabbit-oak by apache.
the class SegmentNodeState method getProperties.
@Override
@Nonnull
public Iterable<PropertyState> getProperties() {
Template template = getTemplate();
PropertyTemplate[] propertyTemplates = template.getPropertyTemplates();
List<PropertyState> list = newArrayListWithCapacity(propertyTemplates.length + 2);
PropertyState primaryType = template.getPrimaryType();
if (primaryType != null) {
list.add(primaryType);
}
PropertyState mixinTypes = template.getMixinTypes();
if (mixinTypes != null) {
list.add(mixinTypes);
}
Segment segment = getSegment();
int ids = 2;
if (template.getChildName() != Template.ZERO_CHILD_NODES) {
ids++;
}
if (propertyTemplates.length > 0) {
ListRecord pIds = new ListRecord(segment.readRecordId(getRecordNumber(), 0, ids), propertyTemplates.length);
for (int i = 0; i < propertyTemplates.length; i++) {
RecordId propertyId = pIds.getEntry(i);
list.add(reader.readProperty(propertyId, propertyTemplates[i]));
}
}
return list;
}
use of javax.annotation.Nonnull in project jackrabbit-oak by apache.
the class SegmentNodeStore method merge.
@Nonnull
@Override
public NodeState merge(@Nonnull NodeBuilder builder, @Nonnull CommitHook commitHook, @Nonnull CommitInfo info) throws CommitFailedException {
checkArgument(builder instanceof SegmentNodeBuilder);
checkArgument(((SegmentNodeBuilder) builder).isRootBuilder());
return scheduler.schedule(new Commit(builder, commitHook, info));
}
Aggregations