Roberto Sánchez
2014-01-21 b83a0ba903b56562751963c106b4c20352c26087
#396 feature - Refactoring error management
1 files deleted
1 files added
8 files modified
changed files
securis/src/main/java/net/curisit/securis/DefaultExceptionHandler.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/MainApp.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/SecurisErrorHandler.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/security/SecurityInterceptor.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/services/ApplicationResource.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/services/LicenseResource.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/services/LicenseTypeResource.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/services/OrganizationResource.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/services/PackResource.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/services/UserResource.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/DefaultExceptionHandler.java
....@@ -0,0 +1,28 @@
1
+package net.curisit.securis;
2
+
3
+import javax.ws.rs.ForbiddenException;
4
+import javax.ws.rs.core.MediaType;
5
+import javax.ws.rs.core.Response;
6
+import javax.ws.rs.core.Response.Status;
7
+import javax.ws.rs.ext.ExceptionMapper;
8
+import javax.ws.rs.ext.Provider;
9
+
10
+@Provider
11
+public class DefaultExceptionHandler implements ExceptionMapper<Exception> {
12
+
13
+ public static final String ERROR_MESSAGE_HEADER = "X-SECURIS-ERROR";
14
+
15
+ public DefaultExceptionHandler() {
16
+ MainApp.log.info("Creating DefaultExceptionHandler ");
17
+ }
18
+
19
+ @Override
20
+ public Response toResponse(Exception e) {
21
+ // log.info("Creating DefaultExceptionHandler ");
22
+ // e.printStackTrace();
23
+ if (e instanceof ForbiddenException)
24
+ return Response.status(Status.UNAUTHORIZED).header(ERROR_MESSAGE_HEADER, "Unathorized access to the application").type(MediaType.APPLICATION_JSON).build();
25
+
26
+ return Response.serverError().header(ERROR_MESSAGE_HEADER, "Unexpected error: " + e.toString()).type(MediaType.APPLICATION_JSON).build();
27
+ }
28
+}
securis/src/main/java/net/curisit/securis/MainApp.java
....@@ -5,10 +5,6 @@
55
66 import javax.inject.Inject;
77 import javax.inject.Named;
8
-import javax.ws.rs.core.MediaType;
9
-import javax.ws.rs.core.Response;
10
-import javax.ws.rs.ext.ExceptionMapper;
11
-import javax.ws.rs.ext.Provider;
128
139 import net.curisit.securis.ioc.RequestsModule;
1410 import net.curisit.securis.ioc.SecurisModule;
....@@ -17,6 +13,7 @@
1713 import org.eclipse.jetty.server.Server;
1814 import org.eclipse.jetty.server.handler.ContextHandlerCollection;
1915 import org.eclipse.jetty.server.handler.ResourceHandler;
16
+import org.eclipse.jetty.servlet.ErrorPageErrorHandler;
2017 import org.eclipse.jetty.servlet.FilterHolder;
2118 import org.eclipse.jetty.servlet.ServletContextHandler;
2219 import org.eclipse.jetty.servlet.ServletHolder;
....@@ -35,7 +32,7 @@
3532
3633 public class MainApp {
3734
38
- private static final Logger log = LoggerFactory.getLogger(MainApp.class);
35
+ static final Logger log = LoggerFactory.getLogger(MainApp.class);
3936
4037 private static Server server;
4138 private static Injector injector = null;
....@@ -74,7 +71,7 @@
7471
7572 context.setInitParameter("resteasy.role.based.security", "true");
7673 context.setInitParameter("resteasy.providers", DefaultExceptionHandler.class.getName());
77
- context.addFilter(new FilterHolder(injector.getInstance(AuthFilter.class)), "/*", null);
74
+ // context.addFilter(new FilterHolder(injector.getInstance(AuthFilter.class)), "/*", null);
7875 context.addFilter(new FilterHolder(injector.getInstance(PersistFilter.class)), "/*", null);
7976 ServletHolder sh = new ServletHolder(HttpServletDispatcher.class);
8077 sh.setName("resteasy");
....@@ -86,16 +83,14 @@
8683 { "/main.html" });
8784 context.setHandler(staticResources);
8885
89
- // ErrorPageErrorHandler errorHandler = new ErrorPageErrorHandler();
90
- // context.setErrorHandler(errorHandler);
86
+ ErrorPageErrorHandler errorHandler = new ErrorPageErrorHandler();
87
+ context.setErrorHandler(errorHandler);
9188 // errorHandler.addErrorPage(HttpResponseCodes.SC_FORBIDDEN, "/login");
9289 // errorHandler.addErrorPage(HttpResponseCodes.SC_NOT_FOUND, "/");
9390 // errorHandler.addErrorPage(javax.ws.rs.NotFoundException.class, "/");
9491 // errorHandler.addErrorPage(javax.ws.rs.ForbiddenException.class, "/");
9592 // errorHandler.addErrorPage(javax.ws.rs.ForbiddenException.class.getCanonicalName(), "/");
9693 // errorHandler.addErrorPage(ErrorPageErrorHandler.GLOBAL_ERROR_PAGE, "/");
97
- context.setWelcomeFiles(new String[]
98
- { "/index" });
9994 log.info("Error Handlers: " + context.getErrorHandler());
10095 ContextHandlerCollection contexts = new ContextHandlerCollection();
10196
....@@ -107,27 +102,6 @@
107102 server.start();
108103 server.join();
109104 log.info("Started server in: http://127.0.0.1:9997/");
110
- }
111
-
112
- @Provider
113
- public static class DefaultExceptionHandler implements ExceptionMapper<Exception> {
114
-
115
- public DefaultExceptionHandler() {
116
- log.info("Creating DefaultExceptionHandler ");
117
- }
118
-
119
- @Override
120
- public Response toResponse(Exception e) {
121
- // log.info("Creating DefaultExceptionHandler ");
122
- e.printStackTrace();
123
- // For simplicity I am preparing error xml by hand.
124
- // Ideally we should create an ErrorResponse class to hold the error info.
125
- StringBuilder response = new StringBuilder("<response>");
126
- response.append("<status>ERROR</status>");
127
- response.append("<message>" + e.getMessage() + "</message>");
128
- response.append("</response>");
129
- return Response.serverError().entity(response.toString()).type(MediaType.APPLICATION_XML).build();
130
- }
131105 }
132106
133107 }
securis/src/main/java/net/curisit/securis/SecurisErrorHandler.java
deleted file mode 100644
....@@ -1,19 +0,0 @@
1
-package net.curisit.securis;
2
-
3
-import java.io.IOException;
4
-import java.io.Writer;
5
-
6
-import javax.servlet.http.HttpServletRequest;
7
-
8
-import org.eclipse.jetty.server.handler.ErrorHandler;
9
-
10
-public class SecurisErrorHandler extends ErrorHandler {
11
-
12
- public static String HEADER_ERROR_MESSAGE = "X-SECURIS-ERROR";
13
-
14
- @Override
15
- protected void writeErrorPageHead(HttpServletRequest request, Writer writer, int code, String message) throws IOException {
16
- // TODO Auto-generated method stub
17
- super.writeErrorPageHead(request, writer, code, message);
18
- }
19
-}
securis/src/main/java/net/curisit/securis/security/SecurityInterceptor.java
....@@ -30,14 +30,7 @@
3030 import org.slf4j.Logger;
3131 import org.slf4j.LoggerFactory;
3232
33
-//@Provider
34
-//@Priority(Priorities.AUTHENTICATION)
35
-//public class SecurityInterceptor implements javax.ws.rs.container.ContainerRequestFilter {
36
-
3733 @Provider
38
-// @ServerInterceptor
39
-// @Precedence("SECURITY")
40
-// public class SecurityInterceptor implements PreProcessInterceptor {
4134 // @PreMatching
4235 @Priority(Priorities.AUTHENTICATION)
4336 public class SecurityInterceptor implements javax.ws.rs.container.ContainerRequestFilter {
securis/src/main/java/net/curisit/securis/services/ApplicationResource.java
....@@ -23,7 +23,7 @@
2323 import javax.ws.rs.core.Response.Status;
2424
2525 import net.curisit.integrity.commons.Utils;
26
-import net.curisit.securis.SecurisErrorHandler;
26
+import net.curisit.securis.DefaultExceptionHandler;
2727 import net.curisit.securis.db.Application;
2828 import net.curisit.securis.utils.TokenHelper;
2929
....@@ -88,7 +88,8 @@
8888 Application app = em.find(Application.class, Integer.parseInt(appid));
8989 if (app == null) {
9090 log.error("Application with id {} not found in DB", appid);
91
- return Response.status(Status.NOT_FOUND).header(SecurisErrorHandler.HEADER_ERROR_MESSAGE, "Application not found with ID: " + appid).build();
91
+
92
+ return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "Application not found with ID: " + appid).build();
9293 }
9394 return Response.ok(app).build();
9495 }
....@@ -121,7 +122,7 @@
121122 Application currentapp = em.find(Application.class, Integer.parseInt(appid));
122123 if (currentapp == null) {
123124 log.error("Application with id {} not found in DB", appid);
124
- return Response.status(Status.NOT_FOUND).header(SecurisErrorHandler.HEADER_ERROR_MESSAGE, "Application not found with ID: " + appid).build();
125
+ return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "Application not found with ID: " + appid).build();
125126 }
126127 currentapp.setName(app.getName());
127128 currentapp.setDescription(app.getDescription());
....@@ -141,11 +142,11 @@
141142 Application app = em.find(Application.class, Integer.parseInt(appid));
142143 if (app == null) {
143144 log.error("Application with id {} can not be deleted, It was not found in DB", appid);
144
- return Response.status(Status.NOT_FOUND).header(SecurisErrorHandler.HEADER_ERROR_MESSAGE, "Application not found with ID: " + appid).build();
145
+ return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "Application not found with ID: " + appid).build();
145146 }
146147
147148 if (app.getLicenseTypes() != null && app.getLicenseTypes().size() > 0) {
148
- return Response.status(Status.FORBIDDEN).header(SecurisErrorHandler.HEADER_ERROR_MESSAGE, "Application can not be deleted becasue has assigned one or more License types, ID: " + appid).build();
149
+ return Response.status(Status.FORBIDDEN).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "Application can not be deleted becasue has assigned one or more License types, ID: " + appid).build();
149150 }
150151
151152 em.remove(app);
securis/src/main/java/net/curisit/securis/services/LicenseResource.java
....@@ -24,7 +24,7 @@
2424
2525 import net.curisit.integrity.commons.Utils;
2626 import net.curisit.integrity.exception.CurisException;
27
-import net.curisit.securis.SecurisErrorHandler;
27
+import net.curisit.securis.DefaultExceptionHandler;
2828 import net.curisit.securis.db.License;
2929 import net.curisit.securis.db.Pack;
3030 import net.curisit.securis.db.User;
....@@ -111,7 +111,7 @@
111111 pack = em.find(Pack.class, lic.getPackId());
112112 if (pack == null) {
113113 log.error("License pack with id {} not found in DB", lic.getPackId());
114
- return Response.status(Status.NOT_FOUND).header(SecurisErrorHandler.HEADER_ERROR_MESSAGE, "License's pack not found with ID: " + lic.getPackId()).build();
114
+ return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "License's pack not found with ID: " + lic.getPackId()).build();
115115 }
116116 }
117117
....@@ -121,7 +121,7 @@
121121 } catch (CurisException ex) {
122122 String createdByUsername = lic.getCreatedById();
123123 log.error("License created by user with id {} not found in DB", createdByUsername);
124
- return Response.status(Status.NOT_FOUND).header(SecurisErrorHandler.HEADER_ERROR_MESSAGE, "License's created by user not found with ID: " + createdByUsername).build();
124
+ return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "License's created by user not found with ID: " + createdByUsername).build();
125125 }
126126
127127 try {
....@@ -130,7 +130,7 @@
130130 } catch (CurisException ex) {
131131 String canceledByUsername = lic.getCreatedById();
132132 log.error("License canceled by user with id {} not found in DB", canceledByUsername);
133
- return Response.status(Status.NOT_FOUND).header(SecurisErrorHandler.HEADER_ERROR_MESSAGE, "License's canceled by user not found with ID: " + canceledByUsername).build();
133
+ return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "License's canceled by user not found with ID: " + canceledByUsername).build();
134134 }
135135
136136 lic.setCreationTimestamp(new Date());
....@@ -166,7 +166,7 @@
166166 pack = em.find(Pack.class, lic.getPackId());
167167 if (pack == null) {
168168 log.error("License pack with id {} not found in DB", lic.getPackId());
169
- return Response.status(Status.NOT_FOUND).header(SecurisErrorHandler.HEADER_ERROR_MESSAGE, "License's pack not found with ID: " + lic.getPackId()).build();
169
+ return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "License's pack not found with ID: " + lic.getPackId()).build();
170170 }
171171 }
172172 User createdBy = null;
....@@ -175,7 +175,7 @@
175175 } catch (CurisException ex) {
176176 String createdByUsername = lic.getCreatedById();
177177 log.error("License created by user with id {} not found in DB", createdByUsername);
178
- return Response.status(Status.NOT_FOUND).header(SecurisErrorHandler.HEADER_ERROR_MESSAGE, "License's created by user not found with ID: " + createdByUsername).build();
178
+ return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "License's created by user not found with ID: " + createdByUsername).build();
179179 }
180180
181181 User canceledBy = null;
....@@ -184,7 +184,7 @@
184184 } catch (CurisException ex) {
185185 String canceledByUsername = lic.getCreatedById();
186186 log.error("License canceled by user with id {} not found in DB", canceledByUsername);
187
- return Response.status(Status.NOT_FOUND).header(SecurisErrorHandler.HEADER_ERROR_MESSAGE, "License's canceled by user not found with ID: " + canceledByUsername).build();
187
+ return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "License's canceled by user not found with ID: " + canceledByUsername).build();
188188 }
189189
190190 lic.setCreatedBy(createdBy);
....@@ -206,7 +206,7 @@
206206 License org = em.find(License.class, Integer.parseInt(licId));
207207 if (org == null) {
208208 log.error("License with id {} can not be deleted, It was not found in DB", licId);
209
- return Response.status(Status.NOT_FOUND).header(SecurisErrorHandler.HEADER_ERROR_MESSAGE, "License was not found, ID: " + licId).build();
209
+ return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "License was not found, ID: " + licId).build();
210210 }
211211
212212 em.remove(org);
securis/src/main/java/net/curisit/securis/services/LicenseTypeResource.java
....@@ -23,7 +23,7 @@
2323 import javax.ws.rs.core.Response.Status;
2424
2525 import net.curisit.integrity.commons.Utils;
26
-import net.curisit.securis.SecurisErrorHandler;
26
+import net.curisit.securis.DefaultExceptionHandler;
2727 import net.curisit.securis.db.Application;
2828 import net.curisit.securis.db.LicenseType;
2929 import net.curisit.securis.utils.TokenHelper;
....@@ -108,11 +108,11 @@
108108 app = em.find(Application.class, lt.getApplicationId());
109109 if (app == null) {
110110 log.error("LicenseType application with id {} not found in DB", lt.getApplicationId());
111
- return Response.status(Status.NOT_FOUND).header(SecurisErrorHandler.HEADER_ERROR_MESSAGE, "License type's app not found with ID: " + lt.getApplicationId()).build();
111
+ return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "License type's app not found with ID: " + lt.getApplicationId()).build();
112112 }
113113 } else {
114114 log.error("Application is missing for current license type data");
115
- return Response.status(Status.NOT_FOUND).header(SecurisErrorHandler.HEADER_ERROR_MESSAGE, "Application is missing for current license type data").build();
115
+ return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "Application is missing for current license type data").build();
116116 }
117117
118118 lt.setApplication(app);
....@@ -135,14 +135,14 @@
135135 LicenseType currentlt = em.find(LicenseType.class, Integer.parseInt(ltid));
136136 if (currentlt == null) {
137137 log.error("LicenseType with id {} not found in DB", ltid);
138
- return Response.status(Status.NOT_FOUND).header(SecurisErrorHandler.HEADER_ERROR_MESSAGE, "License type not found with ID: " + ltid).build();
138
+ return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "License type not found with ID: " + ltid).build();
139139 }
140140 Application app = null;
141141 if (lt.getApplicationId() != null) {
142142 app = em.find(Application.class, lt.getApplicationId());
143143 if (app == null) {
144144 log.error("LicenseType application with id {} not found in DB", lt.getApplicationId());
145
- return Response.status(Status.NOT_FOUND).header(SecurisErrorHandler.HEADER_ERROR_MESSAGE, "License type's app not found with ID: " + lt.getApplicationId()).build();
145
+ return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "License type's app not found with ID: " + lt.getApplicationId()).build();
146146 }
147147 }
148148 currentlt.setCode(lt.getCode());
securis/src/main/java/net/curisit/securis/services/OrganizationResource.java
....@@ -25,7 +25,7 @@
2525 import javax.ws.rs.core.Response.Status;
2626
2727 import net.curisit.integrity.commons.Utils;
28
-import net.curisit.securis.SecurisErrorHandler;
28
+import net.curisit.securis.DefaultExceptionHandler;
2929 import net.curisit.securis.db.Organization;
3030 import net.curisit.securis.db.User;
3131 import net.curisit.securis.security.BasicSecurityContext;
....@@ -146,7 +146,7 @@
146146 parentOrg = em.find(Organization.class, org.getParentOrgId());
147147 if (parentOrg == null) {
148148 log.error("Organization parent with id {} not found in DB", org.getParentOrgId());
149
- return Response.status(Status.NOT_FOUND).header(SecurisErrorHandler.HEADER_ERROR_MESSAGE, "Organization's parent not found with ID: " + org.getParentOrgId()).build();
149
+ return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "Organization's parent not found with ID: " + org.getParentOrgId()).build();
150150 }
151151 }
152152 List<User> users = null;
....@@ -157,7 +157,7 @@
157157 User user = em.find(User.class, username);
158158 if (user == null) {
159159 log.error("Organization user with id {} not found in DB", username);
160
- return Response.status(Status.NOT_FOUND).header(SecurisErrorHandler.HEADER_ERROR_MESSAGE, "Organization's user not found with ID: " + username).build();
160
+ return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "Organization's user not found with ID: " + username).build();
161161 }
162162 users.add(user);
163163 }
....@@ -186,18 +186,18 @@
186186 Organization currentOrg = em.find(Organization.class, Integer.parseInt(orgid));
187187 if (currentOrg == null) {
188188 log.error("Organization with id {} not found in DB", orgid);
189
- return Response.status(Status.NOT_FOUND).header(SecurisErrorHandler.HEADER_ERROR_MESSAGE, "Organization not found with ID: " + orgid).build();
189
+ return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "Organization not found with ID: " + orgid).build();
190190 }
191191 Organization parentOrg = null;
192192 if (org.getParentOrgId() != null) {
193193 parentOrg = em.find(Organization.class, org.getParentOrgId());
194194 if (parentOrg == null) {
195195 log.error("Organization parent with id {} not found in DB", org.getParentOrgId());
196
- return Response.status(Status.NOT_FOUND).header(SecurisErrorHandler.HEADER_ERROR_MESSAGE, "Organization's parent not found with ID: " + org.getParentOrgId()).build();
196
+ return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "Organization's parent not found with ID: " + org.getParentOrgId()).build();
197197 }
198198 if (isCyclicalRelationship(currentOrg.getId(), parentOrg)) {
199199 log.error("Organization parent generate a cyclical relationship, parent id {}, current id: {}", org.getParentOrgId(), currentOrg.getId());
200
- return Response.status(Status.FORBIDDEN).header(SecurisErrorHandler.HEADER_ERROR_MESSAGE, "Cyclical relationships are not allowed, please change the parent organization, current Parent: " + parentOrg.getName()).build();
200
+ return Response.status(Status.FORBIDDEN).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "Cyclical relationships are not allowed, please change the parent organization, current Parent: " + parentOrg.getName()).build();
201201 }
202202 }
203203
....@@ -209,7 +209,7 @@
209209 User user = em.find(User.class, username);
210210 if (user == null) {
211211 log.error("Organization user with id '{}' not found in DB", username);
212
- return Response.status(Status.NOT_FOUND).header(SecurisErrorHandler.HEADER_ERROR_MESSAGE, "Organization's user not found with ID: " + username).build();
212
+ return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "Organization's user not found with ID: " + username).build();
213213 }
214214 users.add(user);
215215 }
....@@ -238,11 +238,11 @@
238238 Organization org = em.find(Organization.class, Integer.parseInt(orgid));
239239 if (org == null) {
240240 log.error("Organization with id {} can not be deleted, It was not found in DB", orgid);
241
- return Response.status(Status.NOT_FOUND).header(SecurisErrorHandler.HEADER_ERROR_MESSAGE, "Organization was not found, ID: " + orgid).build();
241
+ return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "Organization was not found, ID: " + orgid).build();
242242 }
243243 if (org.getChildOrganizations() != null && org.getChildOrganizations().size() > 0) {
244244 log.error("Organization has children and can not be deleted, ID: " + orgid);
245
- return Response.status(Status.FORBIDDEN).header(SecurisErrorHandler.HEADER_ERROR_MESSAGE, "Organization has children and can not be deleted, ID: " + orgid).build();
245
+ return Response.status(Status.FORBIDDEN).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "Organization has children and can not be deleted, ID: " + orgid).build();
246246 }
247247
248248 em.remove(org);
securis/src/main/java/net/curisit/securis/services/PackResource.java
....@@ -24,7 +24,7 @@
2424
2525 import net.curisit.integrity.commons.Utils;
2626 import net.curisit.integrity.exception.CurisException;
27
-import net.curisit.securis.SecurisErrorHandler;
27
+import net.curisit.securis.DefaultExceptionHandler;
2828 import net.curisit.securis.db.Pack;
2929 import net.curisit.securis.db.User;
3030 import net.curisit.securis.utils.TokenHelper;
....@@ -150,7 +150,7 @@
150150 Pack org = em.find(Pack.class, Integer.parseInt(packId));
151151 if (org == null) {
152152 log.error("Pack with id {} can not be deleted, It was not found in DB", packId);
153
- return Response.status(Status.NOT_FOUND).header(SecurisErrorHandler.HEADER_ERROR_MESSAGE, "Pack was not found, ID: " + packId).build();
153
+ return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "Pack was not found, ID: " + packId).build();
154154 }
155155
156156 em.remove(org);
securis/src/main/java/net/curisit/securis/services/UserResource.java
....@@ -27,6 +27,7 @@
2727 import javax.ws.rs.core.Response.Status;
2828
2929 import net.curisit.integrity.commons.Utils;
30
+import net.curisit.securis.DefaultExceptionHandler;
3031 import net.curisit.securis.db.Organization;
3132 import net.curisit.securis.db.User;
3233 import net.curisit.securis.utils.TokenHelper;
....@@ -122,7 +123,7 @@
122123 Organization o = em.find(Organization.class, orgId);
123124 if (o == null) {
124125 log.error("User organization with id {} not found in DB", orgId);
125
- return Response.status(Status.NOT_FOUND).header("SECURIS_ERROR", "User's organization not found with ID: " + orgId).build();
126
+ return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "User's organization not found with ID: " + orgId).build();
126127 }
127128 orgs.add(o);
128129 }
....@@ -161,7 +162,7 @@
161162 Organization o = em.find(Organization.class, orgId);
162163 if (o == null) {
163164 log.error("User organization with id {} not found in DB", orgId);
164
- return Response.status(Status.NOT_FOUND).header("SECURIS_ERROR", "User's user not found with ID: " + orgId).build();
165
+ return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "User's user not found with ID: " + orgId).build();
165166 }
166167 orgs.add(o);
167168 }