Search in sources :

Example 1 with VersionImpl

use of org.apache.jackrabbit.oak.jcr.version.VersionImpl 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);
    }
}
Also used : VersionHistoryImpl(org.apache.jackrabbit.oak.jcr.version.VersionHistoryImpl) VersionManagerDelegate(org.apache.jackrabbit.oak.jcr.delegate.VersionManagerDelegate) NodeDelegate(org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate) PropertyDelegate(org.apache.jackrabbit.oak.jcr.delegate.PropertyDelegate) VersionImpl(org.apache.jackrabbit.oak.jcr.version.VersionImpl) Nonnull(javax.annotation.Nonnull)

Aggregations

Nonnull (javax.annotation.Nonnull)1 NodeDelegate (org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate)1 PropertyDelegate (org.apache.jackrabbit.oak.jcr.delegate.PropertyDelegate)1 VersionManagerDelegate (org.apache.jackrabbit.oak.jcr.delegate.VersionManagerDelegate)1 VersionHistoryImpl (org.apache.jackrabbit.oak.jcr.version.VersionHistoryImpl)1 VersionImpl (org.apache.jackrabbit.oak.jcr.version.VersionImpl)1