@ SuppressWarnings ( "unchecked" ) public void importType ( ObjectType cmisType , NodeTypeManager typeManager , NamespaceRegistry registry ) throws RepositoryException { // TODO: get namespace information and register // registry.registerNamespace(cmisType.getLocalNamespace(), cmisType.getLocalNamespace()); // create node type template NodeTypeTemplate type = typeManager . createNodeTypeTemplate ( ) ; // convert CMIS type's attributes to node type template we have just created type . setName ( cmisType . getId ( ) ) ; type . setAbstract ( false ) ; type . setMixin ( false ) ; type . setOrderableChildNodes ( true ) ; type . setQueryable ( true ) ; if ( ! cmisType . isBaseType ( ) ) { type . setDeclaredSuperTypeNames ( superTypes ( cmisType ) ) ; } Map < String , PropertyDefinition < ? > > props = cmisType . getPropertyDefinitions ( ) ; Set < String > names = props . keySet ( ) ; // properties for ( String name : names ) { PropertyDefinition < ? > pd = props . get ( name ) ; PropertyDefinitionTemplate pt = typeManager . createPropertyDefinitionTemplate ( ) ; pt . setRequiredType ( properties . getJcrType ( pd . getPropertyType ( ) ) ) ; pt . setAutoCreated ( false ) ; pt . setAvailableQueryOperators ( new String [ ] { } ) ; pt . setName ( name ) ; pt . setMandatory ( pd . isRequired ( ) ) ; type . getPropertyDefinitionTemplates ( ) . add ( pt ) ; } // register type NodeTypeDefinition [ ] nodeDefs = new NodeTypeDefinition [ ] { type } ; typeManager . registerNodeTypes ( nodeDefs , true ) ; }
Import given CMIS type to the JCR repository .