Search in sources :

Example 51 with WorkspaceEntity

use of fi.otavanopisto.muikku.model.workspace.WorkspaceEntity in project muikku by otavanopisto.

the class WorkspaceRESTService method deleteWorkspaceMaterialProducer.

@DELETE
@Path("/workspaces/{WORKSPACEENTITYID}/materialProducers/{ID}")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response deleteWorkspaceMaterialProducer(@PathParam("WORKSPACEENTITYID") Long workspaceEntityId, @PathParam("ID") Long workspaceMaterialProducerId) {
    WorkspaceEntity workspaceEntity = workspaceController.findWorkspaceEntityById(workspaceEntityId);
    if (workspaceEntity == null) {
        return Response.status(Status.NOT_FOUND).build();
    }
    if (!sessionController.hasWorkspacePermission(MuikkuPermissions.MANAGE_WORKSPACE_MATERIAL_PRODUCERS, workspaceEntity)) {
        return Response.status(Status.FORBIDDEN).build();
    }
    WorkspaceMaterialProducer materialProducer = workspaceController.findWorkspaceMaterialProducer(workspaceMaterialProducerId);
    workspaceController.deleteWorkspaceMaterialProducer(materialProducer);
    return Response.noContent().build();
}
Also used : WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity) WorkspaceMaterialProducer(fi.otavanopisto.muikku.model.workspace.WorkspaceMaterialProducer) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) RESTPermit(fi.otavanopisto.security.rest.RESTPermit)

Example 52 with WorkspaceEntity

use of fi.otavanopisto.muikku.model.workspace.WorkspaceEntity in project muikku by otavanopisto.

the class WorkspacePermissionsManagementBackingBean method hasUserGroupPermission.

public boolean hasUserGroupPermission(UserGroupBean userGroup, Permission permission) {
    UserGroupEntity userGroupEntity = userGroupEntityController.findUserGroupEntityById(userGroup.getId());
    WorkspaceEntity workspaceEntity = workspaceController.findWorkspaceEntityById(getWorkspaceEntityId());
    return permissionController.hasWorkspaceGroupPermission(workspaceEntity, userGroupEntity, permission);
}
Also used : WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity) UserGroupEntity(fi.otavanopisto.muikku.model.users.UserGroupEntity)

Example 53 with WorkspaceEntity

use of fi.otavanopisto.muikku.model.workspace.WorkspaceEntity in project muikku by otavanopisto.

the class WorkspacePermissionsRoleManagementBackingBean method init.

@RequestAction
public String init() {
    String urlName = getWorkspaceUrlName();
    if (StringUtils.isBlank(urlName)) {
        return NavigationRules.NOT_FOUND;
    }
    WorkspaceEntity workspaceEntity = workspaceController.findWorkspaceEntityByUrlName(urlName);
    if (workspaceEntity == null) {
        return NavigationRules.NOT_FOUND;
    }
    if (!sessionController.hasWorkspacePermission(MuikkuPermissions.WORKSPACE_MANAGEWORKSPACESETTINGS, workspaceEntity)) {
        return NavigationRules.ACCESS_DENIED;
    }
    workspaceEntityId = workspaceEntity.getId();
    workspaceBackingBean.setWorkspaceUrlName(urlName);
    workspaceName = workspaceBackingBean.getWorkspaceName();
    /**
     * View data
     */
    permissions = permissionController.listPermissionsByScope(PermissionScope.WORKSPACE);
    Collections.sort(permissions, new Comparator<Permission>() {

        @Override
        public int compare(Permission o1, Permission o2) {
            return o1.getName().compareTo(o2.getName());
        }
    });
    roleEntities = new ArrayList<RoleEntity>();
    List<SystemRoleEntity> systemRoleEntities = roleController.listSystemRoleEntities();
    List<EnvironmentRoleEntity> environmentRoleEnties = roleController.listEnvironmentRoleEntities();
    List<WorkspaceRoleEntity> workspaceRoleEntities = roleController.listWorkspaceRoleEntities();
    Collections.sort(environmentRoleEnties, new Comparator<EnvironmentRoleEntity>() {

        @Override
        public int compare(EnvironmentRoleEntity o1, EnvironmentRoleEntity o2) {
            return o1.getArchetype().compareTo(o2.getArchetype());
        }
    });
    Collections.sort(workspaceRoleEntities, new Comparator<WorkspaceRoleEntity>() {

        @Override
        public int compare(WorkspaceRoleEntity o1, WorkspaceRoleEntity o2) {
            return o1.getArchetype().compareTo(o2.getArchetype());
        }
    });
    for (SystemRoleEntity systemRoleEntity : systemRoleEntities) {
        roleEntities.add(systemRoleEntity);
    }
    for (EnvironmentRoleEntity environmentRoleEntity : environmentRoleEnties) {
        roleEntities.add(environmentRoleEntity);
    }
    for (WorkspaceRoleEntity workspaceRoleEntity : workspaceRoleEntities) {
        roleEntities.add(workspaceRoleEntity);
    }
    return null;
}
Also used : EnvironmentRoleEntity(fi.otavanopisto.muikku.model.users.EnvironmentRoleEntity) SystemRoleEntity(fi.otavanopisto.muikku.model.users.SystemRoleEntity) WorkspaceRoleEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceRoleEntity) SystemRoleEntity(fi.otavanopisto.muikku.model.users.SystemRoleEntity) RoleEntity(fi.otavanopisto.muikku.model.users.RoleEntity) EnvironmentRoleEntity(fi.otavanopisto.muikku.model.users.EnvironmentRoleEntity) WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity) WorkspaceRoleEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceRoleEntity) Permission(fi.otavanopisto.muikku.model.security.Permission) RequestAction(org.ocpsoft.rewrite.annotation.RequestAction)

Example 54 with WorkspaceEntity

use of fi.otavanopisto.muikku.model.workspace.WorkspaceEntity in project muikku by otavanopisto.

the class WorkspaceUsersBackingBean method init.

@RequestAction
public String init() {
    String urlName = getWorkspaceUrlName();
    if (StringUtils.isBlank(urlName)) {
        return NavigationRules.NOT_FOUND;
    }
    WorkspaceEntity workspaceEntity = workspaceController.findWorkspaceEntityByUrlName(urlName);
    if (workspaceEntity == null) {
        return NavigationRules.NOT_FOUND;
    }
    workspaceEntityId = workspaceEntity.getId();
    workspaceBackingBean.setWorkspaceUrlName(urlName);
    if (!sessionController.hasWorkspacePermission(MuikkuPermissions.LIST_WORKSPACE_MEMBERS, workspaceEntity)) {
        return NavigationRules.NOT_FOUND;
    }
    return null;
}
Also used : WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity) RequestAction(org.ocpsoft.rewrite.annotation.RequestAction)

Example 55 with WorkspaceEntity

use of fi.otavanopisto.muikku.model.workspace.WorkspaceEntity in project muikku by otavanopisto.

the class WorkspaceController method archiveWorkspace.

public void archiveWorkspace(Workspace workspace) {
    WorkspaceEntity workspaceEntity = workspaceSchoolDataController.findWorkspaceEntity(workspace);
    if (workspaceEntity != null) {
        archiveWorkspaceEntity(workspaceEntity);
    }
    workspaceSchoolDataController.removeWorkspace(workspace);
}
Also used : WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)

Aggregations

WorkspaceEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)190 Path (javax.ws.rs.Path)102 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)82 WorkspaceUserEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity)65 UserEntity (fi.otavanopisto.muikku.model.users.UserEntity)51 SchoolDataIdentifier (fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier)49 GET (javax.ws.rs.GET)46 ArrayList (java.util.ArrayList)38 UserSchoolDataIdentifier (fi.otavanopisto.muikku.model.users.UserSchoolDataIdentifier)29 POST (javax.ws.rs.POST)26 WorkspaceMaterial (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterial)25 RESTPermitUnimplemented (fi.otavanopisto.muikku.rest.RESTPermitUnimplemented)21 Workspace (fi.otavanopisto.muikku.schooldata.entity.Workspace)21 WorkspaceForumArea (fi.otavanopisto.muikku.plugins.forum.model.WorkspaceForumArea)20 RequestAction (org.ocpsoft.rewrite.annotation.RequestAction)19 ForumArea (fi.otavanopisto.muikku.plugins.forum.model.ForumArea)17 Date (java.util.Date)17 DELETE (javax.ws.rs.DELETE)17 PUT (javax.ws.rs.PUT)16 WorkspaceRootFolder (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceRootFolder)15