Search in sources :

Example 21 with RequestAction

use of org.ocpsoft.rewrite.annotation.RequestAction in project muikku by otavanopisto.

the class WorkspaceHelpPageBackingBean 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();
    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;
    }
    workspaceId = workspaceEntity.getId();
    workspaceBackingBean.setWorkspaceUrlName(urlName);
    workspaceName = workspaceBackingBean.getWorkspaceName();
    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 22 with RequestAction

use of org.ocpsoft.rewrite.annotation.RequestAction in project muikku by otavanopisto.

the class EvaluationIndexBackingBean method init.

@RequestAction
public String init() {
    UserEntity userEntity = sessionController.getLoggedUserEntity();
    if (userEntity == null) {
        return NavigationRules.ACCESS_DENIED;
    }
    WorkspaceEntity workspaceEntity = null;
    if (workspaceEntityId != null) {
        workspaceEntity = workspaceEntityController.findWorkspaceEntityById(workspaceEntityId);
        if (workspaceEntity == null) {
            return NavigationRules.NOT_FOUND;
        }
    }
    if (workspaceEntity == null) {
        if (!sessionController.hasEnvironmentPermission(EvaluationResourcePermissionCollection.EVALUATION_VIEW_INDEX)) {
            return NavigationRules.ACCESS_DENIED;
        }
    } else {
        if (!sessionController.hasWorkspacePermission(EvaluationResourcePermissionCollection.EVALUATION_VIEW_INDEX, workspaceEntity)) {
            return NavigationRules.ACCESS_DENIED;
        }
    }
    listAllWorkspaces = sessionController.hasEnvironmentPermission(EvaluationResourcePermissionCollection.EVALUATION_LIST_ALL_WORKSPACES);
    return null;
}
Also used : WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity) RequestAction(org.ocpsoft.rewrite.annotation.RequestAction)

Example 23 with RequestAction

use of org.ocpsoft.rewrite.annotation.RequestAction in project muikku by otavanopisto.

the class AnnouncementsViewBackingBean method init.

@RequestAction
public String init() {
    UserEntity loggedUserEntity = sessionController.getLoggedUserEntity();
    if (announcementId != null) {
        currentAnnouncement = announcementController.findById(announcementId);
        if (currentAnnouncement != null) {
            List<AnnouncementWorkspace> announcementWorkspaces = announcementController.listAnnouncementWorkspacesSortByUserFirst(currentAnnouncement, loggedUserEntity);
            currentAnnouncementWorkspaces = new ArrayList<WorkspaceBasicInfo>();
            for (AnnouncementWorkspace aw : announcementWorkspaces) {
                currentAnnouncementWorkspaces.add(workspaceRESTModelController.workspaceBasicInfo(aw.getWorkspaceEntityId()));
            }
        }
    }
    AnnouncementEnvironmentRestriction environment = sessionController.hasEnvironmentPermission(AnnouncerPermissions.LIST_ENVIRONMENT_GROUP_ANNOUNCEMENTS) ? AnnouncementEnvironmentRestriction.PUBLICANDGROUP : AnnouncementEnvironmentRestriction.PUBLIC;
    AnnouncementTimeFrame timeFrame = AnnouncementTimeFrame.CURRENT;
    activeAnnouncements = announcementController.listAnnouncements(true, true, environment, timeFrame, loggedUserEntity, false, false);
    return null;
}
Also used : AnnouncementWorkspace(fi.otavanopisto.muikku.plugins.announcer.workspace.model.AnnouncementWorkspace) AnnouncementTimeFrame(fi.otavanopisto.muikku.plugins.announcer.dao.AnnouncementTimeFrame) AnnouncementEnvironmentRestriction(fi.otavanopisto.muikku.plugins.announcer.dao.AnnouncementEnvironmentRestriction) WorkspaceBasicInfo(fi.otavanopisto.muikku.plugins.workspace.rest.model.WorkspaceBasicInfo) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity) RequestAction(org.ocpsoft.rewrite.annotation.RequestAction)

Example 24 with RequestAction

use of org.ocpsoft.rewrite.annotation.RequestAction in project muikku by otavanopisto.

the class WorkspaceAnnouncerBackingBean 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 (!workspaceEntity.getPublished()) {
        if (!sessionController.hasWorkspacePermission(MuikkuPermissions.ACCESS_UNPUBLISHED_WORKSPACE, workspaceEntity)) {
            return NavigationRules.NOT_FOUND;
        }
    }
    if (workspaceEntity.getAccess() != WorkspaceAccess.ANYONE) {
        if (!sessionController.hasWorkspacePermission(AnnouncerPermissions.WORKSPACE_ANNOUNCER_TOOL, workspaceEntity)) {
            if (!sessionController.isLoggedIn()) {
                return navigationController.requireLogin();
            } else {
                return NavigationRules.ACCESS_DENIED;
            }
        }
    }
    workspaceEntityId = workspaceEntity.getId();
    workspaceBackingBean.setWorkspaceUrlName(urlName);
    workspaceName = workspaceBackingBean.getWorkspaceName();
    workspaceNameExtension = workspaceBackingBean.getWorkspaceNameExtension();
    return null;
}
Also used : WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity) RequestAction(org.ocpsoft.rewrite.annotation.RequestAction)

Example 25 with RequestAction

use of org.ocpsoft.rewrite.annotation.RequestAction in project muikku by otavanopisto.

the class EnvironmentPermissionsManagementBackingBean method init.

@RequestAction
public String init() {
    if (!sessionController.hasEnvironmentPermission(MuikkuPermissions.MANAGE_PERMISSIONS)) {
        return NavigationRules.ACCESS_DENIED;
    }
    permissions = permissionController.listPermissionsByScope(PermissionScope.ENVIRONMENT);
    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> environmentRoleEntities = roleController.listEnvironmentRoleEntities();
    Collections.sort(environmentRoleEntities, new Comparator<EnvironmentRoleEntity>() {

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

Aggregations

RequestAction (org.ocpsoft.rewrite.annotation.RequestAction)27 WorkspaceEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)19 UserEntity (fi.otavanopisto.muikku.model.users.UserEntity)5 WorkspaceMaterial (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterial)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 Permission (fi.otavanopisto.muikku.model.security.Permission)3 HashMap (java.util.HashMap)3 EnvironmentRoleEntity (fi.otavanopisto.muikku.model.users.EnvironmentRoleEntity)2 RoleEntity (fi.otavanopisto.muikku.model.users.RoleEntity)2 SystemRoleEntity (fi.otavanopisto.muikku.model.users.SystemRoleEntity)2 WorkspaceEntityFile (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceEntityFile)2 User (fi.otavanopisto.muikku.schooldata.entity.User)2 Workspace (fi.otavanopisto.muikku.schooldata.entity.Workspace)2 OffsetDateTime (java.time.OffsetDateTime)2 Locale (java.util.Locale)2 AuthenticationProvider (fi.otavanopisto.muikku.auth.AuthenticationProvider)1 AuthenticationResult (fi.otavanopisto.muikku.auth.AuthenticationResult)1 CacheFlushEvent (fi.otavanopisto.muikku.cache.CacheFlushEvent)1 AuthSource (fi.otavanopisto.muikku.model.security.AuthSource)1