Package org.apache.jackrabbit.jcr2spi.hierarchy

Examples of org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry


        int infoType = pi.getType();

        PropertyState propState = null;
        QPropertyDefinition def = null;

        NodeEntry parentEntry = (NodeEntry) parentState.getHierarchyEntry();
        PropertyEntry pEntry = parentEntry.getPropertyEntry(propName);
        if (pEntry != null) {
            // a property with that name already exists...
            try {
                PropertyState existing = pEntry.getPropertyState();
                def = existing.getDefinition();
                if (def.isProtected()) {
                    // skip protected property
                    log.debug("skipping protected property " + LogUtil.safeGetJCRPath(existing, session.getPathResolver()));
                    return;
                }
                if (def.isAutoCreated()
                    && (existing.getType() == infoType || infoType == PropertyType.UNDEFINED)
                    && def.isMultiple() == existing.isMultiValued()) {
                    // this property has already been auto-created, no need to create it
                    propState = existing;
                } else {
                    throw new ItemExistsException(LogUtil.safeGetJCRPath(existing, session.getPathResolver()));
                }
            } catch (ItemNotFoundException e) {
                // property apperently doesn't exist any more
                // -> ignore
            }
        }

        Name[] parentNtNames = parentState.getAllNodeTypeNames();
        if (def == null) {
            // there's no property with that name, find applicable definition
            if (tva.length == 1) {
                // could be single- or multi-valued (n == 1)
                def = session.getItemDefinitionProvider().getQPropertyDefinition(parentNtNames, propName, infoType);
            } else {
                // can only be multi-valued (n == 0 || n > 1)
                def = session.getItemDefinitionProvider().getQPropertyDefinition(parentNtNames, propName, infoType, true);
            }
            if (def.isProtected()) {
                // skip protected property
                log.debug("skipping protected property " + propName);
                return;
            }
        }

        // retrieve the target property type needed for creation of QValue(s)
        // including an eventual conversion. the targetType is then needed for
        // setting/updating the type of the property-state.
        int targetType = def.getRequiredType();
        if (targetType == PropertyType.UNDEFINED) {
            if (infoType == PropertyType.UNDEFINED) {
                targetType = PropertyType.STRING;
            } else {
                targetType = infoType;
            }
        }

        QValue[] values = getPropertyValues(pi, targetType, def.isMultiple(), resolver);
        if (propState == null) {
            // create new property
            Operation ap = AddProperty.create(parentState, propName, targetType, def, values);
            stateMgr.execute(ap);
            propState = parentEntry.getPropertyEntry(propName).getPropertyState();
        } else {
            // modify value of existing property
            Operation sp = SetPropertyValue.create(propState, values, targetType);
            stateMgr.execute(sp);
        }
View Full Code Here


     * @see javax.jcr.version.VersionManager#createConfiguration(String, Version)
     */
    public Node createConfiguration(String absPath, Version baseline) throws UnsupportedRepositoryOperationException, RepositoryException {
        // TODO: add validation
        NodeImpl n = (NodeImpl) itemManager.getNode(resolver.getQPath(absPath));
        NodeEntry entry = vMgr.createConfiguration((NodeState) n.getItemState(), (NodeState) ((NodeImpl) baseline).getItemState());
        return (Node) itemManager.getItem(entry);
    }
View Full Code Here

    /**
     * @see javax.jcr.version.VersionManager#createActivity(String)
     */
    public Node createActivity(String title) throws UnsupportedRepositoryOperationException, RepositoryException {
        // TODO: add validation
        NodeEntry entry = vMgr.createActivity(title);
        return (Node) itemManager.getItem(entry);
    }
View Full Code Here

     * Note, that the given state must not have an overlayed state.
     * @return a state holding a lock or <code>null</code> if neither the
     * given state nor any of its ancestors is locked.
     */
    private NodeState getLockHoldingState(NodeState nodeState) {
        NodeEntry entry = nodeState.getNodeEntry();
        while (!entry.hasPropertyEntry(NameConstants.JCR_LOCKISDEEP)) {
            NodeEntry parent = entry.getParent();
            if (parent == null) {
                // reached root state without finding a locked node
                return null;
            }
            entry = parent;
View Full Code Here

        NodeId lockNodeId = lockInfo.getNodeId();
        if (lockNodeId.equals(nId)) {
            lockHoldingState = nodeState;
        } else {
            NodeEntry lockedEntry = wspManager.getHierarchyManager().getNodeEntry(lockNodeId);
            try {
                lockHoldingState = lockedEntry.getNodeState();
            } catch (RepositoryException e) {
                log.warn("Cannot build LockState");
                throw new RepositoryException("Cannot build LockState", e);
            }
        }
View Full Code Here

     */
    public void visit(SetMixin operation) throws ConstraintViolationException, AccessDeniedException, NoSuchNodeTypeException, UnsupportedRepositoryOperationException, VersionException, RepositoryException {
        // NOTE: nodestate is only modified upon save of the changes!
        Name[] mixinNames = operation.getMixinNames();
        NodeState nState = operation.getNodeState();
        NodeEntry nEntry = nState.getNodeEntry();

        // assert the existence of the property entry and set the array of
        // mixinNames to be set on the corresponding property state
        PropertyEntry mixinEntry = nEntry.getPropertyEntry(NameConstants.JCR_MIXINTYPES);
        if (mixinNames.length > 0) {
            // update/create corresponding property state
            if (mixinEntry != null) {
                // execute value of existing property
                PropertyState pState = mixinEntry.getPropertyState();
View Full Code Here

     */
    public void visit(SetPrimaryType operation) throws ConstraintViolationException, RepositoryException {
        // NOTE: nodestate is only modified upon save of the changes!
        Name primaryName = operation.getPrimaryTypeName();
        NodeState nState = operation.getNodeState();
        NodeEntry nEntry = nState.getNodeEntry();

        // detect obvious node type conflicts

        EffectiveNodeTypeProvider entProvider = mgrProvider.getEffectiveNodeTypeProvider();

        // try to build new effective node type (will throw in case of conflicts)
        Name[] mixins = nState.getMixinTypeNames();
        List<Name> all = new ArrayList<Name>(Arrays.asList(mixins));
        all.add(primaryName);
        EffectiveNodeType entAll = entProvider.getEffectiveNodeType(all.toArray(new Name[all.size()]));

        // modify the value of the jcr:primaryType property entry without
        // changing the node state itself
        PropertyEntry pEntry = nEntry.getPropertyEntry(NameConstants.JCR_PRIMARYTYPE);
        PropertyState pState = pEntry.getPropertyState();
        int options = ItemStateValidator.CHECK_VERSIONING | ItemStateValidator.CHECK_LOCK;
        setPropertyStateValue(pState, getQValues(new Name[] {primaryName}, qValueFactory), PropertyType.NAME, options);

        // mark the affected node state modified and remember the operation
View Full Code Here

        status = STATUS_PERSISTED;
        if (isActivityMerge()) {
            // TODO invalidate
        } else {
            try {
                NodeEntry vhe = mgr.getVersionHistoryEntry(nodeState);
                if (vhe != null) {
                    vhe.invalidate(true);
                }
            } catch (RepositoryException e) {
                log.warn("Error while retrieving VersionHistory entry:", e.getMessage());
            }
            nodeState.getHierarchyEntry().invalidate(true);
View Full Code Here

     * @see javax.jcr.Session#getRootNode()
     */
    public Node getRootNode() throws RepositoryException {
        checkIsAlive();

        NodeEntry re = getHierarchyManager().getRootEntry();
        return (Node) itemManager.getItem(re);
    }
View Full Code Here

     */
    private Node getNodeById(NodeId id) throws ItemNotFoundException, RepositoryException {
        // check sanity of this session
        checkIsAlive();
        try {
            NodeEntry nodeEntry = getHierarchyManager().getNodeEntry(id);
            Item item = getItemManager().getItem(nodeEntry);
            if (item.isNode()) {
                return (Node) item;
            } else {
                log.error("NodeId '" + id + " does not point to a Node");
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry

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.