TSK-1150: added taskId as pathvariable to getTaskComment and deleteTaskComment
this is necessary since the path variable {taskId} is not used otherwise. Furthermore this will require that the search for a comment must match a given taskId.
This commit is contained in:
parent
ce571722d5
commit
93a94f0458
|
@ -414,6 +414,7 @@ public interface TaskService {
|
||||||
/**
|
/**
|
||||||
* Deletes the task comment with the given Id.
|
* Deletes the task comment with the given Id.
|
||||||
*
|
*
|
||||||
|
* @param taskId The task id where the comment is supposed to be attached to
|
||||||
* @param taskCommentId The id of the task comment to delete.
|
* @param taskCommentId The id of the task comment to delete.
|
||||||
* @throws NotAuthorizedException If the current user has no authorization to delete a task
|
* @throws NotAuthorizedException If the current user has no authorization to delete a task
|
||||||
* comment or is not authorized to access the task.
|
* comment or is not authorized to access the task.
|
||||||
|
@ -424,13 +425,14 @@ public interface TaskService {
|
||||||
* existing task.
|
* existing task.
|
||||||
* @throws InvalidArgumentException If the given taskCommentId is null or empty
|
* @throws InvalidArgumentException If the given taskCommentId is null or empty
|
||||||
*/
|
*/
|
||||||
void deleteTaskComment(String taskCommentId)
|
void deleteTaskComment(String taskId, String taskCommentId)
|
||||||
throws NotAuthorizedException, TaskCommentNotFoundException, TaskNotFoundException,
|
throws NotAuthorizedException, TaskCommentNotFoundException, TaskNotFoundException,
|
||||||
InvalidArgumentException;
|
InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a task comment for a given taskCommentId.
|
* Retrieves a task comment for a given taskCommentId.
|
||||||
*
|
*
|
||||||
|
* @param taskId The task id where the comment is supposed to be attached to
|
||||||
* @param taskCommentId The id of the task comment which should be retrieved
|
* @param taskCommentId The id of the task comment which should be retrieved
|
||||||
* @return the task comment identified by taskCommentId
|
* @return the task comment identified by taskCommentId
|
||||||
* @throws TaskCommentNotFoundException If the given taskCommentId in the TaskComment does not
|
* @throws TaskCommentNotFoundException If the given taskCommentId in the TaskComment does not
|
||||||
|
@ -441,7 +443,7 @@ public interface TaskService {
|
||||||
* existing task.
|
* existing task.
|
||||||
* @throws InvalidArgumentException If the given taskCommentId is null or empty
|
* @throws InvalidArgumentException If the given taskCommentId is null or empty
|
||||||
*/
|
*/
|
||||||
TaskComment getTaskComment(String taskCommentId)
|
TaskComment getTaskComment(String taskId, String taskCommentId)
|
||||||
throws TaskCommentNotFoundException, NotAuthorizedException, TaskNotFoundException,
|
throws TaskCommentNotFoundException, NotAuthorizedException, TaskNotFoundException,
|
||||||
InvalidArgumentException;
|
InvalidArgumentException;
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ public interface TaskCommentMapper {
|
||||||
"<script> SELECT ID, TASK_ID, TEXT_FIELD, CREATOR, CREATED, MODIFIED"
|
"<script> SELECT ID, TASK_ID, TEXT_FIELD, CREATOR, CREATED, MODIFIED"
|
||||||
+ " FROM TASK_COMMENT "
|
+ " FROM TASK_COMMENT "
|
||||||
+ "WHERE ID = #{taskCommentId} "
|
+ "WHERE ID = #{taskCommentId} "
|
||||||
|
+ "AND TASK_ID = #{taskId} "
|
||||||
+ "<if test=\"_databaseId == 'db2'\">with UR </if> "
|
+ "<if test=\"_databaseId == 'db2'\">with UR </if> "
|
||||||
+ "</script>")
|
+ "</script>")
|
||||||
@Results(
|
@Results(
|
||||||
|
@ -60,5 +61,6 @@ public interface TaskCommentMapper {
|
||||||
@Result(property = "created", column = "CREATED"),
|
@Result(property = "created", column = "CREATED"),
|
||||||
@Result(property = "modified", column = "MODIFIED"),
|
@Result(property = "modified", column = "MODIFIED"),
|
||||||
})
|
})
|
||||||
TaskCommentImpl findById(@Param("taskCommentId") String taskCommentId);
|
TaskCommentImpl findById(
|
||||||
|
@Param("taskId") String taskId, @Param("taskCommentId") String taskCommentId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package pro.taskana.task.internal;
|
package pro.taskana.task.internal;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ class TaskCommentServiceImpl {
|
||||||
|
|
||||||
TaskComment updateTaskComment(TaskComment taskCommentToUpdate)
|
TaskComment updateTaskComment(TaskComment taskCommentToUpdate)
|
||||||
throws NotAuthorizedException, ConcurrencyException, TaskCommentNotFoundException,
|
throws NotAuthorizedException, ConcurrencyException, TaskCommentNotFoundException,
|
||||||
TaskNotFoundException, InvalidArgumentException {
|
TaskNotFoundException, InvalidArgumentException {
|
||||||
|
|
||||||
LOGGER.debug("entry to updateTaskComment (taskComment = {})", taskCommentToUpdate);
|
LOGGER.debug("entry to updateTaskComment (taskComment = {})", taskCommentToUpdate);
|
||||||
|
|
||||||
|
@ -72,7 +72,8 @@ class TaskCommentServiceImpl {
|
||||||
if (taskCommentToUpdate.getCreator().equals(userId)
|
if (taskCommentToUpdate.getCreator().equals(userId)
|
||||||
|| taskanaEngine.getEngine().isUserInRole(TaskanaRole.ADMIN)) {
|
|| taskanaEngine.getEngine().isUserInRole(TaskanaRole.ADMIN)) {
|
||||||
|
|
||||||
TaskComment oldTaskComment = getTaskComment(taskCommentImplToUpdate.getId());
|
TaskComment oldTaskComment =
|
||||||
|
getTaskComment(taskCommentImplToUpdate.getTaskId(), taskCommentImplToUpdate.getId());
|
||||||
|
|
||||||
checkModifiedHasNotChanged(oldTaskComment, taskCommentImplToUpdate);
|
checkModifiedHasNotChanged(oldTaskComment, taskCommentImplToUpdate);
|
||||||
|
|
||||||
|
@ -127,11 +128,12 @@ class TaskCommentServiceImpl {
|
||||||
return taskCommentImplToCreate;
|
return taskCommentImplToCreate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void deleteTaskComment(String taskCommentId)
|
void deleteTaskComment(String taskId, String taskCommentId)
|
||||||
throws NotAuthorizedException, TaskCommentNotFoundException, TaskNotFoundException,
|
throws NotAuthorizedException, TaskCommentNotFoundException, TaskNotFoundException,
|
||||||
InvalidArgumentException {
|
InvalidArgumentException {
|
||||||
|
|
||||||
LOGGER.debug("entry to deleteTaskComment (taskComment = {}", taskCommentId);
|
LOGGER.debug(
|
||||||
|
"entry to deleteTaskComment (taskId = {}, taskComment = {}", taskId, taskCommentId);
|
||||||
|
|
||||||
String userId = CurrentUserContext.getUserid();
|
String userId = CurrentUserContext.getUserid();
|
||||||
|
|
||||||
|
@ -139,7 +141,7 @@ class TaskCommentServiceImpl {
|
||||||
|
|
||||||
taskanaEngine.openConnection();
|
taskanaEngine.openConnection();
|
||||||
|
|
||||||
TaskComment taskCommentToDelete = getTaskComment(taskCommentId);
|
TaskComment taskCommentToDelete = getTaskComment(taskId, taskCommentId);
|
||||||
|
|
||||||
if (taskCommentToDelete.getCreator().equals(userId)
|
if (taskCommentToDelete.getCreator().equals(userId)
|
||||||
|| taskanaEngine.getEngine().isUserInRole(TaskanaRole.ADMIN)) {
|
|| taskanaEngine.getEngine().isUserInRole(TaskanaRole.ADMIN)) {
|
||||||
|
@ -171,8 +173,7 @@ class TaskCommentServiceImpl {
|
||||||
|
|
||||||
taskService.getTask(taskId);
|
taskService.getTask(taskId);
|
||||||
|
|
||||||
List<TaskComment> taskComments =
|
List<TaskComment> taskComments = new ArrayList<>(taskCommentMapper.findByTaskId(taskId));
|
||||||
taskCommentMapper.findByTaskId(taskId).stream().collect(Collectors.toList());
|
|
||||||
|
|
||||||
if (taskComments.isEmpty()) {
|
if (taskComments.isEmpty()) {
|
||||||
LOGGER.debug("getTaskComments() found no comments for the provided taskId");
|
LOGGER.debug("getTaskComments() found no comments for the provided taskId");
|
||||||
|
@ -188,13 +189,13 @@ class TaskCommentServiceImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskComment getTaskComment(String taskCommentId)
|
TaskComment getTaskComment(String taskId, String taskCommentId)
|
||||||
throws TaskCommentNotFoundException, NotAuthorizedException, TaskNotFoundException,
|
throws TaskCommentNotFoundException, NotAuthorizedException, TaskNotFoundException,
|
||||||
InvalidArgumentException {
|
InvalidArgumentException {
|
||||||
|
|
||||||
LOGGER.debug("entry to getTaskComment (taskCommentId = {})", taskCommentId);
|
LOGGER.debug("entry to getTaskComment (taskId= {}, taskCommentId = {})", taskId, taskCommentId);
|
||||||
|
|
||||||
TaskCommentImpl result = null;
|
TaskCommentImpl result;
|
||||||
|
|
||||||
verifyTaskCommentIdIsNotNullOrEmpty(taskCommentId);
|
verifyTaskCommentIdIsNotNullOrEmpty(taskCommentId);
|
||||||
|
|
||||||
|
@ -202,11 +203,14 @@ class TaskCommentServiceImpl {
|
||||||
|
|
||||||
taskanaEngine.openConnection();
|
taskanaEngine.openConnection();
|
||||||
|
|
||||||
result = taskCommentMapper.findById(taskCommentId);
|
result = taskCommentMapper.findById(taskId, taskCommentId);
|
||||||
|
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
throw new TaskCommentNotFoundException(
|
throw new TaskCommentNotFoundException(
|
||||||
taskCommentId, "TaskComment for id " + taskCommentId + " was not found");
|
taskCommentId,
|
||||||
|
String.format(
|
||||||
|
"TaskComment for taskIid '%s' and taskCommentId '%s' was not found",
|
||||||
|
taskId, taskCommentId));
|
||||||
}
|
}
|
||||||
|
|
||||||
taskService.getTask(result.getTaskId());
|
taskService.getTask(result.getTaskId());
|
||||||
|
|
|
@ -614,17 +614,17 @@ public class TaskServiceImpl implements TaskService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteTaskComment(String taskCommentId)
|
public void deleteTaskComment(String taskId, String taskCommentId)
|
||||||
throws NotAuthorizedException, TaskCommentNotFoundException, TaskNotFoundException,
|
throws NotAuthorizedException, TaskCommentNotFoundException, TaskNotFoundException,
|
||||||
InvalidArgumentException {
|
InvalidArgumentException {
|
||||||
taskCommentService.deleteTaskComment(taskCommentId);
|
taskCommentService.deleteTaskComment(taskId, taskCommentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TaskComment getTaskComment(String taskCommentid)
|
public TaskComment getTaskComment(String taskId, String taskCommentid)
|
||||||
throws TaskCommentNotFoundException, NotAuthorizedException, TaskNotFoundException,
|
throws TaskCommentNotFoundException, NotAuthorizedException, TaskNotFoundException,
|
||||||
InvalidArgumentException {
|
InvalidArgumentException {
|
||||||
return taskCommentService.getTaskComment(taskCommentid);
|
return taskCommentService.getTaskComment(taskId, taskCommentid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -698,9 +698,7 @@ public class TaskServiceImpl implements TaskService {
|
||||||
return bulkLog;
|
return bulkLog;
|
||||||
} else {
|
} else {
|
||||||
final int numberOfAffectedTasks = taskMapper.setOwnerOfTasks(owner, taskIds, Instant.now());
|
final int numberOfAffectedTasks = taskMapper.setOwnerOfTasks(owner, taskIds, Instant.now());
|
||||||
if (numberOfAffectedTasks == taskIds.size()) { // all tasks were updated
|
if (numberOfAffectedTasks != taskIds.size()) { // all tasks were updated
|
||||||
return bulkLog;
|
|
||||||
} else {
|
|
||||||
// check the outcome
|
// check the outcome
|
||||||
existingMinimalTaskSummaries = taskMapper.findExistingTasks(taskIds, null);
|
existingMinimalTaskSummaries = taskMapper.findExistingTasks(taskIds, null);
|
||||||
bulkLog.addAllErrors(
|
bulkLog.addAllErrors(
|
||||||
|
@ -713,8 +711,8 @@ public class TaskServiceImpl implements TaskService {
|
||||||
numberOfAffectedTasks,
|
numberOfAffectedTasks,
|
||||||
bulkLog.getFailedIds().size());
|
bulkLog.getFailedIds().size());
|
||||||
}
|
}
|
||||||
return bulkLog;
|
|
||||||
}
|
}
|
||||||
|
return bulkLog;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
LOGGER.debug("exit from setOwnerOfTasks()");
|
LOGGER.debug("exit from setOwnerOfTasks()");
|
||||||
|
|
|
@ -39,7 +39,8 @@ public class DeleteTaskCommentAccTest extends AbstractAccTest {
|
||||||
taskService.getTaskComments("TKI:000000000000000000000000000000000001");
|
taskService.getTaskComments("TKI:000000000000000000000000000000000001");
|
||||||
assertThat(taskComments).hasSize(2);
|
assertThat(taskComments).hasSize(2);
|
||||||
|
|
||||||
taskService.deleteTaskComment("TCI:000000000000000000000000000000000004");
|
taskService.deleteTaskComment(
|
||||||
|
"TKI:000000000000000000000000000000000001", "TCI:000000000000000000000000000000000004");
|
||||||
|
|
||||||
// make sure the task comment was deleted
|
// make sure the task comment was deleted
|
||||||
List<TaskComment> taskCommentsAfterDeletion =
|
List<TaskComment> taskCommentsAfterDeletion =
|
||||||
|
@ -60,11 +61,12 @@ public class DeleteTaskCommentAccTest extends AbstractAccTest {
|
||||||
taskService.getTaskComments("TKI:000000000000000000000000000000000002");
|
taskService.getTaskComments("TKI:000000000000000000000000000000000002");
|
||||||
assertThat(taskComments).hasSize(2);
|
assertThat(taskComments).hasSize(2);
|
||||||
|
|
||||||
ThrowingCallable httpCall =
|
ThrowingCallable lambda =
|
||||||
() -> {
|
() ->
|
||||||
taskService.deleteTaskComment("TCI:000000000000000000000000000000000005");
|
taskService.deleteTaskComment(
|
||||||
};
|
"TKI:000000000000000000000000000000000001",
|
||||||
assertThatThrownBy(httpCall).isInstanceOf(NotAuthorizedException.class);
|
"TCI:000000000000000000000000000000000005");
|
||||||
|
assertThatThrownBy(lambda).isInstanceOf(NotAuthorizedException.class);
|
||||||
|
|
||||||
// make sure the task comment was not deleted
|
// make sure the task comment was not deleted
|
||||||
List<TaskComment> taskCommentsAfterDeletion =
|
List<TaskComment> taskCommentsAfterDeletion =
|
||||||
|
@ -85,10 +87,16 @@ public class DeleteTaskCommentAccTest extends AbstractAccTest {
|
||||||
taskService.getTaskComments("TKI:000000000000000000000000000000000002");
|
taskService.getTaskComments("TKI:000000000000000000000000000000000002");
|
||||||
assertThat(taskComments).hasSize(2);
|
assertThat(taskComments).hasSize(2);
|
||||||
|
|
||||||
assertThatThrownBy(() -> taskService.deleteTaskComment(""))
|
assertThatThrownBy(() -> taskService.deleteTaskComment("", ""))
|
||||||
.isInstanceOf(InvalidArgumentException.class);
|
.isInstanceOf(InvalidArgumentException.class);
|
||||||
|
|
||||||
assertThatThrownBy(() -> taskService.deleteTaskComment(null))
|
assertThatThrownBy(() -> taskService.deleteTaskComment("", null))
|
||||||
|
.isInstanceOf(InvalidArgumentException.class);
|
||||||
|
|
||||||
|
assertThatThrownBy(() -> taskService.deleteTaskComment(null, ""))
|
||||||
|
.isInstanceOf(InvalidArgumentException.class);
|
||||||
|
|
||||||
|
assertThatThrownBy(() -> taskService.deleteTaskComment(null, null))
|
||||||
.isInstanceOf(InvalidArgumentException.class);
|
.isInstanceOf(InvalidArgumentException.class);
|
||||||
|
|
||||||
// make sure that no task comment was deleted
|
// make sure that no task comment was deleted
|
||||||
|
@ -110,8 +118,9 @@ public class DeleteTaskCommentAccTest extends AbstractAccTest {
|
||||||
taskService.getTaskComments("TKI:000000000000000000000000000000000002");
|
taskService.getTaskComments("TKI:000000000000000000000000000000000002");
|
||||||
assertThat(taskComments).hasSize(2);
|
assertThat(taskComments).hasSize(2);
|
||||||
|
|
||||||
assertThatThrownBy(() -> taskService.deleteTaskComment("non existing task comment id"))
|
ThrowingCallable lambda =
|
||||||
.isInstanceOf(TaskCommentNotFoundException.class);
|
() -> taskService.deleteTaskComment("invalidTaskId", "non existing task comment id");
|
||||||
|
assertThatThrownBy(lambda).isInstanceOf(TaskCommentNotFoundException.class);
|
||||||
|
|
||||||
// make sure the task comment was not deleted
|
// make sure the task comment was not deleted
|
||||||
List<TaskComment> taskCommentsAfterDeletion =
|
List<TaskComment> taskCommentsAfterDeletion =
|
||||||
|
|
|
@ -77,7 +77,8 @@ public class GetTaskCommentAccTest extends AbstractAccTest {
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
|
|
||||||
TaskComment taskComment =
|
TaskComment taskComment =
|
||||||
taskService.getTaskComment("TCI:000000000000000000000000000000000007");
|
taskService.getTaskComment(
|
||||||
|
"TKI:000000000000000000000000000000000002", "TCI:000000000000000000000000000000000007");
|
||||||
assertThat(taskComment.getCreator()).isEqualTo("user_1_1");
|
assertThat(taskComment.getCreator()).isEqualTo("user_1_1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,8 +90,11 @@ public class GetTaskCommentAccTest extends AbstractAccTest {
|
||||||
|
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
|
|
||||||
assertThatThrownBy(() -> taskService.getTaskComment("Definately Non Existing Task Comment Id"))
|
ThrowingCallable lambda =
|
||||||
.isInstanceOf(TaskCommentNotFoundException.class);
|
() ->
|
||||||
|
taskService.getTaskComment(
|
||||||
|
"Invalid Task Id", "Definately Non Existing Task Comment Id");
|
||||||
|
assertThatThrownBy(lambda).isInstanceOf(TaskCommentNotFoundException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@WithAccessId(
|
@WithAccessId(
|
||||||
|
@ -101,7 +105,11 @@ public class GetTaskCommentAccTest extends AbstractAccTest {
|
||||||
|
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
|
|
||||||
assertThatThrownBy(() -> taskService.getTaskComment("TCI:000000000000000000000000000000000012"))
|
ThrowingCallable lambda =
|
||||||
.isInstanceOf(NotAuthorizedException.class);
|
() ->
|
||||||
|
taskService.getTaskComment(
|
||||||
|
"TKI:000000000000000000000000000000000004",
|
||||||
|
"TCI:000000000000000000000000000000000012");
|
||||||
|
assertThatThrownBy(lambda).isInstanceOf(NotAuthorizedException.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,8 @@ public class UpdateTaskCommentAccTest extends AbstractAccTest {
|
||||||
assertThat(taskComments.get(0).getTextField()).isEqualTo("some text in textfield");
|
assertThat(taskComments.get(0).getTextField()).isEqualTo("some text in textfield");
|
||||||
|
|
||||||
TaskComment taskComment =
|
TaskComment taskComment =
|
||||||
taskService.getTaskComment("TCI:000000000000000000000000000000000003");
|
taskService.getTaskComment(
|
||||||
|
"TKI:000000000000000000000000000000000025", "TCI:000000000000000000000000000000000003");
|
||||||
taskComment.setTextField("updated textfield");
|
taskComment.setTextField("updated textfield");
|
||||||
|
|
||||||
taskService.updateTaskComment(taskComment);
|
taskService.updateTaskComment(taskComment);
|
||||||
|
@ -67,7 +68,8 @@ public class UpdateTaskCommentAccTest extends AbstractAccTest {
|
||||||
assertThat(taskComments.get(1).getTextField()).isEqualTo("some other text in textfield");
|
assertThat(taskComments.get(1).getTextField()).isEqualTo("some other text in textfield");
|
||||||
|
|
||||||
TaskComment taskComment =
|
TaskComment taskComment =
|
||||||
taskService.getTaskComment("TCI:000000000000000000000000000000000001");
|
taskService.getTaskComment(
|
||||||
|
"TKI:000000000000000000000000000000000000", "TCI:000000000000000000000000000000000001");
|
||||||
taskComment.setTextField("updated textfield");
|
taskComment.setTextField("updated textfield");
|
||||||
|
|
||||||
assertThatThrownBy(() -> taskService.updateTaskComment(taskComment))
|
assertThatThrownBy(() -> taskService.updateTaskComment(taskComment))
|
||||||
|
@ -96,11 +98,13 @@ public class UpdateTaskCommentAccTest extends AbstractAccTest {
|
||||||
assertThat(taskComments.get(2).getTextField()).isEqualTo("some other text in textfield");
|
assertThat(taskComments.get(2).getTextField()).isEqualTo("some other text in textfield");
|
||||||
|
|
||||||
TaskComment taskCommentToUpdate =
|
TaskComment taskCommentToUpdate =
|
||||||
taskService.getTaskComment("TCI:000000000000000000000000000000000002");
|
taskService.getTaskComment(
|
||||||
|
"TKI:000000000000000000000000000000000000", "TCI:000000000000000000000000000000000002");
|
||||||
taskCommentToUpdate.setTextField("updated textfield");
|
taskCommentToUpdate.setTextField("updated textfield");
|
||||||
|
|
||||||
TaskComment concurrentTaskCommentToUpdate =
|
TaskComment concurrentTaskCommentToUpdate =
|
||||||
taskService.getTaskComment("TCI:000000000000000000000000000000000002");
|
taskService.getTaskComment(
|
||||||
|
"TKI:000000000000000000000000000000000000", "TCI:000000000000000000000000000000000002");
|
||||||
concurrentTaskCommentToUpdate.setTextField("concurrently updated textfield");
|
concurrentTaskCommentToUpdate.setTextField("concurrently updated textfield");
|
||||||
|
|
||||||
taskService.updateTaskComment(taskCommentToUpdate);
|
taskService.updateTaskComment(taskCommentToUpdate);
|
||||||
|
|
|
@ -43,17 +43,17 @@ public class TaskCommentController {
|
||||||
this.taskCommentResourceAssembler = taskCommentResourceAssembler;
|
this.taskCommentResourceAssembler = taskCommentResourceAssembler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping(path = Mapping.URL_TASK_COMMENT)
|
@GetMapping(path = Mapping.URL_TASK_COMMENT)
|
||||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||||
public ResponseEntity<TaskCommentResource> getTaskComment(@PathVariable String taskCommentId)
|
public ResponseEntity<TaskCommentResource> getTaskComment(
|
||||||
|
@PathVariable String taskId, @PathVariable String taskCommentId)
|
||||||
throws NotAuthorizedException, TaskNotFoundException, TaskCommentNotFoundException,
|
throws NotAuthorizedException, TaskNotFoundException, TaskCommentNotFoundException,
|
||||||
InvalidArgumentException {
|
InvalidArgumentException {
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isDebugEnabled()) {
|
||||||
LOGGER.debug("Entry to getTaskComment(taskCommentId= {})", taskCommentId);
|
LOGGER.debug("Entry to getTaskComment(taskId= {}, taskCommentId= {})", taskId, taskCommentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskComment taskComment = taskService.getTaskComment(taskCommentId);
|
TaskComment taskComment = taskService.getTaskComment(taskId, taskCommentId);
|
||||||
|
|
||||||
TaskCommentResource taskCommentResource = taskCommentResourceAssembler.toResource(taskComment);
|
TaskCommentResource taskCommentResource = taskCommentResourceAssembler.toResource(taskComment);
|
||||||
|
|
||||||
|
@ -90,14 +90,16 @@ public class TaskCommentController {
|
||||||
|
|
||||||
@DeleteMapping(path = Mapping.URL_TASK_COMMENT)
|
@DeleteMapping(path = Mapping.URL_TASK_COMMENT)
|
||||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||||
public ResponseEntity<TaskCommentResource> deleteTaskComment(@PathVariable String taskCommentId)
|
public ResponseEntity<TaskCommentResource> deleteTaskComment(
|
||||||
|
@PathVariable String taskId, @PathVariable String taskCommentId)
|
||||||
throws NotAuthorizedException, TaskNotFoundException, TaskCommentNotFoundException,
|
throws NotAuthorizedException, TaskNotFoundException, TaskCommentNotFoundException,
|
||||||
InvalidArgumentException {
|
InvalidArgumentException {
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isDebugEnabled()) {
|
||||||
LOGGER.debug("Entry to deleteTaskComment(taskCommentId= {})", taskCommentId);
|
LOGGER.debug(
|
||||||
|
"Entry to deleteTaskComment(taskId= {}, taskCommentId= {})", taskId, taskCommentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
taskService.deleteTaskComment(taskCommentId);
|
taskService.deleteTaskComment(taskId, taskCommentId);
|
||||||
|
|
||||||
ResponseEntity<TaskCommentResource> result = ResponseEntity.noContent().build();
|
ResponseEntity<TaskCommentResource> result = ResponseEntity.noContent().build();
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,9 @@ public class TaskCommentResourceAssembler
|
||||||
TaskCommentResource taskCommentResource = new TaskCommentResource(taskComment);
|
TaskCommentResource taskCommentResource = new TaskCommentResource(taskComment);
|
||||||
try {
|
try {
|
||||||
taskCommentResource.add(
|
taskCommentResource.add(
|
||||||
linkTo(methodOn(TaskCommentController.class).getTaskComment(taskComment.getId()))
|
linkTo(
|
||||||
|
methodOn(TaskCommentController.class)
|
||||||
|
.getTaskComment(taskComment.getTaskId(), taskComment.getId()))
|
||||||
.withSelfRel());
|
.withSelfRel());
|
||||||
} catch (TaskCommentNotFoundException
|
} catch (TaskCommentNotFoundException
|
||||||
| TaskNotFoundException
|
| TaskNotFoundException
|
||||||
|
@ -54,8 +56,7 @@ public class TaskCommentResourceAssembler
|
||||||
}
|
}
|
||||||
|
|
||||||
@PageLinks(Mapping.URL_TASK_COMMENTS)
|
@PageLinks(Mapping.URL_TASK_COMMENTS)
|
||||||
public TaskCommentListResource toListResource(
|
public TaskCommentListResource toListResource(List<TaskComment> taskComments) {
|
||||||
List<TaskComment> taskComments) {
|
|
||||||
return new TaskCommentListResource(toResources(taskComments));
|
return new TaskCommentListResource(toResources(taskComments));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ import pro.taskana.rest.Mapping;
|
||||||
|
|
||||||
public class TaskCommentControllerRestDocumentation extends BaseRestDocumentation {
|
public class TaskCommentControllerRestDocumentation extends BaseRestDocumentation {
|
||||||
|
|
||||||
private HashMap<String, String> taskCommentFieldDescriptionsMap = new HashMap<String, String>();
|
private HashMap<String, String> taskCommentFieldDescriptionsMap = new HashMap<>();
|
||||||
|
|
||||||
private FieldDescriptor[] allTaskCommentsFieldDescriptors;
|
private FieldDescriptor[] allTaskCommentsFieldDescriptors;
|
||||||
private FieldDescriptor[] taskCommentFieldDescriptors;
|
private FieldDescriptor[] taskCommentFieldDescriptors;
|
||||||
|
@ -58,8 +58,7 @@ public class TaskCommentControllerRestDocumentation extends BaseRestDocumentatio
|
||||||
.type("String"),
|
.type("String"),
|
||||||
fieldWithPath("_links").ignored(),
|
fieldWithPath("_links").ignored(),
|
||||||
fieldWithPath("_links.self").ignored(),
|
fieldWithPath("_links.self").ignored(),
|
||||||
fieldWithPath("_links.self.href").ignored(),
|
fieldWithPath("_links.self.href").ignored()
|
||||||
fieldWithPath("_links.self.templated").ignored()
|
|
||||||
};
|
};
|
||||||
|
|
||||||
createTaskCommentFieldDescriptors =
|
createTaskCommentFieldDescriptors =
|
||||||
|
@ -110,7 +109,7 @@ public class TaskCommentControllerRestDocumentation extends BaseRestDocumentatio
|
||||||
RestDocumentationRequestBuilders.get(
|
RestDocumentationRequestBuilders.get(
|
||||||
restHelper.toUrl(
|
restHelper.toUrl(
|
||||||
Mapping.URL_TASK_COMMENT,
|
Mapping.URL_TASK_COMMENT,
|
||||||
"TKI:100000000000000000000000000000000000",
|
"TKI:000000000000000000000000000000000000",
|
||||||
"TCI:000000000000000000000000000000000000"))
|
"TCI:000000000000000000000000000000000000"))
|
||||||
.accept("application/hal+json")
|
.accept("application/hal+json")
|
||||||
.header("Authorization", "Basic YWRtaW46YWRtaW4="))
|
.header("Authorization", "Basic YWRtaW46YWRtaW4="))
|
||||||
|
|
Loading…
Reference in New Issue