use of org.apache.jackrabbit.oak.jcr.delegate.PropertyDelegate in project jackrabbit-oak by apache.
the class SessionImpl method getItemInternal.
@CheckForNull
private ItemImpl<?> getItemInternal(@Nonnull String oakPath) throws RepositoryException {
checkAlive();
ItemDelegate item = sd.getItem(oakPath);
if (item instanceof NodeDelegate) {
return NodeImpl.createNode((NodeDelegate) item, sessionContext);
} else if (item instanceof PropertyDelegate) {
return new PropertyImpl((PropertyDelegate) item, sessionContext);
} else {
return null;
}
}
use of org.apache.jackrabbit.oak.jcr.delegate.PropertyDelegate in project jackrabbit-oak by apache.
the class NodeImpl method setMixins.
/**
* Simplified implementation of the {@link org.apache.jackrabbit.api.JackrabbitNode#setMixins(String[])}
* method that adds all mixin types that are not yet present on this node
* and removes all mixins that are no longer contained in the specified
* array. Note, that this implementation will not work exactly like the
* variant in Jackrabbit 2.x which first created the effective node type
* and adjusted the set of child items accordingly.
*
* @param mixinNames
* @throws RepositoryException
*/
@Override
public void setMixins(String[] mixinNames) throws RepositoryException {
final Set<String> oakTypeNames = newLinkedHashSet();
for (String mixinName : mixinNames) {
oakTypeNames.add(getOakName(checkNotNull(mixinName)));
}
sessionDelegate.performVoid(new ItemWriteOperation<Void>("setMixins") {
@Override
public void checkPreconditions() throws RepositoryException {
super.checkPreconditions();
if (!isCheckedOut()) {
throw new VersionException(format("Cannot set mixin types. Node [%s] is checked in.", getNodePath()));
}
// check for NODE_TYPE_MANAGEMENT permission here as we cannot
// distinguish between a combination of removeMixin and addMixin
// and Node#remove plus subsequent addNode when it comes to
// autocreated properties like jcr:create, jcr:uuid and so forth.
PropertyDelegate mixinProp = dlg.getPropertyOrNull(JCR_MIXINTYPES);
if (mixinProp != null) {
sessionContext.getAccessManager().checkPermissions(dlg.getTree(), mixinProp.getPropertyState(), Permissions.NODE_TYPE_MANAGEMENT);
}
}
@Override
public void performVoid() throws RepositoryException {
dlg.setMixins(oakTypeNames);
}
});
}
use of org.apache.jackrabbit.oak.jcr.delegate.PropertyDelegate in project jackrabbit-oak by apache.
the class NodeImpl method createNode.
@Nonnull
public static NodeImpl<? extends NodeDelegate> createNode(@Nonnull NodeDelegate delegate, @Nonnull SessionContext context) throws RepositoryException {
PropertyDelegate pd = delegate.getPropertyOrNull(JCR_PRIMARYTYPE);
String type = pd != null ? pd.getString() : null;
if (JcrConstants.NT_VERSION.equals(type)) {
VersionManagerDelegate vmd = VersionManagerDelegate.create(context.getSessionDelegate());
return new VersionImpl(vmd.createVersion(delegate), context);
} else if (JcrConstants.NT_VERSIONHISTORY.equals(type)) {
VersionManagerDelegate vmd = VersionManagerDelegate.create(context.getSessionDelegate());
return new VersionHistoryImpl(vmd.createVersionHistory(delegate), context);
} else {
return new NodeImpl<NodeDelegate>(delegate, context);
}
}
Aggregations