correct logging statements in merged files
This commit is contained in:
parent
e582bc660a
commit
7fb36ac156
|
|
@ -118,7 +118,8 @@ public class ClassificationServiceImpl implements ClassificationService {
|
||||||
classification.setId(IdGenerator.generateWithPrefix(ID_PREFIX_CLASSIFICATION));
|
classification.setId(IdGenerator.generateWithPrefix(ID_PREFIX_CLASSIFICATION));
|
||||||
classification.setCreated(Date.valueOf(LocalDate.now()));
|
classification.setCreated(Date.valueOf(LocalDate.now()));
|
||||||
classificationMapper.insert(classification);
|
classificationMapper.insert(classification);
|
||||||
}
|
LOGGER.info("Method updateClassification() inserted classification {}.", classification);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
taskanaEngineImpl.returnConnection();
|
taskanaEngineImpl.returnConnection();
|
||||||
LOGGER.debug("exit from updateClassification().");
|
LOGGER.debug("exit from updateClassification().");
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ public class SummaryServiceImpl implements SummaryService {
|
||||||
taskanaEngineImpl.openConnection();
|
taskanaEngineImpl.openConnection();
|
||||||
taskSummaries = summaryMapper.findTasksummariesByWorkbasketId(workbasketId);
|
taskSummaries = summaryMapper.findTasksummariesByWorkbasketId(workbasketId);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
LOGGER.error("Getting TASKSUMMARY failed internal.", ex);
|
LOGGER.warn("Getting TASKSUMMARY failed internally.", ex);
|
||||||
} finally {
|
} finally {
|
||||||
if (taskSummaries == null) {
|
if (taskSummaries == null) {
|
||||||
taskSummaries = new ArrayList<>();
|
taskSummaries = new ArrayList<>();
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,17 @@
|
||||||
package pro.taskana.impl;
|
package pro.taskana.impl;
|
||||||
|
|
||||||
|
import java.sql.Date;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import pro.taskana.TaskQuery;
|
import pro.taskana.TaskQuery;
|
||||||
import pro.taskana.TaskService;
|
import pro.taskana.TaskService;
|
||||||
import pro.taskana.TaskanaEngine;
|
import pro.taskana.TaskanaEngine;
|
||||||
|
|
@ -12,18 +21,16 @@ import pro.taskana.exceptions.TaskNotFoundException;
|
||||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||||
import pro.taskana.impl.util.IdGenerator;
|
import pro.taskana.impl.util.IdGenerator;
|
||||||
import pro.taskana.impl.util.LoggerUtils;
|
import pro.taskana.impl.util.LoggerUtils;
|
||||||
import pro.taskana.model.*;
|
import pro.taskana.model.Classification;
|
||||||
|
import pro.taskana.model.DueWorkbasketCounter;
|
||||||
|
import pro.taskana.model.ObjectReference;
|
||||||
|
import pro.taskana.model.Task;
|
||||||
|
import pro.taskana.model.TaskState;
|
||||||
|
import pro.taskana.model.TaskStateCounter;
|
||||||
|
import pro.taskana.model.WorkbasketAuthorization;
|
||||||
import pro.taskana.model.mappings.ObjectReferenceMapper;
|
import pro.taskana.model.mappings.ObjectReferenceMapper;
|
||||||
import pro.taskana.model.mappings.TaskMapper;
|
import pro.taskana.model.mappings.TaskMapper;
|
||||||
|
|
||||||
import java.sql.Date;
|
|
||||||
import java.sql.Timestamp;
|
|
||||||
import java.time.Duration;
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the implementation of TaskService.
|
* This is the implementation of TaskService.
|
||||||
*/
|
*/
|
||||||
|
|
@ -89,7 +96,7 @@ public class TaskServiceImpl implements TaskService {
|
||||||
task.setModified(now);
|
task.setModified(now);
|
||||||
task.setState(TaskState.COMPLETED);
|
task.setState(TaskState.COMPLETED);
|
||||||
taskMapper.update(task);
|
taskMapper.update(task);
|
||||||
LOGGER.debug("Method complete() completed Task '{}'.", id);
|
LOGGER.info("Method complete() completed Task '{}'.", id);
|
||||||
} else {
|
} else {
|
||||||
LOGGER.warn("Method complete() didn't find task with id {}. Throwing TaskNotFoundException", id);
|
LOGGER.warn("Method complete() didn't find task with id {}. Throwing TaskNotFoundException", id);
|
||||||
throw new TaskNotFoundException(id);
|
throw new TaskNotFoundException(id);
|
||||||
|
|
@ -112,15 +119,22 @@ public class TaskServiceImpl implements TaskService {
|
||||||
|
|
||||||
this.taskMapper.insert(task);
|
this.taskMapper.insert(task);
|
||||||
|
|
||||||
LOGGER.debug("Task '{}' created.", task.getId());
|
LOGGER.info("Method create() created Task '{}'.", task.getId());
|
||||||
return task;
|
return task;
|
||||||
} finally {
|
} finally {
|
||||||
taskanaEngineImpl.returnConnection();
|
taskanaEngineImpl.returnConnection();
|
||||||
}
|
LOGGER.debug("exit from create(task = {})");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Task createManualTask(String workbasketId, String classificationId, String domain, Timestamp planned, String name, String description, ObjectReference primaryObjectReference, Map<String, Object> customAttributes) throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
public Task createManualTask(String workbasketId, String classificationId, String domain, Timestamp planned, String name,
|
||||||
|
String description, ObjectReference primaryObjectReference, Map<String, Object> customAttributes) throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||||
|
if (LOGGER.isDebugEnabled()) {
|
||||||
|
LOGGER.debug("entry to createManualTask(workbasketId = {}, classificationId = {}, domain = {}, planned = {}, name = {},"
|
||||||
|
+ " description = {}, primaryObjectReference = {}, customAttributes = {})", workbasketId, classificationId, domain, planned, name,
|
||||||
|
description, primaryObjectReference, LoggerUtils.mapToString(customAttributes));
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
taskanaEngineImpl.openConnection();
|
taskanaEngineImpl.openConnection();
|
||||||
taskanaEngine.getWorkbasketService().checkAuthorization(workbasketId, WorkbasketAuthorization.APPEND);
|
taskanaEngine.getWorkbasketService().checkAuthorization(workbasketId, WorkbasketAuthorization.APPEND);
|
||||||
|
|
@ -276,7 +290,7 @@ public class TaskServiceImpl implements TaskService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Task setTaskRead(String taskId, boolean isRead) throws TaskNotFoundException {
|
public Task setTaskRead(String taskId, boolean isRead) throws TaskNotFoundException {
|
||||||
LOGGER.debug("entry to setTaskRead(taskIdt = {}, isRead = {})", taskId, isRead);
|
LOGGER.debug("entry to setTaskRead(taskId = {}, isRead = {})", taskId, isRead);
|
||||||
Task result = null;
|
Task result = null;
|
||||||
try {
|
try {
|
||||||
taskanaEngineImpl.openConnection();
|
taskanaEngineImpl.openConnection();
|
||||||
|
|
@ -300,15 +314,21 @@ public class TaskServiceImpl implements TaskService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Task> getTasksByWorkbasketIdAndState(String workbasketId, TaskState taskState) throws WorkbasketNotFoundException, NotAuthorizedException, Exception {
|
public List<Task> getTasksByWorkbasketIdAndState(String workbasketId, TaskState taskState) throws WorkbasketNotFoundException, NotAuthorizedException, Exception {
|
||||||
List<Task> resultList = null;
|
LOGGER.debug("entry to getTasksByWorkbasketIdAndState(workbasketId = {}, taskState = {})", workbasketId, taskState);
|
||||||
|
List<Task> result = null;
|
||||||
try {
|
try {
|
||||||
taskanaEngineImpl.openConnection();
|
taskanaEngineImpl.openConnection();
|
||||||
taskanaEngine.getWorkbasketService().checkAuthorization(workbasketId, WorkbasketAuthorization.READ);
|
taskanaEngine.getWorkbasketService().checkAuthorization(workbasketId, WorkbasketAuthorization.READ);
|
||||||
resultList = taskMapper.findTasksByWorkbasketIdAndState(workbasketId, taskState);
|
result = taskMapper.findTasksByWorkbasketIdAndState(workbasketId, taskState);
|
||||||
} finally {
|
} finally {
|
||||||
taskanaEngineImpl.returnConnection();
|
taskanaEngineImpl.returnConnection();
|
||||||
|
if (LOGGER.isDebugEnabled()) {
|
||||||
|
int numberOfResultObjects = result == null ? 0 : result.size();
|
||||||
|
LOGGER.debug("exit from getTasksByWorkbasketIdAndState(workbasketId, taskState). Returning {} resulting Objects: {} ",
|
||||||
|
numberOfResultObjects, LoggerUtils.listToString(result));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return (resultList == null) ? new ArrayList<>() : resultList;
|
return (result == null) ? new ArrayList<>() : result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void standardSettings(Task task) {
|
private void standardSettings(Task task) {
|
||||||
|
|
|
||||||
|
|
@ -153,6 +153,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
||||||
taskanaEngineImpl.openConnection();
|
taskanaEngineImpl.openConnection();
|
||||||
workbasket.setModified(new Timestamp(System.currentTimeMillis()));
|
workbasket.setModified(new Timestamp(System.currentTimeMillis()));
|
||||||
workbasketMapper.update(workbasket);
|
workbasketMapper.update(workbasket);
|
||||||
|
LOGGER.info("Method updateWorkbasket() updated workbasket '{}'", workbasket.getId());
|
||||||
List<String> oldDistributionTargets = distributionTargetMapper.findBySourceId(workbasket.getId());
|
List<String> oldDistributionTargets = distributionTargetMapper.findBySourceId(workbasket.getId());
|
||||||
List<Workbasket> distributionTargets = workbasket.getDistributionTargets();
|
List<Workbasket> distributionTargets = workbasket.getDistributionTargets();
|
||||||
for (Workbasket distributionTarget : distributionTargets) {
|
for (Workbasket distributionTarget : distributionTargets) {
|
||||||
|
|
@ -171,8 +172,6 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
||||||
if (LOGGER.isInfoEnabled()) {
|
if (LOGGER.isInfoEnabled()) {
|
||||||
LOGGER.info("Method updateWorkbasket() deleted distributionTargets for '{}' and old distribution targets {}",
|
LOGGER.info("Method updateWorkbasket() deleted distributionTargets for '{}' and old distribution targets {}",
|
||||||
workbasket.getId(), LoggerUtils.listToString(oldDistributionTargets));
|
workbasket.getId(), LoggerUtils.listToString(oldDistributionTargets));
|
||||||
|
|
||||||
LOGGER.info("Method updateWorkbasket() updated workbasket '{}'", workbasket.getId());
|
|
||||||
}
|
}
|
||||||
result = workbasketMapper.findById(workbasket.getId());
|
result = workbasketMapper.findById(workbasket.getId());
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -245,11 +244,13 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
||||||
public void checkAuthorization(String workbasketId, WorkbasketAuthorization workbasketAuthorization)
|
public void checkAuthorization(String workbasketId, WorkbasketAuthorization workbasketAuthorization)
|
||||||
throws NotAuthorizedException {
|
throws NotAuthorizedException {
|
||||||
LOGGER.debug("entry to checkAuthorization(workbasketId = {}, workbasketAuthorization = {})", workbasketId, workbasketAuthorization);
|
LOGGER.debug("entry to checkAuthorization(workbasketId = {}, workbasketAuthorization = {})", workbasketId, workbasketAuthorization);
|
||||||
|
boolean isAuthorized = false;
|
||||||
try {
|
try {
|
||||||
taskanaEngineImpl.openConnection();
|
taskanaEngineImpl.openConnection();
|
||||||
// Skip permission check is security is not enabled
|
// Skip permission check is security is not enabled
|
||||||
if (!taskanaEngine.getConfiguration().isSecurityEnabled()) {
|
if (!taskanaEngine.getConfiguration().isSecurityEnabled()) {
|
||||||
LOGGER.debug("Skipping permissions check since security is disabled.");
|
LOGGER.debug("Skipping permissions check since security is disabled.");
|
||||||
|
isAuthorized = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -261,15 +262,15 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
||||||
.findByWorkbasketAndAccessIdAndAuthorizations(workbasketId, accessIds, workbasketAuthorization.name());
|
.findByWorkbasketAndAccessIdAndAuthorizations(workbasketId, accessIds, workbasketAuthorization.name());
|
||||||
|
|
||||||
if (accessItems.size() <= 0) {
|
if (accessItems.size() <= 0) {
|
||||||
LOGGER.debug("exit from checkAuthorization() with NotAuthorizedExeption");
|
|
||||||
throw new NotAuthorizedException("Not authorized. Authorization '" + workbasketAuthorization.name()
|
throw new NotAuthorizedException("Not authorized. Authorization '" + workbasketAuthorization.name()
|
||||||
+ "' on workbasket '" + workbasketId + "' is needed.");
|
+ "' on workbasket '" + workbasketId + "' is needed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGGER.debug("normal exit from checkAuthorization(). The user is authorized.");
|
isAuthorized = true;
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
taskanaEngineImpl.returnConnection();
|
taskanaEngineImpl.returnConnection();
|
||||||
|
LOGGER.debug("exit from checkAuthorization(). User is authorized = {}.", isAuthorized);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
package pro.taskana.impl.util;
|
package pro.taskana.impl.util;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Util methods for logging.
|
* Util methods for logging.
|
||||||
|
|
@ -31,4 +34,31 @@ public final class LoggerUtils {
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* make a String for logging from a map.
|
||||||
|
*
|
||||||
|
* @param map the map to be stringified
|
||||||
|
* @return A String representation of the map.
|
||||||
|
*/
|
||||||
|
public static <K, V> String mapToString(Map<K, V> map) {
|
||||||
|
if (map == null || map.isEmpty()) {
|
||||||
|
return "[]";
|
||||||
|
} else {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("[");
|
||||||
|
Set<Entry<K, V>> entrySet = map.entrySet();
|
||||||
|
for (Entry<K, V> entry : entrySet) {
|
||||||
|
builder.append("(");
|
||||||
|
builder.append(entry.getKey());
|
||||||
|
builder.append(" , ");
|
||||||
|
builder.append(entry.getValue());
|
||||||
|
builder.append(")");
|
||||||
|
builder.append(" , ");
|
||||||
|
}
|
||||||
|
builder.append("]");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue