Commit 9491e6df authored by Michael Schimpelsberger's avatar Michael Schimpelsberger
Browse files

exception param neu

parent 42d82b31
......@@ -10,8 +10,9 @@ public class ExceptionParam {
return mediaType;
}
public static void setMediaType(MediaType mediaType) {
if (mediaType==null) {ExceptionParam.mediaType=MediaType.APPLICATION_XML_TYPE;}
else ExceptionParam.mediaType = mediaType;
if (mediaType!=null) {
ExceptionParam.mediaType = mediaType;
}
}
......
......@@ -9,6 +9,7 @@ import java.util.List;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.NotFoundException;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
......@@ -61,7 +62,11 @@ public class StudentResource {
@GET
@Path("/{studentMatrNr}")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public Response getStudent(@PathParam("studentMatrNr")int matrNr, @Context HttpHeaders headers) {
public Response getStudent(@PathParam("studentMatrNr")String matrNrStr, @Context HttpHeaders headers) {
int matrNr=0;
try {
matrNr=Integer.parseInt(matrNrStr);
}catch (Exception e) {throw new NotFoundException();}
ExceptionParam.setMediaType(headers.getMediaType());
Student student= dao.getStudent(matrNr);
return Response.ok().entity(student).build() ;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment