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;
DROP TABLE inscription CASCADE CONSTRAINTS;
-- 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 (
studyId INTEGER,
subjectid INTEGER,
name VARCHAR2(40),
name VARCHAR2(150),
ects INTEGER,
PRIMARY KEY (studyid, subjectid),
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
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 Data inscription
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,3,sysdate);
......
......@@ -25,8 +25,9 @@ public class DaoParam {
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 Paths.get(p2.toAbsolutePath().toString(),"Database").toAbsolutePath().toString();
}
......
......@@ -16,7 +16,7 @@ public class BadRequestExceptionMapper implements ExceptionMapper<BadRequestExce
public Response toResponse(BadRequestException exception) {
return Response.status(Status.BAD_REQUEST)
.entity(new Error(exception.getMessage(),400,ExceptionParam.DOKU))
.type(MediaType.APPLICATION_JSON)
.type(MediaType.APPLICATION_JSON)
.build();
}
......
package university.at.jku.ce.exception;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.ext.ExceptionMapper;
......@@ -13,7 +14,8 @@ public class GenericExceptionMapper implements ExceptionMapper<RuntimeException>
@Override
public Response toResponse(RuntimeException exception) {
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();
}
......
......@@ -16,7 +16,7 @@ public class MethodNotAllowedExceptionMapper implements ExceptionMapper<NotAllow
public Response toResponse(NotAllowedException exception) {
return Response.status(Status.METHOD_NOT_ALLOWED)
.entity(new Error(exception.getMessage(),405,ExceptionParam.DOKU))
.type(MediaType.APPLICATION_JSON)
.type(MediaType.APPLICATION_JSON)
.build();
}
......
......@@ -7,6 +7,7 @@ import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
import university.at.jku.ce.model.Error;
import javax.ws.rs.NotFoundException;
import javax.ws.rs.Produces;
@Provider
public class NotFoundExceptionMapper implements ExceptionMapper<NotFoundException> {
......@@ -14,8 +15,8 @@ public class NotFoundExceptionMapper implements ExceptionMapper<NotFoundExceptio
@Override
public Response toResponse(NotFoundException exception) {
return Response.status(Status.NOT_FOUND)
.entity(new Error(exception.getMessage(),404,ExceptionParam.DOKU))
.type(MediaType.APPLICATION_JSON)
.entity(new Error(exception.getMessage(),404,ExceptionParam.DOKU))
.type(MediaType.APPLICATION_JSON)
.build();
}
......
Subproject commit 22841e6e34e08042ae87f8ee03ffb21bcd874296
Subproject commit 3aa4125b377b8de8a9330f8139ded46155e234c5
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