@Override public void onPasswordChange(@Nonnull User user, String newPassword, @Nonnull Root root, @Nonnull NamePathMapper namePathMapper) throws RepositoryException { if (newPassword == null) { throw new ConstraintViolationException("Expected a new password that is not null."); } String pwHash = getPasswordHash(root, user); if (PasswordUtil.isSame(pwHash, newPassword)) { throw new ConstraintViolationException("New password is identical to the old password."); } }
@Override public void onOk() { try { final IModel<Node> nodeModel = modelReference.getModel(); final Node node = nodeModel.getObject(); final int propertyType = PropertyType.valueFromName(type); if (isMultiple) { node.setProperty(name, getJcrValues(propertyType), propertyType); } else { node.setProperty(name, getJcrValue(propertyType), propertyType); } modelReference.setModel(new JcrNodeModel(node)); } catch (ConstraintViolationException e) { error("It is not allowed to add the property '" + name + "' on this node."); log.info(e.getClass().getName() + " : " + e.getMessage()); } catch (ValueFormatException e) { error(e.toString()); log.info(e.getClass().getName() + " : " + e.getMessage()); } catch (RepositoryException e) { error(e.toString()); log.error(e.getClass().getName() + " : " + e.getMessage(), e); } }
private void setData() { try { loadData(); } catch (ConstraintViolationException e) { e.printStackTrace(); } }
@Nonnull @Override public Node perform() throws RepositoryException { String propName = PathUtils.getName(parentPath); if (grandParent.getPropertyOrNull(propName) != null) { throw new ConstraintViolationException("Can't add new node to property."); throw new PathNotFoundException(relPath); throw new ItemExistsException(relPath); throw new ItemExistsException(format("Node [%s/%s] exists", getNodePath(),oakName));
public RepositoryException asRepositoryException(@Nonnull String message) { if (isConstraintViolation()) { return new ConstraintViolationException(message, this); } else if (isOfType(NAMESPACE)) { return new NamespaceException(message, this); return new UnsupportedRepositoryOperationException(message, this); } else { return new RepositoryException(message, this);
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()); return new NoSuchWorkspaceException(ex.getMessage()); } else if (ex instanceof PathNotFoundException) { return new PathNotFoundException(ex.getMessage()); } else if (ex instanceof ReferentialIntegrityException) { return new ReferentialIntegrityException(ex.getMessage());
@Override public void performVoid() throws RepositoryException { ItemDelegate item = sd.getItem(oakPath); if (item == null) { throw new PathNotFoundException(absPath); } else if (item.isProtected()) { throw new ConstraintViolationException( item.getPath() + " is protected"); } else if (!item.remove()) { throw new RepositoryException( item.getPath() + " could not be removed"); } } });
/** * @see org.apache.jackrabbit.spi.QValueConstraint#check(QValue) */ public void check(QValue value) throws ConstraintViolationException, RepositoryException { if (value == null) { throw new ConstraintViolationException("null value does not satisfy the constraint '" + getString() + "'"); } switch (value.getType()) { case PropertyType.STRING: case PropertyType.URI: String text = value.getString(); Matcher matcher = pattern.matcher(text); if (!matcher.matches()) { throw new ConstraintViolationException("'" + text + "' does not satisfy the constraint '" + getString() + "'"); } return; default: String msg = "String constraint can not be applied to value of type: " + PropertyType.nameFromValue(value.getType()); log.debug(msg); throw new RepositoryException(msg); } }
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);
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));
log.error("Error initializing content in '" + nodeModel.getItemModel().getPath() + "' : " + ex.getMessage(), ex); 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);
@Override public void save() throws AccessDeniedException, ConstraintViolationException, InvalidItemStateException, VersionException, LockException, RepositoryException { if (derivedEngine != null) { try { derivedEngine.save(); } catch (VersionException ex) { log.warn(ex.getClass().getName() + ": " + ex.getMessage(), ex); throw ex; } catch (LockException ex) { log.warn(ex.getClass().getName() + ": " + ex.getMessage(), ex); throw ex; } catch (ConstraintViolationException ex) { log.warn(ex.getClass().getName() + ": " + ex.getMessage(), ex); throw ex; } catch (RepositoryException ex) { log.warn(ex.getClass().getName() + ": " + ex.getMessage(), ex); throw ex; } } try { postMountEnabled(false); super.save(); } finally { postMountEnabled(true); } }
/** * @see DiffHandler#remove(String, String) */ @Override public void remove(String targetPath, String diffValue) throws DiffException { if (!(diffValue == null || diffValue.trim().length() == 0)) { throw new DiffException("'remove' may not have a diffValue."); } try { String itemPath = getItemPath(targetPath); Item item = session.getItem(itemPath); ItemDefinition def = (item.isNode()) ? ((Node) item).getDefinition() : ((Property) item).getDefinition(); if (def.isProtected()) { // delegate to the manager. if (protectedRemoveManager == null || !protectedRemoveManager.remove(session, itemPath)) { throw new ConstraintViolationException("Cannot remove protected node: no suitable handler configured."); } } else { item.remove(); } } catch (RepositoryException e) { throw new DiffException(e.getMessage(), e); } }
throw new RepositoryException("this session has been closed"); if (parent.getDefinition().isProtected()) { String msg = parent.safeGetJCRPath() + ": cannot add a child to a protected node"; log.debug(msg); throw new ConstraintViolationException(msg);
@Override public void checkMandatoryItems(Tree tree) throws ConstraintViolationException { for (NodeType nodeType : nodeTypes.values()) { for (PropertyDefinition pd : nodeType.getPropertyDefinitions()) { String name = pd.getName(); if (pd.isMandatory() && !pd.isProtected() && tree.getProperty(name) == null) { throw new ConstraintViolationException( "Property '" + name + "' in '" + nodeType.getName() + "' is mandatory"); } } for (NodeDefinition nd : nodeType.getChildNodeDefinitions()) { String name = nd.getName(); if (nd.isMandatory() && !nd.isProtected() && !tree.hasChild(name)) { throw new ConstraintViolationException( "Node '" + name + "' in '" + nodeType.getName() + "' is mandatory"); } } } }
/** * Throw a {@link ConstraintViolationException} if this node is protected (based on the its node definition). * * @throws ConstraintViolationException if this node's definition indicates that the node is protected * @throws RepositoryException if an error occurs retrieving the definition for this node */ private void checkNotProtected() throws ConstraintViolationException, RepositoryException { if (getDefinition().isProtected()) { throw new ConstraintViolationException(JcrI18n.cannotRemoveItemWithProtectedDefinition.text(getPath())); } }
String propName = PathUtils.getName(parentPath); if (grandParent.getPropertyOrNull(propName) != null) { throw new ConstraintViolationException("Can't add new node to property."); throw new PathNotFoundException(relPath); throw new ItemExistsException(relPath); throw new ItemExistsException(format("Node [%s/%s] exists", getNodePath(),oakName));
public void checkProtectedNode(String path) throws RepositoryException { NodeDelegate node = getNode(path); if (node == null) { throw new PathNotFoundException( "Node " + path + " does not exist."); } else if (node.isProtected()) { throw new ConstraintViolationException( "Node " + path + " is protected."); } }
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); } }
for (NodeDefinition def : getNamedNodeDefinitions(childName)) { boolean match = true; if (childEffective != null && !childEffective.includesNodeTypes(def.getRequiredPrimaryTypeNames())) { match = false; if (childEffective != null && !childEffective.includesNodeTypes(def.getRequiredPrimaryTypeNames())) { match = false; throw new ConstraintViolationException( "No matching node definition found for " + childName);