public ClientApiWorkspaces handle(User user) {
Iterable<Workspace> workspaces = workspaceRepository.findAll(user);
String activeWorkspaceId = getUserRepository().getCurrentWorkspaceId(user.getUserId());
activeWorkspaceId = activeWorkspaceId != null ? activeWorkspaceId : "";
ClientApiWorkspaces results = new ClientApiWorkspaces();
for (Workspace workspace : workspaces) {
ClientApiWorkspace workspaceClientApi = workspaceRepository.toClientApi(workspace, user, false);
if (workspaceClientApi != null) {
if (activeWorkspaceId.equals(workspace.getWorkspaceId())) { //if its the active one
workspaceClientApi.setActive(true);
}
results.addWorkspace(workspaceClientApi);
}
}
return results;
}