/** * 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()); } }
public Node create(Node parent, SiteMenuItemRepresentation newItem, Position position, String sibling) throws RepositoryException { lockHelper.acquireSimpleLock(getMenuAncestor(parent), 0); final String newItemName = newItem.getName(); try { final Node newChild = parent.addNode(encode(newItemName, true), NODETYPE_HST_SITEMENUITEM); repositionChildIfNecessary(newChild, position, sibling); update(newChild, newItem); return newChild; } catch (ItemExistsException e) { throw createClientException(parent, newItemName, e.getMessage()); } }
/** * Move the source node into the parent at the given childIndex position. * * @param parent the target parent * @param source the target source * @param childIndex the index of child within parent * @throws RepositoryException */ public void move(Node parent, Node source, Integer childIndex) throws RepositoryException { lockHelper.acquireSimpleLock(getMenuAncestor(source), 0); final String sourceName = source.getName(); final String successorNodeName = getSuccessorOfSourceNodeName(parent, sourceName, childIndex); if (!source.getParent().isSame(parent)) { move(source, source.getName(), parent); } try { parent.orderBefore(encode(sourceName, true), successorNodeName); } catch (ItemExistsException e) { throw createClientException(parent, sourceName, e.getMessage()); } }
public void testSameNameErrorMessage() throws Exception { importTestNodeTypes(); String xml = createSimpleImportXml("0120a4f9-196a-3f9e-b9f5-23f31f914da7"); InputStream input = new ByteArrayInputStream(xml.getBytes("UTF-8")); superuser.importXML( "/", input, ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW); // now import same-named node with different UUID xml = createCollidingNodeXml("b2f5ff47-4366-31b6-a533-d8dc3614845d"); input = new ByteArrayInputStream(xml.getBytes("UTF-8")); boolean exceptionThrown = false; try { superuser.importXML( "/testNameCollision", input, ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW); } catch (ItemExistsException iee) { exceptionThrown = true; assertFalse(iee.getMessage().contains("UUID")); } assertTrue(exceptionThrown); }
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);
+ v.getContainingHistory().getVersionableUUID() + ". " + e.getMessage(), e); + versionableIdentifier + ". " + e.getMessage(), e);