Ejemplo n.º 1
0
 @Override
 public JcrNodeType getNodeType(String nodeTypeName)
     throws NoSuchNodeTypeException, RepositoryException {
   session.checkLive();
   Name ntName = context().getValueFactories().getNameFactory().create(nodeTypeName);
   JcrNodeType type = nodeTypes().getNodeType(ntName);
   if (type != null) {
     type = type.with(context(), session);
     return type;
   }
   throw new NoSuchNodeTypeException(JcrI18n.typeNotFound.text(nodeTypeName));
 }
Ejemplo n.º 2
0
  /**
   * Registers a new node type or updates an existing node type using the specified definition and
   * returns the resulting {@link NodeType} object.
   *
   * <p>Typically, the object passed to this method will be a {@link NodeTypeTemplate} (a subclass
   * of {@link NodeTypeDefinition}) acquired from {@link
   * JcrNodeTypeManager#createNodeTypeTemplate()} and then filled-in with definition information.
   *
   * @param template the new node type to register
   * @param allowUpdate this flag is not used
   * @return the {@code newly created node type}
   * @throws InvalidNodeTypeDefinitionException if the {@code NodeTypeDefinition} is invalid
   * @throws NodeTypeExistsException if {@code allowUpdate} is false and the {@code
   *     NodeTypeDefinition} specifies a node type name that already exists
   * @throws UnsupportedRepositoryOperationException if {@code allowUpdate} is true; ModeShape does
   *     not allow updating node types at this time.
   * @throws AccessDeniedException if the current session does not have the {@link
   *     ModeShapePermissions#REGISTER_TYPE register type permission}.
   * @throws RepositoryException if another error occurs
   */
  @Override
  public NodeType registerNodeType(NodeTypeDefinition template, boolean allowUpdate)
      throws InvalidNodeTypeDefinitionException, NodeTypeExistsException,
          UnsupportedRepositoryOperationException, AccessDeniedException, RepositoryException {

    session.checkLive();
    try {
      session.checkPermission((Path) null, ModeShapePermissions.REGISTER_TYPE);
    } catch (AccessControlException ace) {
      throw new AccessDeniedException(ace);
    }
    return this.repositoryTypeManager.registerNodeType(template, !allowUpdate);
  }
Ejemplo n.º 3
0
  @Override
  public NodeTypeIterator getPrimaryNodeTypes() throws RepositoryException {
    session.checkLive();
    Collection<JcrNodeType> rawTypes = nodeTypes().getPrimaryNodeTypes();
    List<JcrNodeType> types = new ArrayList<JcrNodeType>(rawTypes.size());

    // Need to return a version of the node type with the current context
    for (JcrNodeType type : rawTypes) {
      types.add(type.with(context(), session));
    }

    return new JcrNodeTypeIterator(types);
  }
Ejemplo n.º 4
0
  /**
   * Registers or updates the specified Collection of {@code NodeTypeDefinition} objects. This
   * method is used to register or update a set of node types with mutual dependencies. Returns an
   * iterator over the resulting {@code NodeType} objects.
   *
   * <p>The effect of the method is "all or nothing"; if an error occurs, no node types are
   * registered or updated.
   *
   * @param templates the new node types to register
   * @param allowUpdates this flag is not used
   * @return the {@code newly created node types}
   * @throws InvalidNodeTypeDefinitionException if a {@code NodeTypeDefinition} within the
   *     collection is invalid
   * @throws NodeTypeExistsException if {@code allowUpdate} is false and a {@code
   *     NodeTypeDefinition} within the collection specifies a node type name that already exists
   * @throws UnsupportedRepositoryOperationException if {@code allowUpdate} is true; ModeShape does
   *     not allow updating node types at this time.
   * @throws AccessDeniedException if the current session does not have the {@link
   *     ModeShapePermissions#REGISTER_TYPE register type permission}.
   * @throws RepositoryException if another error occurs
   */
  public NodeTypeIterator registerNodeTypes(
      Collection<NodeTypeDefinition> templates, boolean allowUpdates)
      throws InvalidNodeTypeDefinitionException, NodeTypeExistsException,
          UnsupportedRepositoryOperationException, AccessDeniedException, RepositoryException {

    session.checkLive();
    try {
      session.checkPermission((Path) null, ModeShapePermissions.REGISTER_TYPE);
    } catch (AccessControlException ace) {
      throw new AccessDeniedException(ace);
    }
    return new JcrNodeTypeIterator(
        repositoryTypeManager.registerNodeTypes(templates, !allowUpdates, false, true));
  }
Ejemplo n.º 5
0
 @Override
 public NodeTypeIterator getAllNodeTypes() throws RepositoryException {
   session.checkLive();
   return new JcrNodeTypeIterator(nodeTypes().getAllNodeTypes());
 }