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();
}
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;
}
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;
}
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;
}
Aggregations