Package org.apache.jackrabbit.core.id

Examples of org.apache.jackrabbit.core.id.NodeId


    /**
     * {@inheritDoc}
     */
    public Node getNodeByUUID(String uuid) throws ItemNotFoundException, RepositoryException {
        try {
            NodeImpl node = getNodeById(new NodeId(uuid));
            if (node.isNodeType(NameConstants.MIX_REFERENCEABLE)) {
                return node;
            } else {
                // there is a node with that uuid but the node does not expose it
                throw new ItemNotFoundException(uuid);
View Full Code Here


        // /JCR-2425: check whether session is allowed to read root node
        if (hasPermission("/", ACTION_READ)) {
            getItemManager().getRootNode().save();
        } else {
            NodeId id = getItemStateManager().getIdOfRootTransientNodeState();
            getItemManager().getItem(id).save();
        }
    }
View Full Code Here

        if (existing != null && !newTargetDef.allowsSameNameSiblings()) {
            throw new ItemExistsException(
                    "Same name siblings not allowed: " + existing);
        }

        NodeId targetId = targetNode.getNodeId();
        int index = srcName.getIndex();
        if (index == 0) {
            index = 1;
        }
View Full Code Here

     * @see javax.jcr.Session#getNodeByIdentifier(String)
     * @since JCR 2.0
     */
    public Node getNodeByIdentifier(String id)
            throws ItemNotFoundException, RepositoryException {
        NodeId nodeId;
        try {
            nodeId = NodeId.valueOf(id);
        } catch (IllegalArgumentException iae) {
            throw new RepositoryException("invalid identifier: " + id);
        }
View Full Code Here

        Name versionName = labelCache.get(label);
        if (versionName == null) {
            return null;
        }

        NodeId id = nameCache.get(versionName);
        InternalVersion v = versionCache.get(id);
        if (v == null) {
            v = createVersionInstance(versionName);
        }
        return v;
View Full Code Here

        InternalValue[] predecessors;
        if (src.hasProperty(NameConstants.JCR_PREDECESSORS)) {
            predecessors = src.getPropertyValues(NameConstants.JCR_PREDECESSORS);
            // check all predecessors
            for (InternalValue pred: predecessors) {
                NodeId predId = pred.getNodeId();
                // check if version exist
                if (!nameCache.containsValue(predId)) {
                    throw new RepositoryException(
                            "Invalid predecessor in source node: " + predId);
                }
            }
        } else {
            // with simple versioning, the node does not contain a predecessors
            // property and we just use the 'head' version as predecessor
            Iterator<NodeId> iter = nameCache.values().iterator();
            NodeId last = null;
            while (iter.hasNext()) {
                last = iter.next();
            }
            if (last == null) {
                // should never happen
                last = rootVersion.getId();
            }
            predecessors = new InternalValue[]{InternalValue.create(last)};
        }

        NodeId versionId = new NodeId();
        NodeStateEx vNode = node.addNode(name, NameConstants.NT_VERSION, versionId, true);

        // check for jcr:activity
        if (src.hasProperty(NameConstants.JCR_ACTIVITY)) {
            InternalValue act = src.getPropertyValue(NameConstants.JCR_ACTIVITY);
View Full Code Here

    static NodeStateEx create(
            InternalVersionManagerBase vMgr, NodeStateEx parent, Name name,
            NodeState nodeState, NodeId copiedFrom) throws RepositoryException {

        // create history node
        NodeId historyId = new NodeId();
        NodeStateEx pNode = parent.addNode(name, NameConstants.NT_VERSIONHISTORY, historyId, true);

        // set the versionable uuid
        String versionableUUID = nodeState.getNodeId().toString();
        pNode.setPropertyValue(NameConstants.JCR_VERSIONABLEUUID, InternalValue.create(versionableUUID));

        // create label node
        pNode.addNode(NameConstants.JCR_VERSIONLABELS, NameConstants.NT_VERSIONLABELS, null, false);

        // initialize the 'jcr:copiedFrom' property
        if (copiedFrom != null) {
            pNode.setPropertyValue(NameConstants.JCR_COPIEDFROM, InternalValue.create(copiedFrom, true));
        }

        // create root version
        NodeId versionId = new NodeId();
        NodeStateEx vNode = pNode.addNode(NameConstants.JCR_ROOTVERSION, NameConstants.NT_VERSION, versionId, true);

        // initialize 'created' and 'predecessors'
        vNode.setPropertyValue(NameConstants.JCR_CREATED, InternalValue.create(getCurrentTime()));
        vNode.setPropertyValues(NameConstants.JCR_PREDECESSORS, PropertyType.REFERENCE, InternalValue.EMPTY_ARRAY);
View Full Code Here

            // check same-name sibling setting of new node
            if (!def.allowsSameNameSiblings()) {
                throw new ItemExistsException(itemMgr.safeGetJCRPath(nodePath));
            }
            // check same-name sibling setting of existing node
            NodeId newId = cne.getId();
            if (!((NodeImpl) itemMgr.getItem(newId)).getDefinition().allowsSameNameSiblings()) {
                throw new ItemExistsException(itemMgr.safeGetJCRPath(nodePath));
            }
        }

        // (5) do clone operation
        NodeId parentId = getNodeId();
        src.addShareParent(parentId);

        // (6) modify the state of 'this', i.e. the parent node
        NodeId srcId = src.getNodeId();
        thisState = (NodeState) getOrCreateTransientItemState();
        // add new child node entry
        thisState.addChildNodeEntry(name, srcId);

        return itemMgr.getNode(srcId, parentId);
View Full Code Here

            throws ItemNotFoundException, AccessDeniedException, RepositoryException {
        // check state of this instance
        sanityCheck();

        // check if root node
        NodeId parentId = getParentId();
        if (parentId == null) {
            String msg = "root node doesn't have a parent";
            log.debug(msg);
            throw new ItemNotFoundException(msg);
        }
View Full Code Here

        if (nodeTypeName != null) {
            typeName = session.getQName(nodeTypeName);
        }

        // Check that the given UUID (if any) does not already exist
        NodeId id = null;
        if (uuid != null) {
            id = new NodeId(uuid);
            if (itemMgr.itemExists(id)) {
                throw new ItemExistsException(
                        "A node with this UUID already exists: " + uuid);
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.core.id.NodeId

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.