Examples of QPropertyDefinition


Examples of org.apache.jackrabbit.spi.QPropertyDefinition

     * @see OperationVisitor#visit(AddProperty)
     */
    public void visit(AddProperty operation) throws ValueFormatException, LockException, ConstraintViolationException, AccessDeniedException, ItemExistsException, UnsupportedRepositoryOperationException, VersionException, RepositoryException {
        NodeState parent = operation.getParentState();
        Name propertyName = operation.getPropertyName();
        QPropertyDefinition pDef = operation.getDefinition();
        int targetType = pDef.getRequiredType();
        if (targetType == PropertyType.UNDEFINED) {
            targetType = operation.getPropertyType();
            if (targetType == PropertyType.UNDEFINED) {
                targetType = PropertyType.STRING;
            }
View Full Code Here

Examples of org.apache.jackrabbit.spi.QPropertyDefinition

                int options = ItemStateValidator.CHECK_LOCK | ItemStateValidator.CHECK_VERSIONING;
                setPropertyStateValue(pState, getQValues(mixinNames, qValueFactory), PropertyType.NAME, options);
            } else {
                // create new jcr:mixinTypes property
                ItemDefinitionProvider defProvider = mgrProvider.getItemDefinitionProvider();
                QPropertyDefinition pd = defProvider.getQPropertyDefinition(nState.getAllNodeTypeNames(), NameConstants.JCR_MIXINTYPES, PropertyType.NAME, true);
                QValue[] mixinValue = getQValues(mixinNames, qValueFactory);
                int options = ItemStateValidator.CHECK_LOCK | ItemStateValidator.CHECK_VERSIONING;
                addPropertyState(nState, pd.getName(), pd.getRequiredType(), mixinValue, pd, options);
            }
            nState.markModified();
            transientStateMgr.addOperation(operation);
        } else if (mixinEntry != null) {
            // remove the jcr:mixinTypes property state if already present
View Full Code Here

Examples of org.apache.jackrabbit.spi.QPropertyDefinition

        NodeState nodeState = transientStateMgr.createNewNodeState(nodeName, null, nodeTypeName, definition, parent);
        addedStates.add(nodeState);
        if (uuid != null) {
            QValue[] value = getQValues(uuid, qValueFactory);
            ItemDefinitionProvider defProvider = mgrProvider.getItemDefinitionProvider();
            QPropertyDefinition pDef = defProvider.getQPropertyDefinition(NameConstants.MIX_REFERENCEABLE, NameConstants.JCR_UUID, PropertyType.STRING, false);
            addedStates.add(addPropertyState(nodeState, NameConstants.JCR_UUID, PropertyType.STRING, value, pDef, 0));
        }

        // add 'auto-create' properties defined in node type
        for (QPropertyDefinition pd : ent.getAutoCreateQPropertyDefinitions()) {
View Full Code Here

Examples of org.apache.jackrabbit.spi.QPropertyDefinition

        }
    }

    protected void processProperty(NodeState node, PropInfo pInfo) throws RepositoryException {
        PropertyState prop;
        QPropertyDefinition def;

        Name name = pInfo.getName();
        int type = pInfo.getType();

        if (node.hasPropertyName(name)) {
            // a property with that name already exists...
            PropertyId idExisting = new PropertyId(node.getNodeId(), name);
            prop = (PropertyState) itemOps.getItemState(idExisting);
            def = itemOps.findApplicablePropertyDefinition(prop.getName(), prop.getType(), prop.isMultiValued(), node);
            if (def.isProtected()) {
                // skip protected property
                log.debug("skipping protected property "
                        + itemOps.safeGetJCRPath(idExisting));
                return;
            }
            if (!def.isAutoCreated()
                    || (prop.getType() != type && type != PropertyType.UNDEFINED)
                    || def.isMultiple() != prop.isMultiValued()) {
                throw new ItemExistsException(itemOps.safeGetJCRPath(prop.getPropertyId()));
            }
        } else {
            // there's no property with that name,
            // find applicable definition
            def = pInfo.getApplicablePropertyDef(itemOps.getEffectiveNodeType(node));
            if (def.isProtected()) {
                // skip protected property
                log.debug("skipping protected property " + name);
                return;
            }

            // create new property
            prop = itemOps.createPropertyState(node, name, type, def);
        }

        // check multi-valued characteristic
        TextValue[] values = pInfo.getTextValues();
        if (values.length != 1 && !def.isMultiple()) {
            throw new ConstraintViolationException(itemOps.safeGetJCRPath(prop.getPropertyId())
                    + " is not multi-valued");
        }

        // convert serialized values to InternalValue objects
View Full Code Here

Examples of org.apache.jackrabbit.spi.QPropertyDefinition

    private void conditionalAddProperty(
            NodeState node, Name name, int type, boolean multiple,
            InternalValue value)
            throws RepositoryException {
        if (!node.hasPropertyName(name)) {
            QPropertyDefinition def = itemOps.findApplicablePropertyDefinition(
                    name, type, multiple, node);
            PropertyState prop = itemOps.createPropertyState(
                    node, name, type, def);
            prop.setValues(new InternalValue[] { value });
        }
View Full Code Here

Examples of org.apache.jackrabbit.spi.QPropertyDefinition

        // process properties

        for (PropInfo pi : propInfos) {
            // find applicable definition
            QPropertyDefinition def = pi.getApplicablePropertyDef(node.getEffectiveNodeType());
            if (def.isProtected()) {
                // skip protected property
                log.debug("Skipping protected property " + pi.getName());

                // notify the ProtectedPropertyImporter.
                for (ProtectedItemImporter ppi : pItemImporters) {
View Full Code Here

Examples of org.apache.jackrabbit.spi.QPropertyDefinition

    private static QPropertyDefinition getQPropertyDefinition(EffectiveNodeType ent,
                                                              Name name, int type)
            throws ConstraintViolationException {
        // try named property definitions first
        QPropertyDefinition[] defs = ent.getNamedQPropertyDefinitions(name);
        QPropertyDefinition match = getMatchingPropDef(defs, type);
        if (match != null) {
            return match;
        }

        // no item with that name defined;
View Full Code Here

Examples of org.apache.jackrabbit.spi.QPropertyDefinition

        // no applicable definition found
        throw new ConstraintViolationException("no matching property definition found for " + name);
    }

    private static QPropertyDefinition getMatchingPropDef(QPropertyDefinition[] defs, int type) {
        QPropertyDefinition match = null;
        for (int i = 0; i < defs.length; i++) {
            QItemDefinition qDef = defs[i];
            if (!qDef.definesNode()) {
                QPropertyDefinition pd = (QPropertyDefinition) qDef;
                int reqType = pd.getRequiredType();
                // match type
                if (reqType == PropertyType.UNDEFINED
                        || type == PropertyType.UNDEFINED
                        || reqType == type) {
                    if (match == null) {
                        match = pd;
                    } else {
                        // check if this definition is a better match than
                        // the one we've already got
                        if (match.getRequiredType() != pd.getRequiredType()) {
                            if (match.getRequiredType() == PropertyType.UNDEFINED) {
                                // found better match
                                match = pd;
                            }
                        } else {
                            if (match.isMultiple() && !pd.isMultiple()) {
                                // found better match
                                match = pd;
                            }
                        }
                    }
View Full Code Here

Examples of org.apache.jackrabbit.spi.QPropertyDefinition

    }

    private static QPropertyDefinition getMatchingPropDef(QPropertyDefinition[] defs, int type,
                                                   boolean multiValued, boolean throwWhenAmbiguous)
        throws ConstraintViolationException {
        QPropertyDefinition match = null;
        for (int i = 0; i < defs.length; i++) {
            QItemDefinition qDef = defs[i];
            if (!qDef.definesNode()) {
                QPropertyDefinition pd = (QPropertyDefinition) qDef;
                int reqType = pd.getRequiredType();
                // match type
                if (reqType == PropertyType.UNDEFINED
                        || type == PropertyType.UNDEFINED
                        || reqType == type) {
                    // match multiValued flag
                    if (multiValued == pd.isMultiple()) {
                        // found match
                        if (pd.getRequiredType() != PropertyType.UNDEFINED) {
                            if (match != null && throwWhenAmbiguous) {
                                throw new ConstraintViolationException("ambiguous property definitions found: " + match + " vs " + pd);
                            }

                            if (match != null && match.getRequiredType() == PropertyType.STRING) {
View Full Code Here

Examples of org.apache.jackrabbit.spi.QPropertyDefinition

            // setting a property to null is equivalent of removing it
            return canRemoveItem(propertyName);
        }
        try {
            Name name = resolver().getQName(propertyName);
            QPropertyDefinition def;
            try {
                // try to get definition that matches the given value type
                def = getApplicablePropDef(name, value.getType(), false);
            } catch (ConstraintViolationException cve) {
                // fallback: ignore type
                def = getApplicablePropDef(name, PropertyType.UNDEFINED, false);
            }
            if (def.isProtected()) {
                return false;
            }
            if (def.isMultiple()) {
                return false;
            }
            Value v;
            if (def.getRequiredType() != PropertyType.UNDEFINED
                    && def.getRequiredType() != value.getType()) {
                // type conversion required
                v =  ValueHelper.convert(value, def.getRequiredType(), mgrProvider.getJcrValueFactory());
            } else {
                // no type conversion required
                v = value;
            }
            // create QValue from Value
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.