TSK-1647: automatic refactoring
This commit is contained in:
parent
9d290f2c3d
commit
6f344c9363
|
@ -15,6 +15,19 @@ Most of our resources contain a `_links` section which contains navigation links
|
||||||
Besides, helping to navigate through our REST API, the navigation links also encapsulate the API.
|
Besides, helping to navigate through our REST API, the navigation links also encapsulate the API.
|
||||||
Using HATEOAS allows us to change some endpoints without modifying your frontend.
|
Using HATEOAS allows us to change some endpoints without modifying your frontend.
|
||||||
|
|
||||||
|
=== Errors
|
||||||
|
|
||||||
|
In order to support multilingual websites, TASKANA uses error codes to define which error occurred.
|
||||||
|
Additionally, an optional set of message variables, containing some technical information, is added, so that the website can describe the error with all details.
|
||||||
|
|
||||||
|
The table below is an addition to the already documented TASKANA REST Service ErrorCodes
|
||||||
|
|
||||||
|
[%autowidth,width="100%"]
|
||||||
|
|===
|
||||||
|
| Status Code | Key | Message Variables
|
||||||
|
| *404 NOT_FOUND* | HISTORY_EVENT_NOT_FOUND | historyEventId
|
||||||
|
|===
|
||||||
|
|
||||||
== History event
|
== History event
|
||||||
|
|
||||||
include::{snippets}/TaskHistoryEventControllerRestDocTest/getAllTaskHistoryEventsDocTest/auto-section.adoc[]
|
include::{snippets}/TaskHistoryEventControllerRestDocTest/getAllTaskHistoryEventsDocTest/auto-section.adoc[]
|
||||||
|
|
|
@ -134,14 +134,6 @@ public class ClassificationQueryImpl implements ClassificationQuery {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateAllTimeIntervals(TimeInterval[] createdIn) {
|
|
||||||
for (TimeInterval ti : createdIn) {
|
|
||||||
if (!ti.isValid()) {
|
|
||||||
throw new IllegalArgumentException("TimeInterval " + ti + " is invalid.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClassificationQuery nameIn(String... nameIn) {
|
public ClassificationQuery nameIn(String... nameIn) {
|
||||||
this.nameIn = nameIn;
|
this.nameIn = nameIn;
|
||||||
|
@ -537,6 +529,14 @@ public class ClassificationQueryImpl implements ClassificationQuery {
|
||||||
return orderColumns;
|
return orderColumns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void validateAllTimeIntervals(TimeInterval[] createdIn) {
|
||||||
|
for (TimeInterval ti : createdIn) {
|
||||||
|
if (!ti.isValid()) {
|
||||||
|
throw new IllegalArgumentException("TimeInterval " + ti + " is invalid.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private ClassificationQuery addOrderCriteria(String columnName, SortDirection sortDirection) {
|
private ClassificationQuery addOrderCriteria(String columnName, SortDirection sortDirection) {
|
||||||
String orderByDirection =
|
String orderByDirection =
|
||||||
" " + (sortDirection == null ? SortDirection.ASCENDING : sortDirection);
|
" " + (sortDirection == null ? SortDirection.ASCENDING : sortDirection);
|
||||||
|
|
|
@ -142,14 +142,6 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateAllTimeIntervals(TimeInterval[] intervals) {
|
|
||||||
for (TimeInterval ti : intervals) {
|
|
||||||
if (!ti.isValid()) {
|
|
||||||
throw new IllegalArgumentException("TimeInterval " + ti + " is invalid.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WorkbasketQuery descriptionLike(String... description) {
|
public WorkbasketQuery descriptionLike(String... description) {
|
||||||
this.descriptionLike = toUpperCopy(description);
|
this.descriptionLike = toUpperCopy(description);
|
||||||
|
@ -595,6 +587,14 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void validateAllTimeIntervals(TimeInterval[] intervals) {
|
||||||
|
for (TimeInterval ti : intervals) {
|
||||||
|
if (!ti.isValid()) {
|
||||||
|
throw new IllegalArgumentException("TimeInterval " + ti + " is invalid.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void handleCallerRolesAndAccessIds() {
|
private void handleCallerRolesAndAccessIds() {
|
||||||
if (!callerRolesAndAccessIdsAlreadyHandled) {
|
if (!callerRolesAndAccessIdsAlreadyHandled) {
|
||||||
callerRolesAndAccessIdsAlreadyHandled = true;
|
callerRolesAndAccessIdsAlreadyHandled = true;
|
||||||
|
|
|
@ -38,14 +38,13 @@ Additionally, an optional set of message variables, containing some technical in
|
||||||
| *403 FORBIDDEN* | WORKBASKET_WITH_KEY_MISMATCHED_PERMISSION | currentUserId, workbasketKey, domain, requiredPermissions
|
| *403 FORBIDDEN* | WORKBASKET_WITH_KEY_MISMATCHED_PERMISSION | currentUserId, workbasketKey, domain, requiredPermissions
|
||||||
| *404 NOT_FOUND* | CLASSIFICATION_WITH_ID_NOT_FOUND | classificationId
|
| *404 NOT_FOUND* | CLASSIFICATION_WITH_ID_NOT_FOUND | classificationId
|
||||||
| *404 NOT_FOUND* | CLASSIFICATION_WITH_KEY_NOT_FOUND | classificationKey, domain
|
| *404 NOT_FOUND* | CLASSIFICATION_WITH_KEY_NOT_FOUND | classificationKey, domain
|
||||||
| *404 NOT_FOUND* | HISTORY_EVENT_NOT_FOUND | historyEventId
|
|
||||||
| *404 NOT_FOUND* | TASK_COMMENT_NOT_FOUND | taskCommentId
|
| *404 NOT_FOUND* | TASK_COMMENT_NOT_FOUND | taskCommentId
|
||||||
| *404 NOT_FOUND* | TASK_NOT_FOUND | taskId
|
| *404 NOT_FOUND* | TASK_NOT_FOUND | taskId
|
||||||
| *404 NOT_FOUND* | WORKBASKET_WITH_ID_NOT_FOUND | workbasketId
|
| *404 NOT_FOUND* | WORKBASKET_WITH_ID_NOT_FOUND | workbasketId
|
||||||
| *404 NOT_FOUND* | WORKBASKET_WITH_KEY_NOT_FOUND | workbasketKey, domain
|
| *404 NOT_FOUND* | WORKBASKET_WITH_KEY_NOT_FOUND | workbasketKey, domain
|
||||||
| *409 CONFLICT* | ATTACHMENT_ALREADY_EXISTS | attachmentId, taskId
|
| *409 CONFLICT* | ATTACHMENT_ALREADY_EXISTS | attachmentId, taskId
|
||||||
| *409 CONFLICT* | CLASSIFICATION_ALREADY_EXISTS | classificationKey, domain
|
| *409 CONFLICT* | CLASSIFICATION_ALREADY_EXISTS | classificationKey, domain
|
||||||
| *409 CONFLICT* | ENTITY_NOT_UP_TO_DATE |
|
| *409 CONFLICT* | ENTITY_NOT_UP_TO_DATE | entityId
|
||||||
| *409 CONFLICT* | TASK_ALREADY_EXISTS | externalTaskId
|
| *409 CONFLICT* | TASK_ALREADY_EXISTS | externalTaskId
|
||||||
| *409 CONFLICT* | WORKBASKET_ACCESS_ITEM_ALREADY_EXISTS | accessId, workbasketId
|
| *409 CONFLICT* | WORKBASKET_ACCESS_ITEM_ALREADY_EXISTS | accessId, workbasketId
|
||||||
| *409 CONFLICT* | WORKBASKET_ALREADY_EXISTS | workbasketKey, domain
|
| *409 CONFLICT* | WORKBASKET_ALREADY_EXISTS | workbasketKey, domain
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExcep
|
||||||
import pro.taskana.classification.api.exceptions.ClassificationAlreadyExistException;
|
import pro.taskana.classification.api.exceptions.ClassificationAlreadyExistException;
|
||||||
import pro.taskana.classification.api.exceptions.ClassificationInUseException;
|
import pro.taskana.classification.api.exceptions.ClassificationInUseException;
|
||||||
import pro.taskana.classification.api.exceptions.ClassificationNotFoundException;
|
import pro.taskana.classification.api.exceptions.ClassificationNotFoundException;
|
||||||
|
import pro.taskana.classification.api.exceptions.MalformedServiceLevelException;
|
||||||
import pro.taskana.common.api.exceptions.ConcurrencyException;
|
import pro.taskana.common.api.exceptions.ConcurrencyException;
|
||||||
import pro.taskana.common.api.exceptions.DomainNotFoundException;
|
import pro.taskana.common.api.exceptions.DomainNotFoundException;
|
||||||
import pro.taskana.common.api.exceptions.ErrorCode;
|
import pro.taskana.common.api.exceptions.ErrorCode;
|
||||||
|
@ -38,6 +39,7 @@ import pro.taskana.common.api.exceptions.MismatchedRoleException;
|
||||||
import pro.taskana.common.api.exceptions.NotFoundException;
|
import pro.taskana.common.api.exceptions.NotFoundException;
|
||||||
import pro.taskana.common.api.exceptions.TaskanaException;
|
import pro.taskana.common.api.exceptions.TaskanaException;
|
||||||
import pro.taskana.common.api.exceptions.TaskanaRuntimeException;
|
import pro.taskana.common.api.exceptions.TaskanaRuntimeException;
|
||||||
|
import pro.taskana.common.api.exceptions.WrongCustomHolidayFormatException;
|
||||||
import pro.taskana.common.internal.util.MapCreator;
|
import pro.taskana.common.internal.util.MapCreator;
|
||||||
import pro.taskana.common.rest.models.ExceptionRepresentationModel;
|
import pro.taskana.common.rest.models.ExceptionRepresentationModel;
|
||||||
import pro.taskana.spi.history.api.exceptions.TaskanaHistoryEventNotFoundException;
|
import pro.taskana.spi.history.api.exceptions.TaskanaHistoryEventNotFoundException;
|
||||||
|
@ -127,7 +129,8 @@ public class TaskanaRestExceptionHandler extends ResponseEntityExceptionHandler
|
||||||
InvalidOwnerException.class,
|
InvalidOwnerException.class,
|
||||||
InvalidArgumentException.class,
|
InvalidArgumentException.class,
|
||||||
DomainNotFoundException.class,
|
DomainNotFoundException.class,
|
||||||
TaskanaException.class
|
MalformedServiceLevelException.class,
|
||||||
|
WrongCustomHolidayFormatException.class
|
||||||
})
|
})
|
||||||
protected ResponseEntity<Object> handleBadRequestExceptions(TaskanaException ex, WebRequest req) {
|
protected ResponseEntity<Object> handleBadRequestExceptions(TaskanaException ex, WebRequest req) {
|
||||||
return buildResponse(ex.getErrorCode(), ex, req, HttpStatus.BAD_REQUEST);
|
return buildResponse(ex.getErrorCode(), ex, req, HttpStatus.BAD_REQUEST);
|
||||||
|
@ -141,11 +144,17 @@ public class TaskanaRestExceptionHandler extends ResponseEntityExceptionHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionHandler(TaskanaRuntimeException.class)
|
@ExceptionHandler(TaskanaRuntimeException.class)
|
||||||
protected ResponseEntity<Object> handleInternalServerExceptions(
|
protected ResponseEntity<Object> handleUnknownTaskanaRuntimeExceptions(
|
||||||
TaskanaRuntimeException ex, WebRequest req) {
|
TaskanaRuntimeException ex, WebRequest req) {
|
||||||
return buildResponse(ex.getErrorCode(), ex, req, HttpStatus.INTERNAL_SERVER_ERROR);
|
return buildResponse(ex.getErrorCode(), ex, req, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(TaskanaException.class)
|
||||||
|
protected ResponseEntity<Object> handleUnknownTaskanaExceptions(
|
||||||
|
TaskanaException ex, WebRequest req) {
|
||||||
|
return buildResponse(ex.getErrorCode(), ex, req, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
@ExceptionHandler(Exception.class)
|
@ExceptionHandler(Exception.class)
|
||||||
protected ResponseEntity<Object> handleGeneralException(Exception ex, WebRequest req) {
|
protected ResponseEntity<Object> handleGeneralException(Exception ex, WebRequest req) {
|
||||||
return buildResponse(ErrorCode.of("UNKNOWN_ERROR"), ex, req, HttpStatus.INTERNAL_SERVER_ERROR);
|
return buildResponse(ErrorCode.of("UNKNOWN_ERROR"), ex, req, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
|
|
Loading…
Reference in New Issue