task/828: Unify and reduce the response and logger code in the controllers

This commit is contained in:
Jose Ignacio Recuerda Cambil 2019-03-11 16:23:17 +01:00 committed by Martin Rojas Miguel Angel
parent 114edfb50c
commit cbc2ff16ac
9 changed files with 158 additions and 113 deletions

View File

@ -46,26 +46,28 @@ public class AccessIdController {
"searchFor string '" + searchFor + "' is too short. Minimum searchFor length = " "searchFor string '" + searchFor + "' is too short. Minimum searchFor length = "
+ ldapClient.getMinSearchForLength()); + ldapClient.getMinSearchForLength());
} }
ResponseEntity<List<AccessIdResource>> response;
if (ldapClient.useLdap()) { if (ldapClient.useLdap()) {
List<AccessIdResource> accessIdUsers = ldapClient.searchUsersAndGroups(searchFor); List<AccessIdResource> accessIdUsers = ldapClient.searchUsersAndGroups(searchFor);
response = new ResponseEntity<>(accessIdUsers, HttpStatus.OK);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from validateAccessIds(), returning {}", new ResponseEntity<>(accessIdUsers, HttpStatus.OK)); LOGGER.debug("Exit from validateAccessIds(), returning {}", response);
} }
return new ResponseEntity<>(accessIdUsers, HttpStatus.OK); return response;
} else if (ldapCache != null) { } else if (ldapCache != null) {
if (LOGGER.isDebugEnabled()) { response = new ResponseEntity<>(
LOGGER.debug("Exit from validateAccessIds(), returning {}", new ResponseEntity<>(
ldapCache.findMatchingAccessId(searchFor, ldapClient.getMaxNumberOfReturnedAccessIds()),
HttpStatus.OK));
}
return new ResponseEntity<>(
ldapCache.findMatchingAccessId(searchFor, ldapClient.getMaxNumberOfReturnedAccessIds()), ldapCache.findMatchingAccessId(searchFor, ldapClient.getMaxNumberOfReturnedAccessIds()),
HttpStatus.OK); HttpStatus.OK);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from validateAccessIds(), returning {}", response);
}
return response;
} else { } else {
LOGGER.debug("Exit from validateAccessIds(), returning {}", new ResponseEntity<>(new ArrayList<>(), HttpStatus.NOT_FOUND)); response = new ResponseEntity<>(new ArrayList<>(), HttpStatus.NOT_FOUND);
return new ResponseEntity<>(new ArrayList<>(), HttpStatus.NOT_FOUND); LOGGER.debug("Exit from validateAccessIds(), returning {}", response);
return response;
} }
} }
@ -79,24 +81,28 @@ public class AccessIdController {
} }
} }
List<AccessIdResource> accessIdUsers; List<AccessIdResource> accessIdUsers;
ResponseEntity<List<AccessIdResource>> response;
if (ldapClient.useLdap()) { if (ldapClient.useLdap()) {
accessIdUsers = ldapClient.searchUsersAndGroups(accessId); accessIdUsers = ldapClient.searchUsersAndGroups(accessId);
accessIdUsers.addAll(ldapClient.searchGroupsofUsersIsMember(accessId)); accessIdUsers.addAll(ldapClient.searchGroupsofUsersIsMember(accessId));
response = new ResponseEntity<>(accessIdUsers, HttpStatus.OK);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getGroupsByAccessId(), returning {}", new ResponseEntity<>(accessIdUsers, HttpStatus.OK)); LOGGER.debug("Exit from getGroupsByAccessId(), returning {}", response);
} }
return new ResponseEntity<>(accessIdUsers, HttpStatus.OK); return response;
} else if (ldapCache != null) { } else if (ldapCache != null) {
accessIdUsers = ldapCache.findGroupsOfUser(accessId, ldapClient.getMaxNumberOfReturnedAccessIds()); accessIdUsers = ldapCache.findGroupsOfUser(accessId, ldapClient.getMaxNumberOfReturnedAccessIds());
response = new ResponseEntity<>(accessIdUsers, HttpStatus.OK);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getGroupsByAccessId(), returning {}", new ResponseEntity<>(accessIdUsers, HttpStatus.OK)); LOGGER.debug("Exit from getGroupsByAccessId(), returning {}", response);
} }
return new ResponseEntity<>(accessIdUsers, HttpStatus.OK); return response;
} else { } else {
LOGGER.debug("Exit from getGroupsByAccessId(), returning {}", new ResponseEntity<>(new ArrayList<>(), HttpStatus.NOT_FOUND)); response = new ResponseEntity<>(new ArrayList<>(), HttpStatus.NOT_FOUND);
return new ResponseEntity<>(new ArrayList<>(), HttpStatus.NOT_FOUND); LOGGER.debug("Exit from getGroupsByAccessId(), returning {}", response);
return response;
} }
} }

View File

@ -114,11 +114,13 @@ public class ClassificationController extends AbstractPagingController {
PagedResources<ClassificationSummaryResource> pagedResources = assembler.toResources(classificationSummaries, PagedResources<ClassificationSummaryResource> pagedResources = assembler.toResources(classificationSummaries,
pageMetadata); pageMetadata);
ResponseEntity<PagedResources<ClassificationSummaryResource>> response = new ResponseEntity<>(pagedResources,
HttpStatus.OK);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getClassifications(), returning {}", new ResponseEntity<>(pagedResources, HttpStatus.OK)); LOGGER.debug("Exit from getClassifications(), returning {}", response);
} }
return new ResponseEntity<>(pagedResources, HttpStatus.OK); return response;
} }
@GetMapping(path = "/{classificationId}") @GetMapping(path = "/{classificationId}")
@ -128,11 +130,13 @@ public class ClassificationController extends AbstractPagingController {
ConcurrencyException, DomainNotFoundException, InvalidArgumentException { ConcurrencyException, DomainNotFoundException, InvalidArgumentException {
LOGGER.debug("Entry to getClassification(classificationId= {})", classificationId); LOGGER.debug("Entry to getClassification(classificationId= {})", classificationId);
Classification classification = classificationService.getClassification(classificationId); Classification classification = classificationService.getClassification(classificationId);
ResponseEntity<ClassificationResource> response = new ResponseEntity<>(
classificationResourceAssembler.toResource(classification), HttpStatus.OK);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getClassification(), returning {}", ResponseEntity.status(HttpStatus.OK).body(classificationResourceAssembler.toResource(classification))); LOGGER.debug("Exit from getClassification(), returning {}", response);
} }
return ResponseEntity.status(HttpStatus.OK).body(classificationResourceAssembler.toResource(classification)); return response;
} }
@PostMapping @PostMapping
@ -147,13 +151,14 @@ public class ClassificationController extends AbstractPagingController {
Classification classification = classificationResourceAssembler.toModel(resource); Classification classification = classificationResourceAssembler.toModel(resource);
classification = classificationService.createClassification(classification); classification = classificationService.createClassification(classification);
ResponseEntity<ClassificationResource> response = new ResponseEntity<>(
classificationResourceAssembler.toResource(classification), HttpStatus.CREATED);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from createClassification(), returning {}", ResponseEntity.status(HttpStatus.CREATED) LOGGER.debug("Exit from createClassification(), returning {}", response);
.body(classificationResourceAssembler.toResource(classification)));
} }
return ResponseEntity.status(HttpStatus.CREATED) return response;
.body(classificationResourceAssembler.toResource(classification));
} }
@PutMapping(path = "/{classificationId}") @PutMapping(path = "/{classificationId}")
@ -163,14 +168,15 @@ public class ClassificationController extends AbstractPagingController {
throws NotAuthorizedException, ClassificationNotFoundException, ConcurrencyException, throws NotAuthorizedException, ClassificationNotFoundException, ConcurrencyException,
ClassificationAlreadyExistException, DomainNotFoundException, InvalidArgumentException { ClassificationAlreadyExistException, DomainNotFoundException, InvalidArgumentException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to updateClassification(classificationId= {}, resource= {})", classificationId, resource); LOGGER.debug("Entry to updateClassification(classificationId= {}, resource= {})", classificationId,
resource);
} }
ResponseEntity<ClassificationResource> result; ResponseEntity<ClassificationResource> result;
if (classificationId.equals(resource.classificationId)) { if (classificationId.equals(resource.classificationId)) {
Classification classification = classificationResourceAssembler.toModel(resource); Classification classification = classificationResourceAssembler.toModel(resource);
classification = classificationService.updateClassification(classification); classification = classificationService.updateClassification(classification);
result = ResponseEntity.ok(classificationResourceAssembler.toResource(classification)); result = new ResponseEntity<>(classificationResourceAssembler.toResource(classification), HttpStatus.OK);
} else { } else {
throw new InvalidArgumentException( throw new InvalidArgumentException(
"ClassificationId ('" + classificationId "ClassificationId ('" + classificationId
@ -190,8 +196,9 @@ public class ClassificationController extends AbstractPagingController {
throws ClassificationNotFoundException, ClassificationInUseException, NotAuthorizedException { throws ClassificationNotFoundException, ClassificationInUseException, NotAuthorizedException {
LOGGER.debug("Entry to deleteClassification(classificationId= {})", classificationId); LOGGER.debug("Entry to deleteClassification(classificationId= {})", classificationId);
classificationService.deleteClassification(classificationId); classificationService.deleteClassification(classificationId);
LOGGER.debug("Exit from deleteClassification(), returning {}", ResponseEntity.status(HttpStatus.NO_CONTENT).build()); ResponseEntity response = new ResponseEntity<>(HttpStatus.NO_CONTENT);
return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); LOGGER.debug("Exit from deleteClassification(), returning {}", response);
return response;
} }
private ClassificationQuery applySortingParams(ClassificationQuery query, MultiValueMap<String, String> params) private ClassificationQuery applySortingParams(ClassificationQuery query, MultiValueMap<String, String> params)

View File

@ -37,10 +37,8 @@ import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Set; import java.util.Set;
@ -78,11 +76,12 @@ public class ClassificationDefinitionController {
export.add(classificationResourceAssembler.toDefinition(classification)); export.add(classificationResourceAssembler.toDefinition(classification));
} }
ResponseEntity<List<ClassificationResource>> response = new ResponseEntity<>(export, HttpStatus.OK);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from exportClassifications(), returning {}", new ResponseEntity<>(export, HttpStatus.OK)); LOGGER.debug("Exit from exportClassifications(), returning {}", response);
} }
return new ResponseEntity<>(export, HttpStatus.OK); return response;
} }
@PostMapping @PostMapping
@ -95,11 +94,12 @@ public class ClassificationDefinitionController {
Map<String, String> systemIds = getSystemIds(); Map<String, String> systemIds = getSystemIds();
List<ClassificationResource> classificationsResources = extractClassificationResourcesFromFile(file); List<ClassificationResource> classificationsResources = extractClassificationResourcesFromFile(file);
Map<Classification, String> childsInFile = mapChildsToParentKeys(classificationsResources, systemIds); Map<Classification, String> childrenInFile = mapChildrenToParentKeys(classificationsResources, systemIds);
insertOrUpdateClassificationsWithoutParent(classificationsResources, systemIds); insertOrUpdateClassificationsWithoutParent(classificationsResources, systemIds);
updateParentChildRelations(childsInFile); updateParentChildrenRelations(childrenInFile);
LOGGER.debug("Exit from importClassifications(), returning {}", new ResponseEntity<>(HttpStatus.OK)); ResponseEntity<String> response = new ResponseEntity<>(HttpStatus.OK);
return new ResponseEntity<>(HttpStatus.OK); LOGGER.debug("Exit from importClassifications(), returning {}", response);
return response;
} }
private Map<String, String> getSystemIds() { private Map<String, String> getSystemIds() {
@ -111,7 +111,7 @@ public class ClassificationDefinitionController {
} }
private List<ClassificationResource> extractClassificationResourcesFromFile(MultipartFile file) private List<ClassificationResource> extractClassificationResourcesFromFile(MultipartFile file)
throws IOException, JsonParseException, JsonMappingException { throws IOException {
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
List<ClassificationResource> classificationsDefinitions = mapper.readValue(file.getInputStream(), List<ClassificationResource> classificationsDefinitions = mapper.readValue(file.getInputStream(),
@ -121,9 +121,9 @@ public class ClassificationDefinitionController {
return classificationsDefinitions; return classificationsDefinitions;
} }
private Map<Classification, String> mapChildsToParentKeys(List<ClassificationResource> classificationResources, Map<String, String> systemIds) { private Map<Classification, String> mapChildrenToParentKeys(List<ClassificationResource> classificationResources, Map<String, String> systemIds) {
LOGGER.debug("Entry to mapChildsToParentKeys()"); LOGGER.debug("Entry to mapChildrenToParentKeys()");
Map<Classification, String> childsInFile = new HashMap<>(); Map<Classification, String> childrenInFile = new HashMap<>();
Set<String> newKeysWithDomain = new HashSet<>(); Set<String> newKeysWithDomain = new HashSet<>();
classificationResources.forEach(cl -> newKeysWithDomain.add(cl.getKey() + "|" + cl.getDomain())); classificationResources.forEach(cl -> newKeysWithDomain.add(cl.getKey() + "|" + cl.getDomain()));
@ -142,15 +142,15 @@ public class ClassificationDefinitionController {
String parentKeyAndDomain = cl.parentKey + "|" + cl.domain; String parentKeyAndDomain = cl.parentKey + "|" + cl.domain;
if (!cl.getParentKey().isEmpty() && !cl.getParentKey().equals("")) { if (!cl.getParentKey().isEmpty() && !cl.getParentKey().equals("")) {
if (newKeysWithDomain.contains(parentKeyAndDomain) || systemIds.containsKey(parentKeyAndDomain)) { if (newKeysWithDomain.contains(parentKeyAndDomain) || systemIds.containsKey(parentKeyAndDomain)) {
childsInFile.put(classificationResourceAssembler.toModel(cl), cl.getParentKey()); childrenInFile.put(classificationResourceAssembler.toModel(cl), cl.getParentKey());
} }
} }
} }
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from mapChildsToParentKeys(), returning {}", LoggerUtils.mapToString(childsInFile)); LOGGER.debug("Exit from mapChildrenToParentKeys(), returning {}", LoggerUtils.mapToString(childrenInFile));
} }
return childsInFile; return childrenInFile;
} }
private void insertOrUpdateClassificationsWithoutParent(List<ClassificationResource> classificationResources, private void insertOrUpdateClassificationsWithoutParent(List<ClassificationResource> classificationResources,
@ -175,20 +175,20 @@ public class ClassificationDefinitionController {
LOGGER.debug("Exit from insertOrUpdateClassificationsWithoutParent()"); LOGGER.debug("Exit from insertOrUpdateClassificationsWithoutParent()");
} }
private void updateParentChildRelations(Map<Classification, String> childsInFile) private void updateParentChildrenRelations(Map<Classification, String> childrenInFile)
throws ClassificationNotFoundException, NotAuthorizedException, ConcurrencyException, throws ClassificationNotFoundException, NotAuthorizedException, ConcurrencyException,
InvalidArgumentException { InvalidArgumentException {
LOGGER.debug("Entry to updateParentChildRelations()"); LOGGER.debug("Entry to updateParentChildrenRelations()");
for (Classification childRes : childsInFile.keySet()) { for (Classification childRes : childrenInFile.keySet()) {
Classification child = classificationService Classification child = classificationService
.getClassification(childRes.getKey(), childRes.getDomain()); .getClassification(childRes.getKey(), childRes.getDomain());
String parentKey = childsInFile.get(childRes); String parentKey = childrenInFile.get(childRes);
String parentId = classificationService.getClassification(parentKey, childRes.getDomain()).getId(); String parentId = classificationService.getClassification(parentKey, childRes.getDomain()).getId();
child.setParentKey(parentKey); child.setParentKey(parentKey);
child.setParentId(parentId); child.setParentId(parentId);
classificationService.updateClassification(child); classificationService.updateClassification(child);
} }
LOGGER.debug("Exit from updateParentChildRelations()"); LOGGER.debug("Exit from updateParentChildrenRelations()");
} }
private void updateExistingClassification(ClassificationResource cl, private void updateExistingClassification(ClassificationResource cl,

View File

@ -23,8 +23,8 @@ import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.impl.report.TimeIntervalColumnHeader; import pro.taskana.impl.report.TimeIntervalColumnHeader;
import pro.taskana.monitor.ClassificationTimeIntervalColumnHeader; import pro.taskana.monitor.ClassificationTimeIntervalColumnHeader;
import pro.taskana.monitor.WorkbasketTimeIntervalColumnHeader; import pro.taskana.monitor.WorkbasketTimeIntervalColumnHeader;
import pro.taskana.rest.resource.ReportResource;
import pro.taskana.rest.resource.ReportAssembler; import pro.taskana.rest.resource.ReportAssembler;
import pro.taskana.rest.resource.ReportResource;
/** /**
* Controller for all monitoring endpoints. * Controller for all monitoring endpoints.
@ -32,6 +32,7 @@ import pro.taskana.rest.resource.ReportAssembler;
@RestController @RestController
@RequestMapping(path = "/v1/monitor", produces = "application/hal+json") @RequestMapping(path = "/v1/monitor", produces = "application/hal+json")
public class MonitorController { public class MonitorController {
private static final Logger LOGGER = LoggerFactory.getLogger(MonitorController.class); private static final Logger LOGGER = LoggerFactory.getLogger(MonitorController.class);
@Autowired @Autowired
@ -46,16 +47,14 @@ public class MonitorController {
@RequestParam(required = false) List<TaskState> states) throws NotAuthorizedException, @RequestParam(required = false) List<TaskState> states) throws NotAuthorizedException,
InvalidArgumentException { InvalidArgumentException {
LOGGER.debug("Entry to getTasksStatusReport()"); LOGGER.debug("Entry to getTasksStatusReport()");
ResponseEntity<ReportResource> response = new ResponseEntity<>(reportAssembler.toResource(
taskMonitorService.createTaskStatusReportBuilder().stateIn(states).domainIn(domains).buildReport(),
domains, states), HttpStatus.OK);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getTasksStatusReport(), returning {}", reportAssembler.toResource( LOGGER.debug("Exit from getTasksStatusReport(), returning {}", response);
taskMonitorService.createTaskStatusReportBuilder().stateIn(states).domainIn(domains).buildReport(),
domains, states));
} }
return ResponseEntity.status(HttpStatus.OK) return response;
.body(reportAssembler.toResource(
taskMonitorService.createTaskStatusReportBuilder().stateIn(states).domainIn(domains).buildReport(),
domains, states));
} }
@GetMapping(path = "/tasks-workbasket-report") @GetMapping(path = "/tasks-workbasket-report")
@ -65,19 +64,16 @@ public class MonitorController {
@RequestParam(value = "states") List<TaskState> states) @RequestParam(value = "states") List<TaskState> states)
throws NotAuthorizedException, InvalidArgumentException { throws NotAuthorizedException, InvalidArgumentException {
LOGGER.debug("Entry to getTasksWorkbasketReport()"); LOGGER.debug("Entry to getTasksWorkbasketReport()");
ResponseEntity<?> response = new ResponseEntity<>(reportAssembler.toResource(
taskMonitorService.createWorkbasketReportBuilder()
.stateIn(states)
.withColumnHeaders(getTasksWorkbasketsTimeInterval(daysInPast)).buildReport(), daysInPast, states),
HttpStatus.OK);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getTasksWorkbasketReport(), returning {}", reportAssembler.toResource( LOGGER.debug("Exit from getTasksWorkbasketReport(), returning {}", response);
taskMonitorService.createWorkbasketReportBuilder()
.stateIn(states)
.withColumnHeaders(getTasksWorkbasketsTimeInterval(daysInPast)).buildReport(), daysInPast, states));
} }
return ResponseEntity.status(HttpStatus.OK) return response;
.body(reportAssembler.toResource(
taskMonitorService.createWorkbasketReportBuilder()
.stateIn(states)
.withColumnHeaders(getTasksWorkbasketsTimeInterval(daysInPast)).buildReport(), daysInPast, states));
} }
@GetMapping(path = "/tasks-classification-report") @GetMapping(path = "/tasks-classification-report")
@ -85,18 +81,15 @@ public class MonitorController {
public ResponseEntity<ReportResource> getTasksClassificationReport() public ResponseEntity<ReportResource> getTasksClassificationReport()
throws NotAuthorizedException, InvalidArgumentException { throws NotAuthorizedException, InvalidArgumentException {
LOGGER.debug("Entry to getTasksClassificationReport()"); LOGGER.debug("Entry to getTasksClassificationReport()");
ResponseEntity<ReportResource> response = new ResponseEntity<>(reportAssembler.toResource(
taskMonitorService.createClassificationReportBuilder()
.withColumnHeaders(getTaskClassificationTimeInterval())
.buildReport()), HttpStatus.OK);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getTasksClassificationReport(), returning {}", reportAssembler.toResource( LOGGER.debug("Exit from getTasksClassificationReport(), returning {}", response);
taskMonitorService.createClassificationReportBuilder()
.withColumnHeaders(getTaskClassificationTimeInterval())
.buildReport()));
} }
return ResponseEntity.status(HttpStatus.OK) return response;
.body(reportAssembler.toResource(
taskMonitorService.createClassificationReportBuilder()
.withColumnHeaders(getTaskClassificationTimeInterval())
.buildReport()));
} }
private List<TimeIntervalColumnHeader> getTaskClassificationTimeInterval() { private List<TimeIntervalColumnHeader> getTaskClassificationTimeInterval() {

View File

@ -126,11 +126,12 @@ public class TaskController extends AbstractPagingController {
TaskSummaryResourcesAssembler taskSummaryResourcesAssembler = new TaskSummaryResourcesAssembler(); TaskSummaryResourcesAssembler taskSummaryResourcesAssembler = new TaskSummaryResourcesAssembler();
PagedResources<TaskSummaryResource> pagedResources = taskSummaryResourcesAssembler.toResources(taskSummaries, PagedResources<TaskSummaryResource> pagedResources = taskSummaryResourcesAssembler.toResources(taskSummaries,
pageMetadata); pageMetadata);
ResponseEntity<PagedResources<TaskSummaryResource>> response = new ResponseEntity<>(pagedResources, HttpStatus.OK);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getTasks(), returning {}", new ResponseEntity<>(pagedResources, HttpStatus.OK)); LOGGER.debug("Exit from getTasks(), returning {}", response);
} }
return new ResponseEntity<>(pagedResources, HttpStatus.OK); return response;
} }
@GetMapping(path = "/{taskId}") @GetMapping(path = "/{taskId}")

View File

@ -36,21 +36,41 @@ public class TaskanaEngineController {
@GetMapping(path = "/v1/domains", produces = {MediaType.APPLICATION_JSON_VALUE}) @GetMapping(path = "/v1/domains", produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<List<String>> getDomains() { public ResponseEntity<List<String>> getDomains() {
return new ResponseEntity<>(taskanaEngineConfiguration.getDomains(), HttpStatus.OK); ResponseEntity<List<String>> response = new ResponseEntity<>(taskanaEngineConfiguration.getDomains(),
HttpStatus.OK);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getDomains(), returning {}", response);
}
return response;
} }
@GetMapping(path = "/v1/classification-categories", produces = {MediaType.APPLICATION_JSON_VALUE}) @GetMapping(path = "/v1/classification-categories", produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<List<String>> getClassificationCategories(String type) { public ResponseEntity<List<String>> getClassificationCategories(String type) {
LOGGER.debug("Entry to getClassificationCategories(type = {})", type);
ResponseEntity<List<String>> response;
if (type != null) { if (type != null) {
return new ResponseEntity<>(taskanaEngineConfiguration.getClassificationCategoriesByType(type), response = new ResponseEntity<>(taskanaEngineConfiguration.getClassificationCategoriesByType(type),
HttpStatus.OK); HttpStatus.OK);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getClassificationCategories(), returning {}", response);
}
return response;
} }
return new ResponseEntity<>(taskanaEngineConfiguration.getAllClassificationCategories(), HttpStatus.OK); response = new ResponseEntity<>(taskanaEngineConfiguration.getAllClassificationCategories(), HttpStatus.OK);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getClassificationCategories(), returning {}", response);
}
return response;
} }
@GetMapping(path = "/v1/classification-types", produces = {MediaType.APPLICATION_JSON_VALUE}) @GetMapping(path = "/v1/classification-types", produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<List<String>> getClassificationTypes() { public ResponseEntity<List<String>> getClassificationTypes() {
return new ResponseEntity<>(taskanaEngineConfiguration.getClassificationTypes(), HttpStatus.OK); ResponseEntity<List<String>> response = new ResponseEntity<>(
taskanaEngineConfiguration.getClassificationTypes(), HttpStatus.OK);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getClassificationTypes(), returning {}", response);
}
return response;
} }
@GetMapping(path = "/v1/current-user-info", produces = {MediaType.APPLICATION_JSON_VALUE}) @GetMapping(path = "/v1/current-user-info", produces = {MediaType.APPLICATION_JSON_VALUE})
@ -64,17 +84,21 @@ public class TaskanaEngineController {
resource.getRoles().add(role); resource.getRoles().add(role);
} }
} }
ResponseEntity<TaskanaUserInfoResource> response = new ResponseEntity<>(resource, HttpStatus.OK);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getCurrentUserInfo(), returning {}", new ResponseEntity<>(resource, HttpStatus.OK)); LOGGER.debug("Exit from getCurrentUserInfo(), returning {}", response);
} }
return new ResponseEntity<>(resource, HttpStatus.OK); return response;
} }
@GetMapping(path = "/v1/history-provider-enabled", produces = {MediaType.APPLICATION_JSON_VALUE}) @GetMapping(path = "/v1/history-provider-enabled", produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<Boolean> getIsHistoryProviderEnabled() { public ResponseEntity<Boolean> getIsHistoryProviderEnabled() {
return new ResponseEntity<>(((TaskanaEngineImpl) taskanaEngine).getHistoryEventProducer().isEnabled(), ResponseEntity<Boolean> response = new ResponseEntity<>(
((TaskanaEngineImpl) taskanaEngine).getHistoryEventProducer().isEnabled(),
HttpStatus.OK); HttpStatus.OK);
LOGGER.debug("Exit from getIsHistoryProviderEnabled(), returning {}", response);
return response;
} }
/** /**
@ -87,7 +111,8 @@ public class TaskanaEngineController {
LOGGER.debug("Entry to currentVersion()"); LOGGER.debug("Entry to currentVersion()");
VersionResource resource = new VersionResource(); VersionResource resource = new VersionResource();
resource.setVersion(TaskanaEngineConfiguration.class.getPackage().getImplementationVersion()); resource.setVersion(TaskanaEngineConfiguration.class.getPackage().getImplementationVersion());
LOGGER.debug("Exit from currentVersion(), returning {}", new ResponseEntity<>(resource, HttpStatus.OK)); ResponseEntity<VersionResource> response = new ResponseEntity<>(resource, HttpStatus.OK);
return new ResponseEntity<>(resource, HttpStatus.OK); LOGGER.debug("Exit from currentVersion(), returning {}", response);
return response;
} }
} }

View File

@ -103,11 +103,12 @@ public class WorkbasketAccessItemController extends AbstractPagingController {
workbasketAccessItems, workbasketAccessItems,
pageMetadata); pageMetadata);
ResponseEntity<PagedResources<WorkbasketAccessItemResource>> response = new ResponseEntity<>(pagedResources, HttpStatus.OK);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getWorkbasketAccessItems(), returning {}", new ResponseEntity<>(pagedResources, HttpStatus.OK)); LOGGER.debug("Exit from getWorkbasketAccessItems(), returning {}", response);
} }
return new ResponseEntity<>(pagedResources, HttpStatus.OK); return response;
} }
/** /**
@ -136,8 +137,9 @@ public class WorkbasketAccessItemController extends AbstractPagingController {
accessId + " corresponding to a group, not a user. You just can remove access items for a user"); accessId + " corresponding to a group, not a user. You just can remove access items for a user");
} }
LOGGER.debug("Exit from removeWorkbasketAccessItems(), returning {}", ResponseEntity.status(HttpStatus.NO_CONTENT).build()); ResponseEntity<Void> response = new ResponseEntity<>(HttpStatus.NO_CONTENT);
return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); LOGGER.debug("Exit from removeWorkbasketAccessItems(), returning {}", response);
return response;
} }
private WorkbasketAccessItemQuery getAccessIds(WorkbasketAccessItemQuery query, private WorkbasketAccessItemQuery getAccessIds(WorkbasketAccessItemQuery query,

View File

@ -43,14 +43,14 @@ import pro.taskana.exceptions.WorkbasketAlreadyExistException;
import pro.taskana.exceptions.WorkbasketInUseException; import pro.taskana.exceptions.WorkbasketInUseException;
import pro.taskana.exceptions.WorkbasketNotFoundException; import pro.taskana.exceptions.WorkbasketNotFoundException;
import pro.taskana.impl.util.LoggerUtils; import pro.taskana.impl.util.LoggerUtils;
import pro.taskana.rest.resource.DistributionTargetResource;
import pro.taskana.rest.resource.WorkbasketAccessItemResource;
import pro.taskana.rest.resource.WorkbasketResource;
import pro.taskana.rest.resource.WorkbasketSummaryResource;
import pro.taskana.rest.resource.DistributionTargetListAssembler; import pro.taskana.rest.resource.DistributionTargetListAssembler;
import pro.taskana.rest.resource.DistributionTargetResource;
import pro.taskana.rest.resource.WorkbasketAccessItemAssembler; import pro.taskana.rest.resource.WorkbasketAccessItemAssembler;
import pro.taskana.rest.resource.WorkbasketAccessItemListAssembler; import pro.taskana.rest.resource.WorkbasketAccessItemListAssembler;
import pro.taskana.rest.resource.WorkbasketAccessItemResource;
import pro.taskana.rest.resource.WorkbasketResource;
import pro.taskana.rest.resource.WorkbasketResourceAssembler; import pro.taskana.rest.resource.WorkbasketResourceAssembler;
import pro.taskana.rest.resource.WorkbasketSummaryResource;
import pro.taskana.rest.resource.WorkbasketSummaryResourcesAssembler; import pro.taskana.rest.resource.WorkbasketSummaryResourcesAssembler;
/** /**
@ -60,6 +60,7 @@ import pro.taskana.rest.resource.WorkbasketSummaryResourcesAssembler;
@EnableHypermediaSupport(type = HypermediaType.HAL) @EnableHypermediaSupport(type = HypermediaType.HAL)
@RequestMapping(path = "/v1/workbaskets", produces = "application/hal+json") @RequestMapping(path = "/v1/workbaskets", produces = "application/hal+json")
public class WorkbasketController extends AbstractPagingController { public class WorkbasketController extends AbstractPagingController {
private static final Logger LOGGER = LoggerFactory.getLogger(WorkbasketController.class); private static final Logger LOGGER = LoggerFactory.getLogger(WorkbasketController.class);
private static final String LIKE = "%"; private static final String LIKE = "%";
@ -135,11 +136,13 @@ public class WorkbasketController extends AbstractPagingController {
PagedResources<WorkbasketSummaryResource> pagedResources = assembler.toResources(workbasketSummaries, PagedResources<WorkbasketSummaryResource> pagedResources = assembler.toResources(workbasketSummaries,
pageMetadata); pageMetadata);
ResponseEntity<PagedResources<WorkbasketSummaryResource>> response = new ResponseEntity<>(pagedResources,
HttpStatus.OK);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getWorkbaskets(), returning {}", new ResponseEntity<>(pagedResources, HttpStatus.OK)); LOGGER.debug("Exit from getWorkbaskets(), returning {}", response);
} }
return new ResponseEntity<>(pagedResources, HttpStatus.OK); return response;
} }
@GetMapping(path = "/{workbasketId}") @GetMapping(path = "/{workbasketId}")
@ -163,8 +166,10 @@ public class WorkbasketController extends AbstractPagingController {
throws NotAuthorizedException, InvalidArgumentException, throws NotAuthorizedException, InvalidArgumentException,
WorkbasketNotFoundException, WorkbasketInUseException { WorkbasketNotFoundException, WorkbasketInUseException {
LOGGER.debug("Entry to markWorkbasketForDeletion(workbasketId= {})", workbasketId); LOGGER.debug("Entry to markWorkbasketForDeletion(workbasketId= {})", workbasketId);
LOGGER.debug("Exit from markWorkbasketForDeletion(), returning {}", new ResponseEntity<>(workbasketService.deleteWorkbasket(workbasketId), HttpStatus.ACCEPTED)); ResponseEntity<?> response = new ResponseEntity<>(workbasketService.deleteWorkbasket(workbasketId), HttpStatus.ACCEPTED);
return new ResponseEntity<>(workbasketService.deleteWorkbasket(workbasketId), HttpStatus.ACCEPTED); LOGGER.debug("Exit from markWorkbasketForDeletion(), returning {}",
response);
return response;
} }
@PostMapping @PostMapping
@ -178,11 +183,12 @@ public class WorkbasketController extends AbstractPagingController {
Workbasket workbasket = workbasketResourceAssembler.toModel(workbasketResource); Workbasket workbasket = workbasketResourceAssembler.toModel(workbasketResource);
workbasket = workbasketService.createWorkbasket(workbasket); workbasket = workbasketService.createWorkbasket(workbasket);
ResponseEntity<WorkbasketResource> response = new ResponseEntity<>(workbasketResourceAssembler.toResource(workbasket), HttpStatus.CREATED);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from createWorkbasket(), returning {}", new ResponseEntity<>(workbasketResourceAssembler.toResource(workbasket), HttpStatus.CREATED)); LOGGER.debug("Exit from createWorkbasket(), returning {}", response);
} }
return new ResponseEntity<>(workbasketResourceAssembler.toResource(workbasket), HttpStatus.CREATED); return response;
} }
@PutMapping(path = "/{workbasketId}") @PutMapping(path = "/{workbasketId}")
@ -249,11 +255,12 @@ public class WorkbasketController extends AbstractPagingController {
Resources<WorkbasketAccessItemResource> accessItemListResource = accessItemListAssembler Resources<WorkbasketAccessItemResource> accessItemListResource = accessItemListAssembler
.toResource(workbasketId, updatedWbAccessItems); .toResource(workbasketId, updatedWbAccessItems);
ResponseEntity<Resources<WorkbasketAccessItemResource>> response = new ResponseEntity<>(accessItemListResource, HttpStatus.OK);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from setWorkbasketAccessItems(), returning {}", new ResponseEntity<>(accessItemListResource, HttpStatus.OK)); LOGGER.debug("Exit from setWorkbasketAccessItems(), returning {}", response);
} }
return new ResponseEntity<>(accessItemListResource, HttpStatus.OK); return response;
} }
@GetMapping(path = "/{workbasketId}/distribution-targets") @GetMapping(path = "/{workbasketId}/distribution-targets")
@ -280,7 +287,8 @@ public class WorkbasketController extends AbstractPagingController {
@PathVariable(value = "workbasketId") String sourceWorkbasketId, @PathVariable(value = "workbasketId") String sourceWorkbasketId,
@RequestBody List<String> targetWorkbasketIds) throws WorkbasketNotFoundException, NotAuthorizedException { @RequestBody List<String> targetWorkbasketIds) throws WorkbasketNotFoundException, NotAuthorizedException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to getTasksStatusReport(workbasketId= {}, targetWorkbasketIds´= {})", sourceWorkbasketId, LOGGER.debug("Entry to getTasksStatusReport(workbasketId= {}, targetWorkbasketIds´= {})",
sourceWorkbasketId,
LoggerUtils.listToString(targetWorkbasketIds)); LoggerUtils.listToString(targetWorkbasketIds));
} }
@ -290,11 +298,12 @@ public class WorkbasketController extends AbstractPagingController {
Resources<DistributionTargetResource> distributionTargetListResource = distributionTargetListAssembler Resources<DistributionTargetResource> distributionTargetListResource = distributionTargetListAssembler
.toResource(sourceWorkbasketId, distributionTargets); .toResource(sourceWorkbasketId, distributionTargets);
ResponseEntity<Resources<DistributionTargetResource>> response = new ResponseEntity<>(distributionTargetListResource, HttpStatus.OK);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getTasksStatusReport(), returning {}", new ResponseEntity<>(distributionTargetListResource, HttpStatus.OK)); LOGGER.debug("Exit from getTasksStatusReport(), returning {}", response);
} }
return new ResponseEntity<>(distributionTargetListResource, HttpStatus.OK); return response;
} }
@DeleteMapping(path = "/distribution-targets/{workbasketId}") @DeleteMapping(path = "/distribution-targets/{workbasketId}")
@ -308,8 +317,9 @@ public class WorkbasketController extends AbstractPagingController {
workbasketService.removeDistributionTarget(source.getId(), targetWorkbasketId); workbasketService.removeDistributionTarget(source.getId(), targetWorkbasketId);
} }
LOGGER.debug("Exit from removeDistributionTargetForWorkbasketId(), returning {}", new ResponseEntity<>(HttpStatus.NO_CONTENT)); ResponseEntity<Resources<DistributionTargetResource>> response = new ResponseEntity<>(HttpStatus.NO_CONTENT);
return new ResponseEntity<>(HttpStatus.NO_CONTENT); LOGGER.debug("Exit from removeDistributionTargetForWorkbasketId(), returning {}", response);
return response;
} }
private WorkbasketQuery applySortingParams(WorkbasketQuery query, MultiValueMap<String, String> params) private WorkbasketQuery applySortingParams(WorkbasketQuery query, MultiValueMap<String, String> params)

View File

@ -70,12 +70,12 @@ public class WorkbasketDefinitionController {
basketExports.add(workbasketDefinitionAssembler.toResource(workbasket)); basketExports.add(workbasketDefinitionAssembler.toResource(workbasket));
} }
ResponseEntity<List<WorkbasketDefinitionResource>> response = new ResponseEntity<>(basketExports, HttpStatus.OK);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from exportWorkbaskets(), returning {}", LOGGER.debug("Exit from exportWorkbaskets(), returning {}", response);
new ResponseEntity<>(basketExports, HttpStatus.OK));
} }
return new ResponseEntity<>(basketExports, HttpStatus.OK); return response;
} }
/** /**
@ -152,8 +152,9 @@ public class WorkbasketDefinitionController {
// no verification necessary since the workbasket was already imported in step 1. // no verification necessary since the workbasket was already imported in step 1.
idConversion.get(definition.getWorkbasket().getWorkbasketId()), distributionTargets); idConversion.get(definition.getWorkbasket().getWorkbasketId()), distributionTargets);
} }
LOGGER.debug("Exit from importWorkbaskets(), returning {}", new ResponseEntity<>(HttpStatus.OK)); ResponseEntity<String> response = new ResponseEntity<>(HttpStatus.OK);
return new ResponseEntity<>(HttpStatus.OK); LOGGER.debug("Exit from importWorkbaskets(), returning {}", response);
return response;
} }
private String logicalId(WorkbasketSummary workbasket) { private String logicalId(WorkbasketSummary workbasket) {