Search in sources :

Example 6 with MaterialMetaKey

use of fi.otavanopisto.muikku.plugins.material.model.MaterialMetaKey in project muikku by otavanopisto.

the class MaterialMetaRESTService method findMaterialMeta.

@GET
@Path("/materials/{id}/meta/{KEY}")
@Produces(MediaType.APPLICATION_JSON)
@RESTPermitUnimplemented
public Response findMaterialMeta(@PathParam("id") Long id, @PathParam("KEY") String key) {
    Material material = materialController.findMaterialById(id);
    if (material == null) {
        return Response.status(Status.NOT_FOUND).entity("Material not found").build();
    }
    MaterialMetaKey materialMetaKey = materialController.findMaterialMetaKey(key);
    if (materialMetaKey == null) {
        return Response.status(Status.BAD_REQUEST).entity("Invalid key").build();
    }
    MaterialMeta materialMeta = materialController.findMaterialMeta(material, materialMetaKey);
    if (materialMeta == null) {
        return Response.status(Status.NOT_FOUND).entity("Material meta not found").build();
    }
    return Response.ok(createRestModel(materialMeta)).build();
}
Also used : MaterialMeta(fi.otavanopisto.muikku.plugins.material.model.MaterialMeta) MaterialMetaKey(fi.otavanopisto.muikku.plugins.material.model.MaterialMetaKey) Material(fi.otavanopisto.muikku.plugins.material.model.Material) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) RESTPermitUnimplemented(fi.otavanopisto.muikku.rest.RESTPermitUnimplemented) GET(javax.ws.rs.GET)

Aggregations

MaterialMetaKey (fi.otavanopisto.muikku.plugins.material.model.MaterialMetaKey)6 RESTPermitUnimplemented (fi.otavanopisto.muikku.rest.RESTPermitUnimplemented)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 Material (fi.otavanopisto.muikku.plugins.material.model.Material)3 MaterialMeta (fi.otavanopisto.muikku.plugins.material.model.MaterialMeta)2 GET (javax.ws.rs.GET)2 ArrayList (java.util.ArrayList)1 EntityManager (javax.persistence.EntityManager)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 POST (javax.ws.rs.POST)1 PUT (javax.ws.rs.PUT)1