当前位置: 首页>>代码示例>>Java>>正文


Java PropertyDefinition类代码示例

本文整理汇总了Java中javax.jcr.nodetype.PropertyDefinition的典型用法代码示例。如果您正苦于以下问题:Java PropertyDefinition类的具体用法?Java PropertyDefinition怎么用?Java PropertyDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PropertyDefinition类属于javax.jcr.nodetype包,在下文中一共展示了PropertyDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: canSetProperty

import javax.jcr.nodetype.PropertyDefinition; //导入依赖的package包/类
@Override
public boolean canSetProperty(String propertyName, Value value) {
    if (value == null) {
        return canRemoveProperty(propertyName);
    }

    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;
    }
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:20,代码来源:NodeTypeImpl.java

示例2: getDeclaredPropertyDefs

import javax.jcr.nodetype.PropertyDefinition; //导入依赖的package包/类
private List<PropertyDefinition> getDeclaredPropertyDefs(Tree definitions) {
    if (definitions.exists()) {
        List<PropertyDefinition> list = newArrayList();
        String typeName = getOakName();
        for (Tree def : definitions.getChildren()) {
            String declaringTypeName =
                    TreeUtil.getName(def, REP_DECLARING_NODE_TYPE);
            if (typeName.equals(declaringTypeName)) {
                list.add(new PropertyDefinitionImpl(def, this, mapper));
            }
        }
        return list;
    } else {
        return emptyList();
    }
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:17,代码来源:NodeTypeImpl.java

示例3: checkSetProperty

import javax.jcr.nodetype.PropertyDefinition; //导入依赖的package包/类
public void checkSetProperty(PropertyState property) throws RepositoryException {
    PropertyDefinition definition = getDefinition(property);
    if (definition.isProtected()) {
        return;
    }

    NodeType nt = definition.getDeclaringNodeType();
    if (definition.isMultiple()) {
        List<Value> values = ValueFactoryImpl.createValues(property, ntMgr.getNamePathMapper());
        if (!nt.canSetProperty(property.getName(), values.toArray(new Value[values.size()]))) {
            throw new ConstraintViolationException("Cannot set property '" + property.getName() + "' to '" + values + '\'');
        }
    } else {
        Value v = ValueFactoryImpl.createValue(property, ntMgr.getNamePathMapper());
        if (!nt.canSetProperty(property.getName(), v)) {
            throw new ConstraintViolationException("Cannot set property '" + property.getName() + "' to '" + v + '\'');
        }
    }
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:20,代码来源:EffectiveNodeType.java

示例4: propertyDescriptors

import javax.jcr.nodetype.PropertyDefinition; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * 
 * @see org.modelspace.Descriptor#propertyDescriptors()
 */
@Override
public PropertyDescriptor[] propertyDescriptors() throws ModelspaceException {
    return this.modelspace.run( new TaskWithResult< PropertyDescriptor[] >() {

        /**
         * {@inheritDoc}
         * 
         * @see org.modelspace.internal.task.TaskWithResult#run(javax.jcr.Session)
         */
        @Override
        public PropertyDescriptor[] run( final Session session ) throws Exception {
            final NodeTypeManager nodeTypeMgr = session.getWorkspace().getNodeTypeManager();
            final PropertyDefinition[] propDefns = nodeTypeMgr.getNodeType( name ).getPropertyDefinitions();
            final PropertyDescriptor[] propDescriptors = new PropertyDescriptor[ propDefns.length ];
            int i = 0;

            for ( final PropertyDefinition propDefn : propDefns ) {
                propDescriptors[ i++ ] = new PropertyDescriptorImpl( propDefn );
            }

            return propDescriptors;
        }
    } );
}
 
开发者ID:Polyglotter,项目名称:chrysalix,代码行数:30,代码来源:DescriptorImpl.java

示例5: setUp

import javax.jcr.nodetype.PropertyDefinition; //导入依赖的package包/类
@Before
public void setUp() throws RepositoryException {
    initMocks(this);
    final NodeType mockNodeType = mock(NodeType.class);
    when(mockNode.getPrimaryNodeType()).thenReturn(mockNodeType);

    final PropertyDefinition[] mockPropertyDefinitions = new PropertyDefinition[] {mockDefinition};
    when(mockNodeType.getPropertyDefinitions()).thenReturn(mockPropertyDefinitions);
    when(mockDefinition.getName()).thenReturn(mockPropertyName);
    when(mockNode.getPath()).thenReturn("/some/path");
    when(mockNode.getProperty(mockPropertyName)).thenReturn(mockProperty);

    when(mockNode.getMixinNodeTypes()).thenReturn(new NodeType[] { });

    when(mockNode.getSession()).thenReturn(mockSession);
    when(mockSession.getValueFactory()).thenReturn(mockValueFactory);

    idTranslator = new DefaultIdentifierTranslator(mockSession);
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:20,代码来源:NodePropertiesToolsTest.java

示例6: shouldAddReferencePropertyForDomainObject

import javax.jcr.nodetype.PropertyDefinition; //导入依赖的package包/类
@Test
public void shouldAddReferencePropertyForDomainObject() throws RepositoryException {
    when(mockNodeType.getPropertyDefinitions()).thenReturn(new PropertyDefinition[]{});
    when(mockNode.getMixinNodeTypes()).thenReturn(new NodeType[]{});

    when(mockValueFactory.createValue(anyString(), eq(STRING))).thenReturn(mockValue);
    when(mockValueFactory.createValue(mockNode, true)).thenReturn(mockReferenceValue);

    when(mockSession.getNode("/x")).thenReturn(mockNode);

    when(mockNode.setProperty(anyString(), any(Value[].class), anyInt())).thenReturn(mockProperty);

    when(mockNode.getIdentifier()).thenReturn(UUID.randomUUID().toString());

    testObj.addProperty(mockFedoraResource,
            createProperty("some:property"),
            testSubjects.toDomain("x"),
            Collections.<String,String>emptyMap());

    verify(mockNode).setProperty("some:property_ref", new Value[]{mockReferenceValue}, mockReferenceValue.getType
            ());
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:23,代码来源:JcrRdfToolsTest.java

示例7: shouldNotAddReferencePropertyForNonDomainObject

import javax.jcr.nodetype.PropertyDefinition; //导入依赖的package包/类
@Test
public void shouldNotAddReferencePropertyForNonDomainObject() throws RepositoryException {
    when(mockNodeType.getPropertyDefinitions()).thenReturn(new PropertyDefinition[]{});
    when(mockNode.getMixinNodeTypes()).thenReturn(new NodeType[]{});

    when(mockValueFactory.createValue(anyString(), eq(STRING))).thenReturn(mockValue);
    when(mockValueFactory.createValue(mockNode, true)).thenReturn(mockReferenceValue);

    when(mockSession.getNode("/x")).thenReturn(mockNode);

    when(mockNode.setProperty(anyString(), any(Value[].class), anyInt())).thenReturn(mockProperty);

    testObj.addProperty(mockFedoraResource,
            createProperty("some:property"),
            createResource("some:resource"),
            Collections.<String,String>emptyMap());

    verify(mockNode, never()).setProperty(eq("some:property_ref"), any(Value[].class), anyInt());
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:20,代码来源:JcrRdfToolsTest.java

示例8: serialize

import javax.jcr.nodetype.PropertyDefinition; //导入依赖的package包/类
@Override
public void serialize(PropertyDefinition propertyDefinition, JsonGenerator generator, SerializerProvider provider) throws IOException {
    generator.writeStartObject();
    generator.writeStringField("name", getPropertyNameWithOutNamespace(propertyDefinition.getName()));
    generator.writeStringField("type", PropertyType.nameFromValue(propertyDefinition.getRequiredType()));
    generator.writeBooleanField("required", propertyDefinition.isMandatory());
    generator.writeBooleanField("multi_values", propertyDefinition.isMultiple());
    writeConstraints(generator, propertyDefinition.getValueConstraints());
    writeValues(generator,  propertyDefinition.getDefaultValues());
    generator.writeEndObject();
}
 
开发者ID:projectomakase,项目名称:omakase,代码行数:12,代码来源:PropertyDefinitionSerializer.java

示例9: getAuthorizableProperty

import javax.jcr.nodetype.PropertyDefinition; //导入依赖的package包/类
/**
 * Returns the valid authorizable property identified by the specified
 * property location or {@code null} if that property does not exist or
 * isn't a authorizable property because it is protected or outside of the
 * scope of the {@code authorizableTree}.
 *
 * @param authorizableTree The tree of the target authorizable.
 * @param propertyLocation Location to be tested.
 * @param verifyAncestor   If true the property is tested to be a descendant
 *                         of the node of this authorizable; otherwise it is expected that this
 *                         test has been executed by the caller.
 * @return a valid authorizable property or {@code null} if no such property
 *         exists or fi the property is protected or not defined by the rep:authorizable
 *         node type or one of it's sub-node types.
 * @throws RepositoryException If an error occurs.
 */
@CheckForNull
private PropertyState getAuthorizableProperty(Tree authorizableTree, TreeLocation propertyLocation, boolean verifyAncestor) throws RepositoryException {
    if (propertyLocation == null) {
        return null;
    }
    PropertyState property = propertyLocation.getProperty();
    if (property == null) {
        return null;
    }

    String authorizablePath = authorizableTree.getPath();
    if (verifyAncestor && !Text.isDescendant(authorizablePath, propertyLocation.getPath())) {
        log.debug("Attempt to access property outside of authorizable scope.");
        return null;
    }

    Tree parent = propertyLocation.getParent().getTree();
    if (parent == null) {
        log.debug("Unable to determine definition of authorizable property at " + propertyLocation.getPath());
        return null;
    }
    ReadOnlyNodeTypeManager nodeTypeManager = authorizable.getUserManager().getNodeTypeManager();
    PropertyDefinition def = nodeTypeManager.getDefinition(parent, property, true);
    if (def.isProtected() || (authorizablePath.equals(parent.getPath())
            && !def.getDeclaringNodeType().isNodeType(UserConstants.NT_REP_AUTHORIZABLE))) {
        return null;
    } // else: non-protected property somewhere in the subtree of the user tree.

    return property;
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:47,代码来源:AuthorizablePropertiesImpl.java

示例10: checkProtectedProperty

import javax.jcr.nodetype.PropertyDefinition; //导入依赖的package包/类
private void checkProtectedProperty(Tree parent, PropertyState property) throws RepositoryException {
    ReadOnlyNodeTypeManager nodeTypeManager = authorizable.getUserManager().getNodeTypeManager();
    PropertyDefinition def = nodeTypeManager.getDefinition(parent, property, false);
    if (def.isProtected()) {
        throw new ConstraintViolationException(
                "Attempt to set an protected property " + property.getName());
    }
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:9,代码来源:AuthorizablePropertiesImpl.java

示例11: getTargetType

import javax.jcr.nodetype.PropertyDefinition; //导入依赖的package包/类
public int getTargetType(PropertyDefinition def) {
    int target = def.getRequiredType();
    if (target != PropertyType.UNDEFINED) {
        return target;
    } else if (type != PropertyType.UNDEFINED) {
        return type;
    } else {
        return PropertyType.STRING;
    }
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:11,代码来源:PropInfo.java

示例12: getDeclaredPropertyDefinitions

import javax.jcr.nodetype.PropertyDefinition; //导入依赖的package包/类
/**
 * Returns the declared property definitions in their original order.
 *
 * @return declared property definitions
 */
@Override @Nonnull
public PropertyDefinition[] getDeclaredPropertyDefinitions() {
    Map<Integer, PropertyDefinition> definitions = newTreeMap();
    for (Tree child : definition.getChildren()) {
        Matcher matcher = DEFINITION_PATTERN.matcher(child.getName());
        if (matcher.matches()
                && JCR_PROPERTYDEFINITION.equals(matcher.group(1))) {
            definitions.put(
                    Integer.valueOf(matcher.group(2)),
                    new PropertyDefinitionImpl(child, this, mapper));
        }
    }
    return definitions.values().toArray(NO_PROPERTY_DEFINITIONS);
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:20,代码来源:NodeTypeImpl.java

示例13: internalGetPropertyDefinitions

import javax.jcr.nodetype.PropertyDefinition; //导入依赖的package包/类
Collection<PropertyDefinition> internalGetPropertyDefinitions() {
    // TODO distinguish between additive and overriding property definitions. See 3.7.6.8 Item Definitions in Subtypes
    Collection<PropertyDefinition> definitions = new ArrayList<PropertyDefinition>();
    definitions.addAll(Arrays.asList(getDeclaredPropertyDefinitions()));
    for (NodeType type : getSupertypes()) {
        definitions.addAll(Arrays.asList(type.getDeclaredPropertyDefinitions()));
    }
    return definitions;
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:10,代码来源:NodeTypeImpl.java

示例14: getDeclaredNamedPropertyDefinitions

import javax.jcr.nodetype.PropertyDefinition; //导入依赖的package包/类
List<PropertyDefinition> getDeclaredNamedPropertyDefinitions(String oakName) {
    String escapedName = oakName;
    if (JCR_PRIMARYTYPE.equals(oakName)) {
        escapedName = REP_PRIMARY_TYPE;
    } else if (JCR_MIXINTYPES.equals(oakName)) {
        escapedName = REP_MIXIN_TYPES;
    } else if (JCR_UUID.equals(oakName)) {
        escapedName = REP_UUID;
    }
    return getDeclaredPropertyDefs(definition
            .getChild(REP_NAMED_PROPERTY_DEFINITIONS)
            .getChild(escapedName));
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:14,代码来源:NodeTypeImpl.java

示例15: getDefinition

import javax.jcr.nodetype.PropertyDefinition; //导入依赖的package包/类
@Nonnull
@Override
public PropertyDefinition getDefinition(
        Tree parent, PropertyState property, boolean exactTypeMatch)
        throws RepositoryException {
    Type<?> type = property.getType();
    EffectiveNodeType effective = getEffectiveNodeType(parent);
    return effective.getPropertyDefinition(
            property.getName(), type.isArray(), type.tag(), exactTypeMatch);
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:11,代码来源:ReadOnlyNodeTypeManager.java


注:本文中的javax.jcr.nodetype.PropertyDefinition类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。