diff options
author | serena.spinoso <serena.spinoso@polito.it> | 2017-02-25 12:00:55 +0100 |
---|---|---|
committer | serena.spinoso <serena.spinoso@polito.it> | 2017-02-27 13:39:18 +0100 |
commit | 53d83244c1bf36af86e90ce5fe758a369f73563e (patch) | |
tree | f5780b3033763d6b3cd62c40f5d4a63dfac35f7a /verigraph/src/main/java/it/polito/escape/verify/exception | |
parent | f0108f26fb1f62fefbbc4d5484b87241d563737b (diff) |
Add verigraph code base
JIRA: PARSER-111
Change-Id: Ie76e14fabbb6c388ebc89d9a15dd3021b25fa892
Signed-off-by: serena.spinoso <serena.spinoso@polito.it>
Diffstat (limited to 'verigraph/src/main/java/it/polito/escape/verify/exception')
9 files changed, 241 insertions, 0 deletions
diff --git a/verigraph/src/main/java/it/polito/escape/verify/exception/BadRequestException.java b/verigraph/src/main/java/it/polito/escape/verify/exception/BadRequestException.java new file mode 100644 index 0000000..abbdbf0 --- /dev/null +++ b/verigraph/src/main/java/it/polito/escape/verify/exception/BadRequestException.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2017 Politecnico di Torino and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Apache License, Version 2.0 + * which accompanies this distribution, and is available at + * http://www.apache.org/licenses/LICENSE-2.0 + *******************************************************************************/ + +package it.polito.escape.verify.exception; + +public class BadRequestException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = -548472179073745084L; + + public BadRequestException(String message) { + super(message); + } + +} diff --git a/verigraph/src/main/java/it/polito/escape/verify/exception/BadRequestExceptionMapper.java b/verigraph/src/main/java/it/polito/escape/verify/exception/BadRequestExceptionMapper.java new file mode 100644 index 0000000..8f1ba9c --- /dev/null +++ b/verigraph/src/main/java/it/polito/escape/verify/exception/BadRequestExceptionMapper.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2017 Politecnico di Torino and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Apache License, Version 2.0 + * which accompanies this distribution, and is available at + * http://www.apache.org/licenses/LICENSE-2.0 + *******************************************************************************/ + +package it.polito.escape.verify.exception; + +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; + +import it.polito.escape.verify.model.ErrorMessage; + +@Provider +public class BadRequestExceptionMapper implements ExceptionMapper<BadRequestException> { + + @Override + public Response toResponse(BadRequestException exception) { + ErrorMessage errorMessage = new ErrorMessage( exception.getMessage(), + 400, + "http://localhost:8080/verify/api-docs/"); + return Response.status(Status.BAD_REQUEST).entity(errorMessage).build(); + } + +} diff --git a/verigraph/src/main/java/it/polito/escape/verify/exception/DataNotFoundException.java b/verigraph/src/main/java/it/polito/escape/verify/exception/DataNotFoundException.java new file mode 100644 index 0000000..5cd1806 --- /dev/null +++ b/verigraph/src/main/java/it/polito/escape/verify/exception/DataNotFoundException.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2017 Politecnico di Torino and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Apache License, Version 2.0 + * which accompanies this distribution, and is available at + * http://www.apache.org/licenses/LICENSE-2.0 + *******************************************************************************/ + +package it.polito.escape.verify.exception; + +public class DataNotFoundException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = -6012364193903183208L; + + public DataNotFoundException(String message) { + super(message); + } + +} diff --git a/verigraph/src/main/java/it/polito/escape/verify/exception/DataNotFoundExceptionMapper.java b/verigraph/src/main/java/it/polito/escape/verify/exception/DataNotFoundExceptionMapper.java new file mode 100644 index 0000000..62e3556 --- /dev/null +++ b/verigraph/src/main/java/it/polito/escape/verify/exception/DataNotFoundExceptionMapper.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2017 Politecnico di Torino and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Apache License, Version 2.0 + * which accompanies this distribution, and is available at + * http://www.apache.org/licenses/LICENSE-2.0 + *******************************************************************************/ + +package it.polito.escape.verify.exception; + +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; + +import it.polito.escape.verify.model.ErrorMessage; + +@Provider +public class DataNotFoundExceptionMapper implements ExceptionMapper<DataNotFoundException> { + + @Override + public Response toResponse(DataNotFoundException exception) { + ErrorMessage errorMessage = new ErrorMessage( exception.getMessage(), + 404, + "http://localhost:8080/verify/api-docs/"); + return Response.status(Status.NOT_FOUND).entity(errorMessage).build(); + } + +} diff --git a/verigraph/src/main/java/it/polito/escape/verify/exception/ForbiddenException.java b/verigraph/src/main/java/it/polito/escape/verify/exception/ForbiddenException.java new file mode 100644 index 0000000..dc79e97 --- /dev/null +++ b/verigraph/src/main/java/it/polito/escape/verify/exception/ForbiddenException.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2017 Politecnico di Torino and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Apache License, Version 2.0 + * which accompanies this distribution, and is available at + * http://www.apache.org/licenses/LICENSE-2.0 + *******************************************************************************/ + +package it.polito.escape.verify.exception; + +public class ForbiddenException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = -4658914972167044321L; + + public ForbiddenException(String message) { + super(message); + } + +} diff --git a/verigraph/src/main/java/it/polito/escape/verify/exception/ForbiddenExceptionMapper.java b/verigraph/src/main/java/it/polito/escape/verify/exception/ForbiddenExceptionMapper.java new file mode 100644 index 0000000..d060b8b --- /dev/null +++ b/verigraph/src/main/java/it/polito/escape/verify/exception/ForbiddenExceptionMapper.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2017 Politecnico di Torino and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Apache License, Version 2.0 + * which accompanies this distribution, and is available at + * http://www.apache.org/licenses/LICENSE-2.0 + *******************************************************************************/ + +package it.polito.escape.verify.exception; + +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; + +import it.polito.escape.verify.model.ErrorMessage; + +@Provider +public class ForbiddenExceptionMapper implements ExceptionMapper<ForbiddenException> { + + @Override + public Response toResponse(ForbiddenException exception) { + ErrorMessage errorMessage = new ErrorMessage( exception.getMessage(), + 403, + "http://localhost:8080/verify/api-docs/"); + return Response.status(Status.FORBIDDEN).entity(errorMessage).build(); + } + +} diff --git a/verigraph/src/main/java/it/polito/escape/verify/exception/GenericExceptionMapper.java b/verigraph/src/main/java/it/polito/escape/verify/exception/GenericExceptionMapper.java new file mode 100644 index 0000000..96f7caa --- /dev/null +++ b/verigraph/src/main/java/it/polito/escape/verify/exception/GenericExceptionMapper.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2017 Politecnico di Torino and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Apache License, Version 2.0 + * which accompanies this distribution, and is available at + * http://www.apache.org/licenses/LICENSE-2.0 + *******************************************************************************/ + +package it.polito.escape.verify.exception; + +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.ext.ExceptionMapper; + +import it.polito.escape.verify.model.ErrorMessage; + +// @Provider +public class GenericExceptionMapper implements ExceptionMapper<Throwable> { + + @Override + public Response toResponse(Throwable exception) { + ErrorMessage errorMessage = new ErrorMessage("Generic exception: " + exception.getMessage(), + 500, + "http://localhost:8080/verify/api-docs/"); + return Response.status(Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build(); + } + +} diff --git a/verigraph/src/main/java/it/polito/escape/verify/exception/InternalServerErrorException.java b/verigraph/src/main/java/it/polito/escape/verify/exception/InternalServerErrorException.java new file mode 100644 index 0000000..877edb5 --- /dev/null +++ b/verigraph/src/main/java/it/polito/escape/verify/exception/InternalServerErrorException.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2017 Politecnico di Torino and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Apache License, Version 2.0 + * which accompanies this distribution, and is available at + * http://www.apache.org/licenses/LICENSE-2.0 + *******************************************************************************/ + +package it.polito.escape.verify.exception; + +public class InternalServerErrorException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = 156815197709461502L; + + public InternalServerErrorException(String message) { + super(message); + } + +} diff --git a/verigraph/src/main/java/it/polito/escape/verify/exception/InternalServerErrorExceptionMapper.java b/verigraph/src/main/java/it/polito/escape/verify/exception/InternalServerErrorExceptionMapper.java new file mode 100644 index 0000000..02b6765 --- /dev/null +++ b/verigraph/src/main/java/it/polito/escape/verify/exception/InternalServerErrorExceptionMapper.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2017 Politecnico di Torino and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Apache License, Version 2.0 + * which accompanies this distribution, and is available at + * http://www.apache.org/licenses/LICENSE-2.0 + *******************************************************************************/ + +package it.polito.escape.verify.exception; + +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; + +import it.polito.escape.verify.model.ErrorMessage; + +@Provider +public class InternalServerErrorExceptionMapper implements ExceptionMapper<InternalServerErrorException> { + + @Override + public Response toResponse(InternalServerErrorException exception) { + ErrorMessage errorMessage = new ErrorMessage( exception.getMessage(), + 500, + "http://localhost:8080/verify/api-docs/"); + return Response.status(Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build(); + } + +} |