use of org.apache.jackrabbit.core.NodeImpl in project jackrabbit by apache.
the class CachingHierarchyManagerConsistencyTest method replaceNodes.
private void replaceNodes(Session session, int i) throws RepositoryException {
String nodeName = "node-" + (i % 100);
Node root = JcrUtils.getOrCreateByPath(testRoot + TEST_PATH, ntUnstructured, session);
String uuid = UUID.randomUUID().toString();
if (root.hasNode(nodeName)) {
Node n = root.getNode(nodeName);
uuid = n.getIdentifier();
n.remove();
}
Node n = ((NodeImpl) root).addNodeWithUuid(nodeName, ntUnstructured, uuid);
n.addMixin("mix:referenceable");
n.addNode("foo").addNode("bar");
n.addNode("qux");
session.save();
}
use of org.apache.jackrabbit.core.NodeImpl in project jackrabbit by apache.
the class EntryTest method testRestrictions.
public void testRestrictions() throws RepositoryException, NotExecutableException {
// test if restrictions with expanded name are properly resolved
Map<String, Value> restrictions = new HashMap<String, Value>();
restrictions.put(ACLTemplate.P_GLOB.toString(), superuser.getValueFactory().createValue("*/test"));
acl = getPolicy(acMgr, testPath, testUser.getPrincipal());
acl.addEntry(testUser.getPrincipal(), new Privilege[] { acMgr.privilegeFromName(Privilege.JCR_ALL) }, true, restrictions);
acMgr.setPolicy(testPath, acl);
superuser.save();
Map<String, Boolean> toMatch = new HashMap<String, Boolean>();
toMatch.put(acl.getPath(), false);
toMatch.put(acl.getPath() + "test", false);
toMatch.put(acl.getPath() + "/test", true);
toMatch.put(acl.getPath() + "/something/test", true);
toMatch.put(acl.getPath() + "de/test", true);
NodeImpl aclNode = (NodeImpl) superuser.getNode(acl.getPath() + "/rep:policy");
List<Entry> entries = Entry.readEntries(aclNode, testRootNode.getPath());
assertTrue(!entries.isEmpty());
assertEquals(1, entries.size());
Entry entry = entries.iterator().next();
for (String str : toMatch.keySet()) {
assertEquals("Path to match : " + str, toMatch.get(str).booleanValue(), entry.matches(str));
}
}
use of org.apache.jackrabbit.core.NodeImpl in project jackrabbit by apache.
the class EntryTest method testIsLocal.
public void testIsLocal() throws NotExecutableException, RepositoryException {
acl = getPolicy(acMgr, testPath, testUser.getPrincipal());
modifyPrivileges(testPath, Privilege.JCR_READ, true);
NodeImpl aclNode = (NodeImpl) superuser.getNode(acl.getPath() + "/rep:policy");
List<Entry> entries = Entry.readEntries(aclNode, testRootNode.getPath());
assertTrue(!entries.isEmpty());
assertEquals(1, entries.size());
Entry entry = entries.iterator().next();
// false since acl has been created from path only -> no id
assertTrue(entry.isLocal(((NodeImpl) testRootNode).getNodeId()));
// false since internal id is null -> will never match.
assertFalse(entry.isLocal(NodeId.randomId()));
}
use of org.apache.jackrabbit.core.NodeImpl in project jackrabbit by apache.
the class HierarchyConstraint method getBaseNodeId.
/**
* Returns the id of the base node or <code>null</code> if there is no node
* at the base path.
*
* @param context the evaluation context.
* @return the id or <code>null</code> if it doesn't exist.
*/
protected final NodeId getBaseNodeId(EvaluationContext context) {
if (id == null) {
try {
NodeImpl node = (NodeImpl) context.getSession().getNode(path);
id = (NodeId) node.getId();
} catch (RepositoryException e) {
return null;
}
}
return id;
}
use of org.apache.jackrabbit.core.NodeImpl in project jackrabbit by apache.
the class UserImporterTest method testImportSelfAsGroupAbort.
public void testImportSelfAsGroupAbort() throws Exception {
// uuid of the group itself
String invalidId = "0120a4f9-196a-3f9e-b9f5-23f31f914da7";
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<sv:node sv:name=\"gFolder\" xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" xmlns:fn_old=\"http://www.w3.org/2004/10/xpath-functions\" xmlns:fn=\"http://www.w3.org/2005/xpath-functions\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" xmlns:rep=\"internal\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\">" + " <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:AuthorizableFolder</sv:value></sv:property>" + "<sv:node sv:name=\"g1\"><sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:Group</sv:value></sv:property>" + " <sv:property sv:name=\"jcr:uuid\" sv:type=\"String\"><sv:value>" + invalidId + "</sv:value></sv:property>" + " <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>g1</sv:value></sv:property>" + " <sv:property sv:name=\"rep:members\" sv:type=\"WeakReference\"><sv:value>" + invalidId + "</sv:value></sv:property>" + "</sv:node>" + "</sv:node>";
NodeImpl target = (NodeImpl) sImpl.getNode(umgr.getGroupsPath());
try {
doImport(target, xml, UserImporter.ImportBehavior.ABORT);
fail("Importing self as group with ImportBehavior.ABORT must fail.");
} catch (SAXException e) {
// success.
} finally {
sImpl.refresh(false);
}
}
Aggregations