Search in sources :

Example 1 with ResourceRights

use of fi.otavanopisto.muikku.model.security.ResourceRights in project muikku by otavanopisto.

the class SystemForumRESTService method resetForumAreaRights.

@GET
@Path("/resetForumAreaRights/{FORUMAREAID}")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response resetForumAreaRights(@PathParam("FORUMAREAID") Long forumAreaId, @Context Request request) {
    logger.info(String.format("Resetting rights of forum area %d", forumAreaId));
    if (sessionController.hasPermission(MuikkuPermissions.ADMIN, null)) {
        ForumArea forumArea = forumController.findForumAreaById(forumAreaId);
        if (forumArea != null) {
            Long resourceRightsIds = forumArea.getRights();
            if (resourceRightsIds != null) {
                ResourceRights resourceRights = resourceRightsController.findResourceRightsById(resourceRightsIds);
                resourceRightsController.deleteByResourceRights(resourceRights);
            } else {
                return Response.status(Status.NOT_FOUND).entity(String.format("Forum area %d has no rights", forumAreaId)).build();
            }
        } else {
            return Response.status(Status.NOT_FOUND).entity(String.format("Forum area %d not found", forumAreaId)).build();
        }
    } else {
        return Response.status(Status.FORBIDDEN).entity("Not admin").build();
    }
    return Response.status(Status.OK).entity(String.format("Forum area %d rights reset", forumAreaId)).build();
}
Also used : ResourceRights(fi.otavanopisto.muikku.model.security.ResourceRights) ForumArea(fi.otavanopisto.muikku.plugins.forum.model.ForumArea) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) GET(javax.ws.rs.GET)

Example 2 with ResourceRights

use of fi.otavanopisto.muikku.model.security.ResourceRights in project muikku by otavanopisto.

the class ForumController method createWorkspaceForumArea.

public WorkspaceForumArea createWorkspaceForumArea(WorkspaceEntity workspace, String name, String description, Long groupId) {
    UserEntity owner = sessionController.getLoggedUserEntity();
    ResourceRights rights = resourceRightsController.create();
    ForumAreaGroup group = groupId != null ? findForumAreaGroup(groupId) : null;
    WorkspaceForumArea forumArea = workspaceForumAreaDAO.create(workspace, name, description, group, false, owner, rights);
    return forumArea;
}
Also used : WorkspaceForumArea(fi.otavanopisto.muikku.plugins.forum.model.WorkspaceForumArea) ResourceRights(fi.otavanopisto.muikku.model.security.ResourceRights) ForumAreaGroup(fi.otavanopisto.muikku.plugins.forum.model.ForumAreaGroup) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity)

Example 3 with ResourceRights

use of fi.otavanopisto.muikku.model.security.ResourceRights in project muikku by otavanopisto.

the class ForumController method createEnvironmentForumArea.

public EnvironmentForumArea createEnvironmentForumArea(String name, String description, Long groupId) {
    UserEntity owner = sessionController.getLoggedUserEntity();
    ResourceRights rights = resourceRightsController.create();
    ForumAreaGroup group = groupId != null ? findForumAreaGroup(groupId) : null;
    EnvironmentForumArea forumArea = environmentForumAreaDAO.create(name, description, group, false, owner, rights);
    return forumArea;
}
Also used : ResourceRights(fi.otavanopisto.muikku.model.security.ResourceRights) ForumAreaGroup(fi.otavanopisto.muikku.plugins.forum.model.ForumAreaGroup) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity) EnvironmentForumArea(fi.otavanopisto.muikku.plugins.forum.model.EnvironmentForumArea)

Example 4 with ResourceRights

use of fi.otavanopisto.muikku.model.security.ResourceRights in project muikku by otavanopisto.

the class ResourceRightsDAO method create.

public ResourceRights create() {
    ResourceRights rights = new ResourceRights();
    getEntityManager().persist(rights);
    return rights;
}
Also used : ResourceRights(fi.otavanopisto.muikku.model.security.ResourceRights)

Aggregations

ResourceRights (fi.otavanopisto.muikku.model.security.ResourceRights)4 UserEntity (fi.otavanopisto.muikku.model.users.UserEntity)2 ForumAreaGroup (fi.otavanopisto.muikku.plugins.forum.model.ForumAreaGroup)2 EnvironmentForumArea (fi.otavanopisto.muikku.plugins.forum.model.EnvironmentForumArea)1 ForumArea (fi.otavanopisto.muikku.plugins.forum.model.ForumArea)1 WorkspaceForumArea (fi.otavanopisto.muikku.plugins.forum.model.WorkspaceForumArea)1 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1