javax.jcr.nodetype.NodeTypeTemplate Java Examples
The following examples show how to use
javax.jcr.nodetype.NodeTypeTemplate.
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: ContentSessionFactory.java From mycollab with GNU Affero General Public License v3.0 | 5 votes |
private NodeTypeTemplate createMyCollabFolderType(NodeTypeManager manager) throws RepositoryException { // Create content node type NodeTypeTemplate contentTypeTemplate = manager.createNodeTypeTemplate(); contentTypeTemplate.setAbstract(false); contentTypeTemplate.setMixin(false); contentTypeTemplate.setName("mycollab:folder"); contentTypeTemplate.setPrimaryItemName("folder"); contentTypeTemplate.setDeclaredSuperTypeNames(new String[]{NodeType.NT_FOLDER}); contentTypeTemplate.setQueryable(true); contentTypeTemplate.setOrderableChildNodes(false); PropertyDefinitionTemplate createdPropertyTemplate = manager .createPropertyDefinitionTemplate(); createdPropertyTemplate.setMultiple(false); createdPropertyTemplate.setName("mycollab:createdUser"); createdPropertyTemplate.setMandatory(true); createdPropertyTemplate.setRequiredType(PropertyType.STRING); contentTypeTemplate.getPropertyDefinitionTemplates().add(createdPropertyTemplate); PropertyDefinitionTemplate descPropertyTemplate = manager .createPropertyDefinitionTemplate(); descPropertyTemplate.setMultiple(false); descPropertyTemplate.setName("jcr:description"); descPropertyTemplate.setMandatory(false); descPropertyTemplate.setRequiredType(PropertyType.STRING); contentTypeTemplate.getPropertyDefinitionTemplates().add(descPropertyTemplate); return contentTypeTemplate; }
Example #2
Source File: PageSessionFactory.java From mycollab with GNU Affero General Public License v3.0 | 5 votes |
private NodeTypeTemplate createWikiFolderType(NodeTypeManager manager) throws RepositoryException { // Create content node type NodeTypeTemplate folderTypeTemplate = manager.createNodeTypeTemplate(); folderTypeTemplate.setAbstract(false); folderTypeTemplate.setMixin(false); folderTypeTemplate.setName("wiki:folder"); folderTypeTemplate.setPrimaryItemName("folder"); folderTypeTemplate.setDeclaredSuperTypeNames(new String[]{NodeType.NT_FOLDER}); folderTypeTemplate.setQueryable(true); folderTypeTemplate.setOrderableChildNodes(false); PropertyDefinitionTemplate createdPropertyTemplate = manager.createPropertyDefinitionTemplate(); createdPropertyTemplate.setMultiple(false); createdPropertyTemplate.setName("wiki:createdUser"); createdPropertyTemplate.setMandatory(true); createdPropertyTemplate.setRequiredType(PropertyType.STRING); folderTypeTemplate.getPropertyDefinitionTemplates().add(createdPropertyTemplate); PropertyDefinitionTemplate namePropertyTemplate = manager.createPropertyDefinitionTemplate(); namePropertyTemplate.setMultiple(false); namePropertyTemplate.setName("wiki:name"); namePropertyTemplate.setMandatory(true); namePropertyTemplate.setRequiredType(PropertyType.STRING); folderTypeTemplate.getPropertyDefinitionTemplates().add(namePropertyTemplate); PropertyDefinitionTemplate descPropertyTemplate = manager.createPropertyDefinitionTemplate(); descPropertyTemplate.setMultiple(false); descPropertyTemplate.setName("wiki:description"); descPropertyTemplate.setMandatory(true); descPropertyTemplate.setRequiredType(PropertyType.STRING); folderTypeTemplate.getPropertyDefinitionTemplates().add(descPropertyTemplate); return folderTypeTemplate; }
Example #3
Source File: JcrRepositoryStatisticsGatheringTest.java From archiva with Apache License 2.0 | 5 votes |
private static void registerMixinNodeType( NodeTypeManager nodeTypeManager, String type ) throws RepositoryException { NodeTypeTemplate nodeType = nodeTypeManager.createNodeTypeTemplate(); nodeType.setMixin( true ); nodeType.setName( type ); nodeTypeManager.registerNodeType( nodeType, false ); }
Example #4
Source File: NodeTypeManagerWrapper.java From sling-whiteboard with Apache License 2.0 | 4 votes |
@Override public NodeTypeTemplate createNodeTypeTemplate() throws UnsupportedRepositoryOperationException, RepositoryException { return nodeTypeManager.createNodeTypeTemplate(); }
Example #5
Source File: NodeTypeManagerWrapper.java From sling-whiteboard with Apache License 2.0 | 4 votes |
@Override public NodeTypeTemplate createNodeTypeTemplate(NodeTypeDefinition ntd) throws UnsupportedRepositoryOperationException, RepositoryException { return nodeTypeManager.createNodeTypeTemplate(ntd); }
Example #6
Source File: ContentSessionFactory.java From mycollab with GNU Affero General Public License v3.0 | 4 votes |
private NodeTypeTemplate createMyCollabContentType(NodeTypeManager manager) throws RepositoryException { LOG.info("Register mycollab content type"); NodeType hierachyNode = manager.getNodeType(NodeType.NT_HIERARCHY_NODE); // Create content node type NodeTypeTemplate contentTypeTemplate = manager.createNodeTypeTemplate(hierachyNode); contentTypeTemplate.setAbstract(false); contentTypeTemplate.setMixin(false); contentTypeTemplate.setName("mycollab:content"); contentTypeTemplate.setPrimaryItemName("content"); contentTypeTemplate.setDeclaredSuperTypeNames(new String[]{NodeType.NT_HIERARCHY_NODE}); contentTypeTemplate.setQueryable(true); contentTypeTemplate.setOrderableChildNodes(false); PropertyDefinitionTemplate createdUserPropertyTemplate = manager .createPropertyDefinitionTemplate(); createdUserPropertyTemplate.setMultiple(false); createdUserPropertyTemplate.setName("mycollab:createdUser"); createdUserPropertyTemplate.setMandatory(true); createdUserPropertyTemplate.setRequiredType(PropertyType.STRING); contentTypeTemplate.getPropertyDefinitionTemplates().add(createdUserPropertyTemplate); PropertyDefinitionTemplate contentPathPropertyTemplate = manager.createPropertyDefinitionTemplate(); contentPathPropertyTemplate.setMultiple(false); contentPathPropertyTemplate.setName("mycollab:contentPath"); contentPathPropertyTemplate.setMandatory(false); contentPathPropertyTemplate.setRequiredType(PropertyType.STRING); contentTypeTemplate.getPropertyDefinitionTemplates().add(contentPathPropertyTemplate); PropertyDefinitionTemplate thumbnailPathPropertyTemplate = manager.createPropertyDefinitionTemplate(); thumbnailPathPropertyTemplate.setMultiple(false); thumbnailPathPropertyTemplate.setName("mycollab:thumbnailPath"); thumbnailPathPropertyTemplate.setMandatory(false); thumbnailPathPropertyTemplate.setRequiredType(PropertyType.STRING); contentTypeTemplate.getPropertyDefinitionTemplates().add(thumbnailPathPropertyTemplate); PropertyDefinitionTemplate lastModifiedUserPropertyTemplate = manager.createPropertyDefinitionTemplate(); lastModifiedUserPropertyTemplate.setMultiple(false); lastModifiedUserPropertyTemplate.setName("mycollab:lastModifiedUser"); lastModifiedUserPropertyTemplate.setMandatory(true); lastModifiedUserPropertyTemplate.setRequiredType(PropertyType.STRING); contentTypeTemplate.getPropertyDefinitionTemplates().add(lastModifiedUserPropertyTemplate); PropertyDefinitionTemplate mimeTypePropertyTemplate = manager .createPropertyDefinitionTemplate(); mimeTypePropertyTemplate.setMultiple(false); mimeTypePropertyTemplate.setName("mycollab:mimeType"); mimeTypePropertyTemplate.setMandatory(false); mimeTypePropertyTemplate.setRequiredType(PropertyType.STRING); contentTypeTemplate.getPropertyDefinitionTemplates().add(mimeTypePropertyTemplate); PropertyDefinitionTemplate sizePropertyTemplate = manager.createPropertyDefinitionTemplate(); sizePropertyTemplate.setMultiple(false); sizePropertyTemplate.setName("mycollab:size"); sizePropertyTemplate.setMandatory(true); sizePropertyTemplate.setRequiredType(PropertyType.LONG); contentTypeTemplate.getPropertyDefinitionTemplates().add(sizePropertyTemplate); return contentTypeTemplate; }
Example #7
Source File: PageSessionFactory.java From mycollab with GNU Affero General Public License v3.0 | 4 votes |
private NodeTypeTemplate createWikiPageType(NodeTypeManager manager) throws RepositoryException { LOG.info("Register MyCollab content type"); NodeType hierachyNode = manager.getNodeType(NodeType.NT_HIERARCHY_NODE); // Create content node type NodeTypeTemplate pageTypeTemplate = manager.createNodeTypeTemplate(hierachyNode); pageTypeTemplate.setAbstract(false); pageTypeTemplate.setMixin(false); pageTypeTemplate.setName("wiki:page"); pageTypeTemplate.setPrimaryItemName("page"); pageTypeTemplate.setDeclaredSuperTypeNames(new String[]{NodeType.NT_HIERARCHY_NODE}); pageTypeTemplate.setQueryable(true); pageTypeTemplate.setOrderableChildNodes(false); LOG.debug("PROPERTY {} {}", pageTypeTemplate.getDeclaredPropertyDefinitions().length, pageTypeTemplate.getDeclaredChildNodeDefinitions().length); PropertyDefinitionTemplate subjectPropertyTemplate = manager.createPropertyDefinitionTemplate(); subjectPropertyTemplate.setMultiple(false); subjectPropertyTemplate.setName("wiki:subject"); subjectPropertyTemplate.setMandatory(true); subjectPropertyTemplate.setRequiredType(PropertyType.STRING); pageTypeTemplate.getPropertyDefinitionTemplates().add(subjectPropertyTemplate); PropertyDefinitionTemplate contentPropertyTemplate = manager.createPropertyDefinitionTemplate(); contentPropertyTemplate.setMultiple(false); contentPropertyTemplate.setName("wiki:content"); contentPropertyTemplate.setMandatory(true); contentPropertyTemplate.setRequiredType(PropertyType.STRING); pageTypeTemplate.getPropertyDefinitionTemplates().add(contentPropertyTemplate); PropertyDefinitionTemplate lockPropertyTemplate = manager.createPropertyDefinitionTemplate(); lockPropertyTemplate.setMultiple(false); lockPropertyTemplate.setName("wiki:isLock"); lockPropertyTemplate.setMandatory(false); lockPropertyTemplate.setRequiredType(PropertyType.BOOLEAN); pageTypeTemplate.getPropertyDefinitionTemplates().add(lockPropertyTemplate); PropertyDefinitionTemplate statusPropertyTemplate = manager.createPropertyDefinitionTemplate(); statusPropertyTemplate.setMultiple(false); statusPropertyTemplate.setName("wiki:status"); statusPropertyTemplate.setMandatory(true); statusPropertyTemplate.setRequiredType(PropertyType.STRING); pageTypeTemplate.getPropertyDefinitionTemplates().add(statusPropertyTemplate); PropertyDefinitionTemplate categoryPropertyTemplate = manager.createPropertyDefinitionTemplate(); categoryPropertyTemplate.setMultiple(false); categoryPropertyTemplate.setName("wiki:category"); categoryPropertyTemplate.setMandatory(false); categoryPropertyTemplate.setRequiredType(PropertyType.STRING); pageTypeTemplate.getPropertyDefinitionTemplates().add(categoryPropertyTemplate); PropertyDefinitionTemplate createdPropertyTemplate = manager.createPropertyDefinitionTemplate(); createdPropertyTemplate.setMultiple(false); createdPropertyTemplate.setName("wiki:createdUser"); createdPropertyTemplate.setMandatory(true); createdPropertyTemplate.setRequiredType(PropertyType.STRING); pageTypeTemplate.getPropertyDefinitionTemplates().add(createdPropertyTemplate); return pageTypeTemplate; }
Example #8
Source File: StorageUpdate0.java From nextreports-server with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") private void createNodeTypes() throws RepositoryException { Session session = SessionFactoryUtils.getSession(getTemplate().getSessionFactory(), false); Workspace workspace = session.getWorkspace(); LOG.info("Registering namespace 'next' -> http://nextreports.ro/jcr/2.0"); NamespaceRegistry namespaceRegistry = workspace.getNamespaceRegistry(); namespaceRegistry.registerNamespace("next", "http://nextreports.ro/jcr/2.0"); /* // check if the node type is registered already if (nodeTypeManager.hasNodeType(NEXT_REPORT_MIXIN)) { return; } */ LOG.info("Creating node type mixin '" + StorageConstants.NEXT_REPORT_MIXIN + "'"); NodeTypeManagerImpl nodeTypeManager = (NodeTypeManagerImpl) workspace.getNodeTypeManager(); NodeTypeTemplate nodeTypeTemplate = nodeTypeManager.createNodeTypeTemplate(); nodeTypeTemplate.setName(StorageConstants.NEXT_REPORT_MIXIN); nodeTypeTemplate.setMixin(true); nodeTypeTemplate.setOrderableChildNodes(false); nodeTypeTemplate.setPrimaryItemName("nt:unstructured"); nodeTypeTemplate.setDeclaredSuperTypeNames(new String[] { "mix:referenceable", "mix:versionable" }); /* PropertyDefinitionTemplate propertyDefinitionTemplate = nodeTypeManager.createPropertyDefinitionTemplate(); propertyDefinitionTemplate.setName("*"); propertyDefinitionTemplate.setRequiredType(PropertyType.UNDEFINED); propertyDefinitionTemplate.setAutoCreated(false); propertyDefinitionTemplate.setMandatory(false); propertyDefinitionTemplate.setOnParentVersion(OnParentVersionAction.COPY); propertyDefinitionTemplate.setProtected(false); propertyDefinitionTemplate.setMultiple(false); nodeTypeTemplate.getPropertyDefinitionTemplates().add(propertyDefinitionTemplate); */ NodeDefinitionTemplate nodeDefinitionTemplate = nodeTypeManager.createNodeDefinitionTemplate(); nodeDefinitionTemplate.setName("runHistory"); nodeDefinitionTemplate.setDefaultPrimaryTypeName("nt:unstructured"); nodeDefinitionTemplate.setRequiredPrimaryTypeNames(new String[] { "nt:unstructured" }); nodeDefinitionTemplate.setAutoCreated(true); nodeDefinitionTemplate.setMandatory(false); nodeDefinitionTemplate.setOnParentVersion(OnParentVersionAction.IGNORE); nodeDefinitionTemplate.setProtected(false); nodeDefinitionTemplate.setSameNameSiblings(false); nodeTypeTemplate.getNodeDefinitionTemplates().add(nodeDefinitionTemplate); LOG.info("Registering node type mixin '" + StorageConstants.NEXT_REPORT_MIXIN + "'"); nodeTypeManager.registerNodeType(nodeTypeTemplate, true); getTemplate().save(); }
Example #9
Source File: StorageUpdate13.java From nextreports-server with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") private void createNodeTemplates() throws RepositoryException { Session session = SessionFactoryUtils.getSession(getTemplate().getSessionFactory(), false); Workspace workspace = session.getWorkspace(); NodeTypeManagerImpl nodeTypeManager = (NodeTypeManagerImpl) workspace.getNodeTypeManager(); // nodeTypeManager.unregisterNodeType(StorageConstants.NEXT_REPORT_MIXIN); NodeTypeTemplate nodeTypeTemplate = nodeTypeManager.createNodeTypeTemplate(); nodeTypeTemplate.setName(StorageConstants.NEXT_REPORT_MIXIN); nodeTypeTemplate.setMixin(true); nodeTypeTemplate.setOrderableChildNodes(false); nodeTypeTemplate.setPrimaryItemName("nt:unstructured"); nodeTypeTemplate.setDeclaredSuperTypeNames(new String[] { "mix:referenceable", "mix:versionable" }); NodeDefinitionTemplate nodeDefinitionTemplate = nodeTypeManager.createNodeDefinitionTemplate(); nodeDefinitionTemplate.setName("runHistory"); nodeDefinitionTemplate.setDefaultPrimaryTypeName("nt:unstructured"); nodeDefinitionTemplate.setRequiredPrimaryTypeNames(new String[] { "nt:unstructured" }); nodeDefinitionTemplate.setAutoCreated(true); nodeDefinitionTemplate.setMandatory(false); nodeDefinitionTemplate.setOnParentVersion(OnParentVersionAction.IGNORE); nodeDefinitionTemplate.setProtected(false); nodeDefinitionTemplate.setSameNameSiblings(false); nodeTypeTemplate.getNodeDefinitionTemplates().add(nodeDefinitionTemplate); NodeDefinitionTemplate nodeDefinitionTemplate2 = nodeTypeManager.createNodeDefinitionTemplate(); nodeDefinitionTemplate2.setName("templates"); nodeDefinitionTemplate2.setDefaultPrimaryTypeName("nt:unstructured"); nodeDefinitionTemplate2.setRequiredPrimaryTypeNames(new String[] { "nt:unstructured" }); nodeDefinitionTemplate2.setAutoCreated(true); nodeDefinitionTemplate2.setMandatory(false); nodeDefinitionTemplate2.setOnParentVersion(OnParentVersionAction.IGNORE); nodeDefinitionTemplate2.setProtected(false); nodeDefinitionTemplate2.setSameNameSiblings(false); nodeTypeTemplate.getNodeDefinitionTemplates().add(nodeDefinitionTemplate2); LOG.info("Registering node type mixin '" + StorageConstants.NEXT_REPORT_MIXIN + "'"); nodeTypeManager.registerNodeType(nodeTypeTemplate, true); // add templates node to all existing reports String statement = "/jcr:root" + ISO9075.encodePath(StorageConstants.REPORTS_ROOT) + "//*[@className='ro.nextreports.server.domain.Report']"; QueryResult queryResult = getTemplate().query(statement); NodeIterator nodes = queryResult.getNodes(); LOG.info("Create templates nodes : Found " + nodes.getSize() + " report nodes"); while (nodes.hasNext()) { Node node = nodes.nextNode(); node.addNode("templates"); } getTemplate().save(); }