@Test public void testFindUsersWithAccess() throws Exception { SqlWorkspace sqlWorkspace = (SqlWorkspace) sqlWorkspaceRepository.add("test", testUser); List<WorkspaceUser> workspaceUsers = sqlWorkspaceRepository.findUsersWithAccess(sqlWorkspace.getWorkspaceId(), testUser); assertFalse(workspaceUsers.isEmpty()); assertEquals(testUser.getUserId(), workspaceUsers.get(0).getUserId()); assertTrue(workspaceUsers.get(0).isCreator()); }
@Override public List<WorkspaceUser> findUsersWithAccess(String workspaceId, User user) { List<WorkspaceUser> withAccess = new ArrayList<WorkspaceUser>(); List<SqlWorkspaceUser> sqlWorkspaceUsers = getSqlWorkspaceUserLists(workspaceId); for (SqlWorkspaceUser sqlWorkspaceUser : sqlWorkspaceUsers) { if (!sqlWorkspaceUser.getWorkspaceAccess().equals(WorkspaceAccess.NONE.toString())) { String userId = sqlWorkspaceUser.getUser().getUserId(); Workspace workspace = findById(workspaceId, user); boolean isCreator = ((SqlWorkspace) workspace).getWorkspaceCreator().getUserId().equals(userId); withAccess.add(new WorkspaceUser(userId, WorkspaceAccess.valueOf(sqlWorkspaceUser.getWorkspaceAccess()), isCreator)); } } return withAccess; }
SqlWorkspaceRepository extends WorkspaceRepository { @Override public List<WorkspaceUser> findUsersWithAccess(String workspaceId, User user) { List<WorkspaceUser> withAccess = new ArrayList<WorkspaceUser>(); List<SqlWorkspaceUser> sqlWorkspaceUsers = getSqlWorkspaceUserLists(workspaceId); for (SqlWorkspaceUser sqlWorkspaceUser : sqlWorkspaceUsers) { if (!sqlWorkspaceUser.getWorkspaceAccess().equals(WorkspaceAccess.NONE.toString())) { String userId = sqlWorkspaceUser.getUser().getUserId(); Workspace workspace = findById(workspaceId, user); boolean isCreator = ((SqlWorkspace) workspace).getWorkspaceCreator().getUserId().equals(userId); withAccess.add(new WorkspaceUser(userId, WorkspaceAccess.valueOf(sqlWorkspaceUser.getWorkspaceAccess()), isCreator)); } } return withAccess; } }
SqlWorkspaceRepository extends WorkspaceRepository { @Override public List<WorkspaceUser> findUsersWithAccess(String workspaceId, User user) { List<WorkspaceUser> withAccess = new ArrayList<WorkspaceUser>(); List<SqlWorkspaceUser> sqlWorkspaceUsers = getSqlWorkspaceUserLists(workspaceId); for (SqlWorkspaceUser sqlWorkspaceUser : sqlWorkspaceUsers) { if (!sqlWorkspaceUser.getWorkspaceAccess().equals(WorkspaceAccess.NONE.toString())) { String userId = sqlWorkspaceUser.getUser().getUserId(); Workspace workspace = findById(workspaceId, user); boolean isCreator = ((SqlWorkspace) workspace).getWorkspaceCreator().getUserId().equals(userId); withAccess.add(new WorkspaceUser(userId, WorkspaceAccess.valueOf(sqlWorkspaceUser.getWorkspaceAccess()), isCreator)); } } return withAccess; } @Inject  SqlWorkspaceRepository(final SqlUserRepository userRepository, final HibernateSessionManager sessionManager,
                                  final Graph graph); }
SqlWorkspaceRepository extends WorkspaceRepository { @Override public List<WorkspaceUser> findUsersWithAccess(String workspaceId, User user) { List<WorkspaceUser> withAccess = new ArrayList<WorkspaceUser>(); List<SqlWorkspaceUser> sqlWorkspaceUsers = getSqlWorkspaceUserLists(workspaceId); for (SqlWorkspaceUser sqlWorkspaceUser : sqlWorkspaceUsers) { if (!sqlWorkspaceUser.getWorkspaceAccess().equals(WorkspaceAccess.NONE.toString())) { String userId = sqlWorkspaceUser.getUser().getUserId(); Workspace workspace = findById(workspaceId, user); boolean isCreator = ((SqlWorkspace) workspace).getWorkspaceCreator().getUserId().equals(userId); withAccess.add(new WorkspaceUser(userId, WorkspaceAccess.valueOf(sqlWorkspaceUser.getWorkspaceAccess()), isCreator)); } } return withAccess; } @Inject  SqlWorkspaceRepository(final SqlUserRepository userRepository, final HibernateSessionManager sessionManager,
                                  final Graph graph); @Override void delete(Workspace workspace, User user); @Override Workspace findById(String workspaceId, boolean includeHidden, User user); @Override Workspace add(String workspaceId, String title, User user); @Override Iterable<Workspace> findAllForUser(User user); @Override void setTitle(Workspace workspace, String title, User user); @Override List<WorkspaceUser> findUsersWithAccess(String workspaceId, User user); @Override List<WorkspaceEntity> findEntities(Workspace workspace, User user); @Override void softDeleteEntitiesFromWorkspace(Workspace workspace, List<String> entityIdsToDelete, User authUser); @Override void updateEntitiesOnWorkspace(Workspace workspace, Iterable<Update> updates, User user); @Override void deleteUserFromWorkspace(Workspace workspace, String userId, User user); @Override void updateUserOnWorkspace(Workspace workspace, String userId, WorkspaceAccess workspaceAccess, User user); @Override ClientApiWorkspaceDiff getDiff(Workspace workspace, User user, Locale locale, String timeZone); @Override boolean hasCommentPermissions(String workspaceId, User user); @Override boolean hasWritePermissions(String workspaceId, User user); @Override boolean hasReadPermissions(String workspaceId, User user); }
SqlWorkspaceRepository extends WorkspaceRepository { @Override public List<WorkspaceUser> findUsersWithAccess(String workspaceId, User user) { List<WorkspaceUser> withAccess = new ArrayList<WorkspaceUser>(); List<SqlWorkspaceUser> sqlWorkspaceUsers = getSqlWorkspaceUserLists(workspaceId); for (SqlWorkspaceUser sqlWorkspaceUser : sqlWorkspaceUsers) { if (!sqlWorkspaceUser.getWorkspaceAccess().equals(WorkspaceAccess.NONE.toString())) { String userId = sqlWorkspaceUser.getUser().getUserId(); Workspace workspace = findById(workspaceId, user); boolean isCreator = ((SqlWorkspace) workspace).getWorkspaceCreator().getUserId().equals(userId); withAccess.add(new WorkspaceUser(userId, WorkspaceAccess.valueOf(sqlWorkspaceUser.getWorkspaceAccess()), isCreator)); } } return withAccess; } @Inject  SqlWorkspaceRepository(final SqlUserRepository userRepository, final HibernateSessionManager sessionManager,
                                  final Graph graph); @Override void delete(Workspace workspace, User user); @Override Workspace findById(String workspaceId, boolean includeHidden, User user); @Override Workspace add(String workspaceId, String title, User user); @Override Iterable<Workspace> findAllForUser(User user); @Override void setTitle(Workspace workspace, String title, User user); @Override List<WorkspaceUser> findUsersWithAccess(String workspaceId, User user); @Override List<WorkspaceEntity> findEntities(Workspace workspace, User user); @Override void softDeleteEntitiesFromWorkspace(Workspace workspace, List<String> entityIdsToDelete, User authUser); @Override void updateEntitiesOnWorkspace(Workspace workspace, Iterable<Update> updates, User user); @Override void deleteUserFromWorkspace(Workspace workspace, String userId, User user); @Override void updateUserOnWorkspace(Workspace workspace, String userId, WorkspaceAccess workspaceAccess, User user); @Override ClientApiWorkspaceDiff getDiff(Workspace workspace, User user, Locale locale, String timeZone); @Override boolean hasCommentPermissions(String workspaceId, User user); @Override boolean hasWritePermissions(String workspaceId, User user); @Override boolean hasReadPermissions(String workspaceId, User user);  }