Package javax.jcr.nodetype

Examples of javax.jcr.nodetype.PropertyDefinition


        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 null;
    }

    private PropertyDefinition searchPropertyDefinition(final Node node, final String name)
    throws RepositoryException {
        PropertyDefinition result = searchPropertyDefinition(node.getPrimaryNodeType(), name);
        if ( result == null ) {
            if ( node.getMixinNodeTypes() != null ) {
                for(final NodeType mt : node.getMixinNodeTypes()) {
                    result = this.searchPropertyDefinition(mt, name);
                    if ( result != null ) {
View Full Code Here

            setPropertyAsIs(mod, prop);

        } else if (AUTO_PROPS.containsKey(name)) {
            // check if this is a JCR resource and check node type
            if ( mod.node != null ) {
                final PropertyDefinition pd = this.searchPropertyDefinition(mod.node, name);
                if ( pd != null ) {
                    // SLING-2877 (autocreated check is only required for new nodes)
                    if ( (mod.node.isNew() && pd.isAutoCreated()) || pd.isProtected() ) {
                        return;
                    }
                }
            }
View Full Code Here

        return propertyDefinitions;
    }
   
    PropertyDefinition getPropertyDefinition(String name) {
        for (int i = 0; i < propertyDefinitions.length; i++) {
            PropertyDefinition pd = propertyDefinitions[i];
            if (pd.getName().equals(name)) {
                return pd;
            }
        }
        return null;
    }
View Full Code Here

            throws RepositoryException {
        if (property == null) {
            return;
        }

        PropertyDefinition definition = property.getDefinition();
        if (definition.getRequiredType() != expectedType) {
            getLogger().trace("Removing property {0} of type {1} since we need type {2}", property.getName(),
                    definition.getRequiredType(), expectedType);
            property.remove();
            return;
        }

        if (definition.isMultiple() != expectedMultiplicity) {
            getLogger().trace("Removing property {0} of multiplicity {1} since we need type {2}", property.getName(),
                    definition.isMultiple(), expectedMultiplicity);
            property.remove();
            return;
        }
    }
View Full Code Here

        Map<String,VltPropertyDefinition> pds = new HashMap<String,VltPropertyDefinition>();
       
        PropertyDefinition[] declaredPds = nt.getDeclaredPropertyDefinitions();
        if (declaredPds!=null) {
            for (int i = 0; i < declaredPds.length; i++) {
                PropertyDefinition pd = declaredPds[i];
                pds.put(pd.getName(), (VltPropertyDefinition) pd);
            }
        }
       
        NodeType[] superTypes = nt.getSupertypes();
        if (superTypes!=null) {
            for (int i = 0; i < superTypes.length; i++) {
                VltNodeType aSuperType = (VltNodeType) superTypes[i];
               
                VltPropertyDefinition[] superTypePds = (VltPropertyDefinition[])aSuperType.getPropertyDefinitions();
                for (int j = 0; j < superTypePds.length; j++) {
                    VltPropertyDefinition pd = superTypePds[j];
                    VltPropertyDefinition existingPd = pds.get(pd.getName());
                    if (existingPd!=null) {
                        // merge the two
                        existingPd.mergeFrom(pd);
                    } else {
                        pds.put(pd.getName(), pd);
                    }
                }
            }
        }
        nt.setPropertyDefinitions(pds.values().toArray(new VltPropertyDefinition[pds.size()]));
View Full Code Here

                cell.setText("");
            } else if (element instanceof IPropertyDescriptor) {
                IPropertyDescriptor pd = (IPropertyDescriptor)element;
                JcrNode jcrNode = (JcrNode)viewer.getInput();
                Map.Entry me = (Entry) pd.getId();
                PropertyDefinition prd = jcrNode.getPropertyDefinition(String.valueOf(me.getKey()));
                if (index==3) {
                    // protected
                    if (prd!=null) {
                        cell.setText(String.valueOf(prd.isProtected()));
                    } else {
                        cell.setText("false");
                    }
                } else if (index==4) {
                    // mandatory
                    if (prd!=null) {
                        cell.setText(String.valueOf(prd.isMandatory()));
                    } else {
                        cell.setText("false");
                    }
                } else if (index==5) {
                    // multiple
                    if (prd!=null) {
                        cell.setText(String.valueOf(prd.isMultiple()));
                    } else {
                        cell.setText(String.valueOf(jcrNode.getProperty(String.valueOf(me.getKey())).isMultiple()));
                    }
                } else if (index==6) {
                    // auto creatd
                    if (prd!=null) {
                        cell.setText(String.valueOf(prd.isAutoCreated()));
                    } else {
                        cell.setText("false");
                    }
                } else {
                    cell.setText("n/a");
View Full Code Here

        }
        return ntManager.getNodeType(getPrimaryType());
    }

    public int getPropertyType(String propertyName) {
        PropertyDefinition pd = getPropertyDefinition(propertyName);
        if (pd!=null) {
            return pd.getRequiredType();
        }
       
        // otherwise use the SerializationManager to read the
        // underlying vault file and derive the propertyType from there
        GenericJcrRootFile u = properties.getUnderlying();
View Full Code Here

        nodeTypes.addAll(Arrays.asList(nt0.getSupertypes()));
        for (Iterator<NodeType> it = nodeTypes.iterator(); it.hasNext();) {
            NodeType nt = it.next();
            PropertyDefinition[] pds = nt.getPropertyDefinitions();
            for (int i = 0; i < pds.length; i++) {
                PropertyDefinition propertyDefinition = pds[i];
                if (propertyDefinition.getName().equals(propertyName)) {
                    return propertyDefinition;
                }
            }
        }
        return null;
View Full Code Here

        // process properties
        for (PropInfo pi : propInfos) {
            // find applicable definition
            //TODO find better heuristics?
            PropertyDefinition def = pi.getPropertyDef(effectiveNodeTypeProvider.getEffectiveNodeType(tree));

            if (def.isProtected()) {
                // skip protected property
                log.debug("Skipping protected property " + pi.getName());

                // notify the ProtectedPropertyImporter.
                for (ProtectedItemImporter ppi : pItemImporters) {
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.