Search in sources :

Example 91 with WorkspaceEntity

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

the class WorkspaceUserEntityController method listActiveWorkspaceEntitiesByUserEntity.

public List<WorkspaceEntity> listActiveWorkspaceEntitiesByUserEntity(UserEntity userEntity) {
    SchoolDataIdentifier schoolDataIdentifier = toSchoolDataIdentifier(userEntity);
    List<WorkspaceEntity> result = new ArrayList<>();
    List<WorkspaceUserEntity> workspaceUserEntities = listActiveWorkspaceUserEntitiesByUserIdentifier(schoolDataIdentifier);
    for (WorkspaceUserEntity workspaceUserEntity : workspaceUserEntities) {
        result.add(workspaceUserEntity.getWorkspaceEntity());
    }
    return result;
}
Also used : SchoolDataIdentifier(fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier) UserSchoolDataIdentifier(fi.otavanopisto.muikku.model.users.UserSchoolDataIdentifier) WorkspaceUserEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity) WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity) ArrayList(java.util.ArrayList)

Example 92 with WorkspaceEntity

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

the class DefaultPermissionResolver method hasPermission.

@Override
public boolean hasPermission(String permission, ContextReference contextReference, User user) {
    Permission permissionEntity = permissionController.findByName(permission);
    if (permissionEntity == null) {
        logger.severe(String.format("Reference to missing permission %s", permission));
        return false;
    }
    UserEntity userEntity = getUserEntity(user);
    if (userEntity == null) {
        return hasEveryonePermission(permission, contextReference);
    }
    // Workspace access
    if (permissionEntity.getScope().equals(PermissionScope.WORKSPACE) && contextReference != null) {
        WorkspaceEntity workspaceEntity = resolveWorkspace(contextReference);
        if (workspaceEntity != null) {
            if (hasWorkspaceAccess(workspaceEntity, userEntity, permissionEntity)) {
                return true;
            }
        }
    }
    // Environment access
    return hasEnvironmentAccess(userEntity, permissionEntity);
}
Also used : WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity) Permission(fi.otavanopisto.muikku.model.security.Permission) WorkspaceUserEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity)

Example 93 with WorkspaceEntity

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

the class WorkspaceHelpPageManagementBackingBean 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.MANAGE_WORKSPACE_HELP, workspaceEntity)) {
        return NavigationRules.ACCESS_DENIED;
    }
    rootFolder = workspaceMaterialController.findWorkspaceRootFolderByWorkspaceEntity(workspaceEntity);
    workspaceEntityId = workspaceEntity.getId();
    workspaceBackingBean.setWorkspaceUrlName(urlName);
    workspaceName = workspaceBackingBean.getWorkspaceName();
    try {
        WorkspaceMaterial helpPage = workspaceMaterialController.ensureWorkspaceHelpPageExists(workspaceEntity);
        contentNodes = Arrays.asList(workspaceMaterialController.createContentNode(helpPage));
    } catch (WorkspaceMaterialException e) {
        logger.log(Level.SEVERE, "Error loading materials", e);
        return NavigationRules.INTERNAL_ERROR;
    }
    materialsBaseUrl = String.format("/workspace/%s/materials", workspaceUrlName);
    return null;
}
Also used : WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity) WorkspaceMaterial(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterial) RequestAction(org.ocpsoft.rewrite.annotation.RequestAction)

Example 94 with WorkspaceEntity

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

the class WorkspaceJournalBackingBean 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.ACCESS_WORKSPACE_JOURNAL, workspaceEntity)) {
        return NavigationRules.ACCESS_DENIED;
    }
    if (studentId != null && !sessionController.hasWorkspacePermission(MuikkuPermissions.LIST_ALL_JOURNAL_ENTRIES, workspaceEntity)) {
        return NavigationRules.ACCESS_DENIED;
    }
    workspaceBackingBean.setWorkspaceUrlName(urlName);
    workspaceEntityId = workspaceEntity.getId();
    canListAllEntries = sessionController.hasWorkspacePermission(MuikkuPermissions.LIST_ALL_JOURNAL_ENTRIES, workspaceEntity);
    return null;
}
Also used : WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity) RequestAction(org.ocpsoft.rewrite.annotation.RequestAction)

Example 95 with WorkspaceEntity

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

the class WorkspaceManagementBackingBean 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.MANAGE_WORKSPACE, workspaceEntity)) {
        return NavigationRules.ACCESS_DENIED;
    }
    workspaceEntityId = workspaceEntity.getId();
    workspaceBackingBean.setWorkspaceUrlName(urlName);
    WorkspaceEntityFile customFrontImage = workspaceEntityFileController.findWorkspaceEntityFile(workspaceEntity, "workspace-frontpage-image-cropped");
    hasCustomFrontPageImage = customFrontImage != null;
    customFrontPageImageUrl = hasCustomFrontPageImage ? String.format("/rest/workspace/workspaces/%d/workspacefile/workspace-frontpage-image-cropped", workspaceEntity.getId()) : null;
    return null;
}
Also used : WorkspaceEntityFile(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceEntityFile) WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity) RequestAction(org.ocpsoft.rewrite.annotation.RequestAction)

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