Package javax.jcr.nodetype

Examples of javax.jcr.nodetype.PropertyDefinition


     * @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 (definition.isMultiple()) {
            return getPropertyState().getValues();
        } else {
            throw new ValueFormatException(
                    this + " is a single-valued property,"
                    + " so it's value can not be retrieved as an array");
View Full Code Here


     * @return value
     * @throws ValueFormatException if this property is not single-valued
     * @throws RepositoryException
     */
    public InternalValue internalGetValue() throws RepositoryException {
        final PropertyDefinition definition = data.getPropertyDefinition();
        if (definition.isMultiple()) {
            throw new ValueFormatException(
                    this + " is a multi-valued property,"
                    + " so it's values can only be retrieved as an array");
        } else {
            InternalValue[] values = getPropertyState().getValues();
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) {
            if (value != null) {
                reqType = value.getType();
            } else {
                reqType = PropertyType.STRING;
View Full Code Here

                    }
                }
            }
        }

        final PropertyDefinition definition = data.getPropertyDefinition();
        int reqType = definition.getRequiredType();
        if (reqType == PropertyType.UNDEFINED) {
            reqType = valueType; // use the given type as property type
        }

        InternalValue[] internalValues = null;
View Full Code Here

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

        try {
            String name = resolver().getJCRName(ntName);
            synchronized (pdCache) {
                Iterator iter = pdCache.values().iterator();
                while (iter.hasNext()) {
                    PropertyDefinition pd = (PropertyDefinition) iter.next();
                    if (name.equals(pd.getDeclaringNodeType().getName())) {
                        iter.remove();
                    }
                }
            }
            synchronized (ndCache) {
View Full Code Here

        try {
            String name = resolver().getJCRName(ntName);
            synchronized (pdCache) {
                Iterator iter = pdCache.values().iterator();
                while (iter.hasNext()) {
                    PropertyDefinition pd = (PropertyDefinition) iter.next();
                    if (name.equals(pd.getDeclaringNodeType().getName())) {
                        iter.remove();
                    }
                }
            }
            synchronized (ndCache) {
View Full Code Here

                                                                    NamePathResolver resolver,
                                                                    QValueFactory qValueFactory)
            throws RepositoryException {
        QPropertyDefinition[] declaredPropDefs = new QPropertyDefinition[pds.length];
        for (int i = 0; i < pds.length; i++) {
            PropertyDefinition propDef = pds[i];
            Name name = propDef.getName().equals(QItemDefinitionImpl.ANY_NAME.getLocalName())
                    ? QItemDefinitionImpl.ANY_NAME
                    : resolver.getQName(propDef.getName());
            Name declName = resolver.getQName(propDef.getDeclaringNodeType().getName());
            QValue[] defVls = ValueFormat.getQValues(propDef.getDefaultValues(), resolver, qValueFactory);
            String[] jcrConstraints = propDef.getValueConstraints();
            QValueConstraint[] 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

            // use temp set to avoid ConcurrentModificationException
            HashSet<Name> set = new HashSet<Name>(thisState.getPropertyNames());
            for (Name propName : set) {
                PropertyState propState = (PropertyState) stateMgr.getItemState(new PropertyId(thisState.getNodeId(), propName));
                // check if property has been defined by mixin type (or one of its supertypes)
                PropertyDefinition def = ntMgr.getPropertyDefinition(propState.getDefinitionId());
                NodeTypeImpl declaringNT = (NodeTypeImpl) def.getDeclaringNodeType();
                if (!entResulting.includesNodeType(declaringNT.getQName())) {
                    // the resulting effective node type doesn't include the
                    // node type that declared this property

                    // try to find new applicable definition first and
                    // redefine property if possible (JCR-2130)
                    try {
                        PropertyImpl prop = (PropertyImpl) itemMgr.getItem(propState.getId());
                        if (prop.getDefinition().isProtected()) {
                            // remove 'orphaned' protected properties immediately
                            removeChildProperty(propName);
                            continue;
                        }
                        PropertyDefinitionImpl pdi = getApplicablePropertyDefinition(
                                propName, propState.getType(),
                                propState.isMultiValued(), false);
                        if (pdi.getRequiredType() != PropertyType.UNDEFINED
                                && pdi.getRequiredType() != propState.getType()) {
                            // value conversion required
                            if (propState.isMultiValued()) {
                                // convert value
                                Value[] values =
                                        ValueHelper.convert(
                                                prop.getValues(),
                                                pdi.getRequiredType(),
                                                session.getValueFactory());
                                // redefine property
                                prop.onRedefine(pdi.unwrap().getId());
                                // set converted values
                                prop.setValue(values);
                            } else {
                                // convert value
                                Value value =
                                        ValueHelper.convert(
                                                prop.getValue(),
                                                pdi.getRequiredType(),
                                                session.getValueFactory());
                                // redefine property
                                prop.onRedefine(pdi.unwrap().getId());
                                // set converted values
                                prop.setValue(value);
                            }
                        } else {
                            // redefine property
                            prop.onRedefine(pdi.unwrap().getId());
                        }
                    } catch (ValueFormatException vfe) {
                        // value conversion failed, remove it
                        removeChildProperty(propName);
                    } catch (ConstraintViolationException cve) {
                        // no suitable definition found for this property,
                        // remove it
                        removeChildProperty(propName);
                    }
                }
            }
            // use temp array to avoid ConcurrentModificationException
            ArrayList<ChildNodeEntry> list = new ArrayList<ChildNodeEntry>(thisState.getChildNodeEntries());
            // start from tail to avoid problems with same-name siblings
            for (int i = list.size() - 1; i >= 0; i--) {
                ChildNodeEntry entry = list.get(i);
                NodeState nodeState = (NodeState) stateMgr.getItemState(entry.getId());
                NodeDefinition def = ntMgr.getNodeDefinition(nodeState.getDefinitionId());
                // check if node has been defined by mixin type (or one of its supertypes)
                NodeTypeImpl declaringNT = (NodeTypeImpl) def.getDeclaringNodeType();
                if (!entResulting.includesNodeType(declaringNT.getQName())) {
                    // the resulting effective node type doesn't include the
                    // node type that declared this child node

                    try {
View Full Code Here

    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

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.