Search in sources :

Example 6 with WorkspaceMaterialProducer

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

the class WorkspaceRESTService method createWorkspaceMaterialProducer.

@POST
@Path("/workspaces/{WORKSPACEENTITYID}/materialProducers")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response createWorkspaceMaterialProducer(@PathParam("WORKSPACEENTITYID") Long workspaceEntityId, WorkspaceMaterialProducer payload) {
    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.createWorkspaceMaterialProducer(workspaceEntity, payload.getName());
    return Response.ok(createRestModel(materialProducer)).build();
}
Also used : WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity) WorkspaceMaterialProducer(fi.otavanopisto.muikku.model.workspace.WorkspaceMaterialProducer) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) POST(javax.ws.rs.POST)

Aggregations

WorkspaceMaterialProducer (fi.otavanopisto.muikku.model.workspace.WorkspaceMaterialProducer)6 WorkspaceEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)4 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)4 Path (javax.ws.rs.Path)4 DELETE (javax.ws.rs.DELETE)2 POST (javax.ws.rs.POST)2 UserSchoolDataIdentifier (fi.otavanopisto.muikku.model.users.UserSchoolDataIdentifier)1 WorkspaceUserEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity)1 WorkspaceMaterialContainsAnswersExeption (fi.otavanopisto.muikku.plugins.workspace.WorkspaceMaterialContainsAnswersExeption)1 SchoolDataIdentifier (fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier)1 Workspace (fi.otavanopisto.muikku.schooldata.entity.Workspace)1 EntityManager (javax.persistence.EntityManager)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1