Skip to content

Commit

Permalink
MODE-1154 RepositoryNodeTypeManager allows NodeTypes to be updated, b…
Browse files Browse the repository at this point in the history
…ut JcrNodeTypeManager does not pass through allowUpdate

Modified RNTM and JNTM to pass the allowUpdate flag through.
  • Loading branch information
bcarothers-xx committed Apr 16, 2011
1 parent f17f5a5 commit cdbadf0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ public NodeType registerNodeType( NodeTypeDefinition template,
throw new AccessDeniedException(ace);
}
try {
return this.repositoryTypeManager.registerNodeType(template);
return this.repositoryTypeManager.registerNodeType(template, !allowUpdate);
} finally {
schemata = null;
}
Expand Down Expand Up @@ -525,7 +525,7 @@ public NodeTypeIterator registerNodeTypes( Collection<NodeTypeDefinition> templa
throw new AccessDeniedException(ace);
}
try {
return new JcrNodeTypeIterator(repositoryTypeManager.registerNodeTypes(templates));
return new JcrNodeTypeIterator(repositoryTypeManager.registerNodeTypes(templates, !allowUpdates));
} finally {
schemata = null;
}
Expand Down Expand Up @@ -597,7 +597,7 @@ public NodeTypeIterator registerNodeTypes( NodeTypeDefinition[] ntds,
}

try {
return new JcrNodeTypeIterator(this.repositoryTypeManager.registerNodeTypes(ntds));
return new JcrNodeTypeIterator(this.repositoryTypeManager.registerNodeTypes(Arrays.asList(ntds), !allowUpdate));
} finally {
schemata = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1599,8 +1599,8 @@ boolean isNodeTypeInUse( Name nodeTypeName ) throws InvalidQueryException {
}

/**
* Registers a new node type or updates an existing node type using the specified definition and returns the resulting
* {@code NodeType} object.
* Registers a new node type or updates an existing node type using the specified definition and returns the resulting {@code
* NodeType} object.
* <p>
* For details, see {@link #registerNodeTypes(Iterable)}.
* </p>
Expand All @@ -1614,27 +1614,33 @@ boolean isNodeTypeInUse( Name nodeTypeName ) throws InvalidQueryException {
*/
JcrNodeType registerNodeType( NodeTypeDefinition ntd )
throws InvalidNodeTypeDefinitionException, NodeTypeExistsException, RepositoryException {
assert ntd != null;
List<JcrNodeType> result = registerNodeTypes(Collections.singletonList(ntd));
return result.isEmpty() ? null : result.get(0);

return registerNodeType(ntd, true);
}

/**
* Registers or updates the specified {@link NodeTypeDefinition} objects.
* Registers a new node type or updates an existing node type using the specified definition and returns the resulting {@code
* NodeType} object.
* <p>
* For details, see {@link #registerNodeTypes(Iterable)}.
* </p>
*
* @param ntds the node type definitions
* @return the newly registered (or updated) {@link NodeType NodeTypes}
* @throws InvalidNodeTypeDefinitionException
* @throws NodeTypeExistsException
* @throws RepositoryException
* @param ntd the {@code NodeTypeDefinition} to register
* @param failIfNodeTypeExists indicates whether the registration should proceed if there is already a type with the same
* name; {@code true} indicates that the registration should fail with an error if a node type with the same name
* already exists
* @return the newly registered (or updated) {@code NodeType}
* @throws InvalidNodeTypeDefinitionException if the {@code NodeTypeDefinition} is invalid
* @throws NodeTypeExistsException if <code>allowUpdate</code> is false and the {@code NodeTypeDefinition} specifies a node
* type name that is already registered
* @throws RepositoryException if another error occurs
*/
List<JcrNodeType> registerNodeTypes( NodeTypeDefinition[] ntds )
JcrNodeType registerNodeType( NodeTypeDefinition ntd,
boolean failIfNodeTypeExists )
throws InvalidNodeTypeDefinitionException, NodeTypeExistsException, RepositoryException {
assert ntds != null;
return registerNodeTypes(Arrays.asList(ntds));
assert ntd != null;
List<JcrNodeType> result = registerNodeTypes(Collections.singletonList(ntd), failIfNodeTypeExists);
return result.isEmpty() ? null : result.get(0);
}

/**
Expand Down

0 comments on commit cdbadf0

Please sign in to comment.