use of org.apache.jackrabbit.oak.api.CommitFailedException in project jackrabbit-oak by apache.
the class OakInitializer method initialize.
public static void initialize(@Nonnull NodeStore store, @Nonnull RepositoryInitializer initializer, @Nonnull IndexEditorProvider indexEditor) {
try {
NodeBuilder builder = store.getRoot().builder();
initializer.initialize(builder);
store.merge(builder, createHook(indexEditor), createCommitInfo());
} catch (CommitFailedException e) {
throw new RuntimeException(e);
}
}
use of org.apache.jackrabbit.oak.api.CommitFailedException in project jackrabbit-oak by apache.
the class UniquePropertyTest method testUniqueness.
@Test
public void testUniqueness() throws Exception {
Root root = new Oak().with(new OpenSecurityProvider()).with(new PropertyIndexEditorProvider()).with(new InitialContent()).createRoot();
NodeUtil node = new NodeUtil(root.getTree("/"));
String uuid = UUID.randomUUID().toString();
node.setString(JcrConstants.JCR_UUID, uuid);
root.commit();
NodeUtil child = new NodeUtil(root.getTree("/")).addChild("another", "rep:User");
child.setString(JcrConstants.JCR_UUID, uuid);
try {
root.commit();
fail("Duplicate jcr:uuid should be detected.");
} catch (CommitFailedException e) {
// expected
}
}
use of org.apache.jackrabbit.oak.api.CommitFailedException in project jackrabbit-oak by apache.
the class TokenValidatorTest method testManuallyModifyExpirationDate.
@Test
public void testManuallyModifyExpirationDate() throws Exception {
TokenInfo info = tokenProvider.createToken(userId, Collections.<String, Object>emptyMap());
NodeUtil tokenTree = new NodeUtil(getTokenTree(info));
try {
tokenTree.setDate(TOKEN_ATTRIBUTE_EXPIRY, new Date().getTime());
root.commit();
fail("The token expiry must not manually be changed");
} catch (CommitFailedException e) {
assertEquals(63, e.getCode());
}
}
use of org.apache.jackrabbit.oak.api.CommitFailedException in project jackrabbit-oak by apache.
the class TokenValidatorTest method testTokensNodeAtInvalidPathBelowUser.
@Test
public void testTokensNodeAtInvalidPathBelowUser() throws Exception {
Tree userTree = root.getTree(getUserManager(root).getAuthorizable(userId).getPath());
NodeUtil userNode = new NodeUtil(userTree);
NodeUtil n = null;
try {
// Invalid node type of '.tokens' node
n = userNode.addChild("test", JcrConstants.NT_UNSTRUCTURED);
n.addChild(TOKENS_NODE_NAME, TOKENS_NT_NAME);
root.commit();
fail("The token parent node must be located below the user home node.");
} catch (CommitFailedException e) {
assertEquals(68, e.getCode());
} finally {
if (n != null) {
n.getTree().remove();
root.commit(CommitMarker.asCommitAttributes());
}
}
}
use of org.apache.jackrabbit.oak.api.CommitFailedException in project jackrabbit-oak by apache.
the class TokenValidatorTest method testPlaintextTokenKey.
@Test
public void testPlaintextTokenKey() throws Exception {
TokenInfo info = tokenProvider.createToken(userId, Collections.<String, Object>emptyMap());
NodeUtil tokenTree = new NodeUtil(getTokenTree(info));
try {
tokenTree.setString(TOKEN_ATTRIBUTE_KEY, "anotherValue");
root.commit(CommitMarker.asCommitAttributes());
fail("The token key must not be plaintext.");
} catch (CommitFailedException e) {
assertEquals(66, e.getCode());
}
}
Aggregations