Commit 3a680332 authored by Michael Schimpelsberger's avatar Michael Schimpelsberger
Browse files

1) changed length of VARCHAR attributes in DB

2) added JSON format to GenericExceptionMapper
parent 88d90cb5
...@@ -4,14 +4,14 @@ DROP TABLE study CASCADE CONSTRAINTS; ...@@ -4,14 +4,14 @@ DROP TABLE study CASCADE CONSTRAINTS;
DROP TABLE inscription CASCADE CONSTRAINTS; DROP TABLE inscription CASCADE CONSTRAINTS;
-- Create Tables -- Create Tables
CREATE TABLE student (matrnr INTEGER PRIMARY KEY, firstname VARCHAR2(200), lastname VARCHAR2(200)); CREATE TABLE student (matrnr INTEGER PRIMARY KEY, firstname VARCHAR2(150), lastname VARCHAR2(150));
CREATE TABLE study (studyid INTEGER PRIMARY KEY, name VARCHAR(40)); CREATE TABLE study (studyid INTEGER PRIMARY KEY, name VARCHAR(150));
CREATE TABLE subject ( CREATE TABLE subject (
studyId INTEGER, studyId INTEGER,
subjectid INTEGER, subjectid INTEGER,
name VARCHAR2(40), name VARCHAR2(150),
ects INTEGER, ects INTEGER,
PRIMARY KEY (studyid, subjectid), PRIMARY KEY (studyid, subjectid),
FOREIGN KEY (studyId) REFERENCES study(studyId) ON DELETE CASCADE FOREIGN KEY (studyId) REFERENCES study(studyId) ON DELETE CASCADE
...@@ -62,6 +62,7 @@ INSERT INTO subject(studyid, subjectid, name, ects) values(5,2,'Allgemeine Physi ...@@ -62,6 +62,7 @@ INSERT INTO subject(studyid, subjectid, name, ects) values(5,2,'Allgemeine Physi
INSERT INTO subject(studyid, subjectid, name, ects) values(6,1,'Trainingslehre',6); INSERT INTO subject(studyid, subjectid, name, ects) values(6,1,'Trainingslehre',6);
INSERT INTO subject(studyid, subjectid, name, ects) values(6,2,'Bewegungslehre',3); INSERT INTO subject(studyid, subjectid, name, ects) values(6,2,'Bewegungslehre',3);
-- Insert Data inscription
INSERT INTO inscription(matrnr, studyid, ins_date) values (1,1,sysdate); INSERT INTO inscription(matrnr, studyid, ins_date) values (1,1,sysdate);
INSERT INTO inscription(matrnr, studyid, ins_date) values (1,2,sysdate); INSERT INTO inscription(matrnr, studyid, ins_date) values (1,2,sysdate);
INSERT INTO inscription(matrnr, studyid, ins_date) values (1,3,sysdate); INSERT INTO inscription(matrnr, studyid, ins_date) values (1,3,sysdate);
......
...@@ -25,8 +25,9 @@ public class DaoParam { ...@@ -25,8 +25,9 @@ public class DaoParam {
e1.printStackTrace(); e1.printStackTrace();
} }
} }
//enable for printing Path of DB
System.out.println(Paths.get(p2.toAbsolutePath().toString(),"Database").toAbsolutePath().toString());
// Return path as absolute path // Return path as absolute path
return Paths.get(p2.toAbsolutePath().toString(),"Database").toAbsolutePath().toString(); return Paths.get(p2.toAbsolutePath().toString(),"Database").toAbsolutePath().toString();
} }
......
...@@ -16,7 +16,7 @@ public class BadRequestExceptionMapper implements ExceptionMapper<BadRequestExce ...@@ -16,7 +16,7 @@ public class BadRequestExceptionMapper implements ExceptionMapper<BadRequestExce
public Response toResponse(BadRequestException exception) { public Response toResponse(BadRequestException exception) {
return Response.status(Status.BAD_REQUEST) return Response.status(Status.BAD_REQUEST)
.entity(new Error(exception.getMessage(),400,ExceptionParam.DOKU)) .entity(new Error(exception.getMessage(),400,ExceptionParam.DOKU))
.type(MediaType.APPLICATION_JSON) .type(MediaType.APPLICATION_JSON)
.build(); .build();
} }
......
package university.at.jku.ce.exception; package university.at.jku.ce.exception;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.Response.Status;
import javax.ws.rs.ext.ExceptionMapper; import javax.ws.rs.ext.ExceptionMapper;
...@@ -13,7 +14,8 @@ public class GenericExceptionMapper implements ExceptionMapper<RuntimeException> ...@@ -13,7 +14,8 @@ public class GenericExceptionMapper implements ExceptionMapper<RuntimeException>
@Override @Override
public Response toResponse(RuntimeException exception) { public Response toResponse(RuntimeException exception) {
return Response.status(Status.INTERNAL_SERVER_ERROR) return Response.status(Status.INTERNAL_SERVER_ERROR)
.entity(new Error(ExceptionParam.SERVER_ERROR,500,ExceptionParam.DOKU)) .entity(new Error(ExceptionParam.SERVER_ERROR,500,ExceptionParam.DOKU))
.type(MediaType.APPLICATION_JSON)
.build(); .build();
} }
......
...@@ -16,7 +16,7 @@ public class MethodNotAllowedExceptionMapper implements ExceptionMapper<NotAllow ...@@ -16,7 +16,7 @@ public class MethodNotAllowedExceptionMapper implements ExceptionMapper<NotAllow
public Response toResponse(NotAllowedException exception) { public Response toResponse(NotAllowedException exception) {
return Response.status(Status.METHOD_NOT_ALLOWED) return Response.status(Status.METHOD_NOT_ALLOWED)
.entity(new Error(exception.getMessage(),405,ExceptionParam.DOKU)) .entity(new Error(exception.getMessage(),405,ExceptionParam.DOKU))
.type(MediaType.APPLICATION_JSON) .type(MediaType.APPLICATION_JSON)
.build(); .build();
} }
......
...@@ -7,6 +7,7 @@ import javax.ws.rs.ext.ExceptionMapper; ...@@ -7,6 +7,7 @@ import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider; import javax.ws.rs.ext.Provider;
import university.at.jku.ce.model.Error; import university.at.jku.ce.model.Error;
import javax.ws.rs.NotFoundException; import javax.ws.rs.NotFoundException;
import javax.ws.rs.Produces;
@Provider @Provider
public class NotFoundExceptionMapper implements ExceptionMapper<NotFoundException> { public class NotFoundExceptionMapper implements ExceptionMapper<NotFoundException> {
...@@ -14,8 +15,8 @@ public class NotFoundExceptionMapper implements ExceptionMapper<NotFoundExceptio ...@@ -14,8 +15,8 @@ public class NotFoundExceptionMapper implements ExceptionMapper<NotFoundExceptio
@Override @Override
public Response toResponse(NotFoundException exception) { public Response toResponse(NotFoundException exception) {
return Response.status(Status.NOT_FOUND) return Response.status(Status.NOT_FOUND)
.entity(new Error(exception.getMessage(),404,ExceptionParam.DOKU)) .entity(new Error(exception.getMessage(),404,ExceptionParam.DOKU))
.type(MediaType.APPLICATION_JSON) .type(MediaType.APPLICATION_JSON)
.build(); .build();
} }
......
Subproject commit 22841e6e34e08042ae87f8ee03ffb21bcd874296 Subproject commit 3aa4125b377b8de8a9330f8139ded46155e234c5
Supports Markdown
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