Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Franz Reischl
tomcat-miniREST
Commits
3a680332
Commit
3a680332
authored
Mar 10, 2019
by
Michael Schimpelsberger
Browse files
1) changed length of VARCHAR attributes in DB
2) added JSON format to GenericExceptionMapper
parent
88d90cb5
Changes
7
Hide whitespace changes
Inline
Side-by-side
SQL/SQLSkript.txt
View file @
3a680332
...
@@ -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(
20
0), lastname VARCHAR2(
20
0));
CREATE TABLE student (matrnr INTEGER PRIMARY KEY, firstname VARCHAR2(
15
0), lastname VARCHAR2(
15
0));
CREATE TABLE study (studyid INTEGER PRIMARY KEY, name VARCHAR(
4
0));
CREATE TABLE study (studyid INTEGER PRIMARY KEY, name VARCHAR(
15
0));
CREATE TABLE subject (
CREATE TABLE subject (
studyId INTEGER,
studyId INTEGER,
subjectid INTEGER,
subjectid INTEGER,
name VARCHAR2(
4
0),
name VARCHAR2(
15
0),
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);
...
...
src/main/java/university/at/jku/ce/dao/h2dao/DaoParam.java
View file @
3a680332
...
@@ -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
();
}
}
...
...
src/main/java/university/at/jku/ce/exception/BadRequestExceptionMapper.java
View file @
3a680332
...
@@ -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
();
}
}
...
...
src/main/java/university/at/jku/ce/exception/GenericExceptionMapper.java
View file @
3a680332
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
();
}
}
...
...
src/main/java/university/at/jku/ce/exception/MethodNotAllowedExceptionMapper.java
View file @
3a680332
...
@@ -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
();
}
}
...
...
src/main/java/university/at/jku/ce/exception/NotFoundExceptionMapper.java
View file @
3a680332
...
@@ -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
();
}
}
...
...
html-minirest
@
3aa4125b
Compare
22841e6e
...
3aa4125b
Subproject commit
22841e6e34e08042ae87f8ee03ffb21bcd874296
Subproject commit
3aa4125b377b8de8a9330f8139ded46155e234c5
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment