@Override public void propertyChanged(PropertyState before, PropertyState after) throws CommitFailedException { throw new CommitFailedException(type, code, message); }
private static void throwProtected(String name) throws CommitFailedException { throw new CommitFailedException(CommitFailedException.CONSTRAINT, 100, "Property is protected: " + name); }
@Override public void onConstraintViolation(String path, List<String> nodeTypeNames, int code, String message) throws CommitFailedException { String fullPath = path + '[' + nodeTypeNames.toString() + ']'; throw new CommitFailedException(CONSTRAINT, code, fullPath + ": " + message); } };
@Override public void onConstraintViolation(String path, List<String> nodeTypeNames, int code, String message) throws CommitFailedException { String fullPath = path + '[' + nodeTypeNames.toString() + ']'; throw new CommitFailedException(CONSTRAINT, code, fullPath + ": " + message); } };
private void checkPrefix(String prefix) throws CommitFailedException { if (prefix.isEmpty() || !contains(prefixes, namespaces, prefix)) { String msg = "Invalid namespace prefix(" + prefixes + "): " + prefix; if (initPhase && !strictInitialNSChecks) { LOG.warn(msg); return; } throw new CommitFailedException(CommitFailedException.NAME, 1, msg); } }
private static void throwCheckedIn(String msg) throws CommitFailedException { throw new CommitFailedException(CommitFailedException.VERSION, VersionExceptionCode.NODE_CHECKED_IN.ordinal(), msg); }
@Override public void onConstraintViolation(String path, List<String> nodeTypeNames, int code, String message ) { String fullPath = path + '[' + nodeTypeNames.toString() + ']'; log.warn(new CommitFailedException(CONSTRAINT, code, fullPath + ": " + message).getMessage()); } };
@Override public void onMissingIndex(String type, NodeBuilder definition, String path) throws CommitFailedException { if (isDisabled(type)) { return; } throw new CommitFailedException("Async", 2, "Missing index provider detected for type [" + type + "] on index [" + path + "]"); } }
private void checkPrefix(String prefix) throws CommitFailedException { if (prefix.isEmpty() || !contains(prefixes, namespaces, prefix)) { String msg = "Invalid namespace prefix(" + prefixes + "): " + prefix; if (initPhase && !strictInitialNSChecks) { LOG.warn(msg); return; } throw new CommitFailedException(CommitFailedException.NAME, 1, msg); } }
@Override public void onConstraintViolation(String path, List<String> nodeTypeNames, int code, String message ) { String fullPath = path + '[' + nodeTypeNames.toString() + ']'; log.warn(new CommitFailedException(CONSTRAINT, code, fullPath + ": " + message).getMessage()); } };
@Override public Validator childNodeDeleted(String name, NodeState before) throws CommitFailedException { if (isPrivilegeDefinition(before)) { throw new CommitFailedException(CONSTRAINT, 42, "Attempt to un-register privilege " + name); } else { // not handled by this validator return null; } }
@Override public void onMissingIndex(String type, NodeBuilder definition, String path) throws CommitFailedException { if (isDisabled(type)) { return; } throw new CommitFailedException("Async", 2, "Missing index provider detected for type [" + type + "] on index [" + path + "]"); } }
@Override public void enter(NodeState before, NodeState after) throws CommitFailedException { failed = true; throw new CommitFailedException("test", -1, "Testing failures"); }
@NotNull @Override public NodeState processCommit(NodeState before, NodeState after, CommitInfo info) throws CommitFailedException { throw new CommitFailedException(CommitFailedException.OAK, 0, "fail"); } }
private void checkPermissions(@Nonnull Tree tree, long permissions) throws CommitFailedException { if (!getPermissionProvider().isGranted(tree, null, permissions)) { throw new CommitFailedException(ACCESS, 0, "Access denied"); } } }
@NotNull @Override public synchronized NodeState merge(@NotNull NodeBuilder builder, @NotNull CommitHook commitHook, @NotNull CommitInfo info) throws CommitFailedException { throw new CommitFailedException("TestFail", 1, "We must never merge"); } };
@Override public Validator childNodeAdded(String name, NodeState after) throws CommitFailedException { Tree child = checkNotNull(parentAfter.getChild(name)); if (isVersionstorageTree(child)) { child = getVersionHistoryTree(child); if (child == null) { throw new CommitFailedException( ACCESS, 21, "New version storage node without version history: cannot verify permissions."); } } return checkPermissions(child, false, Permissions.ADD_NODE); }
@Override public Validator childNodeDeleted(String name, NodeState before) throws CommitFailedException { Tree child = parentBefore.getChild(name); if (isVersionstorageTree(child)) { throw new CommitFailedException( ACCESS, 22, "Attempt to remove versionstorage node: Fail to verify delete permission."); } return checkPermissions(child, true, Permissions.REMOVE_NODE); }
private boolean isIgnoreOnOPV() throws CommitFailedException { if (this.parent != null) { try { NodeDefinition definition = this.vMgr.getNodeTypeManager().getDefinition(TreeFactory.createTree(parent.node), this.name); return definition.getOnParentVersion() == OnParentVersionAction.IGNORE; } catch (Exception e) { throw new CommitFailedException(CommitFailedException.VERSION, VersionExceptionCode.UNEXPECTED_REPOSITORY_EXCEPTION.ordinal(), e.getMessage()); } } return false; }
private int getOPV(PropertyState property) throws CommitFailedException { try { return this.vMgr.getNodeTypeManager().getDefinition(TreeFactory.createReadOnlyTree(this.node.getNodeState()), property, false).getOnParentVersion(); } catch (Exception e) { throw new CommitFailedException(CommitFailedException.VERSION, VersionExceptionCode.UNEXPECTED_REPOSITORY_EXCEPTION.ordinal(), e.getMessage()); } } }