Package org.apache.jackrabbit.core.virtual

Examples of org.apache.jackrabbit.core.virtual.VirtualNodeState


     * {@inheritDoc}
     * <p/>
     * currently we have no dynamic ones, we just recreate the entire nodetypes tree
     */
    protected VirtualNodeState createRootNodeState() throws RepositoryException {
        VirtualNodeState root = new VirtualNodeState(this, parentId, rootNodeId, NameConstants.REP_NODETYPES, null);
        Name[] ntNames = ntReg.getRegisteredNodeTypes();
        for (int i = 0; i < ntNames.length; i++) {
            QNodeTypeDefinition ntDef = ntReg.getNodeTypeDef(ntNames[i]);
            VirtualNodeState ntState = createNodeTypeState(root, ntDef);
            root.addChildNodeEntry(ntNames[i], ntState.getNodeId());
            // add as hard reference
            root.addStateReference(ntState);
        }
        return root;
    }
View Full Code Here


    /**
     * {@inheritDoc}
     */
    public void onNodeTypeAdded(Name ntName) throws RepositoryException {
        try {
            VirtualNodeState root = (VirtualNodeState) getRootState();
            QNodeTypeDefinition ntDef = ntReg.getNodeTypeDef(ntName);
            VirtualNodeState ntState = createNodeTypeState(root, ntDef);
            root.addChildNodeEntry(ntName, ntState.getNodeId());

            // add as hard reference
            root.addStateReference(ntState);
            root.notifyStateUpdated();
        } catch (ItemStateException e) {
View Full Code Here

     */
    private VirtualNodeState createNodeTypeState(VirtualNodeState parent,
                                                 QNodeTypeDefinition ntDef)
            throws RepositoryException {
        NodeId id = calculateStableId(ntDef.getName().toString());
        VirtualNodeState ntState = createNodeState(parent, ntDef.getName(), id, NameConstants.NT_NODETYPE);

        // add properties
        ntState.setPropertyValue(NameConstants.JCR_NODETYPENAME, InternalValue.create(ntDef.getName()));
        ntState.setPropertyValues(NameConstants.JCR_SUPERTYPES, PropertyType.NAME, InternalValue.create(ntDef.getSupertypes()));
        ntState.setPropertyValue(NameConstants.JCR_ISMIXIN, InternalValue.create(ntDef.isMixin()));
        ntState.setPropertyValue(NameConstants.JCR_HASORDERABLECHILDNODES, InternalValue.create(ntDef.hasOrderableChildNodes()));
        if (ntDef.getPrimaryItemName() != null) {
            ntState.setPropertyValue(NameConstants.JCR_PRIMARYITEMNAME, InternalValue.create(ntDef.getPrimaryItemName()));
        }

        // add property defs
        QPropertyDefinition[] propDefs = ntDef.getPropertyDefs();
        for (int i = 0; i < propDefs.length; i++) {
            VirtualNodeState pdState = createPropertyDefState(ntState, propDefs[i], ntDef, i);
            ntState.addChildNodeEntry(NameConstants.JCR_PROPERTYDEFINITION, pdState.getNodeId());
            // add as hard reference
            ntState.addStateReference(pdState);
        }

        // add child node defs
        QNodeDefinition[] cnDefs = ntDef.getChildNodeDefs();
        for (int i = 0; i < cnDefs.length; i++) {
            VirtualNodeState cnState = createChildNodeDefState(ntState, cnDefs[i], ntDef, i);
            ntState.addChildNodeEntry(NameConstants.JCR_CHILDNODEDEFINITION, cnState.getNodeId());
            // add as hard reference
            ntState.addStateReference(cnState);
        }

        return ntState;
View Full Code Here

                                                    QPropertyDefinition propDef,
                                                    QNodeTypeDefinition ntDef, int n)
            throws RepositoryException {
        NodeId id = calculateStableId(
                ntDef.getName().toString() + "/" + NameConstants.JCR_PROPERTYDEFINITION.toString() + "/" + n);
        VirtualNodeState pState = createNodeState(
                parent, NameConstants.JCR_PROPERTYDEFINITION, id,
                NameConstants.NT_PROPERTYDEFINITION);
        // add properties
        if (!propDef.definesResidual()) {
            pState.setPropertyValue(NameConstants.JCR_NAME, InternalValue.create(propDef.getName()));
        }
        pState.setPropertyValue(NameConstants.JCR_AUTOCREATED, InternalValue.create(propDef.isAutoCreated()));
        pState.setPropertyValue(NameConstants.JCR_MANDATORY, InternalValue.create(propDef.isMandatory()));
        pState.setPropertyValue(NameConstants.JCR_ONPARENTVERSION,
                InternalValue.create(OnParentVersionAction.nameFromValue(propDef.getOnParentVersion())));
        pState.setPropertyValue(NameConstants.JCR_PROTECTED, InternalValue.create(propDef.isProtected()));
        pState.setPropertyValue(NameConstants.JCR_MULTIPLE, InternalValue.create(propDef.isMultiple()));
        pState.setPropertyValue(
                NameConstants.JCR_REQUIREDTYPE,
                InternalValue.create(PropertyType.nameFromValue(propDef.getRequiredType()).toUpperCase()));
        InternalValue[] defVals = InternalValue.create(propDef.getDefaultValues());
        // retrieve the property type from the first default value present with
        // the property definition. in case no default values are defined,
        // fallback to PropertyType.STRING in order to avoid creating a property
        // with type UNDEFINED which is illegal.
        int defValsType = PropertyType.STRING;
        if (defVals != null && defVals.length > 0) {
            defValsType = defVals[0].getType();
        }
        if (defVals != null) {
            pState.setPropertyValues(NameConstants.JCR_DEFAULTVALUES, defValsType, defVals);
        }
        QValueConstraint[] vc = propDef.getValueConstraints();
        InternalValue[] vals = new InternalValue[vc.length];
        for (int i = 0; i < vc.length; i++) {
            vals[i] = InternalValue.create(vc[i].getString());
        }
        pState.setPropertyValues(NameConstants.JCR_VALUECONSTRAINTS, PropertyType.STRING, vals);
        return pState;
    }
View Full Code Here

                                                     QNodeDefinition cnDef,
                                                     QNodeTypeDefinition ntDef, int n)
            throws RepositoryException {
        NodeId id = calculateStableId(
                ntDef.getName().toString() + "/" + NameConstants.JCR_CHILDNODEDEFINITION.toString() + "/" + n);
        VirtualNodeState pState = createNodeState(
                parent, NameConstants.JCR_CHILDNODEDEFINITION, id, NameConstants.NT_CHILDNODEDEFINITION);
        // add properties
        if (!cnDef.definesResidual()) {
            pState.setPropertyValue(NameConstants.JCR_NAME, InternalValue.create(cnDef.getName()));
        }
        pState.setPropertyValue(NameConstants.JCR_AUTOCREATED, InternalValue.create(cnDef.isAutoCreated()));
        pState.setPropertyValue(NameConstants.JCR_MANDATORY, InternalValue.create(cnDef.isMandatory()));
        pState.setPropertyValue(NameConstants.JCR_ONPARENTVERSION,
                InternalValue.create(OnParentVersionAction.nameFromValue(cnDef.getOnParentVersion())));
        pState.setPropertyValue(NameConstants.JCR_PROTECTED, InternalValue.create(cnDef.isProtected()));
        pState.setPropertyValues(NameConstants.JCR_REQUIREDPRIMARYTYPES,
                PropertyType.NAME, InternalValue.create(cnDef.getRequiredPrimaryTypes()));
        if (cnDef.getDefaultPrimaryType() != null) {
            pState.setPropertyValue(NameConstants.JCR_DEFAULTPRIMARYTYPE, InternalValue.create(cnDef.getDefaultPrimaryType()));
        }
        pState.setPropertyValue(NameConstants.JCR_SAMENAMESIBLINGS, InternalValue.create(cnDef.allowsSameNameSiblings()));
        return pState;
    }
View Full Code Here

                                                     NodeDef cnDef,
                                                     NodeTypeDef ntDef, int n)
            throws RepositoryException {
        NodeId id = new NodeId(calculateStableUUID(
                ntDef.getName().toString() + "/" + NameConstants.JCR_CHILDNODEDEFINITION.toString() + "/" + n));
        VirtualNodeState pState = createNodeState(
                parent, NameConstants.JCR_CHILDNODEDEFINITION, id, NameConstants.NT_CHILDNODEDEFINITION);
        // add properties
        if (!cnDef.definesResidual()) {
            pState.setPropertyValue(NameConstants.JCR_NAME, InternalValue.create(cnDef.getName()));
        }
        pState.setPropertyValue(NameConstants.JCR_AUTOCREATED, InternalValue.create(cnDef.isAutoCreated()));
        pState.setPropertyValue(NameConstants.JCR_MANDATORY, InternalValue.create(cnDef.isMandatory()));
        pState.setPropertyValue(NameConstants.JCR_ONPARENTVERSION,
                InternalValue.create(OnParentVersionAction.nameFromValue(cnDef.getOnParentVersion())));
        pState.setPropertyValue(NameConstants.JCR_PROTECTED, InternalValue.create(cnDef.isProtected()));
        pState.setPropertyValues(NameConstants.JCR_REQUIREDPRIMARYTYPES,
                PropertyType.NAME, InternalValue.create(cnDef.getRequiredPrimaryTypes()));
        if (cnDef.getDefaultPrimaryType() != null) {
            pState.setPropertyValue(NameConstants.JCR_DEFAULTPRIMARYTYPE, InternalValue.create(cnDef.getDefaultPrimaryType()));
        }
        pState.setPropertyValue(NameConstants.JCR_SAMENAMESIBLINGS, InternalValue.create(cnDef.allowsSameNameSiblings()));
        return pState;
    }
View Full Code Here

     * {@inheritDoc}
     * <p/>
     * currently we have no dynamic ones, we just recreate the entire nodetypes tree
     */
    protected VirtualNodeState createRootNodeState() throws RepositoryException {
        VirtualNodeState root = new VirtualNodeState(this, parentId, rootNodeId, NameConstants.REP_NODETYPES, null);
        NodeDefId id = ntReg.getEffectiveNodeType(NameConstants.REP_SYSTEM).getApplicableChildNodeDef(
                NameConstants.JCR_NODETYPES, NameConstants.REP_NODETYPES, ntReg).getId();
        root.setDefinitionId(id);
        Name[] ntNames = ntReg.getRegisteredNodeTypes();
        for (int i = 0; i < ntNames.length; i++) {
            NodeTypeDef ntDef = ntReg.getNodeTypeDef(ntNames[i]);
            VirtualNodeState ntState = createNodeTypeState(root, ntDef);
            root.addChildNodeEntry(ntNames[i], ntState.getNodeId());
            // add as hard reference
            root.addStateReference(ntState);
        }
        return root;
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public void onNodeTypeAdded(Name ntName) throws RepositoryException {
        try {
            VirtualNodeState root = (VirtualNodeState) getRootState();
            NodeTypeDef ntDef = ntReg.getNodeTypeDef(ntName);
            VirtualNodeState ntState = createNodeTypeState(root, ntDef);
            root.addChildNodeEntry(ntName, ntState.getNodeId());

            // add as hard reference
            root.addStateReference(ntState);
            root.notifyStateUpdated();
        } catch (ItemStateException e) {
View Full Code Here

     */
    private VirtualNodeState createNodeTypeState(VirtualNodeState parent,
                                                 NodeTypeDef ntDef)
            throws RepositoryException {
        NodeId id = new NodeId(calculateStableUUID(ntDef.getName().toString()));
        VirtualNodeState ntState = createNodeState(parent, ntDef.getName(), id, NameConstants.NT_NODETYPE);

        // add properties
        ntState.setPropertyValue(NameConstants.JCR_NODETYPENAME, InternalValue.create(ntDef.getName()));
        ntState.setPropertyValues(NameConstants.JCR_SUPERTYPES, PropertyType.NAME, InternalValue.create(ntDef.getSupertypes()));
        ntState.setPropertyValue(NameConstants.JCR_ISMIXIN, InternalValue.create(ntDef.isMixin()));
        ntState.setPropertyValue(NameConstants.JCR_HASORDERABLECHILDNODES, InternalValue.create(ntDef.hasOrderableChildNodes()));
        if (ntDef.getPrimaryItemName() != null) {
            ntState.setPropertyValue(NameConstants.JCR_PRIMARYITEMNAME, InternalValue.create(ntDef.getPrimaryItemName()));
        }

        // add property defs
        PropDef[] propDefs = ntDef.getPropertyDefs();
        for (int i = 0; i < propDefs.length; i++) {
            VirtualNodeState pdState = createPropertyDefState(ntState, propDefs[i], ntDef, i);
            ntState.addChildNodeEntry(NameConstants.JCR_PROPERTYDEFINITION, pdState.getNodeId());
            // add as hard reference
            ntState.addStateReference(pdState);
        }

        // add child node defs
        NodeDef[] cnDefs = ntDef.getChildNodeDefs();
        for (int i = 0; i < cnDefs.length; i++) {
            VirtualNodeState cnState = createChildNodeDefState(ntState, cnDefs[i], ntDef, i);
            ntState.addChildNodeEntry(NameConstants.JCR_CHILDNODEDEFINITION, cnState.getNodeId());
            // add as hard reference
            ntState.addStateReference(cnState);
        }

        return ntState;
View Full Code Here

                                                    PropDef propDef,
                                                    NodeTypeDef ntDef, int n)
            throws RepositoryException {
        NodeId id = new NodeId(calculateStableUUID(
                ntDef.getName().toString() + "/" + NameConstants.JCR_PROPERTYDEFINITION.toString() + "/" + n));
        VirtualNodeState pState = createNodeState(
                parent, NameConstants.JCR_PROPERTYDEFINITION, id,
                NameConstants.NT_PROPERTYDEFINITION);
        // add properties
        if (!propDef.definesResidual()) {
            pState.setPropertyValue(NameConstants.JCR_NAME, InternalValue.create(propDef.getName()));
        }
        pState.setPropertyValue(NameConstants.JCR_AUTOCREATED, InternalValue.create(propDef.isAutoCreated()));
        pState.setPropertyValue(NameConstants.JCR_MANDATORY, InternalValue.create(propDef.isMandatory()));
        pState.setPropertyValue(NameConstants.JCR_ONPARENTVERSION,
                InternalValue.create(OnParentVersionAction.nameFromValue(propDef.getOnParentVersion())));
        pState.setPropertyValue(NameConstants.JCR_PROTECTED, InternalValue.create(propDef.isProtected()));
        pState.setPropertyValue(NameConstants.JCR_MULTIPLE, InternalValue.create(propDef.isMultiple()));
        pState.setPropertyValue(
                NameConstants.JCR_REQUIREDTYPE,
                InternalValue.create(PropertyType.nameFromValue(propDef.getRequiredType()).toUpperCase()));
        InternalValue[] defVals = propDef.getDefaultValues();
        // retrieve the property type from the first default value present with
        // the property definition. in case no default values are defined,
        // fallback to PropertyType.STRING in order to avoid creating a property
        // with type UNDEFINED which is illegal.
        int defValsType = PropertyType.STRING;
        if (defVals != null && defVals.length > 0) {
            defValsType = defVals[0].getType();
        }
        pState.setPropertyValues(NameConstants.JCR_DEFAULTVALUES, defValsType, defVals);
        QValueConstraint[] vc = propDef.getValueConstraints();
        InternalValue[] vals = new InternalValue[vc.length];
        for (int i = 0; i < vc.length; i++) {
            vals[i] = InternalValue.create(vc[i].getString());
        }
        pState.setPropertyValues(NameConstants.JCR_VALUECONSTRAINTS, PropertyType.STRING, vals);
        return pState;
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.core.virtual.VirtualNodeState

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.