Skip to content

Commit

Permalink
Merge branch 'finalRepoCommentsApis' of github.com:fidelity-contribut…
Browse files Browse the repository at this point in the history
…ions/camunda-camunda-bpm-platform into fidelity-contributions-finalRepoCommentsApis
  • Loading branch information
yanavasileva committed Sep 20, 2024
2 parents ebd3974 + 970ec8d commit 535c773
Show file tree
Hide file tree
Showing 27 changed files with 520 additions and 196 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
id = "deleteProcessInstanceComments"
tag = "Process Instance Comment"
summary = "Delete ProcessInstance Comments"
desc = "Deletes all comments of a processIntance by processInstance id." />
desc = "Deletes all comments of a process instance by id." />

"parameters": [

Expand All @@ -23,6 +23,13 @@
code = "204"
desc = "Request successful." />

<@lib.response
code = "400"
dto = "ExceptionDto"
last = true
desc = "Returned if a given process instance id is invalid.
See the [Introduction](${docsUrl}/reference/rest/overview/#error-handling) for the error response format."/>

<@lib.response
code = "401"
dto = "ExceptionDto"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<@lib.endpointInfo
id = "getProcessInstanceComments"
tag = "Process Instance"
tag = "Process Instance comment"
summary = "Get Process Instance Comments"
desc = "Gets the comments for a process instance by id." />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@
<@lib.response
code = "400"
dto = "ExceptionDto"
desc = "Returned if some of the query parameters are invalid, for example if
the value of `commentId` parameter is supplied as null. See the
[Introduction](${docsUrl}/reference/rest/overview/#error-handling)
for the error response format." />
desc = "Returned if a given process instance id or comment id is invalid.
See the [Introduction](${docsUrl}/reference/rest/overview/#error-handling) for the error response format."/>

<@lib.response
code = "401"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
location = "path"
type = "string"
required = true
desc = "The id of the processInstance." />
desc = "The id of the process instance." />

<@lib.parameter
name = "commentId"
Expand All @@ -32,6 +32,13 @@
code = "204"
desc = "Request successful." />

<@lib.response
code = "400"
dto = "ExceptionDto"
last = true
desc = "Returned if a given process instance id or comment id is invalid.
See the [Introduction](${docsUrl}/reference/rest/overview/#error-handling) for the error response format."/>

<@lib.response
code = "401"
dto = "ExceptionDto"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
code = "204"
desc = "Request successful." />

<@lib.response
code = "400"
dto = "ExceptionDto"
last = true
desc = "Returned if a given task id is invalid.
See the [Introduction](${docsUrl}/reference/rest/overview/#error-handling) for the error response format."/>

<@lib.response
code = "401"
dto = "ExceptionDto"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@
code = "204"
desc = "Request successful." />

<@lib.response
code = "400"
dto = "ExceptionDto"
last = true
desc = "Returned if a given task id or comment id is invalid.
See the [Introduction](${docsUrl}/reference/rest/overview/#error-handling) for the error response format."/>

<@lib.response
code = "401"
dto = "ExceptionDto"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
code = "204"
desc = "Request successful." />

<@lib.response
code = "400"
dto = "ExceptionDto"
last = true
desc = "Returned if a given task id or comment id is invalid.
See the [Introduction](${docsUrl}/reference/rest/overview/#error-handling) for the error response format."/>

<@lib.response
code = "401"
dto = "ExceptionDto"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
import org.camunda.bpm.engine.AuthorizationException;
import org.camunda.bpm.engine.IdentityService;
import org.camunda.bpm.engine.ProcessEngine;
import org.camunda.bpm.engine.ProcessEngineException;
import org.camunda.bpm.engine.TaskService;
import org.camunda.bpm.engine.exception.NotValidException;
import org.camunda.bpm.engine.exception.NullValueException;
import org.camunda.bpm.engine.history.HistoricProcessInstance;
import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl;
Expand Down Expand Up @@ -73,10 +71,10 @@ public void deleteComment(String commentId) {
TaskService taskService = engine.getTaskService();
try {
taskService.deleteProcessInstanceComment(processInstanceId, commentId);
} catch (NotValidException e) {
throw new InvalidRequestException(Status.NOT_FOUND,
"Deletion is not possible. No comment exists for processInstanceId '" + processInstanceId
+ "' and comment id '" + commentId + "'.");
} catch (AuthorizationException e) {
throw e;
} catch (NullValueException e) {
throw new InvalidRequestException(Status.BAD_REQUEST, e.getMessage());
}
}

Expand All @@ -90,16 +88,10 @@ public void updateComment(CommentDto comment) {
TaskService taskService = engine.getTaskService();
try {
taskService.updateProcessInstanceComment(processInstanceId, comment.getId(), comment.getMessage());
} catch (NotValidException e) {
throw new InvalidRequestException(Status.NOT_FOUND,
"Update is not possible. No comment exists for process instance id '" + processInstanceId
+ "' and comment id '" + comment.getId() + "'.");
} catch (AuthorizationException e) {
throw e;
} catch (NullValueException e) {
throw new InvalidRequestException(Status.BAD_REQUEST, e.getMessage());
} catch (ProcessEngineException e) {
throw new InvalidRequestException(Status.BAD_REQUEST, e, "Not enough parameters submitted");
}
}

Expand All @@ -114,9 +106,10 @@ public void deleteComments() {

try {
taskService.deleteProcessInstanceComments(processInstanceId);
} catch (NotValidException e) {
throw new InvalidRequestException(Status.NOT_FOUND,
"Deletion of comments not possible for processInstance id '" + processInstanceId + "'.");
} catch (AuthorizationException e) {
throw e;
} catch (NullValueException e) {
throw new InvalidRequestException(Status.BAD_REQUEST, e.getMessage());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.camunda.bpm.engine.ProcessEngine;
import org.camunda.bpm.engine.ProcessEngineException;
import org.camunda.bpm.engine.TaskService;
import org.camunda.bpm.engine.exception.NotValidException;
import org.camunda.bpm.engine.exception.NullValueException;
import org.camunda.bpm.engine.history.HistoricTaskInstance;
import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl;
Expand Down Expand Up @@ -86,10 +85,10 @@ public void deleteComment(String commentId) {
TaskService taskService = engine.getTaskService();
try {
taskService.deleteTaskComment(taskId, commentId);
} catch (NotValidException e) {
throw new InvalidRequestException(Status.NOT_FOUND,
"Deletion is not possible. No comment exists for task id '" + taskId + "' and comment id '" + commentId
+ "'.");
} catch (AuthorizationException e) {
throw e;
} catch (NullValueException e) {
throw new InvalidRequestException(Status.BAD_REQUEST, e.getMessage());
}
}

Expand All @@ -99,16 +98,10 @@ public void updateComment(CommentDto comment) {

try {
engine.getTaskService().updateTaskComment(taskId, comment.getId(), comment.getMessage());
} catch (NotValidException e) {
throw new InvalidRequestException(Status.NOT_FOUND,
"Update is not possible. No comment exists for task id '" + taskId + "' and comment id '" + comment.getId()
+ "'.");
} catch (AuthorizationException e) {
throw e;
} catch (NullValueException e) {
throw new InvalidRequestException(Status.BAD_REQUEST, e.getMessage());
} catch (ProcessEngineException e) {
throw new InvalidRequestException(Status.BAD_REQUEST, e, "Not enough parameters submitted");
}
}

Expand All @@ -119,9 +112,10 @@ public void deleteComments() {

try {
taskService.deleteTaskComments(taskId);
} catch (NotValidException e) {
throw new InvalidRequestException(Status.NOT_FOUND,
"Deletion of comments not possible for task id '" + taskId + "'.");
} catch (AuthorizationException e) {
throw e;
} catch (NullValueException e) {
throw new InvalidRequestException(Status.BAD_REQUEST, e.getMessage());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,8 @@ public void testDeleteInstanceComment() {
.statusCode(Status.NO_CONTENT.getStatusCode())
.when()
.delete(SINGLE_PROCESS_INSTANCE_SINGLE_COMMENT_URL);

verify(taskServiceMock).deleteProcessInstanceComment(EXAMPLE_PROCESS_INSTANCE_ID, EXAMPLE_PROCESS_INSTANCE_COMMENT_ID);
}

@Test
Expand Down Expand Up @@ -902,11 +904,8 @@ public void testDeleteInstanceCommentForNonExistingCommentId() {
.header("accept", MediaType.APPLICATION_JSON)
.then()
.expect()
.statusCode(Status.NOT_FOUND.getStatusCode())
.statusCode(Status.BAD_REQUEST.getStatusCode())
.contentType(ContentType.JSON)
.body(containsString(
"Deletion is not possible. No comment exists for processInstanceId '" + EXAMPLE_PROCESS_INSTANCE_ID
+ "' and comment id '" + NON_EXISTING_ID + "'."))
.when()
.delete(SINGLE_PROCESS_INSTANCE_SINGLE_COMMENT_URL);
}
Expand Down Expand Up @@ -986,6 +985,8 @@ public void testDeleteProcessInstanceComments() {
.statusCode(Status.NO_CONTENT.getStatusCode())
.when()
.delete(PROCESS_INSTANCE_COMMENTS_URL);

verify(taskServiceMock).deleteProcessInstanceComments(EXAMPLE_PROCESS_INSTANCE_ID);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3751,6 +3751,7 @@ public void testDeleteTaskComment() {
.statusCode(Status.NO_CONTENT.getStatusCode())
.when()
.delete(SINGLE_TASK_SINGLE_COMMENT_URL);
verify(taskServiceMock).deleteTaskComment(EXAMPLE_TASK_ID, EXAMPLE_TASK_COMMENT_ID );
}

@Test
Expand All @@ -3777,11 +3778,8 @@ public void testDeleteTaskCommentForNonExistingCommentId() {
.header("accept", MediaType.APPLICATION_JSON)
.then()
.expect()
.statusCode(Status.NOT_FOUND.getStatusCode())
.statusCode(Status.BAD_REQUEST.getStatusCode())
.contentType(ContentType.JSON)
.body(containsString(
"Deletion is not possible. No comment exists for task id '" + EXAMPLE_TASK_ID + "' and comment id '"
+ NON_EXISTING_ID + "'."))
.when()
.delete(SINGLE_TASK_SINGLE_COMMENT_URL);
}
Expand Down Expand Up @@ -3855,6 +3853,7 @@ public void testDeleteTaskComments() {
.statusCode(Status.NO_CONTENT.getStatusCode())
.when()
.delete(SINGLE_TASK_COMMENTS_URL);
verify(taskServiceMock).deleteTaskComments(EXAMPLE_TASK_ID);
}

@Test
Expand Down
13 changes: 7 additions & 6 deletions engine/src/main/java/org/camunda/bpm/engine/TaskService.java
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,7 @@ public interface TaskService {
* @param commentId id of a comment that is intended to be deleted
* @throws NotFoundException if no task with the given id exists
* @throws BadUserRequestException if task id or error code were null or empty
* @throws BadUserRequestException when given both task and comment ids are null
* @throws ProcessEngineException when task and comment don't exist with the given taskId and commentId
* @throws AuthorizationException If the user hasn't any of {@link Permissions#UPDATE}, {@link Permissions#TASK_WORK} permissions on {@link Resources#TASK}
* or no {@link Permissions#UPDATE_TASK}, {@link Permissions#TASK_WORK} permissions on {@link Resources#PROCESS_DEFINITION}
Expand Down Expand Up @@ -1177,12 +1178,12 @@ public interface TaskService {
* @param processInstanceId id of a process instance of a comment that is intended to be updated
* @param commentId id of a comment that is intended to be updated
* @param message new message that needs to be updated
* @throws NotFoundException if no process instance with the given processInstanceId id exists
* @throws NotFoundException if no comment found to be updated for a given comment id
* @throws ProcessEngineException when given process instance id and comment id are passed as null
* @throws AuthorizationException If the user hasn't any of {@link Permissions#UPDATE}, {@link Permissions#TASK_WORK} permissions on {@link Resources#TASK}
* or no {@link Permissions#UPDATE_TASK}, {@link Permissions#TASK_WORK} permissions on {@link Resources#PROCESS_DEFINITION}
* (if the task is part of a running process instance).
* @throws NotFoundException if no process instance with the given processInstanceId id exists
* @throws NotFoundException if no comment found to be updated for a given comment id
* @throws BadUserRequestException when given both process instance id and comment id are passed as null
* @throws AuthorizationException If the user hasn't any of {@link Permissions#UPDATE}, {@link Permissions#TASK_WORK} permissions on {@link Resources#TASK}
* or no {@link Permissions#UPDATE_TASK}, {@link Permissions#TASK_WORK} permissions on {@link Resources#PROCESS_DEFINITION}
* (if the task is part of a running process instance).
*/
void updateProcessInstanceComment(String processInstanceId, String commentId, String message);

Expand Down
Loading

0 comments on commit 535c773

Please sign in to comment.