本文整理汇总了Java中javax.jcr.Workspace.getNodeTypeManager方法的典型用法代码示例。如果您正苦于以下问题:Java Workspace.getNodeTypeManager方法的具体用法?Java Workspace.getNodeTypeManager怎么用?Java Workspace.getNodeTypeManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.jcr.Workspace
的用法示例。
在下文中一共展示了Workspace.getNodeTypeManager方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerNodeTypes
import javax.jcr.Workspace; //导入方法依赖的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: initialize
import javax.jcr.Workspace; //导入方法依赖的package包/类
static void initialize( Session session )
throws RepositoryException
{
// TODO: consider using namespaces for facets instead of the current approach:
// (if used, check if actually called by normal injection)
// for ( String facetId : metadataFacetFactories.keySet() )
// {
// session.getWorkspace().getNamespaceRegistry().registerNamespace( facetId, facetId );
// }
Workspace workspace = session.getWorkspace();
NamespaceRegistry registry = workspace.getNamespaceRegistry();
if ( !Arrays.asList( registry.getPrefixes() ).contains( "archiva" ) )
{
registry.registerNamespace( "archiva", "http://archiva.apache.org/jcr/" );
}
NodeTypeManager nodeTypeManager = workspace.getNodeTypeManager();
registerMixinNodeType( nodeTypeManager, JcrMetadataRepository.NAMESPACE_NODE_TYPE );
registerMixinNodeType( nodeTypeManager, JcrMetadataRepository.PROJECT_NODE_TYPE );
registerMixinNodeType( nodeTypeManager, JcrMetadataRepository.PROJECT_VERSION_NODE_TYPE );
registerMixinNodeType( nodeTypeManager, JcrMetadataRepository.ARTIFACT_NODE_TYPE );
registerMixinNodeType( nodeTypeManager, JcrMetadataRepository.FACET_NODE_TYPE );
registerMixinNodeType( nodeTypeManager, JcrMetadataRepository.DEPENDENCY_NODE_TYPE );
}
示例3: setUp
import javax.jcr.Workspace; //导入方法依赖的package包/类
@Override
@Before
public void setUp()
throws Exception
{
super.setUp();
File confFile = new File( "src/test/repository.xml" );
File dir = new File( "target/jcr" );
FileUtils.deleteDirectory( dir );
assertTrue( confFile.exists() );
assertFalse( dir.exists() );
TransientRepository repository = new TransientRepository( confFile, dir );
session = repository.login( new SimpleCredentials( "username", "password".toCharArray() ) );
// TODO: perhaps have an archiva-jcr-utils module shared by these plugins that does this and can contain
// structure information
Workspace workspace = session.getWorkspace();
NamespaceRegistry registry = workspace.getNamespaceRegistry();
registry.registerNamespace( "archiva", "http://archiva.apache.org/jcr/" );
NodeTypeManager nodeTypeManager = workspace.getNodeTypeManager();
registerMixinNodeType( nodeTypeManager, "archiva:namespace" );
registerMixinNodeType( nodeTypeManager, "archiva:project" );
registerMixinNodeType( nodeTypeManager, "archiva:projectVersion" );
registerMixinNodeType( nodeTypeManager, "archiva:artifact" );
registerMixinNodeType( nodeTypeManager, "archiva:facet" );
metadataRepository = mock( MetadataRepository.class );
when( metadataRepository.canObtainAccess( Session.class ) ).thenReturn( true );
when( metadataRepository.obtainAccess( Session.class ) ).thenReturn( session );
repositoryStatisticsManager = new DefaultRepositoryStatisticsManager();
}
示例4: initialize
import javax.jcr.Workspace; //导入方法依赖的package包/类
public static void initialize( Session session )
throws RepositoryException
{
// TODO: consider using namespaces for facets instead of the current approach:
// (if used, check if actually called by normal injection)
// for ( String facetId : metadataFacetFactories.keySet() )
// {
// session.getWorkspace().getNamespaceRegistry().registerNamespace( facetId, facetId );
// }
Workspace workspace = session.getWorkspace();
NamespaceRegistry registry = workspace.getNamespaceRegistry();
if ( !Arrays.asList( registry.getPrefixes() ).contains( "archiva" ) )
{
registry.registerNamespace( "archiva", "http://archiva.apache.org/jcr/" );
}
NodeTypeManager nodeTypeManager = workspace.getNodeTypeManager();
registerMixinNodeType( nodeTypeManager, JcrMetadataRepository.NAMESPACE_NODE_TYPE );
registerMixinNodeType( nodeTypeManager, JcrMetadataRepository.PROJECT_NODE_TYPE );
registerMixinNodeType( nodeTypeManager, JcrMetadataRepository.PROJECT_VERSION_NODE_TYPE );
registerMixinNodeType( nodeTypeManager, JcrMetadataRepository.ARTIFACT_NODE_TYPE );
registerMixinNodeType( nodeTypeManager, JcrMetadataRepository.FACET_NODE_TYPE );
registerMixinNodeType( nodeTypeManager, JcrMetadataRepository.DEPENDENCY_NODE_TYPE );
}
示例5: createNodeTypes
import javax.jcr.Workspace; //导入方法依赖的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();
}
示例6: createNodeTemplates
import javax.jcr.Workspace; //导入方法依赖的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();
}