@Override public NodeTypeTemplate build() throws ConstraintViolationException { template.setMixin(super.isMixin); template.setOrderableChildNodes(super.isOrderable); template.setAbstract(super.isAbstract); template.setQueryable(super.queryable); template.setDeclaredSuperTypeNames(supertypes.toArray(new String[supertypes.size()])); return template; }
@Override public NodeTypeTemplate build() throws ConstraintViolationException { template.setMixin(super.isMixin); template.setOrderableChildNodes(super.isOrderable); template.setAbstract(super.isAbstract); template.setQueryable(super.queryable); template.setDeclaredSuperTypeNames(supertypes.toArray(new String[supertypes.size()])); return template; }
@Override public NodeTypeTemplate build() throws ConstraintViolationException { template.setMixin(super.isMixin); template.setOrderableChildNodes(super.isOrderable); template.setAbstract(super.isAbstract); template.setQueryable(super.queryable); template.setDeclaredSuperTypeNames(supertypes.toArray(new String[supertypes.size()])); return template; }
private static void registerMixinNodeType( NodeTypeManager nodeTypeManager, String name ) throws RepositoryException { NodeTypeTemplate nodeType = nodeTypeManager.createNodeTypeTemplate(); nodeType.setMixin( true ); nodeType.setName( name ); // for now just don't re-create - but in future if we change the definition, make sure to remove first as an // upgrade path if ( !nodeTypeManager.hasNodeType( name ) ) { nodeTypeManager.registerNodeType( nodeType, false ); } }
private static void registerMixinNodeType( NodeTypeManager nodeTypeManager, String name ) throws RepositoryException { NodeTypeTemplate nodeType = nodeTypeManager.createNodeTypeTemplate(); nodeType.setMixin( true ); nodeType.setName( name ); // for now just don't re-create - but in future if we change the definition, make sure to remove first as an // upgrade path if ( !nodeTypeManager.hasNodeType( name ) ) { nodeTypeManager.registerNodeType( nodeType, false ); } }
@SuppressWarnings( "unchecked" ) @Override public NodeTypeDefinition getNodeTypeDefinition( final NodeTypeManager ntMgr, final ValueFactory vFac ) throws RepositoryException { NodeTypeTemplate t = ntMgr.createNodeTypeTemplate(); t.setName( PHO_MIX + "pentahoVersionable" ); //$NON-NLS-1$ t.setMixin( true ); t.setDeclaredSuperTypeNames( new String[] { MIX + "simpleVersionable" } ); //$NON-NLS-1$ t.getPropertyDefinitionTemplates().add( getAuthorProperty( ntMgr, vFac ) ); t.getPropertyDefinitionTemplates().add( getMessageProperty( ntMgr, vFac ) ); t.getPropertyDefinitionTemplates().add( getAclOnlyChangeProperty( ntMgr, vFac ) ); return t; }
/** * Register new mixin type if does not exists on workspace * * @param session the JCR session * @param mixin the mixin name to register * @throws RepositoryException */ public static void registerMixinType(Session session, String mixin) throws RepositoryException { NodeTypeManager nodeTypeManager = session.getWorkspace().getNodeTypeManager(); if (!nodeTypeManager.hasNodeType(mixin)) { NodeTypeTemplate nodeTypeTemplate = nodeTypeManager.createNodeTypeTemplate(); nodeTypeTemplate.setMixin(true); nodeTypeTemplate.setName(mixin); NodeTypeDefinition[] nodeTypes = new NodeTypeDefinition[]{nodeTypeTemplate}; nodeTypeManager.registerNodeTypes(nodeTypes, true); } }
private NodeTypeDefinition setUpNodeType(String nodeType, NodeTypeManager manager) throws RepositoryException { NodeTypeTemplate ntt = manager.createNodeTypeTemplate(); ntt.setName(nodeType); ntt.setMixin(false); return ntt; }
public NodeTypeTemplate buildNodeType(OMElement omElement) throws JaxenException, RepositoryException { nodeTypeTemplate = nodeTypeManager.createNodeTypeTemplate(); nodeTypeTemplate.setName(getAttrValue("name", omElement)); nodeTypeTemplate.setMixin(Boolean.valueOf(getAttrValue("isMixin", omElement))); nodeTypeTemplate.setOrderableChildNodes(Boolean.valueOf(getAttrValue("hasOrderableChildNodes", omElement))); nodeTypeTemplate.setAbstract(Boolean.valueOf(getAttrValue("isAbstract", omElement))); nodeTypeTemplate.setQueryable(Boolean.valueOf(getAttrValue("isQueryable", omElement))); nodeTypeTemplate.setPrimaryItemName(getAttrValue("primaryItemName", omElement)); buildSupertypes(omElement); buildChildNodeDefs(omElement); buildPropertyDefs(omElement); // System.out.println(omElement.toString()); return nodeTypeTemplate; }
/** * Create a {@link NodeTypeTemplate} used a NodeType definition. */ public static NodeTypeTemplate createNodeType(NodeTypeManager nodeTypeManager, String name, String[] superTypeNames, boolean isMixin, boolean isOrderableChildNodes, String primaryItemName, boolean isQueryable) throws RepositoryException { // Create node definition NodeTypeTemplate nodeType = nodeTypeManager.createNodeTypeTemplate(); nodeType.setName(name); nodeType.setDeclaredSuperTypeNames(superTypeNames); nodeType.setMixin(isMixin); nodeType.setOrderableChildNodes(isOrderableChildNodes); nodeType.setPrimaryItemName(primaryItemName); nodeType.setQueryable(isQueryable); return nodeType; }
private void registerMixin( String name, String... declaredSuperTypes ) throws RepositoryException { NodeTypeTemplate nodeTypeTemplate = nodeTypeMgr.createNodeTypeTemplate(); nodeTypeTemplate.setMixin(true); nodeTypeTemplate.setName(name); nodeTypeTemplate.setQueryable(true); if (declaredSuperTypes.length > 0) { nodeTypeTemplate.setDeclaredSuperTypeNames(declaredSuperTypes); } nodeTypeMgr.registerNodeType(nodeTypeTemplate, true); } }
@SuppressWarnings( {"unchecked"} ) private NodeTypeTemplate createMixinC( NodeTypeManager mgr ) throws RepositoryException { NodeTypeTemplate mixinTypeC = mgr.createNodeTypeTemplate(); mixinTypeC.setName(MIXIN_TYPE_C); mixinTypeC.setMixin(true); PropertyDefinitionTemplate propertyB = mgr.createPropertyDefinitionTemplate(); propertyB.setName(PROPERTY_B); propertyB.setOnParentVersion(OnParentVersionAction.IGNORE); propertyB.setRequiredType(PropertyType.STRING); mixinTypeC.getPropertyDefinitionTemplates().add(propertyB); return mixinTypeC; }
@Override protected void setUp() throws Exception { super.setUp(); vMgr = superuser.getWorkspace().getVersionManager(); NodeTypeManager ntMgr = superuser.getWorkspace().getNodeTypeManager(); NodeDefinitionTemplate def = ntMgr.createNodeDefinitionTemplate(); def.setOnParentVersion(OnParentVersionAction.ABORT); def.setName("child"); def.setRequiredPrimaryTypeNames(new String[] {NT_BASE}); NodeTypeTemplate tmpl = ntMgr.createNodeTypeTemplate(); tmpl.setName("OpvAbortTest"); tmpl.setMixin(true); tmpl.getNodeDefinitionTemplates().add(def); ntMgr.registerNodeType(tmpl, true); testRootNode.addMixin(MIX_VERSIONABLE); superuser.save(); }
private NodeDefinitionTemplate createNodeDefinitionWithIgnoreOPVNode(String nodeTypeName) throws RepositoryException { NodeTypeManager manager = superuser.getWorkspace().getNodeTypeManager(); NodeDefinitionTemplate def = manager.createNodeDefinitionTemplate(); def.setOnParentVersion(OnParentVersionAction.IGNORE); def.setName("child"); def.setRequiredPrimaryTypeNames(new String[]{JcrConstants.NT_BASE}); NodeTypeTemplate tmpl = manager.createNodeTypeTemplate(); tmpl.setName(nodeTypeName); tmpl.setMixin(true); tmpl.getNodeDefinitionTemplates().add(def); manager.registerNodeType(tmpl, true); return def; } }
private NodeTypeTemplate createNodeTypeWithIgnoreOPVProperty(String propertyName) throws RepositoryException { NodeTypeManager manager = superuser.getWorkspace().getNodeTypeManager(); NodeTypeTemplate nt = manager.createNodeTypeTemplate(); nt.setName("testType"); nt.setMixin(true); PropertyDefinitionTemplate opt = manager.createPropertyDefinitionTemplate(); opt.setMandatory(false); opt.setName(propertyName); opt.setRequiredType(PropertyType.STRING); opt.setOnParentVersion(OnParentVersionAction.IGNORE); List pdt = nt.getPropertyDefinitionTemplates(); pdt.add(opt); manager.registerNodeType(nt, true); return nt; }
@SuppressWarnings( {"unchecked"} ) private NodeTypeTemplate createMixinA( NodeTypeManager mgr ) throws RepositoryException { NodeTypeTemplate mixinTypeA = mgr.createNodeTypeTemplate(); mixinTypeA.setName(MIXIN_TYPE_A); mixinTypeA.setMixin(true); NodeDefinitionTemplate childNodeA = mgr.createNodeDefinitionTemplate(); childNodeA.setName(CHILD_NODE_A); childNodeA.setOnParentVersion(OnParentVersionAction.IGNORE); mixinTypeA.getNodeDefinitionTemplates().add(childNodeA); PropertyDefinitionTemplate propertyA = mgr.createPropertyDefinitionTemplate(); propertyA.setName(PROPERTY_A); propertyA.setOnParentVersion(OnParentVersionAction.IGNORE); propertyA.setRequiredType(PropertyType.STRING); mixinTypeA.getPropertyDefinitionTemplates().add(propertyA); return mixinTypeA; }
@SuppressWarnings( {"unchecked"} ) private NodeTypeTemplate createMixinWithAutoChild( NodeTypeManager mgr ) throws RepositoryException { NodeTypeTemplate mixinTypeWithAutoChild = mgr.createNodeTypeTemplate(); mixinTypeWithAutoChild.setName("mixinTypeWithAutoCreatedChildNode"); mixinTypeWithAutoChild.setMixin(true); NodeDefinitionTemplate childNodeB = mgr.createNodeDefinitionTemplate(); childNodeB.setName(CHILD_NODE_B); childNodeB.setOnParentVersion(OnParentVersionAction.IGNORE); childNodeB.setMandatory(true); childNodeB.setAutoCreated(true); childNodeB.setDefaultPrimaryTypeName("nt:unstructured"); childNodeB.setRequiredPrimaryTypeNames(new String[] {"nt:unstructured"}); mixinTypeWithAutoChild.getNodeDefinitionTemplates().add(childNodeB); return mixinTypeWithAutoChild; }
protected void registerNodeType( String typeName, boolean queryable, boolean mixin, String...declaredSuperTypes) throws RepositoryException { NodeTypeManager mgr = session.getWorkspace().getNodeTypeManager(); // Create a template for the node type ... NodeTypeTemplate type = mgr.createNodeTypeTemplate(); type.setName(typeName); type.setDeclaredSuperTypeNames(declaredSuperTypes); type.setAbstract(false); type.setOrderableChildNodes(true); type.setMixin(mixin); type.setQueryable(queryable); mgr.registerNodeType(type, true); }
private void registerNodeType( String typeName ) throws RepositoryException { NodeTypeManager nodeTypeManager = session.getWorkspace().getNodeTypeManager(); // Create a template for the node type ... NodeTypeTemplate type = nodeTypeManager.createNodeTypeTemplate(); type.setName(typeName); type.setDeclaredSuperTypeNames(new String[] {"nt:unstructured"}); type.setAbstract(false); type.setOrderableChildNodes(true); type.setMixin(false); type.setQueryable(true); nodeTypeManager.registerNodeType(type, true); }
@SuppressWarnings( {"unchecked"} ) private NodeTypeTemplate createMixinWithAutoProperty( NodeTypeManager mgr ) throws RepositoryException { NodeTypeTemplate mixinTypeWithAutoProperty = mgr.createNodeTypeTemplate(); mixinTypeWithAutoProperty.setName("mixinTypeWithAutoCreatedProperty"); mixinTypeWithAutoProperty.setMixin(true); PropertyDefinitionTemplate propertyB = mgr.createPropertyDefinitionTemplate(); propertyB.setName(PROPERTY_B); propertyB.setMandatory(true); propertyB.setAutoCreated(true); propertyB.setOnParentVersion(OnParentVersionAction.IGNORE); propertyB.setRequiredType(PropertyType.LONG); propertyB.setDefaultValues(new Value[] {session.getValueFactory().createValue("10")}); mixinTypeWithAutoProperty.getPropertyDefinitionTemplates().add(propertyB); return mixinTypeWithAutoProperty; }