javax.jcr.nodetype.PropertyDefinition Java Examples

The following examples show how to use javax.jcr.nodetype.PropertyDefinition. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DocViewPropertyTest.java    From jackrabbit-filevault with Apache License 2.0 7 votes vote down vote up
@Test
public void testEmptyMVBoolean() throws Exception {
    Property p = Mockito.mock(Property.class);
    Value value = Mockito.mock(Value.class);

    Mockito.when(value.getString()).thenReturn("false");
    Value[] values = new Value[]{value};
    PropertyDefinition pd = Mockito.mock(PropertyDefinition.class);
    Mockito.when(pd.isMultiple()).thenReturn(true);

    Mockito.when(p.getType()).thenReturn(PropertyType.BOOLEAN);
    Mockito.when(p.getName()).thenReturn("foo");
    Mockito.when(p.getValues()).thenReturn(values);
    Mockito.when(p.getDefinition()).thenReturn(pd);

    String result = DocViewProperty.format(p);
    Assert.assertEquals("formatted property", "{Boolean}[false]", result);

    // now round trip back
    DocViewProperty dp = DocViewProperty.parse("foo", result);
    Assert.assertEquals(new DocViewProperty("foo", new String[] {"false"}, true, PropertyType.BOOLEAN), dp);
}
 
Example #2
Source File: DocViewPropertyTest.java    From jackrabbit-filevault with Apache License 2.0 6 votes vote down vote up
/**
 * Special test for mv properties with 1 empty string value (JCR-3661)
 * @throws Exception
 */
@Test
public void testEmptyMVString() throws Exception {
    Property p = Mockito.mock(Property.class);
    Value value = Mockito.mock(Value.class);

    Mockito.when(value.getString()).thenReturn("");
    Value[] values = new Value[]{value};
    PropertyDefinition pd = Mockito.mock(PropertyDefinition.class);
    Mockito.when(pd.isMultiple()).thenReturn(true);

    Mockito.when(p.getType()).thenReturn(PropertyType.STRING);
    Mockito.when(p.getName()).thenReturn("foo");
    Mockito.when(p.getValues()).thenReturn(values);
    Mockito.when(p.getDefinition()).thenReturn(pd);

    String result = DocViewProperty.format(p);
    Assert.assertEquals("formatted property", "[\\0]", result);

    // now round trip back
    DocViewProperty dp = DocViewProperty.parse("foo", result);
    Assert.assertEquals(new DocViewProperty("foo", new String[] {""}, true, PropertyType.UNDEFINED), dp);
}
 
Example #3
Source File: PropertyWrapper.java    From sling-whiteboard with Apache License 2.0 4 votes vote down vote up
@Override
public PropertyDefinition getDefinition() throws RepositoryException {
    return delegate.getDefinition();
}
 
Example #4
Source File: NodeTypeImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public PropertyDefinition[] getPropertyDefinitions() {
    return new PropertyDefinition[0];
}
 
Example #5
Source File: NodeTypeImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public PropertyDefinition[] getDeclaredPropertyDefinitions() {
    return new PropertyDefinition[0];
}
 
Example #6
Source File: PropertyImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public PropertyDefinition getDefinition() throws RepositoryException {
    return new PropertyDefinition() {
        @Override
        public int getRequiredType() {
            return 0;
        }


        @Override
        public String[] getValueConstraints() {
            return new String[0];
        }


        @Override
        public Value[] getDefaultValues() {
            return new Value[0];
        }


        @Override
        public boolean isMultiple() {
            return PropertyImpl.this.isMultiple();
        }


        @Override
        public String[] getAvailableQueryOperators() {
            return new String[0];
        }


        @Override
        public boolean isFullTextSearchable() {
            return false;
        }


        @Override
        public boolean isQueryOrderable() {
            return false;
        }


        @Override
        public NodeType getDeclaringNodeType() {
            return null;
        }


        @Override
        public String getName() {
            return null;
        }


        @Override
        public boolean isAutoCreated() {
            return false;
        }


        @Override
        public boolean isMandatory() {
            return false;
        }


        @Override
        public int getOnParentVersion() {
            return 0;
        }


        @Override
        public boolean isProtected() {
            return false;
        }
    };
}
 
Example #7
Source File: AggregateManagerImpl.java    From jackrabbit-filevault with Apache License 2.0 4 votes vote down vote up
/**
 * internally add the node type and all transitive ones to the set of
 * used node types.
 * @param nodeType to add
 */
private void internalAddNodeType(NodeType nodeType) {
    if (nodeType != null && !nodeTypes.contains(nodeType.getName())) {
        nodeTypes.add(nodeType.getName());
        NodeType[] superTypes = nodeType.getSupertypes();
        for (NodeType superType: superTypes) {
            nodeTypes.add(superType.getName());
        }
        NodeDefinition[] nodeDefs = nodeType.getChildNodeDefinitions();
        if (nodeDefs != null) {
            for (NodeDefinition nodeDef: nodeDefs) {
                internalAddNodeType(nodeDef.getDefaultPrimaryType());
                NodeType[] reqs = nodeDef.getRequiredPrimaryTypes();
                if (reqs != null) {
                    for (NodeType req: reqs) {
                        internalAddNodeType(req);
                    }
                }
            }
        }

        // check reference constraints, too (bug #33367)
        PropertyDefinition[] propDefs = nodeType.getPropertyDefinitions();
        if (propDefs != null) {
            for (PropertyDefinition propDef: propDefs) {
                if (propDef.getRequiredType() == PropertyType.REFERENCE ||
                        propDef.getRequiredType() == PropertyType.WEAKREFERENCE) {
                    String[] vcs = propDef.getValueConstraints();
                    if (vcs != null) {
                        for (String vc: vcs) {
                            try {
                                internalAddNodeType(session.getWorkspace().getNodeTypeManager().getNodeType(vc));
                            } catch (RepositoryException e) {
                                // ignore
                            }
                        }
                    }
                }
            }
        }
    }

}