From 53d83244c1bf36af86e90ce5fe758a369f73563e Mon Sep 17 00:00:00 2001 From: "serena.spinoso" Date: Sat, 25 Feb 2017 12:00:55 +0100 Subject: Add verigraph code base JIRA: PARSER-111 Change-Id: Ie76e14fabbb6c388ebc89d9a15dd3021b25fa892 Signed-off-by: serena.spinoso --- .../verify/exception/BadRequestException.java | 23 +++++++++++++++++ .../exception/BadRequestExceptionMapper.java | 30 ++++++++++++++++++++++ .../verify/exception/DataNotFoundException.java | 23 +++++++++++++++++ .../exception/DataNotFoundExceptionMapper.java | 30 ++++++++++++++++++++++ .../verify/exception/ForbiddenException.java | 23 +++++++++++++++++ .../verify/exception/ForbiddenExceptionMapper.java | 30 ++++++++++++++++++++++ .../verify/exception/GenericExceptionMapper.java | 29 +++++++++++++++++++++ .../exception/InternalServerErrorException.java | 23 +++++++++++++++++ .../InternalServerErrorExceptionMapper.java | 30 ++++++++++++++++++++++ 9 files changed, 241 insertions(+) create mode 100644 verigraph/src/main/java/it/polito/escape/verify/exception/BadRequestException.java create mode 100644 verigraph/src/main/java/it/polito/escape/verify/exception/BadRequestExceptionMapper.java create mode 100644 verigraph/src/main/java/it/polito/escape/verify/exception/DataNotFoundException.java create mode 100644 verigraph/src/main/java/it/polito/escape/verify/exception/DataNotFoundExceptionMapper.java create mode 100644 verigraph/src/main/java/it/polito/escape/verify/exception/ForbiddenException.java create mode 100644 verigraph/src/main/java/it/polito/escape/verify/exception/ForbiddenExceptionMapper.java create mode 100644 verigraph/src/main/java/it/polito/escape/verify/exception/GenericExceptionMapper.java create mode 100644 verigraph/src/main/java/it/polito/escape/verify/exception/InternalServerErrorException.java create mode 100644 verigraph/src/main/java/it/polito/escape/verify/exception/InternalServerErrorExceptionMapper.java (limited to 'verigraph/src/main/java/it/polito/escape/verify/exception') 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 { + + @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 { + + @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 { + + @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 { + + @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 { + + @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(); + } + +} -- cgit 1.2.3-korg