testRoot.addMixin("exo:owneable");
assertEquals("admin", testRoot.getProperty("exo:owner").getString());
assertEquals("admin", testRoot.getACL().getOwner());
Session sessJohn = repository.login(new CredentialsImpl("john", "exo".toCharArray()), "ws");
Node file = sessJohn.getRootNode().getNode("restricted").addNode("accept.gif", "nt:file");
file.addMixin("exo:privilegeable");
perm = new HashMap<String, String[]>();
perm.put("*:/platform/administrators", new String[]{"read", "add_node", "set_property", "remove"});
perm.put("root", new String[]{"read", "add_node", "set_property", "remove"});
perm.put("*:/organization/management/executive-board", new String[]{"read", "add_node", "set_property", "remove"});
perm.put("/platform/administrators", new String[]{"read", "add_node", "set_property", "remove"});
perm.put("any", new String[]{"read"});
((ExtendedNode)file).setPermissions(perm);
file.addMixin("exo:owneable");
assertEquals("john", file.getProperty("exo:owner").getString());
assertEquals("john", ((ExtendedNode)file).getACL().getOwner());
Node cont = (NodeImpl)file.addNode("jcr:content", "nt:resource");
cont.setProperty("jcr:mimeType", "text/plain");
cont.setProperty("jcr:lastModified", Calendar.getInstance());
cont.setProperty("jcr:data", new FileInputStream(createBLOBTempFile(1)));
sessJohn.save();
assertEquals("john", ((ExtendedNode)cont).getACL().getOwner());
Credentials cred = new CredentialsImpl("demo", "exo".toCharArray());
Session sess = repository.login(cred, "ws");
assertNotNull(sess.getItem("/restricted/accept.gif"));
assertNotNull(sess.getItem("/restricted/accept.gif/jcr:content"));
sess.logout();
// export
File exportFile = isSystemViewExport ? File.createTempFile("sys-export", ".xml") : File.createTempFile("doc-export", ".xml");
exportFile.deleteOnExit();
if (isSystemViewExport)
{
sess.exportSystemView(file.getPath(), new FileOutputStream(exportFile), false, false);
}
else
{
sess.exportDocumentView(file.getPath(), new FileOutputStream(exportFile), false, false);
}
// remove existed node
file.remove();
sessJohn.save();
try
{
testRoot.getNode("accept.gif");
fail();
}
catch (PathNotFoundException e) {
//ok
}
// check import
session.importXML("/restricted", new FileInputStream(exportFile), ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING);
session.save();
assertEquals("admin", ((ExtendedNode)session.getItem("/restricted")).getACL().getOwner());
assertEquals("admin", ((ExtendedNode)session.getItem("/restricted")).getProperty("exo:owner").getString());
assertEquals("john", ((ExtendedNode)session.getItem("/restricted/accept.gif")).getACL().getOwner());
assertEquals("john", ((ExtendedNode)session.getItem("/restricted/accept.gif")).getProperty("exo:owner").getString());
assertEquals("john", ((ExtendedNode)session.getItem("/restricted/accept.gif/jcr:content")).getACL().getOwner());
Credentials newCredentials = new CredentialsImpl("demo", "exo".toCharArray());
Session newSession = repository.login(newCredentials, "ws");
assertNotNull(newSession.getItem("/restricted/accept.gif"));
assertNotNull(newSession.getItem("/restricted/accept.gif/jcr:content"));
}