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