| .. | .. |
|---|
| 25 | 25 | import javax.ws.rs.core.Response.Status; |
|---|
| 26 | 26 | |
|---|
| 27 | 27 | import net.curisit.integrity.commons.Utils; |
|---|
| 28 | | -import net.curisit.securis.SecurisErrorHandler; |
|---|
| 28 | +import net.curisit.securis.DefaultExceptionHandler; |
|---|
| 29 | 29 | import net.curisit.securis.db.Organization; |
|---|
| 30 | 30 | import net.curisit.securis.db.User; |
|---|
| 31 | 31 | import net.curisit.securis.security.BasicSecurityContext; |
|---|
| .. | .. |
|---|
| 146 | 146 | parentOrg = em.find(Organization.class, org.getParentOrgId()); |
|---|
| 147 | 147 | if (parentOrg == null) { |
|---|
| 148 | 148 | 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(); |
|---|
| 150 | 150 | } |
|---|
| 151 | 151 | } |
|---|
| 152 | 152 | List<User> users = null; |
|---|
| .. | .. |
|---|
| 157 | 157 | User user = em.find(User.class, username); |
|---|
| 158 | 158 | if (user == null) { |
|---|
| 159 | 159 | 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(); |
|---|
| 161 | 161 | } |
|---|
| 162 | 162 | users.add(user); |
|---|
| 163 | 163 | } |
|---|
| .. | .. |
|---|
| 186 | 186 | Organization currentOrg = em.find(Organization.class, Integer.parseInt(orgid)); |
|---|
| 187 | 187 | if (currentOrg == null) { |
|---|
| 188 | 188 | 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(); |
|---|
| 190 | 190 | } |
|---|
| 191 | 191 | Organization parentOrg = null; |
|---|
| 192 | 192 | if (org.getParentOrgId() != null) { |
|---|
| 193 | 193 | parentOrg = em.find(Organization.class, org.getParentOrgId()); |
|---|
| 194 | 194 | if (parentOrg == null) { |
|---|
| 195 | 195 | 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(); |
|---|
| 197 | 197 | } |
|---|
| 198 | 198 | if (isCyclicalRelationship(currentOrg.getId(), parentOrg)) { |
|---|
| 199 | 199 | 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(); |
|---|
| 201 | 201 | } |
|---|
| 202 | 202 | } |
|---|
| 203 | 203 | |
|---|
| .. | .. |
|---|
| 209 | 209 | User user = em.find(User.class, username); |
|---|
| 210 | 210 | if (user == null) { |
|---|
| 211 | 211 | 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(); |
|---|
| 213 | 213 | } |
|---|
| 214 | 214 | users.add(user); |
|---|
| 215 | 215 | } |
|---|
| .. | .. |
|---|
| 238 | 238 | Organization org = em.find(Organization.class, Integer.parseInt(orgid)); |
|---|
| 239 | 239 | if (org == null) { |
|---|
| 240 | 240 | 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(); |
|---|
| 242 | 242 | } |
|---|
| 243 | 243 | if (org.getChildOrganizations() != null && org.getChildOrganizations().size() > 0) { |
|---|
| 244 | 244 | 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(); |
|---|
| 246 | 246 | } |
|---|
| 247 | 247 | |
|---|
| 248 | 248 | em.remove(org); |
|---|