本文整理汇总了Java中org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl类的典型用法代码示例。如果您正苦于以下问题:Java NodeTypeManagerImpl类的具体用法?Java NodeTypeManagerImpl怎么用?Java NodeTypeManagerImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NodeTypeManagerImpl类属于org.apache.jackrabbit.core.nodetype包,在下文中一共展示了NodeTypeManagerImpl类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerNodeTypes
import org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl; //导入依赖的package包/类
@Override
protected void registerNodeTypes() throws Exception {
if (!ObjectUtils.isEmpty(nodeDefinitions)) {
Session session = getBareSession();
Workspace ws = session.getWorkspace();
NodeTypeManagerImpl jackrabbitNodeTypeManager = (NodeTypeManagerImpl) ws.getNodeTypeManager();
boolean debug = LOG.isDebugEnabled();
for (int i = 0; i < nodeDefinitions.length; i++) {
Resource resource = nodeDefinitions[i];
if (debug) {
LOG.debug("adding node type definitions from " + resource.getDescription());
}
try {
// ws.getNodeTypeManager().registerNodeType(ntd, allowUpdate)
jackrabbitNodeTypeManager.registerNodeTypes(resource.getInputStream(), contentType);
} catch (RepositoryException ex) {
LOG.error("Error registering nodetypes ", ex.getCause());
}
}
session.logout();
}
}
示例2: createNodeTypes
import org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl; //导入依赖的package包/类
@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();
}
示例3: createNodeTemplates
import org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl; //导入依赖的package包/类
@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();
}