use of org.nuxeo.ecm.directory.Session in project nuxeo-drive-server by nuxeo.
the class AbstractChangeFinderTestCase method init.
@Before
public void init() throws Exception {
// Enable deletion listener because the tear down disables it
eventServiceAdmin.setListenerEnabledFlag("nuxeoDriveFileSystemDeletionListener", true);
lastEventLogId = 0;
lastSyncActiveRootDefinitions = "";
Framework.getProperties().put("org.nuxeo.drive.document.change.limit", "20");
// Create test users
try (Session userDir = directoryService.open("userDirectory")) {
Map<String, Object> user1 = new HashMap<>();
user1.put("username", "user1");
user1.put("groups", Arrays.asList(new String[] { "members" }));
userDir.createEntry(user1);
}
user1Session = coreFeature.openCoreSession("user1");
commitAndWaitForAsyncCompletion();
folder1 = session.createDocument(session.createDocumentModel("/", "folder1", "Folder"));
folder2 = session.createDocument(session.createDocumentModel("/", "folder2", "Folder"));
folder3 = session.createDocument(session.createDocumentModel("/", "folder3", "Folder"));
setPermissions(folder1, new ACE("user1", SecurityConstants.READ_WRITE));
setPermissions(folder2, new ACE("user1", SecurityConstants.READ_WRITE));
commitAndWaitForAsyncCompletion();
}
use of org.nuxeo.ecm.directory.Session in project nuxeo-drive-server by nuxeo.
the class TestNuxeoDriveManager method createUserSessionsAndFolders.
@Before
public void createUserSessionsAndFolders() throws Exception {
try (Session userDir = directoryService.open("userDirectory")) {
if (userDir.getEntry("user1") != null) {
userDir.deleteEntry("user1");
}
Map<String, Object> user1 = new HashMap<>();
user1.put("username", "user1");
user1.put("groups", Arrays.asList(new String[] { "members" }));
userDir.createEntry(user1);
if (userDir.getEntry("user2") != null) {
userDir.deleteEntry("user2");
}
Map<String, Object> user2 = new HashMap<>();
user2.put("username", "user2");
user2.put("groups", Arrays.asList(new String[] { "members" }));
userDir.createEntry(user2);
}
workspace_1 = session.createDocument(session.createDocumentModel("/default-domain/workspaces", "workspace-1", "Workspace"));
folder_1_1 = session.createDocument(session.createDocumentModel("/default-domain/workspaces/workspace-1", "folder-1-1", "Folder"));
workspace_2 = session.createDocument(session.createDocumentModel("/default-domain/workspaces", "workspace-2", "Workspace"));
folder_2_1 = session.createDocument(session.createDocumentModel("/default-domain/workspaces/workspace-2", "folder-2-1", "Folder"));
setPermissions(workspace_1, new ACE("members", SecurityConstants.READ));
setPermissions(workspace_2, new ACE("members", SecurityConstants.READ_WRITE));
user1Session = coreFeature.openCoreSession(userManager.getPrincipal("user1"));
user2Session = coreFeature.openCoreSession(userManager.getPrincipal("user2"));
user1Workspace = userWorkspaceService.getCurrentUserPersonalWorkspace(user1Session, user1Session.getDocument(new PathRef("/default-domain"))).getRef();
user2Workspace = userWorkspaceService.getCurrentUserPersonalWorkspace(user2Session, user2Session.getDocument(new PathRef("/default-domain"))).getRef();
}
use of org.nuxeo.ecm.directory.Session in project nuxeo-drive-server by nuxeo.
the class TestNuxeoDriveManager method closeSessionsAndDeleteUsers.
@After
public void closeSessionsAndDeleteUsers() throws Exception {
if (user1Session != null) {
((CloseableCoreSession) user1Session).close();
}
if (user2Session != null) {
((CloseableCoreSession) user2Session).close();
}
try (Session usersDir = directoryService.open("userDirectory")) {
usersDir.deleteEntry("user1");
usersDir.deleteEntry("user2");
}
// Simulate root deletion to cleanup the cache between the tests
nuxeoDriveManager.handleFolderDeletion((IdRef) doc("/").getRef());
}
use of org.nuxeo.ecm.directory.Session in project nuxeo-drive-server by nuxeo.
the class TestPermissionHierarchyFileSystemChanges method createUser.
protected void createUser(String userName, String password) {
try (Session userDir = directoryService.open("userDirectory")) {
Map<String, Object> user = new HashMap<String, Object>();
user.put("username", userName);
user.put("password", password);
userDir.createEntry(user);
}
}
Aggregations