Search in sources :

Example 1 with UpdateDefaultWorkspace

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));
    }
}
Also used : Project(io.lumeer.api.model.Project) Organization(io.lumeer.api.model.Organization) User(io.lumeer.api.model.User) UpdateCurrentUser(io.lumeer.engine.api.event.UpdateCurrentUser) CreateOrUpdateUser(io.lumeer.engine.api.event.CreateOrUpdateUser) RemoveUser(io.lumeer.engine.api.event.RemoveUser) UpdateDefaultWorkspace(io.lumeer.engine.api.event.UpdateDefaultWorkspace) DefaultWorkspace(io.lumeer.api.model.DefaultWorkspace) UpdateDefaultWorkspace(io.lumeer.engine.api.event.UpdateDefaultWorkspace)

Aggregations

DefaultWorkspace (io.lumeer.api.model.DefaultWorkspace)1 Organization (io.lumeer.api.model.Organization)1 Project (io.lumeer.api.model.Project)1 User (io.lumeer.api.model.User)1 CreateOrUpdateUser (io.lumeer.engine.api.event.CreateOrUpdateUser)1 RemoveUser (io.lumeer.engine.api.event.RemoveUser)1 UpdateCurrentUser (io.lumeer.engine.api.event.UpdateCurrentUser)1 UpdateDefaultWorkspace (io.lumeer.engine.api.event.UpdateDefaultWorkspace)1