summaryrefslogtreecommitdiffstats
path: root/verigraph/src/it/polito/verigraph/exception
diff options
context:
space:
mode:
authorjulien zhang <zhang.jun3g@zte.com.cn>2017-09-12 14:47:37 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-09-12 14:47:37 +0000
commit8153ff1bac0ec3664c777302396698e4fb5f34b9 (patch)
tree2b97892774e3ced5f0c10e400657d28f9222749b /verigraph/src/it/polito/verigraph/exception
parent96de9387460091e7cf0dc5fde1afaa637a8b2b79 (diff)
parenta42de79292d9541db7865b54e93be2d0b6e6a094 (diff)
Merge "update verigraph"
Diffstat (limited to 'verigraph/src/it/polito/verigraph/exception')
-rw-r--r--verigraph/src/it/polito/verigraph/exception/BadRequestException.java19
-rw-r--r--verigraph/src/it/polito/verigraph/exception/BadRequestExceptionMapper.java29
-rw-r--r--verigraph/src/it/polito/verigraph/exception/DataNotFoundException.java19
-rw-r--r--verigraph/src/it/polito/verigraph/exception/DataNotFoundExceptionMapper.java29
-rw-r--r--verigraph/src/it/polito/verigraph/exception/ForbiddenException.java19
-rw-r--r--verigraph/src/it/polito/verigraph/exception/ForbiddenExceptionMapper.java29
-rw-r--r--verigraph/src/it/polito/verigraph/exception/GenericExceptionMapper.java28
-rw-r--r--verigraph/src/it/polito/verigraph/exception/InternalServerErrorException.java19
-rw-r--r--verigraph/src/it/polito/verigraph/exception/InternalServerErrorExceptionMapper.java29
9 files changed, 220 insertions, 0 deletions
diff --git a/verigraph/src/it/polito/verigraph/exception/BadRequestException.java b/verigraph/src/it/polito/verigraph/exception/BadRequestException.java
new file mode 100644
index 0000000..254a035
--- /dev/null
+++ b/verigraph/src/it/polito/verigraph/exception/BadRequestException.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * 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.verigraph.exception;
+
+public class BadRequestException extends RuntimeException {
+
+ private static final long serialVersionUID = -548472179073745084L;
+
+ public BadRequestException(String message) {
+ super(message);
+ }
+
+} \ No newline at end of file
diff --git a/verigraph/src/it/polito/verigraph/exception/BadRequestExceptionMapper.java b/verigraph/src/it/polito/verigraph/exception/BadRequestExceptionMapper.java
new file mode 100644
index 0000000..0eea67a
--- /dev/null
+++ b/verigraph/src/it/polito/verigraph/exception/BadRequestExceptionMapper.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.verigraph.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.verigraph.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/verigraph/api-docs/");
+ return Response.status(Status.BAD_REQUEST).entity(errorMessage).build();
+ }
+
+} \ No newline at end of file
diff --git a/verigraph/src/it/polito/verigraph/exception/DataNotFoundException.java b/verigraph/src/it/polito/verigraph/exception/DataNotFoundException.java
new file mode 100644
index 0000000..5c0a96c
--- /dev/null
+++ b/verigraph/src/it/polito/verigraph/exception/DataNotFoundException.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * 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.verigraph.exception;
+
+public class DataNotFoundException extends RuntimeException {
+
+ private static final long serialVersionUID = -6012364193903183208L;
+
+ public DataNotFoundException(String message) {
+ super(message);
+ }
+
+} \ No newline at end of file
diff --git a/verigraph/src/it/polito/verigraph/exception/DataNotFoundExceptionMapper.java b/verigraph/src/it/polito/verigraph/exception/DataNotFoundExceptionMapper.java
new file mode 100644
index 0000000..e4b9071
--- /dev/null
+++ b/verigraph/src/it/polito/verigraph/exception/DataNotFoundExceptionMapper.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.verigraph.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.verigraph.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/verigraph/api-docs/");
+ return Response.status(Status.NOT_FOUND).entity(errorMessage).build();
+ }
+
+} \ No newline at end of file
diff --git a/verigraph/src/it/polito/verigraph/exception/ForbiddenException.java b/verigraph/src/it/polito/verigraph/exception/ForbiddenException.java
new file mode 100644
index 0000000..2e39667
--- /dev/null
+++ b/verigraph/src/it/polito/verigraph/exception/ForbiddenException.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * 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.verigraph.exception;
+
+public class ForbiddenException extends RuntimeException {
+
+ private static final long serialVersionUID = -4658914972167044321L;
+
+ public ForbiddenException(String message) {
+ super(message);
+ }
+
+} \ No newline at end of file
diff --git a/verigraph/src/it/polito/verigraph/exception/ForbiddenExceptionMapper.java b/verigraph/src/it/polito/verigraph/exception/ForbiddenExceptionMapper.java
new file mode 100644
index 0000000..dc63898
--- /dev/null
+++ b/verigraph/src/it/polito/verigraph/exception/ForbiddenExceptionMapper.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.verigraph.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.verigraph.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/verigraph/api-docs/");
+ return Response.status(Status.FORBIDDEN).entity(errorMessage).build();
+ }
+
+} \ No newline at end of file
diff --git a/verigraph/src/it/polito/verigraph/exception/GenericExceptionMapper.java b/verigraph/src/it/polito/verigraph/exception/GenericExceptionMapper.java
new file mode 100644
index 0000000..dcf3707
--- /dev/null
+++ b/verigraph/src/it/polito/verigraph/exception/GenericExceptionMapper.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * 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.verigraph.exception;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.ext.ExceptionMapper;
+
+import it.polito.verigraph.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/verigraph/api-docs/");
+ return Response.status(Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build();
+ }
+
+} \ No newline at end of file
diff --git a/verigraph/src/it/polito/verigraph/exception/InternalServerErrorException.java b/verigraph/src/it/polito/verigraph/exception/InternalServerErrorException.java
new file mode 100644
index 0000000..ecbde7e
--- /dev/null
+++ b/verigraph/src/it/polito/verigraph/exception/InternalServerErrorException.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * 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.verigraph.exception;
+
+public class InternalServerErrorException extends RuntimeException {
+
+ private static final long serialVersionUID = 156815197709461502L;
+
+ public InternalServerErrorException(String message) {
+ super(message);
+ }
+
+} \ No newline at end of file
diff --git a/verigraph/src/it/polito/verigraph/exception/InternalServerErrorExceptionMapper.java b/verigraph/src/it/polito/verigraph/exception/InternalServerErrorExceptionMapper.java
new file mode 100644
index 0000000..3706d31
--- /dev/null
+++ b/verigraph/src/it/polito/verigraph/exception/InternalServerErrorExceptionMapper.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.verigraph.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.verigraph.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/verigraph/api-docs/");
+ return Response.status(Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build();
+ }
+
+} \ No newline at end of file