/** * Unregisters the named node type if it is not referenced by other node types as a supertype, a default primary type of a * child node (or nodes), or a required primary type of a child node (or nodes). * * @param nodeTypeName * @throws NoSuchNodeTypeException if node type name does not correspond to a registered node type * @throws InvalidNodeTypeDefinitionException if the node type with the given name cannot be unregistered because it is the * supertype, one of the required primary types, or a default primary type of another node type * @throws AccessDeniedException if the current session does not have the {@link ModeShapePermissions#REGISTER_TYPE register * type permission}. * @throws RepositoryException if any other error occurs */ @Override public void unregisterNodeType( String nodeTypeName ) throws NoSuchNodeTypeException, InvalidNodeTypeDefinitionException, RepositoryException { unregisterNodeTypes(Collections.singleton(nodeTypeName)); }
/** * Allows the collection of node types to be unregistered if they are not referenced by other node types as supertypes, * default primary types of child nodes, or required primary types of child nodes. * * @param names the names of the node types to be unregistered * @throws NoSuchNodeTypeException if any of the node type names do not correspond to a registered node type * @throws InvalidNodeTypeDefinitionException if any of the node types with the given names cannot be unregistered because * they are the supertype, one of the required primary types, or a default primary type of a node type that is not * being unregistered. * @throws AccessDeniedException if the current session does not have the {@link ModeShapePermissions#REGISTER_TYPE register * type permission}. * @throws RepositoryException if any other error occurs */ @Override public void unregisterNodeTypes( String[] names ) throws NoSuchNodeTypeException, RepositoryException { unregisterNodeTypes(Arrays.asList(names)); }
/** * Unregisters the named node type if it is not referenced by other node types as a supertype, a default primary type of a * child node (or nodes), or a required primary type of a child node (or nodes). * * @param nodeTypeName * @throws NoSuchNodeTypeException if node type name does not correspond to a registered node type * @throws InvalidNodeTypeDefinitionException if the node type with the given name cannot be unregistered because it is the * supertype, one of the required primary types, or a default primary type of another node type * @throws AccessDeniedException if the current session does not have the {@link ModeShapePermissions#REGISTER_TYPE register * type permission}. * @throws RepositoryException if any other error occurs */ @Override public void unregisterNodeType( String nodeTypeName ) throws NoSuchNodeTypeException, InvalidNodeTypeDefinitionException, RepositoryException { unregisterNodeTypes(Collections.singleton(nodeTypeName)); }
/** * Allows the collection of node types to be unregistered if they are not referenced by other node types as supertypes, * default primary types of child nodes, or required primary types of child nodes. * * @param names the names of the node types to be unregistered * @throws NoSuchNodeTypeException if any of the node type names do not correspond to a registered node type * @throws InvalidNodeTypeDefinitionException if any of the node types with the given names cannot be unregistered because * they are the supertype, one of the required primary types, or a default primary type of a node type that is not * being unregistered. * @throws AccessDeniedException if the current session does not have the {@link ModeShapePermissions#REGISTER_TYPE register * type permission}. * @throws RepositoryException if any other error occurs */ @Override public void unregisterNodeTypes( String[] names ) throws NoSuchNodeTypeException, RepositoryException { unregisterNodeTypes(Arrays.asList(names)); }
private void testRegisterType( Session session ) throws Exception { JcrNodeTypeManager nodeTypes = (JcrNodeTypeManager)session.getWorkspace().getNodeTypeManager(); NodeTypeTemplate newType = nodeTypes.createNodeTypeTemplate(); String nodeTypeName = session.getUserID() + "Type"; newType.setName(nodeTypeName); nodeTypes.registerNodeType(newType, false); nodeTypes.unregisterNodeTypes(Collections.singleton(nodeTypeName)); }
@Test( expected = InvalidNodeTypeDefinitionException.class ) public void shouldNotAllowUnregisteringUsedPrimaryType() throws Exception { Session adminSession = null; try { adminSession = repository.login(); assertThat(adminSession.getNamespaceURI("car"), is("http://www.modeshape.org/examples/cars/1.0")); // Re-register one of the used namespaces in a session ... adminSession.setNamespacePrefix("cars", "http://www.modeshape.org/examples/cars/1.0"); JcrNodeTypeManager nodeTypeManager = (JcrNodeTypeManager)adminSession.getWorkspace().getNodeTypeManager(); nodeTypeManager.unregisterNodeTypes(Collections.singletonList("cars:Car")); } finally { if (adminSession != null) adminSession.logout(); } }