Package javax.jcr.nodetype

Examples of javax.jcr.nodetype.PropertyDefinition


    }

    private void resetToDefaultValue(NodeBuilder dest, PropertyState p)
            throws RepositoryException {
        ImmutableTree tree = new ImmutableTree(dest.getNodeState());
        PropertyDefinition def = ntMgr.getDefinition(tree, p, true);
        Value[] values = def.getDefaultValues();
        if (values != null) {
            if (p.isArray()) {
                p = PropertyStates.createProperty(p.getName(), values);
                dest.setProperty(p);
            } else if (values.length > 0) {
View Full Code Here


        }

        try {
            EffectiveNodeType effective =
                    new EffectiveNodeType(this, getManager());
            PropertyDefinition def = effective.getPropertyDefinition(
                    propertyName, false, value.getType(), false);
            return !def.isProtected() &&
                    meetsTypeConstraints(value, def.getRequiredType()) &&
                    meetsValueConstraints(value, def.getValueConstraints());
        } catch (RepositoryException e) {  // TODO don't use exceptions for flow control. Use internal method in ReadOnlyNodeTypeManager instead.
            log.debug(e.getMessage());
            return false;
        }
    }
View Full Code Here

        try {
            int type = (values.length == 0) ? PropertyType.STRING : values[0].getType();
            EffectiveNodeType effective =
                    new EffectiveNodeType(this, getManager());
            PropertyDefinition def = effective.getPropertyDefinition(
                    propertyName, true, type, false);
            return !def.isProtected() &&
                    meetsTypeConstraints(values, def.getRequiredType()) &&
                    meetsValueConstraints(values, def.getValueConstraints());
        } catch (RepositoryException e) {  // TODO don't use exceptions for flow control. Use internal method in ReadOnlyNodeTypeManager instead.
            log.debug(e.getMessage());
            return false;
        }
    }
View Full Code Here

        if (pds == null || pds.length == 0) {
            return QPropertyDefinition.EMPTY_ARRAY;
        }
        QPropertyDefinition[] declaredPropDefs = new QPropertyDefinition[pds.length];
        for (int i = 0; i < pds.length; i++) {
            PropertyDefinition propDef = pds[i];
            Name name = propDef.getName().equals(NameConstants.ANY_NAME.getLocalName())
                    ? NameConstants.ANY_NAME
                    : resolver.getQName(propDef.getName());
            // check if propDef provides declaring node type and if it matches 'this' one.
            if (propDef.getDeclaringNodeType() != null) {
                if (!declName.equals(resolver.getQName(propDef.getDeclaringNodeType().getName()))) {
                    throw new RepositoryException("Property definition specified invalid declaring nodetype: "
                            + propDef.getDeclaringNodeType().getName() + ", but should be " + declName);
                }
            }
            QValue[] defVls = propDef.getDefaultValues() == null
                    ? QValue.EMPTY_ARRAY
                    : ValueFormat.getQValues(propDef.getDefaultValues(), resolver, qValueFactory);
            String[] jcrConstraints = propDef.getValueConstraints();
            QValueConstraint[] constraints = QValueConstraint.EMPTY_ARRAY;
            if (jcrConstraints != null && jcrConstraints.length > 0) {
                constraints = new QValueConstraint[jcrConstraints.length];
                for (int j=0; j<constraints.length; j++) {
                    constraints[j] = ValueConstraint.create(propDef.getRequiredType(), jcrConstraints[j], resolver);
                }
            }
            declaredPropDefs[i] = new QPropertyDefinitionImpl(
                    name, declName,
                    propDef.isAutoCreated(),
                    propDef.isMandatory(),
                    propDef.getOnParentVersion(),
                    propDef.isProtected(),
                    defVls,
                    propDef.isMultiple(),
                    propDef.getRequiredType(),
                    constraints,
                    propDef.getAvailableQueryOperators(),
                    propDef.isFullTextSearchable(),
                    propDef.isQueryOrderable());
        }
        return declaredPropDefs;
    }
View Full Code Here

     * @return
     */
    @Override
    public PropertyDefinition getPropertyDefinition(QPropertyDefinition def) {
        synchronized (pdCache) {
            PropertyDefinition pdi = pdCache.get(def);
            if (pdi == null) {
                pdi = new PropertyDefinitionImpl(def, this, getNamePathResolver(), valueFactory);
                pdCache.put(def, pdi);
            }
            return pdi;
View Full Code Here

        try {
            String name = getNamePathResolver().getJCRName(ntName);
            synchronized (pdCache) {
                Iterator<PropertyDefinition> iter = pdCache.values().iterator();
                while (iter.hasNext()) {
                    PropertyDefinition pd = iter.next();
                    if (name.equals(pd.getDeclaringNodeType().getName())) {
                        iter.remove();
                    }
                }
            }
            synchronized (ndCache) {
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

        // 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 == UNDEFINED) {
            reqType = 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 == UNDEFINED) {
            reqType = NAME;
        }

        InternalValue[] internalValues = null;
View Full Code Here

     * @return array of values
     * @throws ValueFormatException if this property is not multi-valued
     * @throws RepositoryException
     */
    public InternalValue[] internalGetValues() throws RepositoryException {
        final PropertyDefinition definition = data.getPropertyDefinition();
        if (isMultiple()) {
            return getPropertyState().getValues();
        } else {
            throw new ValueFormatException(
                    this + " is a single-valued property,"
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.