Package org.apache.jackrabbit.core.nodetype

Examples of org.apache.jackrabbit.core.nodetype.PropDef


                }

                // mandatory child properties
                PropDef[] pda = ent.getMandatoryPropDefs();
                for (int i = 0; i < pda.length; i++) {
                    PropDef pd = pda[i];
                    if (pd.getDeclaringNodeType().equals(NameConstants.MIX_VERSIONABLE)
                            || pd.getDeclaringNodeType().equals(NameConstants.MIX_SIMPLE_VERSIONABLE)) {
                        /**
                         * todo FIXME workaround for mix:versionable:
                         * the mandatory properties are initialized at a
                         * later stage and might not exist yet
                         */
                        continue;
                    }
                    if (!nodeState.hasPropertyName(pd.getName())) {
                        String msg = itemMgr.safeGetJCRPath(id)
                                + ": mandatory property " + pd.getName()
                                + " does not exist";
                        log.debug(msg);
                        throw new ConstraintViolationException(msg);
                    }
                }
View Full Code Here


            }
        }
        // mandatory properties
        PropDef[] pda = entPrimaryAndMixins.getMandatoryPropDefs();
        for (int i = 0; i < pda.length; i++) {
            PropDef pd = pda[i];
            if (!nodeState.hasPropertyName(pd.getName())) {
                String msg = safeGetJCRPath(nodeState.getNodeId())
                        + ": mandatory property " + pd.getName()
                        + " does not exist";
                log.debug(msg);
                throw new ConstraintViolationException(msg);
            }
        }
View Full Code Here

     * @throws ConstraintViolationException if any of the validations fail
     * @throws RepositoryException          if another error occurs
     */
    public void validate(PropertyState propState)
            throws ConstraintViolationException, RepositoryException {
        PropDef def = ntReg.getPropDef(propState.getDefinitionId());
        InternalValue[] values = propState.getValues();
        int type = PropertyType.UNDEFINED;
        for (int i = 0; i < values.length; i++) {
            if (type == PropertyType.UNDEFINED) {
                type = values[i].getType();
            } else if (type != values[i].getType()) {
                throw new ConstraintViolationException(safeGetJCRPath(propState.getPropertyId())
                        + ": inconsistent value types");
            }
            if (def.getRequiredType() != PropertyType.UNDEFINED
                    && def.getRequiredType() != type) {
                throw new ConstraintViolationException(safeGetJCRPath(propState.getPropertyId())
                        + ": requiredType constraint is not satisfied");
            }
        }
        EffectiveNodeType.checkSetPropertyValueConstraints(def, values);
View Full Code Here

            node.addShare(parent.getNodeId());
        }

        if (!node.getMixinTypeNames().isEmpty()) {
            // create jcr:mixinTypes property
            PropDef pd = ent.getApplicablePropertyDef(NameConstants.JCR_MIXINTYPES,
                    PropertyType.NAME, true);
            createPropertyState(node, pd.getName(), pd.getRequiredType(), pd);
        }

        // add 'auto-create' properties defined in node type
        PropDef[] pda = ent.getAutoCreatePropDefs();
        for (int i = 0; i < pda.length; i++) {
            PropDef pd = pda[i];
            createPropertyState(node, pd.getName(), pd.getRequiredType(), pd);
        }

        // recursively add 'auto-create' child nodes defined in node type
        NodeDef[] nda = ent.getAutoCreateNodeDefs();
        for (int i = 0; i < nda.length; i++) {
View Full Code Here

                    "cannot create property state for " + propName
                    + " because manager is not in edit mode");
        }

        // find applicable definition
        PropDef def;
        // multi- or single-valued property?
        if (numValues == 1) {
            // could be single- or multi-valued (n == 1)
            try {
                // try single-valued
View Full Code Here

                 * mix:lockable, et.al.)
                 *
                 * todo FIXME delegate to 'node type instance handler'
                 */
                PropDefId defId = srcChildState.getDefinitionId();
                PropDef def = ntReg.getPropDef(defId);
                if (def.getDeclaringNodeType().equals(NameConstants.MIX_LOCKABLE)) {
                    // skip properties defined by mix:lockable
                    continue;
                }

                PropertyState newChildState =
View Full Code Here

                                            NodeId parentId,
                                            Name propName)
            throws RepositoryException {

        PropDefId defId = srcState.getDefinitionId();
        PropDef def = ntReg.getPropDef(defId);

        PropertyState newState = stateMgr.createNew(propName, parentId);

        newState.setDefinitionId(defId);
        newState.setType(srcState.getType());
        newState.setMultiValued(srcState.isMultiValued());
        InternalValue[] values = srcState.getValues();
        if (values != null) {
            /**
             * special handling required for properties with special semantics
             * (e.g. those defined by mix:referenceable, mix:versionable,
             * mix:lockable, et.al.)
             *
             * todo FIXME delegate to 'node type instance handler'
             */
            if (def.getDeclaringNodeType().equals(NameConstants.MIX_REFERENCEABLE)
                    && propName.equals(NameConstants.JCR_UUID)) {
                // set correct value of jcr:uuid property
                newState.setValues(new InternalValue[]{InternalValue.create(parentId.getUUID().toString())});
            } else {
                InternalValue[] newValues = new InternalValue[values.length];
View Full Code Here

                "true", getDefaultValue(def, 0));
    }

    /** Test for the <code>date</code> property definition type. */
    public void testDateProperty() {
        PropDef def = getProperty("propertyNodeType", "dateProperty");
        assertEquals("dateProperty requiredType",
                PropertyType.DATE, def.getRequiredType());
        assertEquals("dateProperty valueConstraints",
                1, def.getValueConstraints().length);
        assertEquals("dateProperty valueConstraints[0]",
                "[2005-01-01T00:00:00.000Z,2006-01-01T00:00:00.000Z)",
                (def.getValueConstraints())[0].getDefinition());
        assertEquals("dateProperty defaultValues",
                1, def.getDefaultValues().length);
        assertEquals("dateProperty defaultValues[0]",
                "2005-01-01T00:00:00.000Z", getDefaultValue(def, 0));
    }
View Full Code Here

                "2005-01-01T00:00:00.000Z", getDefaultValue(def, 0));
    }

    /** Test for the <code>double</code> property definition type. */
    public void testDoubleProperty() {
        PropDef def = getProperty("propertyNodeType", "doubleProperty");
        assertEquals("doubleProperty requiredType",
                PropertyType.DOUBLE, def.getRequiredType());
        assertEquals("doubleProperty valueConstraints",
                3, def.getValueConstraints().length);
        assertEquals("doubleProperty valueConstraints[0]",
                "[,0.0)", (def.getValueConstraints())[0].getDefinition());
        assertEquals("doubleProperty valueConstraints[1]",
                "(1.0,2.0)", (def.getValueConstraints())[1].getDefinition());
        assertEquals("doubleProperty valueConstraints[2]",
                "(3.0,]", (def.getValueConstraints())[2].getDefinition());
        assertEquals("doubleProperty defaultValues",
                1, def.getDefaultValues().length);
        assertEquals("doubleProperty defaultValues[0]",
                "1.5", getDefaultValue(def, 0));
    }
View Full Code Here

                "1.5", getDefaultValue(def, 0));
    }

    /** Test for the <code>long</code> property definition type. */
    public void testLongProperty() {
        PropDef def = getProperty("propertyNodeType", "longProperty");
        assertEquals("longProperty requiredType",
                PropertyType.LONG, def.getRequiredType());
        assertEquals("longProperty valueConstraints",
                3, def.getValueConstraints().length);
        assertEquals("longProperty valueConstraints[0]",
                "(-10,0]", (def.getValueConstraints())[0].getDefinition());
        assertEquals("longProperty valueConstraints[1]",
                "[1,2]", (def.getValueConstraints())[1].getDefinition());
        assertEquals("longProperty valueConstraints[2]",
                "[10,100)", (def.getValueConstraints())[2].getDefinition());
        assertEquals("longProperty defaultValues",
                1, def.getDefaultValues().length);
        assertEquals("longProperty defaultValues[0]",
                "25", getDefaultValue(def, 0));
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.core.nodetype.PropDef

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.