use of io.lumeer.engine.api.event.UpdateDefaultWorkspace in project engine by Lumeer.
the class UserFacade method setDefaultWorkspace.
public void setDefaultWorkspace(DefaultWorkspace workspace) {
Organization organization;
if (workspace.getOrganizationId() != null) {
organization = checkOrganizationPermissions(workspace.getOrganizationId(), RoleType.Read);
} else {
organization = checkOrganizationPermissionsByCode(workspace.getOrganizationCode(), RoleType.Read);
}
projectDao.setOrganization(organization);
Project project;
if (workspace.getProjectId() != null) {
project = checkProjectPermissions(organization.getId(), workspace.getProjectId(), RoleType.Read);
} else {
project = checkProjectPermissionsByCode(organization.getId(), workspace.getProjectCode(), RoleType.Read);
}
DefaultWorkspace defaultWorkspace = new DefaultWorkspace(organization.getId(), project.getId());
User currentUser = authenticatedUser.getCurrentUser();
currentUser.setDefaultWorkspace(defaultWorkspace);
User updatedUser = userDao.updateUser(currentUser.getId(), currentUser);
userCache.updateUser(updatedUser.getEmail(), updatedUser);
if (updateDefaultWorkspaceEvent != null) {
updateDefaultWorkspaceEvent.fire(new UpdateDefaultWorkspace(organization, project));
}
}
Aggregations