@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); } }
throw new NotExecutableException("server does not support making the parent versionable: " + ex.getMessage());
@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); } }
throw new NotExecutableException("server does not support making the parent versionable: " + ex.getMessage());
/** * @see Node#canAddMixin(String) */ public boolean canAddMixin(String mixinName) throws RepositoryException { if (!isWritable()) { // shortcut: repository does not support writing anyway. return false; } try { // first check if node is writable regarding protection status, // locks, versioning, access restriction. session.getValidator().checkIsWritable(getNodeState(), ItemStateValidator.CHECK_ALL); // then make sure the new mixin would not conflict. return canAddMixin(getQName(mixinName)); } catch (LockException e) { log.debug("Cannot add mixin '" + mixinName + "': " + e.getMessage()); return false; } catch (VersionException e) { log.debug("Cannot add mixin '" + mixinName + "': " + e.getMessage()); return false; } catch (ConstraintViolationException e) { log.debug("Cannot add mixin '" + mixinName + "': " + e.getMessage()); return false; } }
/** * @see Node#canAddMixin(String) */ public boolean canAddMixin(String mixinName) throws RepositoryException { if (!isWritable()) { // shortcut: repository does not support writing anyway. return false; } try { // first check if node is writable regarding protection status, // locks, versioning, access restriction. session.getValidator().checkIsWritable(getNodeState(), ItemStateValidator.CHECK_ALL); // then make sure the new mixin would not conflict. return canAddMixin(getQName(mixinName)); } catch (LockException e) { log.debug("Cannot add mixin '" + mixinName + "': " + e.getMessage()); return false; } catch (VersionException e) { log.debug("Cannot add mixin '" + mixinName + "': " + e.getMessage()); return false; } catch (ConstraintViolationException e) { log.debug("Cannot add mixin '" + mixinName + "': " + e.getMessage()); return false; } }
@Test @FixFor( "MODE-2281" ) public void shouldAllowUsingSystemNodeTypesInNonSystemArea() throws Exception { try { Node rootNode = session().getRootNode(); Node myVersionNode = rootNode.addNode("myVersion", "nt:version"); myVersionNode.addNode("frozen", "nt:frozenNode"); } catch (ConstraintViolationException e) { if (!e.getMessage().contains("is protected")) { // It's not the exception we expect ... throw e; } } }
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);
/** * @see <a href="https://issues.apache.org/jira/browse/OAK-2810">OAK-2810</a> */ @Test public void testCopyToProtectedParentDestination() throws Exception { // create a protected target parent node (not meant for permission validation this time) allow(targetPath, privilegesFromName(Privilege.JCR_ALL)); Node destParent = null; NodeIterator nodeIterator = superuser.getNode(targetPath).getNode(AccessControlConstants.REP_POLICY).getNodes(); while (nodeIterator.hasNext()) { Node n = nodeIterator.nextNode(); if (n.getDefinition().isProtected()) { destParent = n; break; } } if (destParent == null) { throw new NotExecutableException("No protected parent found"); } try { superuser.getWorkspace().copy(childNPath, destParent.getPath() + "/copy"); fail("Copy must fail with constraint-violation if the destination parent is a protected node."); } catch (ConstraintViolationException e) { // success assertEquals("Node " + destParent.getPath() + " is protected.", e.getMessage()); } }
} catch (ConstraintViolationException e) { assertTrue(e.getMessage().contains("OakConstraint0021"));
} catch (ConstraintViolationException e) { assertTrue(e.getMessage().contains("OakConstraint0021"));
} catch (ConstraintViolationException e) { assertTrue(e.getMessage().contains("OakConstraint0022"));
} catch (ConstraintViolationException e) { assertTrue(e.getMessage().contains("OakConstraint0021"));