reformatted code

This commit is contained in:
Mustapha Zorgati 2020-06-12 11:39:04 +02:00
parent 02e05a7d3b
commit a2318c267e
58 changed files with 327 additions and 442 deletions

View File

@ -13,9 +13,7 @@ import pro.taskana.spi.history.api.TaskanaHistory;
import pro.taskana.spi.history.api.events.TaskanaHistoryEvent; import pro.taskana.spi.history.api.events.TaskanaHistoryEvent;
import pro.taskana.spi.history.api.exceptions.TaskanaHistoryEventNotFoundException; import pro.taskana.spi.history.api.exceptions.TaskanaHistoryEventNotFoundException;
/** /** This is the implementation of TaskanaHistory. */
* This is the implementation of TaskanaHistory.
*/
public class SimpleHistoryServiceImpl implements TaskanaHistory { public class SimpleHistoryServiceImpl implements TaskanaHistory {
private static final Logger LOGGER = LoggerFactory.getLogger(SimpleHistoryServiceImpl.class); private static final Logger LOGGER = LoggerFactory.getLogger(SimpleHistoryServiceImpl.class);
@ -25,7 +23,7 @@ public class SimpleHistoryServiceImpl implements TaskanaHistory {
@Override @Override
public void initialize(TaskanaEngineConfiguration taskanaEngineConfiguration) { public void initialize(TaskanaEngineConfiguration taskanaEngineConfiguration) {
this.taskanaHistoryEngine = getTaskanaEngine(taskanaEngineConfiguration); this.taskanaHistoryEngine = getTaskanaEngine(taskanaEngineConfiguration);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug( LOGGER.debug(

View File

@ -485,7 +485,6 @@ public class TaskHistoryEventController extends AbstractPagingController {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from applyFilterParams(), returning {}", query); LOGGER.debug("Exit from applyFilterParams(), returning {}", query);
} }
} }
private TimeInterval getTimeIntervalOf(String[] created) { private TimeInterval getTimeIntervalOf(String[] created) {

View File

@ -32,24 +32,24 @@ public class TaskHistoryEventListResourceAssembler extends AbstractRessourcesAss
.withRel(IanaLinkRelations.FIRST)); .withRel(IanaLinkRelations.FIRST));
pagedResources.add( pagedResources.add(
Link.of( Link.of(
this.getOriginal() this.getOriginal()
.replaceQueryParam("page", pageMetadata.getTotalPages()) .replaceQueryParam("page", pageMetadata.getTotalPages())
.toUriString()) .toUriString())
.withRel(IanaLinkRelations.LAST)); .withRel(IanaLinkRelations.LAST));
if (pageMetadata.getNumber() > 1) { if (pageMetadata.getNumber() > 1) {
pagedResources.add( pagedResources.add(
Link.of( Link.of(
this.getOriginal() this.getOriginal()
.replaceQueryParam("page", pageMetadata.getNumber() - 1) .replaceQueryParam("page", pageMetadata.getNumber() - 1)
.toUriString()) .toUriString())
.withRel(IanaLinkRelations.PREV)); .withRel(IanaLinkRelations.PREV));
} }
if (pageMetadata.getNumber() < pageMetadata.getTotalPages()) { if (pageMetadata.getNumber() < pageMetadata.getTotalPages()) {
pagedResources.add( pagedResources.add(
Link.of( Link.of(
this.getOriginal() this.getOriginal()
.replaceQueryParam("page", pageMetadata.getNumber() + 1) .replaceQueryParam("page", pageMetadata.getNumber() + 1)
.toUriString()) .toUriString())
.withRel(IanaLinkRelations.NEXT)); .withRel(IanaLinkRelations.NEXT));
} }
} }

View File

@ -396,9 +396,7 @@ public class ClassificationQueryImpl implements ClassificationQuery {
taskanaEngine.returnConnection(); taskanaEngine.returnConnection();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug( LOGGER.debug(
"exit from list(). Returning {} resulting Objects: {} ", "exit from list(). Returning {} resulting Objects: {} ", result.size(), result);
result.size(),
result);
} }
} }
} }
@ -450,9 +448,7 @@ public class ClassificationQueryImpl implements ClassificationQuery {
taskanaEngine.returnConnection(); taskanaEngine.returnConnection();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug( LOGGER.debug(
"Exit from listValues. Returning {} resulting Objects: {} ", "Exit from listValues. Returning {} resulting Objects: {} ", result.size(), result);
result.size(),
result);
} }
} }
} }

View File

@ -45,10 +45,6 @@ public class GroupPrincipal implements Group {
@Override @Override
public String toString() { public String toString() {
return "GroupPrincipal [name=" return "GroupPrincipal [name=" + name + ", members=" + this.members + "]";
+ name
+ ", members="
+ this.members
+ "]";
} }
} }

View File

@ -18,4 +18,3 @@ public interface CheckedConsumer<T, E extends Throwable> {
void accept(T t) throws E; void accept(T t) throws E;
} }

View File

@ -60,7 +60,6 @@ public abstract class FoldableRow<I extends QueryItem> extends SingleRow<I> {
@Override @Override
public String toString() { public String toString() {
return String.format( return String.format(
"FoldableRow [detailRows= %s, columnSize= %d]", "FoldableRow [detailRows= %s, columnSize= %d]", this.foldableRows, columnSize);
this.foldableRows, columnSize);
} }
} }

View File

@ -40,8 +40,8 @@ public class WorkingDaysToDaysReportConverter {
} }
public static WorkingDaysToDaysReportConverter initialize( public static WorkingDaysToDaysReportConverter initialize(
List<? extends TimeIntervalColumnHeader> columnHeaders, List<? extends TimeIntervalColumnHeader> columnHeaders, WorkingDaysToDaysConverter converter)
WorkingDaysToDaysConverter converter) throws InvalidArgumentException { throws InvalidArgumentException {
return initialize(columnHeaders, converter, Instant.now()); return initialize(columnHeaders, converter, Instant.now());
} }

View File

@ -2,10 +2,7 @@ package pro.taskana.task.api;
import pro.taskana.common.api.QueryColumnName; import pro.taskana.common.api.QueryColumnName;
/** /** Enum containing the column names for TaskQueryMapper.queryTaskColumnValues. */
* Enum containing the column names for TaskQueryMapper.queryTaskColumnValues.
*
*/
public enum TaskQueryColumnName implements QueryColumnName { public enum TaskQueryColumnName implements QueryColumnName {
ID("t.id"), ID("t.id"),
EXTERNAL_ID("t.external_id"), EXTERNAL_ID("t.external_id"),

View File

@ -84,9 +84,7 @@ public class ObjectReferenceQueryImpl implements ObjectReferenceQuery {
taskanaEngine.returnConnection(); taskanaEngine.returnConnection();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug( LOGGER.debug(
"exit from list(). Returning {} resulting Objects: {} ", "exit from list(). Returning {} resulting Objects: {} ", result.size(), result);
result.size(),
result);
} }
} }
} }
@ -138,9 +136,7 @@ public class ObjectReferenceQueryImpl implements ObjectReferenceQuery {
taskanaEngine.returnConnection(); taskanaEngine.returnConnection();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug( LOGGER.debug(
"Exit from listValues. Returning {} resulting Objects: {} ", "Exit from listValues. Returning {} resulting Objects: {} ", result.size(), result);
result.size(),
result);
} }
} }
} }

View File

@ -162,8 +162,7 @@ public interface TaskMapper {
+ " WHERE ID IN <foreach item='taskId' index='index' separator=',' open='(' close=')' collection='taskIds'>#{taskId}</foreach>" + " WHERE ID IN <foreach item='taskId' index='index' separator=',' open='(' close=')' collection='taskIds'>#{taskId}</foreach>"
+ "</script>") + "</script>")
void updateCompleted( void updateCompleted(
@Param("taskIds") List<String> taskIds, @Param("taskIds") List<String> taskIds, @Param("referenceTask") TaskSummary referenceTask);
@Param("referenceTask") TaskSummary referenceTask);
@Update( @Update(
"<script>" "<script>"
@ -171,8 +170,7 @@ public interface TaskMapper {
+ " WHERE ID IN <foreach item='taskId' index='index' separator=',' open='(' close=')' collection='taskIds'>#{taskId}</foreach>" + " WHERE ID IN <foreach item='taskId' index='index' separator=',' open='(' close=')' collection='taskIds'>#{taskId}</foreach>"
+ "</script>") + "</script>")
void updateClaimed( void updateClaimed(
@Param("taskIds") List<String> taskIds, @Param("taskIds") List<String> taskIds, @Param("referenceTask") TaskSummary referenceTask);
@Param("referenceTask") TaskSummary referenceTask);
@Select( @Select(
"<script>SELECT ID, EXTERNAL_ID, STATE, WORKBASKET_ID, OWNER, MODIFIED, CLASSIFICATION_ID, " "<script>SELECT ID, EXTERNAL_ID, STATE, WORKBASKET_ID, OWNER, MODIFIED, CLASSIFICATION_ID, "
@ -298,5 +296,4 @@ public interface TaskMapper {
@Results(value = {@Result(property = "id", column = "ID")}) @Results(value = {@Result(property = "id", column = "ID")})
List<String> filterTaskIdsNotAuthorizedFor( List<String> filterTaskIdsNotAuthorizedFor(
@Param("taskIds") List<String> taskIds, @Param("accessIds") List<String> accessIds); @Param("taskIds") List<String> taskIds, @Param("accessIds") List<String> accessIds);
} }

View File

@ -976,10 +976,7 @@ public class TaskQueryImpl implements TaskQuery {
List<TaskSummaryImpl> tasks = List<TaskSummaryImpl> tasks =
taskanaEngine.getSqlSession().selectList(getLinkToMapperScript(), this); taskanaEngine.getSqlSession().selectList(getLinkToMapperScript(), this);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug( LOGGER.debug("mapper returned {} resulting Objects: {} ", tasks.size(), tasks);
"mapper returned {} resulting Objects: {} ",
tasks.size(),
tasks);
} }
result = taskService.augmentTaskSummariesByContainedSummaries(tasks); result = taskService.augmentTaskSummariesByContainedSummaries(tasks);
return result; return result;
@ -987,9 +984,7 @@ public class TaskQueryImpl implements TaskQuery {
taskanaEngine.returnConnection(); taskanaEngine.returnConnection();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug( LOGGER.debug(
"exit from list(). Returning {} resulting Objects: {} ", "exit from list(). Returning {} resulting Objects: {} ", result.size(), result);
result.size(),
result);
} }
} }
} }
@ -1061,9 +1056,7 @@ public class TaskQueryImpl implements TaskQuery {
taskanaEngine.returnConnection(); taskanaEngine.returnConnection();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug( LOGGER.debug(
"Exit from listValues. Returning {} resulting Objects: {} ", "Exit from listValues. Returning {} resulting Objects: {} ", result.size(), result);
result.size(),
result);
} }
} }
} }

View File

@ -1060,20 +1060,20 @@ public class TaskServiceImpl implements TaskService {
getTasksToChange(taskIds).stream() getTasksToChange(taskIds).stream()
.collect(Collectors.toMap(TaskSummary::getId, e -> (TaskSummaryImpl) e)); .collect(Collectors.toMap(TaskSummary::getId, e -> (TaskSummaryImpl) e));
return taskIds.stream() return taskIds.stream()
.map(id -> Pair.of(id, taskSummaryMap.get(id))) .map(id -> Pair.of(id, taskSummaryMap.get(id)))
.filter( .filter(
pair -> { pair -> {
if (pair.getRight() == null) { if (pair.getRight() == null) {
String taskId = pair.getLeft(); String taskId = pair.getLeft();
bulkLog.addError( bulkLog.addError(
taskId, taskId,
new TaskNotFoundException( new TaskNotFoundException(
taskId, String.format(TASK_WITH_ID_WAS_NOT_FOUND, taskId))); taskId, String.format(TASK_WITH_ID_WAS_NOT_FOUND, taskId)));
return false; return false;
} }
return true; return true;
}) })
.map(Pair::getRight); .map(Pair::getRight);
} }
private static Predicate<TaskSummaryImpl> addErrorToBulkLog( private static Predicate<TaskSummaryImpl> addErrorToBulkLog(

View File

@ -133,8 +133,7 @@ public class TaskCleanupJob extends AbstractTaskanaJob {
} }
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug( LOGGER.debug("exit from getTasksCompletedBefore(), returning {}", taskList);
"exit from getTasksCompletedBefore(), returning {}", taskList);
} }
return taskList; return taskList;
@ -142,9 +141,7 @@ public class TaskCleanupJob extends AbstractTaskanaJob {
private int deleteTasksTransactionally(List<TaskSummary> tasksToBeDeleted) { private int deleteTasksTransactionally(List<TaskSummary> tasksToBeDeleted) {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug( LOGGER.debug("entry to deleteTasksTransactionally(tasksToBeDeleted = {})", tasksToBeDeleted);
"entry to deleteTasksTransactionally(tasksToBeDeleted = {})",
tasksToBeDeleted);
} }
int deletedTaskCount = 0; int deletedTaskCount = 0;

View File

@ -92,9 +92,7 @@ abstract class AbstractWorkbasketAccessItemQueryImpl<
taskanaEngine.returnConnection(); taskanaEngine.returnConnection();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug( LOGGER.debug(
"exit from list(). Returning {} resulting Objects: {} ", "exit from list(). Returning {} resulting Objects: {} ", result.size(), result);
result.size(),
result);
} }
} }
} }

View File

@ -107,10 +107,7 @@ public class WorkbasketAccessItemQueryImpl implements WorkbasketAccessItemQuery
taskanaEngine.openAndReturnConnection( taskanaEngine.openAndReturnConnection(
() -> new ArrayList<>(taskanaEngine.getSqlSession().selectList(LINK_TO_MAPPER, this))); () -> new ArrayList<>(taskanaEngine.getSqlSession().selectList(LINK_TO_MAPPER, this)));
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug( LOGGER.debug("exit from list(). Returning {} resulting Objects: {} ", result.size(), result);
"exit from list(). Returning {} resulting Objects: {} ",
result.size(),
result);
} }
return result; return result;
} }

View File

@ -447,9 +447,7 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
taskanaEngine.returnConnection(); taskanaEngine.returnConnection();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug( LOGGER.debug(
"Exit from listValues. Returning {} resulting Objects: {} ", "Exit from listValues. Returning {} resulting Objects: {} ", result.size(), result);
result.size(),
result);
} }
} }
} }

View File

@ -40,9 +40,7 @@ import pro.taskana.workbasket.internal.models.WorkbasketAccessItemImpl;
import pro.taskana.workbasket.internal.models.WorkbasketImpl; import pro.taskana.workbasket.internal.models.WorkbasketImpl;
import pro.taskana.workbasket.internal.models.WorkbasketSummaryImpl; import pro.taskana.workbasket.internal.models.WorkbasketSummaryImpl;
/** /** This is the implementation of WorkbasketService. */
* This is the implementation of WorkbasketService.
*/
public class WorkbasketServiceImpl implements WorkbasketService { public class WorkbasketServiceImpl implements WorkbasketService {
private static final Logger LOGGER = LoggerFactory.getLogger(WorkbasketServiceImpl.class); private static final Logger LOGGER = LoggerFactory.getLogger(WorkbasketServiceImpl.class);
@ -743,9 +741,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
public BulkOperationResults<String, TaskanaException> deleteWorkbaskets( public BulkOperationResults<String, TaskanaException> deleteWorkbaskets(
List<String> workbasketsIds) throws NotAuthorizedException, InvalidArgumentException { List<String> workbasketsIds) throws NotAuthorizedException, InvalidArgumentException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug( LOGGER.debug("entry to deleteWorkbaskets(workbasketId = {})", workbasketsIds);
"entry to deleteWorkbaskets(workbasketId = {})",
workbasketsIds);
} }
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN); taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);

View File

@ -225,7 +225,6 @@ class UpdateClassificationAccTest extends AbstractAccTest {
// TODO - resume old behaviour after attachment query is possible. // TODO - resume old behaviour after attachment query is possible.
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
List<String> tasksWithP1D = List<String> tasksWithP1D =
new ArrayList<>( new ArrayList<>(
Arrays.asList( Arrays.asList(

View File

@ -615,6 +615,4 @@ class CompleteTaskAccTest extends AbstractAccTest {
.isAfterOrEqualTo(beforeBulkComplete); .isAfterOrEqualTo(beforeBulkComplete);
assertThat(task.getOwner()).isEqualTo("user-3-2"); assertThat(task.getOwner()).isEqualTo("user-3-2");
} }
} }

View File

@ -437,8 +437,7 @@ class CreateTaskAccTest extends AbstractAccTest {
assertThat(readTask.getPriority()).isEqualTo(99); assertThat(readTask.getPriority()).isEqualTo(99);
Instant expDue = Instant expDue = converter.addWorkingDaysToInstant(readTask.getPlanned(), Duration.ofDays(1));
converter.addWorkingDaysToInstant(readTask.getPlanned(), Duration.ofDays(1));
assertThat(readTask.getDue()).isEqualTo(expDue); assertThat(readTask.getDue()).isEqualTo(expDue);
} }

View File

@ -455,7 +455,8 @@ public class ServiceLevelPriorityAccTest extends AbstractAccTest {
task.setPlanned(planned); task.setPlanned(planned);
task = taskService.updateTask(task); task = taskService.updateTask(task);
String serviceLevel = task.getClassificationSummary().getServiceLevel(); String serviceLevel = task.getClassificationSummary().getServiceLevel();
Instant expDue = converter.addWorkingDaysToInstant(task.getPlanned(), Duration.parse(serviceLevel)); Instant expDue =
converter.addWorkingDaysToInstant(task.getPlanned(), Duration.parse(serviceLevel));
assertThat(task.getPlanned()).isEqualTo(planned); assertThat(task.getPlanned()).isEqualTo(planned);
assertThat(task.getDue()).isEqualTo(expDue); assertThat(task.getDue()).isEqualTo(expDue);
} }

View File

@ -336,12 +336,15 @@ class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
assertThat(task.getPriority()).isEqualTo(101); assertThat(task.getPriority()).isEqualTo(101);
Instant expDue = converter.addWorkingDaysToInstant(task.getPlanned(), Duration.ofDays(1)); Instant expDue = converter.addWorkingDaysToInstant(task.getPlanned(), Duration.ofDays(1));
assertThat(task.getDue()).isEqualTo(expDue); assertThat(task.getDue()).isEqualTo(expDue);
assertThat(task.getAttachments()).hasSize(2) assertThat(task.getAttachments())
.areExactly(1, .hasSize(2)
.areExactly(
1,
new Condition<>( new Condition<>(
e -> "E-MAIL".equals(e.getChannel()) && e.getCustomAttributes().size() == 3, e -> "E-MAIL".equals(e.getChannel()) && e.getCustomAttributes().size() == 3,
"E-MAIL with 3 custom attributes")) "E-MAIL with 3 custom attributes"))
.areExactly(1, .areExactly(
1,
new Condition<>( new Condition<>(
e -> "ROHRPOST".equals(e.getChannel()) && e.getCustomAttributes().size() == 4, e -> "ROHRPOST".equals(e.getChannel()) && e.getCustomAttributes().size() == 4,
"ROHRPOST with 4 custom attributes")); "ROHRPOST with 4 custom attributes"));
@ -368,11 +371,13 @@ class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
assertThat(task.getDue()).isEqualTo(expDue); assertThat(task.getDue()).isEqualTo(expDue);
assertThat(task.getAttachments()) assertThat(task.getAttachments())
.hasSize(2) .hasSize(2)
.areExactly(1, .areExactly(
1,
new Condition<>( new Condition<>(
e -> "FAX".equals(e.getChannel()) && e.getCustomAttributes().size() == 3, e -> "FAX".equals(e.getChannel()) && e.getCustomAttributes().size() == 3,
"FAX with 3 custom attributes")) "FAX with 3 custom attributes"))
.areExactly(1, .areExactly(
1,
new Condition<>( new Condition<>(
e -> "ROHRPOST".equals(e.getChannel()) && e.getCustomAttributes().size() == 4, e -> "ROHRPOST".equals(e.getChannel()) && e.getCustomAttributes().size() == 4,
"ROHRPOST with 4 custom attributes")); "ROHRPOST with 4 custom attributes"));

View File

@ -71,8 +71,10 @@ class AsyncUpdateJobIntTest {
classification.setServiceLevel("P5D"); classification.setServiceLevel("P5D");
classification.setPriority(1000); classification.setPriority(1000);
TEMPLATE.exchange(restHelper.toUrl(Mapping.URL_CLASSIFICATIONS_ID, CLASSIFICATION_ID), TEMPLATE.exchange(
HttpMethod.PUT, new HttpEntity<>(classification, restHelper.getHeadersTeamlead_1()), restHelper.toUrl(Mapping.URL_CLASSIFICATIONS_ID, CLASSIFICATION_ID),
HttpMethod.PUT,
new HttpEntity<>(classification, restHelper.getHeadersTeamlead_1()),
ParameterizedTypeReference.forType(ClassificationRepresentationModel.class)); ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
// trigger jobs twice to refresh all entries. first entry on the first call and follow up on the // trigger jobs twice to refresh all entries. first entry on the first call and follow up on the

View File

@ -103,9 +103,8 @@ public class ClassificationController extends AbstractPagingController {
@GetMapping(path = Mapping.URL_CLASSIFICATIONS) @GetMapping(path = Mapping.URL_CLASSIFICATIONS)
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<TaskanaPagedModel<ClassificationSummaryRepresentationModel>> public ResponseEntity<TaskanaPagedModel<ClassificationSummaryRepresentationModel>>
getClassifications( getClassifications(@RequestParam MultiValueMap<String, String> params)
@RequestParam MultiValueMap<String, String> params) throws InvalidArgumentException {
throws InvalidArgumentException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to getClassifications(params= {})", params); LOGGER.debug("Entry to getClassifications(params= {})", params);
} }
@ -155,8 +154,8 @@ public class ClassificationController extends AbstractPagingController {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to createClassification(resource= {})", resource); LOGGER.debug("Entry to createClassification(resource= {})", resource);
} }
Classification classification = classificationRepresentationModelAssembler Classification classification =
.toEntityModel(resource); classificationRepresentationModelAssembler.toEntityModel(resource);
classification = classificationService.createClassification(classification); classification = classificationService.createClassification(classification);
ResponseEntity<ClassificationRepresentationModel> response = ResponseEntity<ClassificationRepresentationModel> response =
@ -185,8 +184,8 @@ public class ClassificationController extends AbstractPagingController {
ResponseEntity<ClassificationRepresentationModel> result; ResponseEntity<ClassificationRepresentationModel> result;
if (classificationId.equals(resource.getClassificationId())) { if (classificationId.equals(resource.getClassificationId())) {
Classification classification = classificationRepresentationModelAssembler Classification classification =
.toEntityModel(resource); classificationRepresentationModelAssembler.toEntityModel(resource);
classification = classificationService.updateClassification(classification); classification = classificationService.updateClassification(classification);
result = result =
ResponseEntity.ok(classificationRepresentationModelAssembler.toModel(classification)); ResponseEntity.ok(classificationRepresentationModelAssembler.toModel(classification));
@ -229,7 +228,7 @@ public class ClassificationController extends AbstractPagingController {
if (sortBy != null) { if (sortBy != null) {
SortDirection sortDirection; SortDirection sortDirection;
if (params.getFirst(SORT_DIRECTION) != null if (params.getFirst(SORT_DIRECTION) != null
&& "desc".equals(params.getFirst(SORT_DIRECTION))) { && "desc".equals(params.getFirst(SORT_DIRECTION))) {
sortDirection = SortDirection.DESCENDING; sortDirection = SortDirection.DESCENDING;
} else { } else {
sortDirection = SortDirection.ASCENDING; sortDirection = SortDirection.ASCENDING;
@ -260,8 +259,7 @@ public class ClassificationController extends AbstractPagingController {
return query; return query;
} }
private void applyFilterParams( private void applyFilterParams(ClassificationQuery query, MultiValueMap<String, String> params)
ClassificationQuery query, MultiValueMap<String, String> params)
throws InvalidArgumentException { throws InvalidArgumentException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to applyFilterParams(query= {}, params= {})", query, params); LOGGER.debug("Entry to applyFilterParams(query= {}, params= {})", query, params);
@ -332,6 +330,5 @@ public class ClassificationController extends AbstractPagingController {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from applyFilterParams(), returning {}", query); LOGGER.debug("Exit from applyFilterParams(), returning {}", query);
} }
} }
} }

View File

@ -175,9 +175,7 @@ public class ClassificationDefinitionController {
} }
} }
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug( LOGGER.debug("Exit from mapChildrenToParentKeys(), returning {}", childrenInFile);
"Exit from mapChildrenToParentKeys(), returning {}",
childrenInFile);
} }
return childrenInFile; return childrenInFile;

View File

@ -35,8 +35,7 @@ public class ClassificationRepresentationModelAssembler
@NonNull @NonNull
@Override @Override
public ClassificationRepresentationModel toModel(@NonNull Classification classification) { public ClassificationRepresentationModel toModel(@NonNull Classification classification) {
ClassificationRepresentationModel repModel = ClassificationRepresentationModel repModel = new ClassificationRepresentationModel();
new ClassificationRepresentationModel();
repModel.setClassificationId(classification.getId()); repModel.setClassificationId(classification.getId());
repModel.setApplicationEntryPoint(classification.getApplicationEntryPoint()); repModel.setApplicationEntryPoint(classification.getApplicationEntryPoint());
repModel.setCategory(classification.getCategory()); repModel.setCategory(classification.getCategory());
@ -63,8 +62,8 @@ public class ClassificationRepresentationModelAssembler
try { try {
repModel.add( repModel.add(
WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder.linkTo(
methodOn(ClassificationController.class) methodOn(ClassificationController.class)
.getClassification(classification.getId())) .getClassification(classification.getId()))
.withSelfRel()); .withSelfRel());
} catch (ClassificationNotFoundException e) { } catch (ClassificationNotFoundException e) {
throw new SystemException("caught unexpected Exception.", e.getCause()); throw new SystemException("caught unexpected Exception.", e.getCause());
@ -77,14 +76,11 @@ public class ClassificationRepresentationModelAssembler
return TaskanaPagedModelKeys.CLASSIFICATIONS; return TaskanaPagedModelKeys.CLASSIFICATIONS;
} }
public Classification toEntityModel( public Classification toEntityModel(ClassificationRepresentationModel repModel) {
ClassificationRepresentationModel repModel) {
ClassificationImpl classification = ClassificationImpl classification =
(ClassificationImpl) (ClassificationImpl)
classificationService.newClassification( classificationService.newClassification(
repModel.getKey(), repModel.getKey(), repModel.getDomain(), repModel.getType());
repModel.getDomain(),
repModel.getType());
classification.setApplicationEntryPoint(repModel.getApplicationEntryPoint()); classification.setApplicationEntryPoint(repModel.getApplicationEntryPoint());
classification.setCategory(repModel.getCategory()); classification.setCategory(repModel.getCategory());

View File

@ -62,8 +62,9 @@ public class ClassificationSummaryRepresentationModelAssembler
public ClassificationSummary toEntityModel(ClassificationSummaryRepresentationModel repModel) { public ClassificationSummary toEntityModel(ClassificationSummaryRepresentationModel repModel) {
ClassificationSummaryImpl classification = ClassificationSummaryImpl classification =
(ClassificationSummaryImpl) (ClassificationSummaryImpl)
classificationService.newClassification( classificationService
repModel.getKey(), repModel.getDomain(), repModel.getType()).asSummary(); .newClassification(repModel.getKey(), repModel.getDomain(), repModel.getType())
.asSummary();
classification.setId(repModel.getClassificationId()); classification.setId(repModel.getClassificationId());
classification.setApplicationEntryPoint(repModel.getApplicationEntryPoint()); classification.setApplicationEntryPoint(repModel.getApplicationEntryPoint());
classification.setCategory(repModel.getCategory()); classification.setCategory(repModel.getCategory());

View File

@ -4,9 +4,7 @@ import org.springframework.hateoas.RepresentationModel;
import pro.taskana.classification.api.models.ClassificationSummary; import pro.taskana.classification.api.models.ClassificationSummary;
/** /** EntityModel class for {@link ClassificationSummary}. */
* EntityModel class for {@link ClassificationSummary}.
*/
public class ClassificationSummaryRepresentationModel public class ClassificationSummaryRepresentationModel
extends RepresentationModel<ClassificationSummaryRepresentationModel> { extends RepresentationModel<ClassificationSummaryRepresentationModel> {

View File

@ -14,8 +14,7 @@ public interface TaskanaPagingAssembler<T, D extends RepresentationModel<? super
TaskanaPagedModelKeys getProperty(); TaskanaPagedModelKeys getProperty();
default TaskanaPagedModel<D> toPageModel( default TaskanaPagedModel<D> toPageModel(Iterable<T> entities, PageMetadata pageMetadata) {
Iterable<T> entities, PageMetadata pageMetadata) {
return StreamSupport.stream(entities.spliterator(), false) return StreamSupport.stream(entities.spliterator(), false)
.map(this::toModel) .map(this::toModel)
.collect( .collect(

View File

@ -116,9 +116,7 @@ public class LdapClient {
SearchControls.SUBTREE_SCOPE, SearchControls.SUBTREE_SCOPE,
userAttributesToReturn, userAttributesToReturn,
new UserContextMapper()); new UserContextMapper());
LOGGER.debug( LOGGER.debug("exit from searchUsersByName. Retrieved the following users: {}.", accessIds);
"exit from searchUsersByName. Retrieved the following users: {}.",
accessIds);
return accessIds; return accessIds;
} }
@ -144,9 +142,7 @@ public class LdapClient {
SearchControls.SUBTREE_SCOPE, SearchControls.SUBTREE_SCOPE,
getLookUpGoupAttributesToReturn(), getLookUpGoupAttributesToReturn(),
new GroupContextMapper()); new GroupContextMapper());
LOGGER.debug( LOGGER.debug("Exit from searchGroupsByName. Retrieved the following groups: {}", accessIds);
"Exit from searchGroupsByName. Retrieved the following groups: {}",
accessIds);
return accessIds; return accessIds;
} }
@ -187,8 +183,7 @@ public class LdapClient {
userAttributesToReturn, userAttributesToReturn,
new GroupContextMapper()); new GroupContextMapper());
LOGGER.debug( LOGGER.debug(
"exit from searchGroupsofUsersIsMember. Retrieved the following users: {}.", "exit from searchGroupsofUsersIsMember. Retrieved the following users: {}.", accessIds);
accessIds);
return accessIds; return accessIds;
} }

View File

@ -11,20 +11,16 @@ import org.springframework.ldap.core.support.LdapContextSource;
@Configuration @Configuration
public class LdapConfiguration { public class LdapConfiguration {
private final Environment env;
@Value("${taskana.ldap.serverUrl:ldap://localhost:10389}") @Value("${taskana.ldap.serverUrl:ldap://localhost:10389}")
private String ldapServerUrl; private String ldapServerUrl;
@Value("${taskana.ldap.baseDn:OU=Test,O=TASKANA}") @Value("${taskana.ldap.baseDn:OU=Test,O=TASKANA}")
private String ldapBaseDn; private String ldapBaseDn;
@Value("${taskana.ldap.bindDn:uid=admin}") @Value("${taskana.ldap.bindDn:uid=admin}")
private String ldapBindDn; private String ldapBindDn;
@Value("${taskana.ldap.bindPassword:secret}") @Value("${taskana.ldap.bindPassword:secret}")
private String ldapBindPassowrd; private String ldapBindPassowrd;
private final Environment env;
public LdapConfiguration(Environment env) { public LdapConfiguration(Environment env) {
this.env = env; this.env = env;
} }

View File

@ -76,5 +76,4 @@ public class PagedResources<T> extends RepresentationModel<PagedResources<T>> {
public Collection<T> getContent() { public Collection<T> getContent() {
return Collections.unmodifiableCollection(content); return Collections.unmodifiableCollection(content);
} }
} }

View File

@ -35,9 +35,7 @@ public class ReportRepresentationModel extends RepresentationModel<ReportReprese
return sumRow; return sumRow;
} }
/** /** EntityModel class for {@link SingleRow}. */
* EntityModel class for {@link SingleRow}.
*/
public static class RowResource { public static class RowResource {
private final int[] cells; private final int[] cells;
@ -87,9 +85,7 @@ public class ReportRepresentationModel extends RepresentationModel<ReportReprese
} }
} }
/** /** Meta Information about this ReportResource. */
* Meta Information about this ReportResource.
*/
public static class MetaInformation { public static class MetaInformation {
private static final String TOTAL_DESC = "Total"; private static final String TOTAL_DESC = "Total";

View File

@ -53,15 +53,13 @@ public abstract class AbstractRessourcesAssembler {
.withRel("last")); .withRel("last"));
if (pageMetadata.getNumber() > 1L) { if (pageMetadata.getNumber() > 1L) {
pagedResources.add( pagedResources.add(
(Link.of( (Link.of(original.replaceQueryParam("page", pageMetadata.getNumber() - 1L).toUriString()))
original.replaceQueryParam("page", pageMetadata.getNumber() - 1L).toUriString()))
.withRel("prev")); .withRel("prev"));
} }
if (pageMetadata.getNumber() < pageMetadata.getTotalPages()) { if (pageMetadata.getNumber() < pageMetadata.getTotalPages()) {
pagedResources.add( pagedResources.add(
(Link.of( (Link.of(original.replaceQueryParam("page", pageMetadata.getNumber() + 1L).toUriString()))
original.replaceQueryParam("page", pageMetadata.getNumber() + 1L).toUriString()))
.withRel("next")); .withRel("next"));
} }

View File

@ -44,33 +44,6 @@ public class SpringSecurityToJaasFilter extends GenericFilterBean {
chain.doFilter(request, response); chain.doFilter(request, response);
} }
private void initializeUserPrincipalFromAuthentication(
Authentication authentication, Subject subject) {
if (subject.getPrincipals().isEmpty()) {
LOGGER.debug("Setting the principal of the subject with {}.", authentication.getPrincipal());
subject
.getPrincipals()
.add(new UserPrincipal(((UserDetails) authentication.getPrincipal()).getUsername()));
} else {
LOGGER.debug("Principal of the subject is already set to {}.", subject.getPrincipals());
throw new SystemException("Finding an existing principal is unexpected. Please investigate.");
}
}
private void initializeGroupPrincipalsFromAuthentication(
Authentication authentication, Subject subject) {
LOGGER.debug("Adding roles {} to subject.", authentication.getAuthorities());
authentication
.getAuthorities()
.forEach(
grantedAuthority ->
subject.getPrincipals().add(new GroupPrincipal(grantedAuthority.getAuthority())));
LOGGER.debug("{}", subject.getPublicCredentials(GroupPrincipal.class));
}
/** /**
* Obtains the <code>Subject</code> to run as or <code>null</code> if no <code>Subject</code> is * Obtains the <code>Subject</code> to run as or <code>null</code> if no <code>Subject</code> is
* available. * available.
@ -100,4 +73,31 @@ public class SpringSecurityToJaasFilter extends GenericFilterBean {
Optional<Authentication> getCurrentAuthentication() { Optional<Authentication> getCurrentAuthentication() {
return Optional.ofNullable(SecurityContextHolder.getContext().getAuthentication()); return Optional.ofNullable(SecurityContextHolder.getContext().getAuthentication());
} }
private void initializeUserPrincipalFromAuthentication(
Authentication authentication, Subject subject) {
if (subject.getPrincipals().isEmpty()) {
LOGGER.debug("Setting the principal of the subject with {}.", authentication.getPrincipal());
subject
.getPrincipals()
.add(new UserPrincipal(((UserDetails) authentication.getPrincipal()).getUsername()));
} else {
LOGGER.debug("Principal of the subject is already set to {}.", subject.getPrincipals());
throw new SystemException("Finding an existing principal is unexpected. Please investigate.");
}
}
private void initializeGroupPrincipalsFromAuthentication(
Authentication authentication, Subject subject) {
LOGGER.debug("Adding roles {} to subject.", authentication.getAuthorities());
authentication
.getAuthorities()
.forEach(
grantedAuthority ->
subject.getPrincipals().add(new GroupPrincipal(grantedAuthority.getAuthority())));
LOGGER.debug("{}", subject.getPublicCredentials(GroupPrincipal.class));
}
} }

View File

@ -32,9 +32,7 @@ import pro.taskana.task.api.models.TaskComment;
import pro.taskana.task.rest.assembler.TaskCommentRepresentationModelAssembler; import pro.taskana.task.rest.assembler.TaskCommentRepresentationModelAssembler;
import pro.taskana.task.rest.models.TaskCommentRepresentationModel; import pro.taskana.task.rest.models.TaskCommentRepresentationModel;
/** /** Controller for all {@link TaskComment} related endpoints. */
* Controller for all {@link TaskComment} related endpoints.
*/
@RestController @RestController
@EnableHypermediaSupport(type = HypermediaType.HAL) @EnableHypermediaSupport(type = HypermediaType.HAL)
public class TaskCommentController { public class TaskCommentController {
@ -46,7 +44,6 @@ public class TaskCommentController {
private static final String CREATED = "created"; private static final String CREATED = "created";
private static final String MODIFIED = "modified"; private static final String MODIFIED = "modified";
private final TaskService taskService; private final TaskService taskService;
private final TaskCommentRepresentationModelAssembler taskCommentRepresentationModelAssembler; private final TaskCommentRepresentationModelAssembler taskCommentRepresentationModelAssembler;
@ -63,7 +60,7 @@ public class TaskCommentController {
public ResponseEntity<TaskCommentRepresentationModel> getTaskComment( public ResponseEntity<TaskCommentRepresentationModel> getTaskComment(
@PathVariable String taskCommentId) @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(taskCommentId= {})", taskCommentId);
} }
@ -96,7 +93,7 @@ public class TaskCommentController {
List<TaskComment> taskComments = taskService.getTaskComments(taskId); List<TaskComment> taskComments = taskService.getTaskComments(taskId);
//TODO Maybe introduce a query for task comments // TODO Maybe introduce a query for task comments
applySortingParams(taskComments, params); applySortingParams(taskComments, params);
TaskanaPagedModel<TaskCommentRepresentationModel> taskCommentListResource = TaskanaPagedModel<TaskCommentRepresentationModel> taskCommentListResource =
@ -117,7 +114,7 @@ public class TaskCommentController {
public ResponseEntity<TaskCommentRepresentationModel> deleteTaskComment( public ResponseEntity<TaskCommentRepresentationModel> deleteTaskComment(
@PathVariable String taskCommentId) @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(taskCommentId= {})", taskCommentId);
} }
@ -139,7 +136,7 @@ public class TaskCommentController {
@PathVariable String taskCommentId, @PathVariable String taskCommentId,
@RequestBody TaskCommentRepresentationModel taskCommentRepresentationModel) @RequestBody TaskCommentRepresentationModel taskCommentRepresentationModel)
throws NotAuthorizedException, TaskNotFoundException, TaskCommentNotFoundException, throws NotAuthorizedException, TaskNotFoundException, TaskCommentNotFoundException,
InvalidArgumentException, ConcurrencyException { InvalidArgumentException, ConcurrencyException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug( LOGGER.debug(
"Entry to updateTaskComment(taskCommentId= {}, taskCommentResource= {})", "Entry to updateTaskComment(taskCommentId= {}, taskCommentResource= {})",
@ -204,12 +201,13 @@ public class TaskCommentController {
return result; return result;
} }
private List<TaskComment> applySortingParams(List<TaskComment> taskComments, private List<TaskComment> applySortingParams(
MultiValueMap<String, String> params) throws InvalidArgumentException { List<TaskComment> taskComments, MultiValueMap<String, String> params)
throws InvalidArgumentException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER LOGGER.debug(
.debug("Entry to applySortingParams(taskComments= {}, params= {})", taskComments, params); "Entry to applySortingParams(taskComments= {}, params= {})", taskComments, params);
} }
String sortBy = params.getFirst(SORT_BY); String sortBy = params.getFirst(SORT_BY);
@ -219,20 +217,18 @@ public class TaskCommentController {
switch (sortBy) { switch (sortBy) {
case (CREATED): case (CREATED):
if (params.getFirst(SORT_DIRECTION) != null if (params.getFirst(SORT_DIRECTION) != null
&& "desc".equals(params.getFirst(SORT_DIRECTION))) { && "desc".equals(params.getFirst(SORT_DIRECTION))) {
taskComments.sort(Comparator.comparing(TaskComment::getCreated).reversed()); taskComments.sort(Comparator.comparing(TaskComment::getCreated).reversed());
} else { } else {
taskComments.sort(Comparator.comparing(TaskComment::getCreated)); taskComments.sort(Comparator.comparing(TaskComment::getCreated));
} }
break; break;
case (MODIFIED): case (MODIFIED):
if (params.getFirst(SORT_DIRECTION) != null if (params.getFirst(SORT_DIRECTION) != null
&& "desc".equals(params.getFirst(SORT_DIRECTION))) { && "desc".equals(params.getFirst(SORT_DIRECTION))) {
taskComments.sort(Comparator.comparing(TaskComment::getModified).reversed()); taskComments.sort(Comparator.comparing(TaskComment::getModified).reversed());
} else { } else {
taskComments.sort(Comparator.comparing(TaskComment::getModified)); taskComments.sort(Comparator.comparing(TaskComment::getModified));
} }
break; break;
default: default:

View File

@ -5,12 +5,9 @@ import java.util.Map;
import pro.taskana.task.api.models.Attachment; import pro.taskana.task.api.models.Attachment;
/** /** EntityModel class for {@link Attachment}. */
* EntityModel class for {@link Attachment}. public class AttachmentRepresentationModel extends AttachmentSummaryRepresentationModel {
*/
public class AttachmentRepresentationModel
extends AttachmentSummaryRepresentationModel {
private Map<String, String> customAttributes = new HashMap<>(); private Map<String, String> customAttributes = new HashMap<>();
public Map<String, String> getCustomAttributes() { public Map<String, String> getCustomAttributes() {

View File

@ -11,9 +11,7 @@ import pro.taskana.task.api.models.ObjectReference;
import pro.taskana.workbasket.api.models.WorkbasketSummary; import pro.taskana.workbasket.api.models.WorkbasketSummary;
import pro.taskana.workbasket.rest.models.WorkbasketSummaryRepresentationModel; import pro.taskana.workbasket.rest.models.WorkbasketSummaryRepresentationModel;
/** /** EntityModel class for {@link WorkbasketSummary}. */
* EntityModel class for {@link WorkbasketSummary}.
*/
public class TaskSummaryRepresentationModel public class TaskSummaryRepresentationModel
extends RepresentationModel<TaskSummaryRepresentationModel> { extends RepresentationModel<TaskSummaryRepresentationModel> {
@ -55,8 +53,7 @@ public class TaskSummaryRepresentationModel
protected String custom14; protected String custom14;
protected String custom15; protected String custom15;
protected String custom16; protected String custom16;
private List<AttachmentSummaryRepresentationModel> attachmentSummaries = private List<AttachmentSummaryRepresentationModel> attachmentSummaries = new ArrayList<>();
new ArrayList<>();
public String getTaskId() { public String getTaskId() {
return taskId; return taskId;
@ -183,8 +180,7 @@ public class TaskSummaryRepresentationModel
return workbasketSummary; return workbasketSummary;
} }
public void setWorkbasketSummary( public void setWorkbasketSummary(WorkbasketSummaryRepresentationModel workbasketSummary) {
WorkbasketSummaryRepresentationModel workbasketSummary) {
this.workbasketSummary = workbasketSummary; this.workbasketSummary = workbasketSummary;
} }
@ -372,6 +368,4 @@ public class TaskSummaryRepresentationModel
public void setCustom16(String custom16) { public void setCustom16(String custom16) {
this.custom16 = custom16; this.custom16 = custom16;
} }
} }

View File

@ -55,13 +55,14 @@ public class WorkbasketAccessItemController extends AbstractPagingController {
@Autowired @Autowired
public WorkbasketAccessItemController( public WorkbasketAccessItemController(
LdapClient ldapClient, WorkbasketService workbasketService, LdapClient ldapClient,
WorkbasketService workbasketService,
WorkbasketAccessItemRepresentationModelAssembler WorkbasketAccessItemRepresentationModelAssembler
workbasketAccessItemRepresentationModelAssembler) { workbasketAccessItemRepresentationModelAssembler) {
this.ldapClient = ldapClient; this.ldapClient = ldapClient;
this.workbasketService = workbasketService; this.workbasketService = workbasketService;
this.workbasketAccessItemRepresentationModelAssembler this.workbasketAccessItemRepresentationModelAssembler =
= workbasketAccessItemRepresentationModelAssembler; workbasketAccessItemRepresentationModelAssembler;
} }
/** /**
@ -69,14 +70,13 @@ public class WorkbasketAccessItemController extends AbstractPagingController {
* *
* @param params filter, order and access ids. * @param params filter, order and access ids.
* @return all WorkbasketAccesItemResource. * @return all WorkbasketAccesItemResource.
* @throws NotAuthorizedException if the user is not authorized. * @throws NotAuthorizedException if the user is not authorized.
* @throws InvalidArgumentException if some argument is invalid. * @throws InvalidArgumentException if some argument is invalid.
*/ */
@GetMapping(path = Mapping.URL_WORKBASKET_ACCESS_ITEMS) @GetMapping(path = Mapping.URL_WORKBASKET_ACCESS_ITEMS)
public ResponseEntity<TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>> public ResponseEntity<TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>>
getWorkbasketAccessItems( getWorkbasketAccessItems(@RequestParam MultiValueMap<String, String> params)
@RequestParam MultiValueMap<String, String> params) throws NotAuthorizedException, InvalidArgumentException {
throws NotAuthorizedException, InvalidArgumentException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to getWorkbasketAccessItems(params= {})", params); LOGGER.debug("Entry to getWorkbasketAccessItems(params= {})", params);
} }
@ -135,8 +135,7 @@ public class WorkbasketAccessItemController extends AbstractPagingController {
return response; return response;
} }
private void getAccessIds( private void getAccessIds(WorkbasketAccessItemQuery query, MultiValueMap<String, String> params) {
WorkbasketAccessItemQuery query, MultiValueMap<String, String> params) {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to getAccessIds(query= {}, params= {})", query, params); LOGGER.debug("Entry to getAccessIds(query= {}, params= {})", query, params);
} }
@ -150,7 +149,6 @@ public class WorkbasketAccessItemController extends AbstractPagingController {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getAccessIds(), returning {}", query); LOGGER.debug("Exit from getAccessIds(), returning {}", query);
} }
} }
private void applyFilterParams( private void applyFilterParams(
@ -180,7 +178,6 @@ public class WorkbasketAccessItemController extends AbstractPagingController {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from applyFilterParams(), returning {}", query); LOGGER.debug("Exit from applyFilterParams(), returning {}", query);
} }
} }
private WorkbasketAccessItemQuery applySortingParams( private WorkbasketAccessItemQuery applySortingParams(
@ -195,7 +192,7 @@ public class WorkbasketAccessItemController extends AbstractPagingController {
if (sortBy != null) { if (sortBy != null) {
BaseQuery.SortDirection sortDirection; BaseQuery.SortDirection sortDirection;
if (params.getFirst(SORT_DIRECTION) != null if (params.getFirst(SORT_DIRECTION) != null
&& "desc".equals(params.getFirst(SORT_DIRECTION))) { && "desc".equals(params.getFirst(SORT_DIRECTION))) {
sortDirection = BaseQuery.SortDirection.DESCENDING; sortDirection = BaseQuery.SortDirection.DESCENDING;
} else { } else {
sortDirection = BaseQuery.SortDirection.ASCENDING; sortDirection = BaseQuery.SortDirection.ASCENDING;

View File

@ -78,8 +78,6 @@ public class WorkbasketController extends AbstractPagingController {
private final WorkbasketSummaryRepresentationModelAssembler private final WorkbasketSummaryRepresentationModelAssembler
workbasketSummaryRepresentationModelAssembler; workbasketSummaryRepresentationModelAssembler;
private final WorkbasketAccessItemRepresentationModelAssembler private final WorkbasketAccessItemRepresentationModelAssembler
workbasketAccessItemRepresentationModelAssembler; workbasketAccessItemRepresentationModelAssembler;
@ -146,7 +144,7 @@ public class WorkbasketController extends AbstractPagingController {
public ResponseEntity<WorkbasketRepresentationModel> deleteWorkbasket( public ResponseEntity<WorkbasketRepresentationModel> deleteWorkbasket(
@PathVariable(value = "workbasketId") String workbasketId) @PathVariable(value = "workbasketId") String workbasketId)
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
WorkbasketInUseException { WorkbasketInUseException {
LOGGER.debug("Entry to markWorkbasketForDeletion(workbasketId= {})", workbasketId); LOGGER.debug("Entry to markWorkbasketForDeletion(workbasketId= {})", workbasketId);
ResponseEntity<WorkbasketRepresentationModel> response; ResponseEntity<WorkbasketRepresentationModel> response;
@ -223,7 +221,7 @@ public class WorkbasketController extends AbstractPagingController {
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>> public ResponseEntity<TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>>
getWorkbasketAccessItems(@PathVariable(value = "workbasketId") String workbasketId) getWorkbasketAccessItems(@PathVariable(value = "workbasketId") String workbasketId)
throws NotAuthorizedException, WorkbasketNotFoundException { throws NotAuthorizedException, WorkbasketNotFoundException {
LOGGER.debug("Entry to getWorkbasketAccessItems(workbasketId= {})", workbasketId); LOGGER.debug("Entry to getWorkbasketAccessItems(workbasketId= {})", workbasketId);
ResponseEntity<TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>> result; ResponseEntity<TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>> result;
@ -244,10 +242,10 @@ public class WorkbasketController extends AbstractPagingController {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity<TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>> public ResponseEntity<TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>>
setWorkbasketAccessItems( setWorkbasketAccessItems(
@PathVariable(value = "workbasketId") String workbasketId, @PathVariable(value = "workbasketId") String workbasketId,
@RequestBody List<WorkbasketAccessItemRepresentationModel> workbasketAccessResourceItems) @RequestBody List<WorkbasketAccessItemRepresentationModel> workbasketAccessResourceItems)
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
WorkbasketAccessItemAlreadyExistException { WorkbasketAccessItemAlreadyExistException {
LOGGER.debug("Entry to setWorkbasketAccessItems(workbasketId= {})", workbasketId); LOGGER.debug("Entry to setWorkbasketAccessItems(workbasketId= {})", workbasketId);
if (workbasketAccessResourceItems == null) { if (workbasketAccessResourceItems == null) {
throw new InvalidArgumentException("Can´t create something with NULL body-value."); throw new InvalidArgumentException("Can´t create something with NULL body-value.");
@ -255,8 +253,9 @@ public class WorkbasketController extends AbstractPagingController {
List<WorkbasketAccessItem> wbAccessItems = new ArrayList<>(); List<WorkbasketAccessItem> wbAccessItems = new ArrayList<>();
workbasketAccessResourceItems.forEach( workbasketAccessResourceItems.forEach(
item -> wbAccessItems item ->
.add(workbasketAccessItemRepresentationModelAssembler.toEntityModel(item))); wbAccessItems.add(
workbasketAccessItemRepresentationModelAssembler.toEntityModel(item)));
workbasketService.setWorkbasketAccessItems(workbasketId, wbAccessItems); workbasketService.setWorkbasketAccessItems(workbasketId, wbAccessItems);
List<WorkbasketAccessItem> updatedWbAccessItems = List<WorkbasketAccessItem> updatedWbAccessItems =
workbasketService.getWorkbasketAccessItems(workbasketId); workbasketService.getWorkbasketAccessItems(workbasketId);
@ -276,14 +275,14 @@ public class WorkbasketController extends AbstractPagingController {
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>> public ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>>
getDistributionTargets(@PathVariable(value = "workbasketId") String workbasketId) getDistributionTargets(@PathVariable(value = "workbasketId") String workbasketId)
throws WorkbasketNotFoundException, NotAuthorizedException { throws WorkbasketNotFoundException, NotAuthorizedException {
LOGGER.debug("Entry to getDistributionTargets(workbasketId= {})", workbasketId); LOGGER.debug("Entry to getDistributionTargets(workbasketId= {})", workbasketId);
List<WorkbasketSummary> distributionTargets = List<WorkbasketSummary> distributionTargets =
workbasketService.getDistributionTargets(workbasketId); workbasketService.getDistributionTargets(workbasketId);
TaskanaPagedModel<WorkbasketSummaryRepresentationModel> distributionTargetListResource = TaskanaPagedModel<WorkbasketSummaryRepresentationModel> distributionTargetListResource =
workbasketSummaryRepresentationModelAssembler workbasketSummaryRepresentationModelAssembler.toDistributionTargetPageModel(
.toDistributionTargetPageModel(distributionTargets, null); distributionTargets, null);
ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>> result = ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>> result =
ResponseEntity.ok(distributionTargetListResource); ResponseEntity.ok(distributionTargetListResource);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
@ -297,9 +296,9 @@ public class WorkbasketController extends AbstractPagingController {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>> public ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>>
setDistributionTargetsForWorkbasketId( setDistributionTargetsForWorkbasketId(
@PathVariable(value = "workbasketId") String sourceWorkbasketId, @PathVariable(value = "workbasketId") String sourceWorkbasketId,
@RequestBody List<String> targetWorkbasketIds) @RequestBody List<String> targetWorkbasketIds)
throws WorkbasketNotFoundException, NotAuthorizedException { throws WorkbasketNotFoundException, NotAuthorizedException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug( LOGGER.debug(
"Entry to getTasksStatusReport(workbasketId= {}, targetWorkbasketIds´= {})", "Entry to getTasksStatusReport(workbasketId= {}, targetWorkbasketIds´= {})",
@ -313,8 +312,8 @@ public class WorkbasketController extends AbstractPagingController {
workbasketService.getDistributionTargets(sourceWorkbasketId); workbasketService.getDistributionTargets(sourceWorkbasketId);
ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>> response = ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>> response =
ResponseEntity.ok( ResponseEntity.ok(
workbasketSummaryRepresentationModelAssembler workbasketSummaryRepresentationModelAssembler.toDistributionTargetPageModel(
.toDistributionTargetPageModel(distributionTargets, null)); distributionTargets, null));
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getTasksStatusReport(), returning {}", response); LOGGER.debug("Exit from getTasksStatusReport(), returning {}", response);
} }
@ -326,8 +325,8 @@ public class WorkbasketController extends AbstractPagingController {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>> public ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>>
removeDistributionTargetForWorkbasketId( removeDistributionTargetForWorkbasketId(
@PathVariable(value = "workbasketId") String targetWorkbasketId) @PathVariable(value = "workbasketId") String targetWorkbasketId)
throws WorkbasketNotFoundException, NotAuthorizedException { throws WorkbasketNotFoundException, NotAuthorizedException {
LOGGER.debug( LOGGER.debug(
"Entry to removeDistributionTargetForWorkbasketId(workbasketId= {})", targetWorkbasketId); "Entry to removeDistributionTargetForWorkbasketId(workbasketId= {})", targetWorkbasketId);
@ -354,7 +353,7 @@ public class WorkbasketController extends AbstractPagingController {
if (sortBy != null) { if (sortBy != null) {
SortDirection sortDirection; SortDirection sortDirection;
if (params.getFirst(SORT_DIRECTION) != null if (params.getFirst(SORT_DIRECTION) != null
&& "desc".equals(params.getFirst(SORT_DIRECTION))) { && "desc".equals(params.getFirst(SORT_DIRECTION))) {
sortDirection = SortDirection.DESCENDING; sortDirection = SortDirection.DESCENDING;
} else { } else {
sortDirection = SortDirection.ASCENDING; sortDirection = SortDirection.ASCENDING;
@ -388,8 +387,8 @@ public class WorkbasketController extends AbstractPagingController {
return query; return query;
} }
private void applyFilterParams( private void applyFilterParams(WorkbasketQuery query, MultiValueMap<String, String> params)
WorkbasketQuery query, MultiValueMap<String, String> params) throws InvalidArgumentException { throws InvalidArgumentException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to applyFilterParams(query= {}, params= {})", query, params); LOGGER.debug("Entry to applyFilterParams(query= {}, params= {})", query, params);
} }
@ -512,6 +511,5 @@ public class WorkbasketController extends AbstractPagingController {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from applyFilterParams(), returning {}", query); LOGGER.debug("Exit from applyFilterParams(), returning {}", query);
} }
} }
} }

View File

@ -152,8 +152,7 @@ public class WorkbasketDefinitionController {
// STEP 1: update or create workbaskets from the import // STEP 1: update or create workbaskets from the import
for (WorkbasketDefinitionRepresentationModel definition : definitions.getContent()) { for (WorkbasketDefinitionRepresentationModel definition : definitions.getContent()) {
Workbasket importedWb = Workbasket importedWb = workbasketAssembler.toEntityModel(definition.getWorkbasket());
workbasketAssembler.toEntityModel(definition.getWorkbasket());
String newId; String newId;
WorkbasketImpl wbWithoutId = (WorkbasketImpl) removeId(importedWb); WorkbasketImpl wbWithoutId = (WorkbasketImpl) removeId(importedWb);
if (systemIds.containsKey(logicalId(importedWb))) { if (systemIds.containsKey(logicalId(importedWb))) {
@ -230,8 +229,7 @@ public class WorkbasketDefinitionController {
List<String> identifiers = new ArrayList<>(); List<String> identifiers = new ArrayList<>();
Set<String> duplicates = new HashSet<>(); Set<String> duplicates = new HashSet<>();
for (WorkbasketDefinitionRepresentationModel definition : definitions) { for (WorkbasketDefinitionRepresentationModel definition : definitions) {
String identifier = String identifier = logicalId(workbasketAssembler.toEntityModel(definition.getWorkbasket()));
logicalId(workbasketAssembler.toEntityModel(definition.getWorkbasket()));
if (identifiers.contains(identifier)) { if (identifiers.contains(identifier)) {
duplicates.add(identifier); duplicates.add(identifier);
} else { } else {

View File

@ -64,8 +64,8 @@ public class WorkbasketRepresentationModelAssembler
} }
public Workbasket toEntityModel(WorkbasketRepresentationModel repModel) { public Workbasket toEntityModel(WorkbasketRepresentationModel repModel) {
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket(repModel.getKey(), WorkbasketImpl workbasket =
repModel.getDomain()); (WorkbasketImpl) workbasketService.newWorkbasket(repModel.getKey(), repModel.getDomain());
workbasket.setId(repModel.getWorkbasketId()); workbasket.setId(repModel.getWorkbasketId());
workbasket.setName(repModel.getName()); workbasket.setName(repModel.getName());
workbasket.setType(repModel.getType()); workbasket.setType(repModel.getType());

View File

@ -11,6 +11,7 @@ public class WorkbasketDefinitionRepresentationModel
@JsonIgnoreProperties("_links") @JsonIgnoreProperties("_links")
private WorkbasketRepresentationModel workbasket; private WorkbasketRepresentationModel workbasket;
private Collection<WorkbasketAccessItemRepresentationModel> authorizations; private Collection<WorkbasketAccessItemRepresentationModel> authorizations;
private Set<String> distributionTargets; private Set<String> distributionTargets;

View File

@ -4,11 +4,8 @@ import java.time.Instant;
import pro.taskana.workbasket.api.models.Workbasket; import pro.taskana.workbasket.api.models.Workbasket;
/** /** EntityModel class for {@link Workbasket}. */
* EntityModel class for {@link Workbasket}. public class WorkbasketRepresentationModel extends WorkbasketSummaryRepresentationModel {
*/
public class WorkbasketRepresentationModel
extends WorkbasketSummaryRepresentationModel {
private Instant created; // ISO-8601 private Instant created; // ISO-8601
private Instant modified; // ISO-8601 private Instant modified; // ISO-8601

View File

@ -5,9 +5,7 @@ import org.springframework.hateoas.RepresentationModel;
import pro.taskana.workbasket.api.WorkbasketType; import pro.taskana.workbasket.api.WorkbasketType;
import pro.taskana.workbasket.api.models.WorkbasketSummary; import pro.taskana.workbasket.api.models.WorkbasketSummary;
/** /** EntityModel class for {@link WorkbasketSummary}. */
* EntityModel class for {@link WorkbasketSummary}.
*/
public class WorkbasketSummaryRepresentationModel public class WorkbasketSummaryRepresentationModel
extends RepresentationModel<WorkbasketSummaryRepresentationModel> { extends RepresentationModel<WorkbasketSummaryRepresentationModel> {
@ -155,5 +153,4 @@ public class WorkbasketSummaryRepresentationModel
public void setMarkedForDeletion(boolean markedForDeletion) { public void setMarkedForDeletion(boolean markedForDeletion) {
this.markedForDeletion = markedForDeletion; this.markedForDeletion = markedForDeletion;
} }
} }

View File

@ -110,15 +110,11 @@ class ClassificationControllerIntTest {
assertThat(response.getBody().getContent()).hasSize(5); assertThat(response.getBody().getContent()).hasSize(5);
assertThat(response.getBody().getContent().iterator().next().getKey()).isEqualTo("L1050"); assertThat(response.getBody().getContent().iterator().next().getKey()).isEqualTo("L1050");
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
String href = response String href = response.getBody().getRequiredLink(IanaLinkRelations.SELF).getHref();
.getBody()
.getRequiredLink(IanaLinkRelations.SELF)
.getHref();
assertThat( assertThat(
href href.endsWith(
.endsWith( "/api/v1/classifications?"
"/api/v1/classifications?" + "domain=DOMAIN_A&sort-by=key&order=asc&page-size=5&page=2"))
+ "domain=DOMAIN_A&sort-by=key&order=asc&page-size=5&page=2"))
.isTrue(); .isTrue();
assertThat(response.getBody().getLink(IanaLinkRelations.FIRST)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.FIRST)).isNotNull();
assertThat(response.getBody().getLink(IanaLinkRelations.LAST)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.LAST)).isNotNull();

View File

@ -25,8 +25,7 @@ class AccessIdControllerIntTest {
private static RestTemplate template; private static RestTemplate template;
@Autowired @Autowired RestHelper restHelper;
RestHelper restHelper;
@BeforeAll @BeforeAll
static void init() { static void init() {

View File

@ -24,8 +24,7 @@ class GeneralExceptionHandlingTest {
new ParameterizedTypeReference< new ParameterizedTypeReference<
TaskanaPagedModel<ClassificationSummaryRepresentationModel>>() {}; TaskanaPagedModel<ClassificationSummaryRepresentationModel>>() {};
private static RestTemplate template; private static RestTemplate template;
@Autowired @Autowired RestHelper restHelper;
RestHelper restHelper;
@BeforeAll @BeforeAll
static void init() { static void init() {

View File

@ -19,8 +19,7 @@ import pro.taskana.common.rest.models.TaskanaUserInfoRepresentationModel;
class TaskanaEngineControllerIntTest { class TaskanaEngineControllerIntTest {
private static RestTemplate template; private static RestTemplate template;
@Autowired @Autowired RestHelper restHelper;
RestHelper restHelper;
@BeforeAll @BeforeAll
static void init() { static void init() {

View File

@ -67,36 +67,6 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
return bean; return bean;
} }
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.and()
.csrf()
.disable()
.httpBasic()
.and()
.addFilter(jaasApiIntegrationFilter())
.addFilterAfter(new SpringSecurityToJaasFilter(), JaasApiIntegrationFilter.class)
.authorizeRequests()
.anyRequest()
.fullyAuthenticated();
}
@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.ldapAuthentication()
.userDnPatterns(ldapUserDnPatterns)
.groupSearchBase(ldapGroupSearchBase)
.ldapAuthoritiesPopulator(authoritiesPopulator())
.authoritiesMapper(grantedAuthoritiesMapper())
.contextSource()
.url(ldapServerUrl + "/" + ldapBaseDn)
.and()
.passwordCompare()
.passwordAttribute("userPassword");
}
@Bean @Bean
public LdapAuthoritiesPopulator authoritiesPopulator() { public LdapAuthoritiesPopulator authoritiesPopulator() {
Function<Map<String, List<String>>, GrantedAuthority> authorityMapper = Function<Map<String, List<String>>, GrantedAuthority> authorityMapper =
@ -127,12 +97,34 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
return grantedAuthoritiesMapper; return grantedAuthoritiesMapper;
} }
private static class CorsWebMvcConfigurer implements WebMvcConfigurer { @Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.ldapAuthentication()
.userDnPatterns(ldapUserDnPatterns)
.groupSearchBase(ldapGroupSearchBase)
.ldapAuthoritiesPopulator(authoritiesPopulator())
.authoritiesMapper(grantedAuthoritiesMapper())
.contextSource()
.url(ldapServerUrl + "/" + ldapBaseDn)
.and()
.passwordCompare()
.passwordAttribute("userPassword");
}
@Override @Override
public void addCorsMappings(CorsRegistry registry) { protected void configure(HttpSecurity http) throws Exception {
registry.addMapping("/**").allowedOrigins("*");
} http.authorizeRequests()
.and()
.csrf()
.disable()
.httpBasic()
.and()
.addFilter(jaasApiIntegrationFilter())
.addFilterAfter(new SpringSecurityToJaasFilter(), JaasApiIntegrationFilter.class)
.authorizeRequests()
.anyRequest()
.fullyAuthenticated();
} }
private JaasApiIntegrationFilter jaasApiIntegrationFilter() { private JaasApiIntegrationFilter jaasApiIntegrationFilter() {
@ -140,4 +132,12 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
filter.setCreateEmptySubject(true); filter.setCreateEmptySubject(true);
return filter; return filter;
} }
private static class CorsWebMvcConfigurer implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedOrigins("*");
}
}
} }

View File

@ -22,13 +22,10 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import pro.taskana.common.rest.Mapping; import pro.taskana.common.rest.Mapping;
/** /** Generate REST Dokumentation for ClassificationController. */
* Generate REST Dokumentation for ClassificationController.
*/
class ClassificationControllerRestDocumentation extends BaseRestDocumentation { class ClassificationControllerRestDocumentation extends BaseRestDocumentation {
private final HashMap<String, String> classificationFieldDescriptionsMap = private final HashMap<String, String> classificationFieldDescriptionsMap = new HashMap<>();
new HashMap<>();
private FieldDescriptor[] allClassificationsFieldDescriptors; private FieldDescriptor[] allClassificationsFieldDescriptors;
private FieldDescriptor[] classificationFieldDescriptors; private FieldDescriptor[] classificationFieldDescriptors;
@ -253,7 +250,7 @@ class ClassificationControllerRestDocumentation extends BaseRestDocumentation {
this.mockMvc this.mockMvc
.perform( .perform(
RestDocumentationRequestBuilders.get( RestDocumentationRequestBuilders.get(
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS) + "?domain=DOMAIN_B") restHelper.toUrl(Mapping.URL_CLASSIFICATIONS) + "?domain=DOMAIN_B")
.accept("application/hal+json") .accept("application/hal+json")
.header("Authorization", TEAMLEAD_1_CREDENTIALS)) .header("Authorization", TEAMLEAD_1_CREDENTIALS))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())

View File

@ -82,10 +82,10 @@ class TaskCommentControllerRestDocumentation extends BaseRestDocumentation {
}; };
allTaskCommentsFieldDescriptors = allTaskCommentsFieldDescriptors =
new FieldDescriptor[]{ new FieldDescriptor[] {
subsectionWithPath(TaskanaPagedModelKeys.TASK_COMMENTS.getPropertyName()).description( subsectionWithPath(TaskanaPagedModelKeys.TASK_COMMENTS.getPropertyName())
"An Array of task comments"), .description("An Array of task comments"),
fieldWithPath("_links.self.href").ignored() fieldWithPath("_links.self.href").ignored()
}; };
} }

View File

@ -60,11 +60,9 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
taskFieldDescriptionsMap.put("priority", "The priority of the task"); taskFieldDescriptionsMap.put("priority", "The priority of the task");
taskFieldDescriptionsMap.put("state", "he state of the task. See (...)"); taskFieldDescriptionsMap.put("state", "he state of the task. See (...)");
taskFieldDescriptionsMap.put( taskFieldDescriptionsMap.put(
"classificationSummary", "classificationSummary", "The <<classification-subset, Classification>> of the task");
"The <<classification-subset, Classification>> of the task");
taskFieldDescriptionsMap.put( taskFieldDescriptionsMap.put(
"workbasketSummary", "workbasketSummary", "The <<workbasket-subset, Workbasket>> of the task");
"The <<workbasket-subset, Workbasket>> of the task");
taskFieldDescriptionsMap.put("businessProcessId", ""); taskFieldDescriptionsMap.put("businessProcessId", "");
taskFieldDescriptionsMap.put("parentBusinessProcessId", ""); taskFieldDescriptionsMap.put("parentBusinessProcessId", "");
taskFieldDescriptionsMap.put( taskFieldDescriptionsMap.put(
@ -133,30 +131,28 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
.description(taskFieldDescriptionsMap.get("planned")) .description(taskFieldDescriptionsMap.get("planned"))
.type("String"), .type("String"),
fieldWithPath("due").description(taskFieldDescriptionsMap.get("due")).type("String"), fieldWithPath("due").description(taskFieldDescriptionsMap.get("due")).type("String"),
fieldWithPath("name").description(taskFieldDescriptionsMap.get("name")), fieldWithPath("name").description(taskFieldDescriptionsMap.get("name")),
fieldWithPath("creator").description(taskFieldDescriptionsMap.get("creator")), fieldWithPath("creator").description(taskFieldDescriptionsMap.get("creator")),
fieldWithPath("description").description(taskFieldDescriptionsMap.get("description")), fieldWithPath("description").description(taskFieldDescriptionsMap.get("description")),
fieldWithPath("note") fieldWithPath("note")
.description(taskFieldDescriptionsMap.get("note")) .description(taskFieldDescriptionsMap.get("note"))
.description("Some custom Note"), .description("Some custom Note"),
fieldWithPath("priority").description(taskFieldDescriptionsMap.get("priority")), fieldWithPath("priority").description(taskFieldDescriptionsMap.get("priority")),
fieldWithPath("state").description(taskFieldDescriptionsMap.get("state")), fieldWithPath("state").description(taskFieldDescriptionsMap.get("state")),
subsectionWithPath("classificationSummary") subsectionWithPath("classificationSummary")
.description( .description(taskFieldDescriptionsMap.get("classificationSummary")),
taskFieldDescriptionsMap.get("classificationSummary")), subsectionWithPath("workbasketSummary")
subsectionWithPath("workbasketSummary") .description(taskFieldDescriptionsMap.get("workbasketSummary")),
.description(taskFieldDescriptionsMap.get("workbasketSummary")), fieldWithPath("businessProcessId")
fieldWithPath("businessProcessId") .description(taskFieldDescriptionsMap.get("businessProcessId")),
.description(taskFieldDescriptionsMap.get("businessProcessId")), fieldWithPath("parentBusinessProcessId")
fieldWithPath("parentBusinessProcessId") .description(taskFieldDescriptionsMap.get("parentBusinessProcessId")),
.description(taskFieldDescriptionsMap.get("parentBusinessProcessId")), fieldWithPath("owner").description(taskFieldDescriptionsMap.get("owner")).type("String"),
fieldWithPath("owner").description(taskFieldDescriptionsMap.get("owner")).type( fieldWithPath("primaryObjRef.id")
"String"), .description(taskFieldDescriptionsMap.get("primaryObjRef.id"))
fieldWithPath("primaryObjRef.id") .type("String"),
.description(taskFieldDescriptionsMap.get("primaryObjRef.id")) fieldWithPath("primaryObjRef.company")
.type("String"), .description(taskFieldDescriptionsMap.get("primaryObjRef.company")),
fieldWithPath("primaryObjRef.company")
.description(taskFieldDescriptionsMap.get("primaryObjRef.company")),
fieldWithPath("primaryObjRef.system") fieldWithPath("primaryObjRef.system")
.description(taskFieldDescriptionsMap.get("primaryObjRef.system")), .description(taskFieldDescriptionsMap.get("primaryObjRef.system")),
fieldWithPath("primaryObjRef.systemInstance") fieldWithPath("primaryObjRef.systemInstance")
@ -238,29 +234,28 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
.description(taskFieldDescriptionsMap.get("planned")) .description(taskFieldDescriptionsMap.get("planned"))
.type("String"), .type("String"),
fieldWithPath("due").description(taskFieldDescriptionsMap.get("due")).type("String"), fieldWithPath("due").description(taskFieldDescriptionsMap.get("due")).type("String"),
fieldWithPath("name").description(taskFieldDescriptionsMap.get("name")), fieldWithPath("name").description(taskFieldDescriptionsMap.get("name")),
fieldWithPath("creator").description(taskFieldDescriptionsMap.get("creator")), fieldWithPath("creator").description(taskFieldDescriptionsMap.get("creator")),
fieldWithPath("description").ignored(), fieldWithPath("description").ignored(),
fieldWithPath("note") fieldWithPath("note")
.description(taskFieldDescriptionsMap.get("note")) .description(taskFieldDescriptionsMap.get("note"))
.description("Some custom Note"), .description("Some custom Note"),
fieldWithPath("priority").description(taskFieldDescriptionsMap.get("priority")), fieldWithPath("priority").description(taskFieldDescriptionsMap.get("priority")),
fieldWithPath("state").description(taskFieldDescriptionsMap.get("state")), fieldWithPath("state").description(taskFieldDescriptionsMap.get("state")),
subsectionWithPath("classificationSummary") subsectionWithPath("classificationSummary")
.description( .description(taskFieldDescriptionsMap.get("classificationSummary")),
taskFieldDescriptionsMap.get("classificationSummary")), subsectionWithPath("workbasketSummary")
subsectionWithPath("workbasketSummary") .description(taskFieldDescriptionsMap.get("workbasketSummary")),
.description(taskFieldDescriptionsMap.get("workbasketSummary")), fieldWithPath("businessProcessId")
fieldWithPath("businessProcessId") .description(taskFieldDescriptionsMap.get("businessProcessId")),
.description(taskFieldDescriptionsMap.get("businessProcessId")), fieldWithPath("parentBusinessProcessId")
fieldWithPath("parentBusinessProcessId") .description(taskFieldDescriptionsMap.get("parentBusinessProcessId")),
.description(taskFieldDescriptionsMap.get("parentBusinessProcessId")), fieldWithPath("owner").description(taskFieldDescriptionsMap.get("owner")),
fieldWithPath("owner").description(taskFieldDescriptionsMap.get("owner")), fieldWithPath("primaryObjRef.id")
fieldWithPath("primaryObjRef.id") .description(taskFieldDescriptionsMap.get("primaryObjRef.id"))
.description(taskFieldDescriptionsMap.get("primaryObjRef.id")) .type("String"),
.type("String"), fieldWithPath("primaryObjRef.company")
fieldWithPath("primaryObjRef.company") .description(taskFieldDescriptionsMap.get("primaryObjRef.company")),
.description(taskFieldDescriptionsMap.get("primaryObjRef.company")),
fieldWithPath("primaryObjRef.system") fieldWithPath("primaryObjRef.system")
.description(taskFieldDescriptionsMap.get("primaryObjRef.system")), .description(taskFieldDescriptionsMap.get("primaryObjRef.system")),
fieldWithPath("primaryObjRef.systemInstance") fieldWithPath("primaryObjRef.systemInstance")
@ -294,21 +289,21 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
}; };
createTaskFieldDescriptors = createTaskFieldDescriptors =
new FieldDescriptor[]{ new FieldDescriptor[] {
subsectionWithPath("classificationSummary") subsectionWithPath("classificationSummary")
.description("The new classificationSummary for the task"), .description("The new classificationSummary for the task"),
subsectionWithPath("workbasketSummary") subsectionWithPath("workbasketSummary")
.description("The new workbasketSummary for the task"), .description("The new workbasketSummary for the task"),
fieldWithPath("externalId") fieldWithPath("externalId")
.description(taskFieldDescriptionsMap.get("externalId")) .description(taskFieldDescriptionsMap.get("externalId"))
.type("String") .type("String")
.optional(), .optional(),
fieldWithPath("primaryObjRef.company") fieldWithPath("primaryObjRef.company")
.description(taskFieldDescriptionsMap.get("primaryObjRef.company")), .description(taskFieldDescriptionsMap.get("primaryObjRef.company")),
fieldWithPath("primaryObjRef.system") fieldWithPath("primaryObjRef.system")
.description(taskFieldDescriptionsMap.get("primaryObjRef.system")), .description(taskFieldDescriptionsMap.get("primaryObjRef.system")),
fieldWithPath("primaryObjRef.systemInstance") fieldWithPath("primaryObjRef.systemInstance")
.description(taskFieldDescriptionsMap.get("primaryObjRef.systemInstance")), .description(taskFieldDescriptionsMap.get("primaryObjRef.systemInstance")),
fieldWithPath("primaryObjRef.type") fieldWithPath("primaryObjRef.type")
.description(taskFieldDescriptionsMap.get("primaryObjRef.type")), .description(taskFieldDescriptionsMap.get("primaryObjRef.type")),
fieldWithPath("primaryObjRef.value") fieldWithPath("primaryObjRef.value")

View File

@ -38,8 +38,8 @@ class WorkbasketDefinitionControllerRestDocumentation extends BaseRestDocumentat
void exportAllWorkbasketDefinitions() throws Exception { void exportAllWorkbasketDefinitions() throws Exception {
this.mockMvc this.mockMvc
.perform( .perform(
RestDocumentationRequestBuilders RestDocumentationRequestBuilders.get(
.get(restHelper.toUrl(Mapping.URL_WORKBASKET_DEFINITIONS)) restHelper.toUrl(Mapping.URL_WORKBASKET_DEFINITIONS))
.accept("application/json") .accept("application/json")
.header("Authorization", TEAMLEAD_1_CREDENTIALS)) .header("Authorization", TEAMLEAD_1_CREDENTIALS))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())

View File

@ -24,9 +24,7 @@ import pro.taskana.monitor.api.reports.item.DetailedMonitorQueryItem;
import pro.taskana.monitor.api.reports.item.MonitorQueryItem; import pro.taskana.monitor.api.reports.item.MonitorQueryItem;
import pro.taskana.monitor.rest.assembler.ReportRepresentationModelAssembler; import pro.taskana.monitor.rest.assembler.ReportRepresentationModelAssembler;
/** /** Test for {@link ReportRepresentationModelAssembler}. */
* Test for {@link ReportRepresentationModelAssembler}.
*/
@TaskanaSpringBootTest @TaskanaSpringBootTest
class ReportRepresentationModelTest { class ReportRepresentationModelTest {

View File

@ -26,23 +26,19 @@ import pro.taskana.common.rest.TaskanaSpringBootTest;
import pro.taskana.common.rest.models.TaskanaPagedModel; import pro.taskana.common.rest.models.TaskanaPagedModel;
import pro.taskana.task.rest.models.TaskCommentRepresentationModel; import pro.taskana.task.rest.models.TaskCommentRepresentationModel;
/** /** Test TaskCommentController. */
* Test TaskCommentController.
*/
@TaskanaSpringBootTest @TaskanaSpringBootTest
class TaskCommentControllerIntTest { class TaskCommentControllerIntTest {
private static final ParameterizedTypeReference<TaskanaPagedModel<TaskCommentRepresentationModel>> private static final ParameterizedTypeReference<TaskanaPagedModel<TaskCommentRepresentationModel>>
TASK_COMMENT_PAGE_MODEL_TYPE = TASK_COMMENT_PAGE_MODEL_TYPE =
new ParameterizedTypeReference<TaskanaPagedModel<TaskCommentRepresentationModel>>() { new ParameterizedTypeReference<TaskanaPagedModel<TaskCommentRepresentationModel>>() {};
};
private static RestTemplate template; private static RestTemplate template;
@Value("${taskana.schemaName:TASKANA}") @Value("${taskana.schemaName:TASKANA}")
public String schemaName; public String schemaName;
@Autowired @Autowired RestHelper restHelper;
RestHelper restHelper;
@BeforeAll @BeforeAll
static void init() { static void init() {
@ -92,15 +88,16 @@ class TaskCommentControllerIntTest {
void should_ReturnSortedAndOrederedTaskCommentsSortedByModified_When_UsingSortAndOrderParams() { void should_ReturnSortedAndOrederedTaskCommentsSortedByModified_When_UsingSortAndOrderParams() {
String url = String url =
restHelper.toUrl(Mapping.URL_TASK_GET_POST_COMMENTS, restHelper.toUrl(
"TKI:000000000000000000000000000000000000"); Mapping.URL_TASK_GET_POST_COMMENTS, "TKI:000000000000000000000000000000000000");
ResponseEntity<TaskanaPagedModel<TaskCommentRepresentationModel>> ResponseEntity<TaskanaPagedModel<TaskCommentRepresentationModel>>
getTaskCommentsSortedByModifiedOrderedByDescendingResponse = template.exchange( getTaskCommentsSortedByModifiedOrderedByDescendingResponse =
url + "?sort-by=modified&order=desc", template.exchange(
HttpMethod.GET, url + "?sort-by=modified&order=desc",
new HttpEntity<String>(restHelper.getHeadersAdmin()), HttpMethod.GET,
TASK_COMMENT_PAGE_MODEL_TYPE); new HttpEntity<String>(restHelper.getHeadersAdmin()),
TASK_COMMENT_PAGE_MODEL_TYPE);
assertThat(getTaskCommentsSortedByModifiedOrderedByDescendingResponse.getBody().getContent()) assertThat(getTaskCommentsSortedByModifiedOrderedByDescendingResponse.getBody().getContent())
.hasSize(3) .hasSize(3)
@ -108,11 +105,12 @@ class TaskCommentControllerIntTest {
.isSortedAccordingTo(Comparator.reverseOrder()); .isSortedAccordingTo(Comparator.reverseOrder());
ResponseEntity<TaskanaPagedModel<TaskCommentRepresentationModel>> ResponseEntity<TaskanaPagedModel<TaskCommentRepresentationModel>>
getTaskCommentsSortedByModifiedOrderedByAscendingResponse = template.exchange( getTaskCommentsSortedByModifiedOrderedByAscendingResponse =
url + "?sort-by=modified", template.exchange(
HttpMethod.GET, url + "?sort-by=modified",
new HttpEntity<String>(restHelper.getHeadersAdmin()), HttpMethod.GET,
TASK_COMMENT_PAGE_MODEL_TYPE); new HttpEntity<String>(restHelper.getHeadersAdmin()),
TASK_COMMENT_PAGE_MODEL_TYPE);
assertThat(getTaskCommentsSortedByModifiedOrderedByAscendingResponse.getBody().getContent()) assertThat(getTaskCommentsSortedByModifiedOrderedByAscendingResponse.getBody().getContent())
.hasSize(3) .hasSize(3)
@ -120,11 +118,12 @@ class TaskCommentControllerIntTest {
.isSortedAccordingTo(Comparator.naturalOrder()); .isSortedAccordingTo(Comparator.naturalOrder());
ResponseEntity<TaskanaPagedModel<TaskCommentRepresentationModel>> ResponseEntity<TaskanaPagedModel<TaskCommentRepresentationModel>>
getTaskCommentsSortedByCreatedOrderedByDescendingResponse = template.exchange( getTaskCommentsSortedByCreatedOrderedByDescendingResponse =
url + "?sort-by=created&order=desc", template.exchange(
HttpMethod.GET, url + "?sort-by=created&order=desc",
new HttpEntity<String>(restHelper.getHeadersAdmin()), HttpMethod.GET,
TASK_COMMENT_PAGE_MODEL_TYPE); new HttpEntity<String>(restHelper.getHeadersAdmin()),
TASK_COMMENT_PAGE_MODEL_TYPE);
assertThat(getTaskCommentsSortedByCreatedOrderedByDescendingResponse.getBody().getContent()) assertThat(getTaskCommentsSortedByCreatedOrderedByDescendingResponse.getBody().getContent())
.hasSize(3) .hasSize(3)
@ -132,26 +131,26 @@ class TaskCommentControllerIntTest {
.isSortedAccordingTo(Comparator.reverseOrder()); .isSortedAccordingTo(Comparator.reverseOrder());
ResponseEntity<TaskanaPagedModel<TaskCommentRepresentationModel>> ResponseEntity<TaskanaPagedModel<TaskCommentRepresentationModel>>
getTaskCommentsSortedByCreatedOrderedByAscendingResponse = template.exchange( getTaskCommentsSortedByCreatedOrderedByAscendingResponse =
url + "?sort-by=created", template.exchange(
HttpMethod.GET, url + "?sort-by=created",
new HttpEntity<String>(restHelper.getHeadersAdmin()), HttpMethod.GET,
TASK_COMMENT_PAGE_MODEL_TYPE); new HttpEntity<String>(restHelper.getHeadersAdmin()),
TASK_COMMENT_PAGE_MODEL_TYPE);
assertThat(getTaskCommentsSortedByCreatedOrderedByAscendingResponse.getBody().getContent()) assertThat(getTaskCommentsSortedByCreatedOrderedByAscendingResponse.getBody().getContent())
.hasSize(3) .hasSize(3)
.extracting(TaskCommentRepresentationModel::getCreated) .extracting(TaskCommentRepresentationModel::getCreated)
.isSortedAccordingTo(Comparator.naturalOrder()); .isSortedAccordingTo(Comparator.naturalOrder());
} }
@Test @Test
void should_ThrowException_When_UsingInvalidSortParam() { void should_ThrowException_When_UsingInvalidSortParam() {
String url = String url =
restHelper.toUrl(Mapping.URL_TASK_GET_POST_COMMENTS, restHelper.toUrl(
"TKI:000000000000000000000000000000000000"); Mapping.URL_TASK_GET_POST_COMMENTS, "TKI:000000000000000000000000000000000000");
ThrowingCallable httpCall = ThrowingCallable httpCall =
() -> { () -> {
template.exchange( template.exchange(
@ -163,10 +162,8 @@ class TaskCommentControllerIntTest {
assertThatThrownBy(httpCall) assertThatThrownBy(httpCall)
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode()) .extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
.isEqualTo(HttpStatus.BAD_REQUEST); .isEqualTo(HttpStatus.BAD_REQUEST);
} }
@Disabled("Disabled until Authorization check is up!") @Disabled("Disabled until Authorization check is up!")
@Test @Test
void should_FailToReturnTaskComment_When_TaskIstNotVisible() { void should_FailToReturnTaskComment_When_TaskIstNotVisible() {
@ -338,12 +335,12 @@ class TaskCommentControllerIntTest {
ResponseEntity<TaskanaPagedModel<TaskCommentRepresentationModel>> ResponseEntity<TaskanaPagedModel<TaskCommentRepresentationModel>>
getTaskCommentsBeforeDeleteionResponse = getTaskCommentsBeforeDeleteionResponse =
template.exchange( template.exchange(
restHelper.toUrl( restHelper.toUrl(
Mapping.URL_TASK_COMMENTS, "TKI:000000000000000000000000000000000001"), Mapping.URL_TASK_COMMENTS, "TKI:000000000000000000000000000000000001"),
HttpMethod.GET, HttpMethod.GET,
new HttpEntity<String>(restHelper.getHeadersAdmin()), new HttpEntity<String>(restHelper.getHeadersAdmin()),
TASK_COMMENT_PAGE_MODEL_TYPE); TASK_COMMENT_PAGE_MODEL_TYPE);
assertThat(getTaskCommentsBeforeDeleteionResponse.getBody().getContent()).hasSize(2); assertThat(getTaskCommentsBeforeDeleteionResponse.getBody().getContent()).hasSize(2);
String url = String url =

View File

@ -149,9 +149,7 @@ class WorkbasketControllerIntTest {
TEMPLATE.exchange( TEMPLATE.exchange(
restHelper.toUrl(Mapping.URL_WORKBASKET_ID, workbasketId), restHelper.toUrl(Mapping.URL_WORKBASKET_ID, workbasketId),
HttpMethod.PUT, HttpMethod.PUT,
new HttpEntity<>( new HttpEntity<>(workbasketRepresentationModel, restHelper.getHeadersTeamlead_1()),
workbasketRepresentationModel,
restHelper.getHeadersTeamlead_1()),
ParameterizedTypeReference.forType(WorkbasketRepresentationModel.class)); ParameterizedTypeReference.forType(WorkbasketRepresentationModel.class));
}; };
assertThatThrownBy(httpCall) assertThatThrownBy(httpCall)
@ -287,8 +285,7 @@ class WorkbasketControllerIntTest {
WORKBASKET_SUMMARY_PAGE_MODEL_TYPE); WORKBASKET_SUMMARY_PAGE_MODEL_TYPE);
assertThat(response.getBody()).isNotNull(); assertThat(response.getBody()).isNotNull();
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
assertThat(response.getHeaders().getContentType()) assertThat(response.getHeaders().getContentType()).isEqualTo(MediaTypes.HAL_JSON);
.isEqualTo(MediaTypes.HAL_JSON);
assertThat(response.getBody().getContent()).hasSize(4); assertThat(response.getBody().getContent()).hasSize(4);
} }
} }