Package org.apache.jackrabbit.uuid

Examples of org.apache.jackrabbit.uuid.UUID


        Property prop = internalSetProperty(QName.JCR_ISCHECKEDOUT, InternalValue.create(true));
        prop.save();
        prop = internalSetProperty(QName.JCR_PREDECESSORS,
                new InternalValue[]{
                    InternalValue.create(new UUID(getBaseVersion().getUUID()))
                });
        prop.save();
    }
View Full Code Here


        // get frozen node type
        NodeTypeManagerImpl ntMgr = session.getNodeTypeManager();
        NodeTypeImpl nt = ntMgr.getNodeType(frozen.getFrozenPrimaryType());

        // get frozen uuid
        UUID uuid = frozen.getFrozenUUID();

        NodeImpl node = internalAddChildNode(name, nt, new NodeId(uuid));

        // get frozen mixin
        // todo: also respect mixing types on creation?
View Full Code Here

        // get frozen node type
        NodeTypeManagerImpl ntMgr = session.getNodeTypeManager();
        NodeTypeImpl nt = ntMgr.getNodeType(frozen.getFrozenPrimaryType());

        // get frozen uuid
        UUID uuid = frozen.getFrozenUUID();

        NodeImpl node = internalAddNode(relPath, nt, new NodeId(uuid));

        // get frozen mixin
        // todo: also respect mixing types on creation?
View Full Code Here

        HashSet restored = new HashSet();
        restoreFrozenState(version.getFrozenNode(), vsel, restored, removeExisting);
        restored.add(version);

        // 2. N's jcr:baseVersion property will be changed to point to V.
        UUID uuid = ((NodeId) version.getId()).getUUID();
        internalSetProperty(QName.JCR_BASEVERSION, InternalValue.create(uuid));

        // 4. N's jcr:predecessor property is set to null
        internalSetProperty(QName.JCR_PREDECESSORS, InternalValue.EMPTY_ARRAY, PropertyType.REFERENCE);
View Full Code Here

    void restoreFrozenState(InternalFrozenNode freeze, VersionSelector vsel, Set restored, boolean removeExisting)
            throws RepositoryException {

        // check uuid
        if (isNodeType(QName.MIX_REFERENCEABLE)) {
            UUID uuid = freeze.getFrozenUUID();
            if (!internalGetUUID().equals(uuid)) {
                throw new ItemExistsException("Unable to restore version of " + safeGetJCRPath() + ". UUID changed.");
            }
        }

        // check primary type
        if (!freeze.getFrozenPrimaryType().equals(primaryTypeName)) {
            // todo: check with spec what should happen here
            throw new ItemExistsException("Unable to restore version of " + safeGetJCRPath() + ". PrimaryType changed.");
        }

        // adjust mixins
        QName[] mixinNames = freeze.getFrozenMixinTypes();
        setMixinTypesProperty(new HashSet(Arrays.asList(mixinNames)));

        // copy frozen properties
        PropertyState[] props = freeze.getFrozenProperties();
        HashSet propNames = new HashSet();
        for (int i = 0; i < props.length; i++) {
            PropertyState prop = props[i];
            propNames.add(prop.getName());
            if (prop.isMultiValued()) {
                internalSetProperty(props[i].getName(), prop.getValues());
            } else {
                internalSetProperty(props[i].getName(), prop.getValues()[0]);
            }
        }
        // remove properties that do not exist in the frozen representation
        PropertyIterator piter = getProperties();
        while (piter.hasNext()) {
            PropertyImpl prop = (PropertyImpl) piter.nextProperty();
            // ignore some props that are not well guarded by the OPV
            if (prop.getQName().equals(QName.JCR_VERSIONHISTORY)) {
                continue;
            } else if (prop.getQName().equals(QName.JCR_PREDECESSORS)) {
                continue;
            }
            if (prop.getDefinition().getOnParentVersion() == OnParentVersionAction.COPY
                    || prop.getDefinition().getOnParentVersion() == OnParentVersionAction.VERSION) {
                if (!propNames.contains(prop.getQName())) {
                    removeChildProperty(prop.getQName());
                }
            }
        }

        // add 'auto-create' properties that do not exist yet
        NodeTypeManagerImpl ntMgr = session.getNodeTypeManager();
        for (int j = 0; j < mixinNames.length; j++) {
            NodeTypeImpl mixin = ntMgr.getNodeType(mixinNames[j]);
            PropertyDefinition[] pda = mixin.getAutoCreatedPropertyDefinitions();
            for (int i = 0; i < pda.length; i++) {
                PropertyDefinitionImpl pd = (PropertyDefinitionImpl) pda[i];
                if (!hasProperty(pd.getQName())) {
                    createChildProperty(pd.getQName(), pd.getRequiredType(), pd);
                }
            }
        }

        // first delete some of the version histories
        NodeIterator iter = getNodes();
        while (iter.hasNext()) {
            NodeImpl n = (NodeImpl) iter.nextNode();
            if (n.getDefinition().getOnParentVersion() == OnParentVersionAction.COPY) {
                // only remove OPV=Copy nodes
                n.internalRemove(true);
            } else if (n.getDefinition().getOnParentVersion() == OnParentVersionAction.VERSION) {
                // only remove, if node to be restored does not contain child,
                // or if restored child is not versionable
                UUID vhUUID = n.hasProperty(QName.JCR_VERSIONHISTORY)
                        ? new UUID(n.getProperty(QName.JCR_VERSIONHISTORY).getString())
                        : null;
                if (vhUUID == null || !freeze.hasFrozenHistory(vhUUID)) {
                    n.internalRemove(true);
                }
            }
View Full Code Here

     *
     * @param uuid UUID string
     * @throws IllegalArgumentException if the UUID string is invalid
     */
    public NodeId(String uuid) throws IllegalArgumentException {
        this(new UUID(uuid));
    }
View Full Code Here

     */
    public static NodeId valueOf(String s) throws IllegalArgumentException {
        if (s == null) {
            throw new IllegalArgumentException("invalid NodeId literal");
        }
        return new NodeId(new UUID(s));
    }
View Full Code Here

                    buff.append('-');
                }
            }
        }
        String u = buff.toString();
        return new UUID(u);
    }   
View Full Code Here

        }
        String[] files = itemFs.listFiles(path);
        Arrays.sort(files);
        for (int i = 0; i < files.length; i++) {
            String f = files[i];
            UUID u = getUUIDFromFileName(path + FileSystem.SEPARATOR + f);
            if (u == null) {
                continue;
            }
            if (bigger != null && bigger.toString().compareTo(u.toString()) >= 0) {
                continue;
            }
            NodeId n = new NodeId(u);
            list.add(n);
            if (maxCount > 0 && list.size() >= maxCount) {
View Full Code Here

            byte[] bytes = new byte[16];
            int pos = 0;
            while (pos < 16) {
                pos += in.read(bytes, pos, 16 - pos);
            }
            return new UUID(bytes);
        } else {
            return null;
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.uuid.UUID

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.