Package javax.jcr.nodetype

Examples of javax.jcr.nodetype.PropertyDefinition


    private void setUpNodeWithUndefinedProperty(boolean multiple)
        throws NotExecutableException {

        try {
            // locate a property definition of type undefined
            PropertyDefinition propDef =
                    NodeTypeUtil.locatePropertyDef(superuser, PropertyType.UNDEFINED, multiple, false, false, false);

            if (propDef == null) {
                throw new NotExecutableException("No testable property of type " +
                                                 "UNDEFINED has been found.");
            }

            // create a node of type propDef.getDeclaringNodeType()
            String nodeType = propDef.getDeclaringNodeType().getName();
            testNode = testRootNode.addNode(nodeName1, nodeType);
            testPropName = propDef.getName();
        }
        catch (RepositoryException e) {
            throw new NotExecutableException("Not able to set up test items.");
        }
    }
View Full Code Here


        NodeTypeManager manager = session.getWorkspace().getNodeTypeManager();
        NodeTypeIterator types = manager.getAllNodeTypes();

        while (types.hasNext()) {
            NodeType type = types.nextNodeType();
            PropertyDefinition propDefs[] = type.getDeclaredPropertyDefinitions();
            for (int i = 0; i < propDefs.length; i++) {
                PropertyDefinition propDef = propDefs[i];

                if (propertyType != ANY_PROPERTY_TYPE &&
                        propDef.getRequiredType() != propertyType) {
                    continue;
                }

                if (propertyType == ANY_PROPERTY_TYPE &&
                        propDef.getRequiredType() == PropertyType.UNDEFINED) {
                    continue;
                }

                if (multiple && !propDef.isMultiple()) {
                    continue;
                }
                if (!multiple && propDef.isMultiple()) {
                    continue;
                }

                if (isProtected && !propDef.isProtected()) {
                    continue;
                }
                if (!isProtected && propDef.isProtected()) {
                    continue;
                }

                String vc[] = propDef.getValueConstraints();
                if (!constraints && vc != null && vc.length > 0) {
                    continue;
                }
                if (constraints) {
                    // property def with constraints requested
                    if (vc == null || vc.length == 0) {
                        // property def has no constraints
                        continue;
                    }
                }

                if (!residual && propDef.getName().equals("*")) {
                    continue;
                }

                if (residual && !propDef.getName().equals("*")) {
                    continue;
                }

                // also skip property residual property definition if there
                // is another residual definition
View Full Code Here

     */
    private static int getNumResidualPropDefs(NodeType type) {
        PropertyDefinition[] pDefs = type.getPropertyDefinitions();
        int residuals = 0;
        for (int j = 0; j < pDefs.length; j++) {
            PropertyDefinition pDef = pDefs[j];
            if (pDef.getName().equals("*")) {
                residuals++;
            }
        }
        return residuals;
    }
View Full Code Here

        NodeTypeManager manager = session.getWorkspace().getNodeTypeManager();
        NodeTypeIterator types = manager.getAllNodeTypes();

        while (types.hasNext()) {
            NodeType type = types.nextNodeType();
            PropertyDefinition propDefs[] = type.getDeclaredPropertyDefinitions();
            for (int i = 0; i < propDefs.length; i++) {
                PropertyDefinition propDef = propDefs[i];

                if (propDef.getName().equals("*")) {
                    continue;
                }

                if (isProtected && !propDef.isProtected()) {
                    continue;
                }
                if (!isProtected && propDef.isProtected()) {
                    continue;
                }

                if (mandatory && !propDef.isMandatory()) {
                    continue;
                }
                if (!mandatory && propDef.isMandatory()) {
                    continue;
                }

                return propDef;
            }
View Full Code Here

    }

    PropertyImpl createPropertyInstance(PropertyState state)
            throws RepositoryException {
        // 1. get definition for the specified property
        PropertyDefinition def = getDefinition(state);
        // 2. create instance
        return createPropertyInstance(state, def);
    }
View Full Code Here

     * by the rep:authorizable node type or one of it's sub-node types;
     * <code>false</code> otherwise.
     * @throws RepositoryException If the property definition cannot be retrieved.
     */
    private static boolean isAuthorizableProperty(Property prop) throws RepositoryException {
        PropertyDefinition def = prop.getDefinition();
        if (def.isProtected()) {
            return false;
        } else  {
            NodeTypeImpl declaringNt = (NodeTypeImpl) prop.getDefinition().getDeclaringNodeType();
            return declaringNt.isNodeType(UserConstants.NT_REP_AUTHORIZABLE);
        }
View Full Code Here

        }
    }


    private boolean canSetProperty(NodeType nodeType, String propertyName, int propertyType, boolean isMultiple) {
        PropertyDefinition propDefs[] = nodeType.getPropertyDefinitions();

        for (int i = 0; i < propDefs.length; i++) {
            if (propDefs[i].getName().equals(propertyName) || propDefs[i].getName().equals("*")) {
                if ((propDefs[i].getRequiredType() == propertyType || propDefs[i].getRequiredType() == PropertyType.UNDEFINED)
                    && propDefs[i].isMultiple() == isMultiple) {
View Full Code Here

    protected void checkSetValue(boolean multipleValues)
            throws ValueFormatException, VersionException,
            LockException, ConstraintViolationException,
            RepositoryException {
        NodeImpl parent = (NodeImpl) getParent();
        PropertyDefinition definition = data.getPropertyDefinition();
        // check multi-value flag
        if (multipleValues != definition.isMultiple()) {
            String msg = (multipleValues) ?
                    "Single-valued property can not be set to an array of values:" :
                    "Multivalued property can not be set to a single value (an array of lenght one is OK): ";
            throw new ValueFormatException(msg + this);
        }
View Full Code Here

        // check pre-conditions for setting property value
        checkSetValue(false);

        // check type according to definition of this property
        final PropertyDefinition definition = data.getPropertyDefinition();
        int reqType = definition.getRequiredType();
        if (reqType == PropertyType.UNDEFINED) {
            reqType = PropertyType.NAME;
        }

        if (name == null) {
View Full Code Here

        // check pre-conditions for setting property value
        checkSetValue(true);

        // check type according to definition of this property
        final PropertyDefinition definition = data.getPropertyDefinition();
        int reqType = definition.getRequiredType();
        if (reqType == PropertyType.UNDEFINED) {
            reqType = PropertyType.NAME;
        }

        InternalValue[] internalValues = null;
View Full Code Here

TOP

Related Classes of javax.jcr.nodetype.PropertyDefinition

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.