private void assertMementoDoesNotExist(final FedoraSession session, final String mementoPath) { if (exists(session, mementoPath)) { throw new RepositoryRuntimeException(new ItemExistsException( "Memento " + mementoPath + " already exists")); } } }
@Override protected Node doExec(Node context, ErrorHandler errorHandler) throws RepositoryException { if (context.hasProperty(name)) { throw new ItemExistsException(String.format("Property %s already exists at %s", name, context.getPath())); } final Value value = PropertyUtil.createValue(newValue, context.getSession().getValueFactory()); context.setProperty(name, value); return context; } };
@Override protected Node doExec(Node context, ErrorHandler errorHandler) throws RepositoryException { if (!context.hasProperty(name)) { throw new ItemNotFoundException(String.format("Property %s does not exist at %s", name, context.getPath())); } if (context.hasProperty(newName)) { throw new ItemExistsException(String.format("Property %s already exists at %s", newName, context.getPath())); } final Value value = context.getProperty(name).getValue(); context.setProperty(newName, value); context.getProperty(name).remove(); return context; } };
/** * Validate if node exists current action type is NOT APPEND or parameter allowIgnoreConflict is true * @param nodePath Node path * @param actionType current action type * @param session current session * @param allowIgnoreConflict if true and node exists with action type APPEND <em>may</em> be ignored * @return true if there is no conflict, false if there was a conflict but the above system parameter is true * @throws RepositoryException if node exists and action type is APPEND and !allowIgnoreConflict */ private boolean validateAppendAction(final String nodePath, final ActionType actionType, final Session session, final boolean allowIgnoreConflict) throws RepositoryException { final boolean nodeExists = session.nodeExists(nodePath); if (nodeExists && actionType == APPEND) { if (allowIgnoreConflict) { return false; } throw new ItemExistsException(String.format("Node already exists at path %s", nodePath)); } return true; }
public Property addProperty(String key, Value value) throws RepositoryException { Node parent = getOrCreateParent(key); if (parent.hasProperty(key)) { throw new ItemExistsException(key); } Property p = parent.setProperty(key, value); treeManager.split(this, parent, p); if (autoSave) { p.getSession().save(); } return p; }
public Property addProperty(String key, Value value) throws RepositoryException { Node parent = getOrCreateParent(key); if (parent.hasProperty(key)) { throw new ItemExistsException(key); } Property p = parent.setProperty(key, value); treeManager.split(this, parent, p); if (autoSave) { p.getSession().save(); } return p; }
public Property addProperty(String key, Value value) throws RepositoryException { Node parent = getOrCreateParent(key); if (parent.hasProperty(key)) { throw new ItemExistsException(key); } Property p = parent.setProperty(key, value); treeManager.split(this, parent, p); if (autoSave) { p.getSession().save(); } return p; }
@Override protected Content doExec(Content context, ErrorHandler errorHandler) throws RepositoryException { if (context.hasNodeData(name)) { // throw new ItemExistsException("Property " + name + " already exists at " + context.getHandle()); throw new ItemExistsException(name); } context.createNodeData(name, value); return context; } };
@Override public void move(String srcAbsPath, String destAbsPath) throws RepositoryException { if (nodeExists(destAbsPath)) { throw new ItemExistsException("The move operation was not completed due to an item with the same name already present."); } super.move(srcAbsPath, destAbsPath); } }
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); } }
/** * {@inheritDoc} */ @Override public JcrPackage upload(InputStream in, boolean replace, boolean strict) throws RepositoryException, IOException { try { return registry.upload(in, replace); } catch (PackageExistsException e) { throw new ItemExistsException(e.getMessage(), e); } }
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); } }
public Node addNode(String key, String primaryNodeTypeName) throws RepositoryException { Node parent = getOrCreateParent(key); if (parent.hasNode(key)) { throw new ItemExistsException(key); } Node n; if (parent.getPrimaryNodeType().hasOrderableChildNodes()) { Node dest = getSuccessor(parent, key); n = parent.addNode(key, primaryNodeTypeName); parent.orderBefore(key, dest == null ? null : dest.getName()); } else { n = parent.addNode(key, primaryNodeTypeName); } treeManager.split(this, parent, n); if (autoSave) { parent.getSession().save(); } return n; }
public Node addNode(String key, String primaryNodeTypeName) throws RepositoryException { Node parent = getOrCreateParent(key); if (parent.hasNode(key)) { throw new ItemExistsException(key); } Node n; if (parent.getPrimaryNodeType().hasOrderableChildNodes()) { Node dest = getSuccessor(parent, key); n = parent.addNode(key, primaryNodeTypeName); parent.orderBefore(key, dest == null ? null : dest.getName()); } else { n = parent.addNode(key, primaryNodeTypeName); } treeManager.split(this, parent, n); if (autoSave) { parent.getSession().save(); } return n; }
public Node addNode(String key, String primaryNodeTypeName) throws RepositoryException { Node parent = getOrCreateParent(key); if (parent.hasNode(key)) { throw new ItemExistsException(key); } Node n; if (parent.getPrimaryNodeType().hasOrderableChildNodes()) { Node dest = getSuccessor(parent, key); n = parent.addNode(key, primaryNodeTypeName); parent.orderBefore(key, dest == null ? null : dest.getName()); } else { n = parent.addNode(key, primaryNodeTypeName); } treeManager.split(this, parent, n); if (autoSave) { parent.getSession().save(); } return n; }
/** * {@inheritDoc} */ @Override public JcrPackage upload(File file, boolean isTmpFile, boolean replace, String nameHint, boolean strict) throws RepositoryException, IOException { ZipVaultPackage pack = new ZipVaultPackage(file, isTmpFile, strict); try { return registry.upload(pack, replace); } catch (PackageExistsException e) { throw new ItemExistsException(e.getMessage(), e); } }
/** * * @param parentState * @param propertyName * @throws ItemExistsException * @throws RepositoryException */ private void checkCollision(NodeState parentState, Name propertyName) throws ItemExistsException, RepositoryException { NodeEntry parentEntry = (NodeEntry) parentState.getHierarchyEntry(); // NOTE: check for name collisions with existing child node has been // removed as with JSR 283 having same-named node and property can be // allowed. thus delegate the corresponding validation to the underlying // SPI implementation. // check for name collisions with an existing property PropertyEntry pe = parentEntry.getPropertyEntry(propertyName); if (pe != null) { try { pe.getPropertyState(); throw new ItemExistsException("Property '" + pe.getName() + "' already exists."); } catch (ItemNotFoundException e) { // apparently conflicting entry does not exist any more // ignore and return } } }
@Override protected Content doExec(Content context, ErrorHandler errorHandler) throws RepositoryException { if (!context.hasNodeData(name)) { throw new ItemNotFoundException(name); } if (context.hasNodeData(newName)) { //throw new ItemExistsException("Property " + newName + " already exists at " + context.getHandle()); throw new ItemExistsException(newName); } final Value value = context.getNodeData(name).getValue(); context.setNodeData(newName, value); context.deleteNodeData(name); return context; } };
/** * Calculates next child node index. Is used existed node definition, if no - get one based on node name * and node type. */ private int getNextChildIndex(InternalQName nameToAdd, InternalQName primaryTypeName, NodeData parentNode, NodeDefinitionData def) throws RepositoryException, ItemExistsException { boolean allowSns = def.isAllowsSameNameSiblings(); int ind = 1; boolean hasSibling = dataManager.hasItemData(parentNode, new QPathEntry(nameToAdd, ind), ItemType.NODE); while (hasSibling) { if (allowSns) { ind++; hasSibling = dataManager.hasItemData(parentNode, new QPathEntry(nameToAdd, ind), ItemType.NODE); } else { throw new ItemExistsException("The node " + nameToAdd + " already exists in " + getPath() + " and same name sibling is not allowed "); } }; return ind; }