Package org.apache.jackrabbit.name

Examples of org.apache.jackrabbit.name.QName


         * todo: need to come up with some callback mechanism for applying system generated values
         * (e.g. using a NodeTypeInstanceHandler interface)
         */

        // compute system generated values
        QName declaringNT = def.getDeclaringNodeType();
        QName name = def.getName();
        if (QName.MIX_REFERENCEABLE.equals(declaringNT)) {
            // mix:referenceable node type
            if (QName.JCR_UUID.equals(name)) {
                // jcr:uuid property
                genValues = new InternalValue[]{InternalValue.create(
View Full Code Here


        // remove properties
        // use temp set to avoid ConcurrentModificationException
        HashSet tmp = new HashSet(targetState.getPropertyNames());
        for (Iterator iter = tmp.iterator(); iter.hasNext();) {
            QName propName = (QName) iter.next();
            PropertyId propId =
                    new PropertyId(targetState.getNodeId(), propName);
            try {
                PropertyState propState =
                        (PropertyState) stateMgr.getItemState(propId);
View Full Code Here

                newState.addChildNodeEntry(entry.getName(), newChildState.getNodeId());
            }
            // copy properties
            iter = srcState.getPropertyNames().iterator();
            while (iter.hasNext()) {
                QName propName = (QName) iter.next();
                PropertyId propId = new PropertyId(srcState.getNodeId(), propName);
                if (!srcAccessMgr.isGranted(propId, AccessManager.READ)) {
                    continue;
                }
                PropertyState srcChildState =
                        (PropertyState) srcStateMgr.getItemState(propId);

                /**
                 * special handling required for properties with special semantics
                 * (e.g. those defined by mix:referenceable, mix:versionable,
                 * mix:lockable, et.al.)
                 *
                 * todo FIXME delegate to 'node type instance handler'
                 */
                PropDefId defId = srcChildState.getDefinitionId();
                PropDef def = ntReg.getPropDef(defId);
                if (def.getDeclaringNodeType().equals(QName.MIX_LOCKABLE)) {
                    // skip properties defined by mix:lockable
                    continue;
                }

                PropertyState newChildState =
                        copyPropertyState(srcChildState, id, propName);

                if (versionable && flag == COPY) {
                    /**
                     * a versionable node is being copied:
                     * copied properties declared by mix:versionable need to be
                     * adjusted accordingly.
                     */
                    if (propName.equals(QName.JCR_VERSIONHISTORY)) {
                        // jcr:versionHistory
                        VersionHistory vh = getOrCreateVersionHistory(newState);
                        newChildState.setValues(new InternalValue[]{InternalValue.create(new UUID(vh.getUUID()))});
                    } else if (propName.equals(QName.JCR_BASEVERSION)) {
                        // jcr:baseVersion
                        VersionHistory vh = getOrCreateVersionHistory(newState);
                        newChildState.setValues(new InternalValue[]{InternalValue.create(new UUID(vh.getRootVersion().getUUID()))});
                    } else if (propName.equals(QName.JCR_PREDECESSORS)) {
                        // jcr:predecessors
                        VersionHistory vh = getOrCreateVersionHistory(newState);
                        newChildState.setValues(new InternalValue[]{InternalValue.create(new UUID(vh.getRootVersion().getUUID()))});
                    } else if (propName.equals(QName.JCR_ISCHECKEDOUT)) {
                        // jcr:isCheckedOut
                        newChildState.setValues(new InternalValue[]{InternalValue.create(true)});
                    }
                }

View Full Code Here

        out.writeShort(state.getModCount());
        // properties (names)
        c = state.getPropertyNames();
        out.writeInt(c.size()); // count
        for (Iterator iter = c.iterator(); iter.hasNext();) {
            QName propName = (QName) iter.next();
            out.writeUTF(propName.toString());   // name
        }
        // child nodes (list of name/uuid pairs)
        c = state.getChildNodeEntries();
        out.writeInt(c.size()); // count
        for (Iterator iter = c.iterator(); iter.hasNext();) {
View Full Code Here

            state.addPropertyName(QName.valueOf(in.readUTF())); // name
        }
        // child nodes (list of name/uuid pairs)
        count = in.readInt();   // count
        for (int i = 0; i < count; i++) {
            QName name = QName.valueOf(in.readUTF());    // name
            // uuid
            in.readFully(uuidBytes);
            state.addChildNodeEntry(name, new NodeId(new UUID(uuidBytes)));
        }
    }
View Full Code Here

     * @return true if the specified node is <i>referenceable</i>, false otherwise.
     * @throws ItemStateException if an error occurs
     */
    private boolean isReferenceable(NodeState state) throws ItemStateException {
        // shortcut: check some wellknown built-in types first
        QName primary = state.getNodeTypeName();
        Set mixins = state.getMixinTypeNames();
        if (mixins.contains(QName.MIX_REFERENCEABLE)
                || mixins.contains(QName.MIX_VERSIONABLE)
                || primary.equals(QName.NT_RESOURCE)) {
            return true;
        }
        // build effective node type
        QName[] types = new QName[mixins.size() + 1];
        mixins.toArray(types);
View Full Code Here

        if (elements.length == next) {
            return state.getId();
        }
        Path.PathElement elem = elements[next];

        QName name = elem.getName();
        int index = elem.getIndex();
        if (index == 0) {
            index = 1;
        }
View Full Code Here

            } else {
                builder.addLast(entry.getName(), entry.getIndex());
            }
        } else {
            PropertyState propState = (PropertyState) state;
            QName name = propState.getName();
            // add to path
            builder.addLast(name);
        }
    }
View Full Code Here

                    if (stateMgr.hasItemState(id)) {
                        NodeState state = (NodeState) stateMgr.getItemState(id);
                        NodeStateEx pNode = new NodeStateEx(stateMgr, ntReg, state, null);
                        NodeId parentId = pNode.getParentId();
                        InternalVersionItem parent = getItem(parentId);
                        QName ntName = state.getNodeTypeName();
                        if (ntName.equals(QName.NT_FROZENNODE)) {
                            item = new InternalFrozenNodeImpl(this, pNode, parent);
                        } else if (ntName.equals(QName.NT_VERSIONEDCHILD)) {
                            item = new InternalFrozenVHImpl(this, pNode, parent);
                        } else if (ntName.equals(QName.NT_VERSION)) {
                            item = ((InternalVersionHistory) parent).getVersion(id);
                        } else if (ntName.equals(QName.NT_VERSIONHISTORY)) {
                            item = new InternalVersionHistoryImpl(this, pNode);
                        } else {
                            return null;
                        }
                    } else {
View Full Code Here

            // process node

            NodeState node = null;
            NodeId id = nodeInfo.getId();
            QName nodeName = nodeInfo.getName();
            QName ntName = nodeInfo.getNodeTypeName();
            QName[] mixins = nodeInfo.getMixinNames();

            if (parent == null) {
                // parent node was skipped, skip this child node also
                parents.push(null); // push null onto stack for skipped node
                succeeded = true;
                log.debug("skipping node " + nodeName);
                return;
            }
            if (parent.hasChildNodeEntry(nodeName)) {
                // a node with that name already exists...
                NodeState.ChildNodeEntry entry =
                        parent.getChildNodeEntry(nodeName, 1);
                NodeId idExisting = entry.getId();
                NodeState existing = (NodeState) itemOps.getItemState(idExisting);
                NodeDef def = ntReg.getNodeDef(existing.getDefinitionId());

                if (!def.allowsSameNameSiblings()) {
                    // existing doesn't allow same-name siblings,
                    // check for potential conflicts
                    EffectiveNodeType entExisting =
                            itemOps.getEffectiveNodeType(existing);
                    if (def.isProtected() && entExisting.includesNodeType(ntName)) {
                        // skip protected node
                        parents.push(null); // push null onto stack for skipped node
                        succeeded = true;
                        log.debug("skipping protected node "
                                + itemOps.safeGetJCRPath(existing.getNodeId()));
                        return;
                    }
                    if (def.isAutoCreated() && entExisting.includesNodeType(ntName)) {
                        // this node has already been auto-created,
                        // no need to create it
                        node = existing;
                    } else {
                        throw new ItemExistsException(itemOps.safeGetJCRPath(existing.getNodeId()));
                    }
                }
            }

            if (node == null) {
                // there's no node with that name...
                if (id == null) {
                    // no potential uuid conflict, always create new node

                    NodeDef def =
                            itemOps.findApplicableNodeDefinition(nodeName, ntName, parent);
                    if (def.isProtected()) {
                        // skip protected node
                        parents.push(null); // push null onto stack for skipped node
                        succeeded = true;
                        log.debug("skipping protected node " + nodeName);
                        return;
                    }

                    if (parent.hasPropertyName(nodeName)) {
                        /**
                         * a property with the same name already exists; if this property
                         * has been imported as well (e.g. through document view import
                         * where an element can have the same name as one of the attributes
                         * of its parent element) we have to rename the onflicting property;
                         *
                         * see http://issues.apache.org/jira/browse/JCR-61
                         */
                        PropertyId propId = new PropertyId(parent.getNodeId(), nodeName);
                        PropertyState conflicting = itemOps.getPropertyState(propId);
                        if (conflicting.getStatus() == ItemState.STATUS_NEW) {
                            // assume this property has been imported as well;
                            // rename conflicting property
                            // @todo use better reversible escaping scheme to create unique name
                            QName newName = new QName(nodeName.getNamespaceURI(), nodeName.getLocalName() + "_");
                            if (parent.hasPropertyName(newName)) {
                                newName = new QName(newName.getNamespaceURI(), newName.getLocalName() + "_");
                            }
                            PropertyState newProp =
                                    itemOps.createPropertyState(parent, newName,
                                            conflicting.getType(), conflicting.getValues().length);
                            newProp.setValues(conflicting.getValues());
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.name.QName

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.