throw new ItemExistsException(msg); } else if (uuidBehavior == ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING) { if (conflicting == null) { throw new RepositoryException(msg); String msg = "cannot remove ancestor node"; log.debug(msg); throw new ConstraintViolationException(msg); throw new RepositoryException(msg); String msg = "root node cannot be replaced"; log.debug(msg); throw new RepositoryException(msg);
/** * Move the given node by appending it as the last child of the new parent and assigning it the give new node name. * * @param node the node to move * @param newNodeName the new name of the node * @param newParent the new parent of the node * @throws RepositoryException */ private void move(Node node, String newNodeName, Node newParent) throws RepositoryException { try { node.getSession().move(node.getPath(), newParent.getPath() + "/" + encode(newNodeName, true)); } catch (ItemExistsException e) { throw createClientException(newParent, newNodeName, e.getMessage()); } }
String message = "Item already exists. At least two items with the path: " + e.getLocalizedMessage(); log.error(message, e); throw new RulesRepositoryException(message); } catch (RepositoryException e) { log.error(e.getMessage(), e); throw new RulesRepositoryException("Repository error when importing from stream.",
paths.add(nd.getPath()); throw new ItemExistsException("Unable to restore with " + "removeExisting=false. Existing nodes in " + "workspace: " + paths); success = true; } catch (CommitFailedException e) { throw new RepositoryException(e); } finally { if (!success) {
throw new RepositoryException(msg, e); String msg = "no definition found in parent node's node type for new node"; log.debug(msg); throw new ConstraintViolationException(msg, re); throw new ItemExistsException(itemMgr.safeGetJCRPath(nodePath)); if (!((NodeImpl) itemMgr.getItem(newId)).getDefinition().allowsSameNameSiblings()) { throw new ItemExistsException(itemMgr.safeGetJCRPath(nodePath));
RepositoryException ex) { if (ex instanceof AccessDeniedException) { return new AccessDeniedException(ex.getMessage()); } else if (ex instanceof ConstraintViolationException) { return new ConstraintViolationException(ex.getMessage()); } else if (ex instanceof InvalidItemStateException) { return new InvalidItemStateException(ex.getMessage()); } else if (ex instanceof InvalidQueryException) { return new InvalidQueryException(ex.getMessage()); return new InvalidSerializedDataException(ex.getMessage()); } else if (ex instanceof ItemExistsException) { return new ItemExistsException(ex.getMessage()); } else if (ex instanceof ItemNotFoundException) { return new ItemNotFoundException(ex.getMessage());
throw new ItemExistsException("Workspace restore. Can't restore a node. " + v.getContainingHistory().getVersionableUUID() + ". " + e.getMessage(), e); throw new RepositoryException("Workspace restore. Can't restore a node. " + v.getContainingHistory().getVersionableUUID() + ". Repository error: " + e.getMessage(), e); throw new ItemExistsException("Workspace restore. Can't restore a node not existed before. " + versionableIdentifier + ". " + e.getMessage(), e); throw new RepositoryException("Workspace restore. Can't restore a node not existed before. " + versionableIdentifier + ". Repository error: " + e.getMessage(), e);
throw new RepositoryException("Source and destination workspace are equals " + name); throw new RepositoryException("DestPath should not contain an index " + destAbsPath); if (!destNode.getDefinition().allowsSameNameSiblings()) throw new ItemExistsException(msg);
throw new RepositoryException(JcrI18n.pathCannotHaveSameNameSiblingIndex.text(destAbsPath)); throw new RepositoryException(JcrI18n.cannotCloneSubgraphIntoRoot.text(srcAbsPath, srcWorkspace, getName())); throw new ConstraintViolationException(JcrI18n.operationNotSupportedForUnorderedCollections.text("clone")); throw new RepositoryException(JcrI18n.unableToShareNodeWithinSubgraph.text(srcAbsPath, destAbsPath)); throw new ItemExistsException(JcrI18n.itemAlreadyExistsWithUuid.text(srcKey, workspaceName, srcNode.getPath())); if (cloneSessionNode.nodeDefinition().isMandatory()) { throw new ConstraintViolationException( JcrI18n.cannotRemoveNodeFromClone.text(cloneSessionNode.getPath(), cloneSessionNode.getIdentifier())); throw new ItemExistsException(JcrI18n.itemAlreadyExistsWithUuid.text(srcKey, workspaceName, cloneSessionNode.getPath()));
error("Import failed: " + ex.getMessage()); } catch (ItemExistsException ex) { log.error("Error initializing content in '" + nodeModel.getItemModel().getPath() + "' : " + ex.getMessage(), ex); error("Import failed: " + ex.getMessage()); } catch (ConstraintViolationException ex) { log.error("Error initializing content in '" + nodeModel.getItemModel().getPath() + "' : " + ex.getMessage(), ex); error("Import failed: " + ex.getMessage()); } catch (VersionException ex) { log.error("Error initializing content in '" + nodeModel.getItemModel().getPath() + "' : " + ex.getMessage(), ex); error("Import failed: " + ex.getMessage()); } catch (RepositoryException ex) { log.error("Error initializing content in '" + nodeModel.getItemModel().getPath() + "' : " + ex.getMessage(), ex); error("Import failed: " + ex.getMessage()); } catch (IOException ex) { log.error("IOException initializing content in '" + nodeModel.getItemModel().getPath() + "' : " + ex.getMessage(), ex);
if (parent.getDefinition().isProtected()) { if (!def.allowsSameNameSiblings()) { if (def.isProtected() && existing.isNodeType(ntName)) { throw new ItemExistsException( "Same name sibling not allowed for " + existing + " by definition " + def.getName() + " (declaring type " + def.getDeclaringNodeType().getName() + ")");
if (parentDef.isProtected()) { if (!def.allowsSameNameSiblings()) { if (def.isProtected() && isNodeType(existing, ntName)) { && (uuidBehavior == ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING || uuidBehavior == ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING))) { throw new ItemExistsException( "Node with the same UUID exists:" + existing);
public void throwFailure() throws ConstraintViolationException, ItemExistsException { String msg = JcrI18n.unableToAddChildUnderParent.text(childName, childPrimaryType, parentPath, parentPrimaryType, parentMixinTypes, workspaceName, repositoryName, reasons); if (constraintViolation) throw new ConstraintViolationException(msg); throw new ItemExistsException(msg); } }
nt = sessionContext.getNodeTypeManager().getNodeType(nodeTypeName); if (nt.isMixin()) { throw new ConstraintViolationException( "Unable to add a node with a mixin node type: " + sessionContext.getJCRName(nodeTypeName)); } else if (nt.isAbstract()) { throw new ConstraintViolationException( "Unable to add a node with an abstract node type: " + sessionContext.getJCRName(nodeTypeName)); def = getApplicableChildNodeDefinition(nodeName, nodeTypeName); } catch (RepositoryException e) { throw new ConstraintViolationException( "No child node definition for " + sessionContext.getJCRName(nodeName) + " found in " + this, e); throw new ItemExistsException( "This node already exists: " + itemMgr.safeGetJCRPath(nodePath)); if (!existing.getDefinition().allowsSameNameSiblings()) { throw new ItemExistsException( "Same-name siblings not allowed for " + existing);
return nodeInfo; if (def.isAutoCreated() && ntName != null && conflicting.isNodeType(ntName)) { log.debug("Overwriting autocreated node {}", conflicting.safeGetJCRPath()); conflicting.remove(); if (def.allowsSameNameSiblings()) { return nodeInfo; } else { + " and same-name siblings are not allowed." + " Conflicting node name is: " + nodeInfo.getName(); throw new ItemExistsException(errorMessage);
key, parent.getPath()); throw new ConstraintViolationException(text); shareableNodeAlreadyExists = true; } else { throw new ItemExistsException(JcrI18n.itemAlreadyExistsWithUuid.text(key, session().workspace() .getName(), boolean nodeAlreadyExists = existingNode != null && existingNode.getDefinition().isAutoCreated();
private void assertMementoDoesNotExist(final FedoraSession session, final String mementoPath) { if (exists(session, mementoPath)) { throw new RepositoryRuntimeException(new ItemExistsException( "Memento " + mementoPath + " already exists")); } } }
protected NodeImpl addNode(NodeImpl parentImpl, Name name, Name ntName, NodeId nodeId) throws RepositoryException { checkPermission(parentImpl, name, getPermission(true, false)); // validation: make sure Node is not locked or checked-in. parentImpl.checkSetProperty(); NodeTypeImpl nodeType = parentImpl.sessionContext.getNodeTypeManager().getNodeType(ntName); org.apache.jackrabbit.spi.commons.nodetype.NodeDefinitionImpl def = parentImpl.getApplicableChildNodeDefinition(name, ntName); // check for name collisions // TODO: improve. copied from NodeImpl NodeState thisState = parentImpl.getNodeState(); ChildNodeEntry cne = thisState.getChildNodeEntry(name, 1); if (cne != null) { // there's already a child node entry with that name; // check same-name sibling setting of new node if (!def.allowsSameNameSiblings()) { throw new ItemExistsException(); } // check same-name sibling setting of existing node NodeId newId = cne.getId(); NodeImpl n = (NodeImpl) parentImpl.sessionContext.getItemManager().getItem(newId); if (!n.getDefinition().allowsSameNameSiblings()) { throw new ItemExistsException(); } } return parentImpl.createChildNode(name, nodeType, nodeId); }
throw new ItemExistsException(JcrI18n.itemAlreadyExistsWithUuid.text(match.getKey(), session.workspace().getName(), match.getPath(cache))); switch (child.getDefinition().getOnParentVersion()) { case OnParentVersionAction.ABORT: case OnParentVersionAction.VERSION:
@Test @FixFor( "MODE-1975" ) public void shouldNotCloneEntireWorkspacesIfExternalNodesExist() throws Exception { federationManager.createProjection("/testRoot", SOURCE_NAME, MockConnector.DOC2_LOCATION, "fed2"); Session ws1Session = jcrSessionTo("ws1"); ws1Session.getRootNode().addNode("testRoot"); ws1Session.save(); ((Workspace)ws1Session.getWorkspace()).getFederationManager().createProjection("/testRoot", SOURCE_NAME, MockConnector.DOC2_LOCATION, "ws1Fed2"); try { ws1Session.getWorkspace().clone("default", "/", "/", false); fail("Expected an ItemExistsException because the target workspace already contains an external node"); } catch (ItemExistsException e) { // expected if (print) { e.printStackTrace(); } } finally { ws1Session.logout(); } }