TSK-253 Remove unnecessary getX() calls at the end of a service
This commit is contained in:
parent
4417028bba
commit
b626fc4603
|
|
@ -281,36 +281,38 @@ public class TaskServiceImpl implements TaskService {
|
||||||
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException,
|
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException,
|
||||||
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException {
|
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException {
|
||||||
LOGGER.debug("entry to createTask(task = {})", taskToCreate);
|
LOGGER.debug("entry to createTask(task = {})", taskToCreate);
|
||||||
|
TaskImpl task = (TaskImpl) taskToCreate;
|
||||||
try {
|
try {
|
||||||
taskanaEngine.openConnection();
|
taskanaEngine.openConnection();
|
||||||
TaskImpl task = (TaskImpl) taskToCreate;
|
|
||||||
if (task.getId() != "" && task.getId() != null) {
|
if (task.getId() != "" && task.getId() != null) {
|
||||||
throw new TaskAlreadyExistException(taskToCreate.getId());
|
throw new TaskAlreadyExistException(task.getId());
|
||||||
} else {
|
} else {
|
||||||
LOGGER.debug("Task {} cannot be be found, so it can be created.", taskToCreate.getId());
|
LOGGER.debug("Task {} cannot be be found, so it can be created.", task.getId());
|
||||||
Workbasket workbasket;
|
Workbasket workbasket;
|
||||||
|
|
||||||
if (taskToCreate.getWorkbasketSummary().getId() != null) {
|
if (task.getWorkbasketSummary().getId() != null) {
|
||||||
workbasket = workbasketService.getWorkbasket(taskToCreate.getWorkbasketSummary().getId());
|
workbasket = workbasketService.getWorkbasket(task.getWorkbasketSummary().getId());
|
||||||
} else if (taskToCreate.getWorkbasketKey() != null) {
|
} else if (task.getWorkbasketKey() != null) {
|
||||||
workbasket = workbasketService.getWorkbasket(task.getWorkbasketKey(), task.getDomain());
|
workbasket = workbasketService.getWorkbasket(task.getWorkbasketKey(), task.getDomain());
|
||||||
} else {
|
} else {
|
||||||
throw new InvalidArgumentException("Cannot create a task outside a workbasket");
|
throw new InvalidArgumentException("Cannot create a task outside a workbasket");
|
||||||
}
|
}
|
||||||
|
|
||||||
task.setWorkbasketSummary(workbasket.asSummary());
|
task.setWorkbasketSummary(workbasket.asSummary());
|
||||||
|
task.setDomain(workbasket.getDomain());
|
||||||
|
|
||||||
workbasketService.checkAuthorization(task.getWorkbasketSummary().getId(),
|
workbasketService.checkAuthorization(task.getWorkbasketSummary().getId(),
|
||||||
WorkbasketPermission.APPEND);
|
WorkbasketPermission.APPEND);
|
||||||
String classificationKey = task.getClassificationKey();
|
String classificationKey = task.getClassificationKey();
|
||||||
if (classificationKey == null || classificationKey.length() == 0) {
|
if (classificationKey == null || classificationKey.length() == 0) {
|
||||||
throw new InvalidArgumentException("classificationKey of task must not be empty");
|
throw new InvalidArgumentException("classificationKey of task must not be empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
Classification classification = this.classificationService.getClassification(classificationKey,
|
Classification classification = this.classificationService.getClassification(classificationKey,
|
||||||
workbasket.getDomain());
|
workbasket.getDomain());
|
||||||
task.setClassificationSummary(classification.asSummary());
|
task.setClassificationSummary(classification.asSummary());
|
||||||
validateObjectReference(task.getPrimaryObjRef(), "primary ObjectReference", "Task");
|
validateObjectReference(task.getPrimaryObjRef(), "primary ObjectReference", "Task");
|
||||||
PrioDurationHolder prioDurationFromAttachments = handleAttachments(task);
|
PrioDurationHolder prioDurationFromAttachments = handleAttachments(task);
|
||||||
task.setDomain(workbasket.getDomain());
|
|
||||||
standardSettings(task, classification, prioDurationFromAttachments);
|
standardSettings(task, classification, prioDurationFromAttachments);
|
||||||
this.taskMapper.insert(task);
|
this.taskMapper.insert(task);
|
||||||
LOGGER.debug("Method createTask() created Task '{}'.", task.getId());
|
LOGGER.debug("Method createTask() created Task '{}'.", task.getId());
|
||||||
|
|
@ -318,7 +320,7 @@ public class TaskServiceImpl implements TaskService {
|
||||||
return task;
|
return task;
|
||||||
} finally {
|
} finally {
|
||||||
taskanaEngine.returnConnection();
|
taskanaEngine.returnConnection();
|
||||||
LOGGER.debug("exit from createTask(task = {})");
|
LOGGER.debug("exit from createTask(task = {})", task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -547,19 +549,18 @@ public class TaskServiceImpl implements TaskService {
|
||||||
public Task setTaskRead(String taskId, boolean isRead)
|
public Task setTaskRead(String taskId, boolean isRead)
|
||||||
throws TaskNotFoundException {
|
throws TaskNotFoundException {
|
||||||
LOGGER.debug("entry to setTaskRead(taskId = {}, isRead = {})", taskId, isRead);
|
LOGGER.debug("entry to setTaskRead(taskId = {}, isRead = {})", taskId, isRead);
|
||||||
Task result = null;
|
TaskImpl task = null;
|
||||||
try {
|
try {
|
||||||
taskanaEngine.openConnection();
|
taskanaEngine.openConnection();
|
||||||
TaskImpl task = (TaskImpl) getTask(taskId);
|
task = (TaskImpl) getTask(taskId);
|
||||||
task.setRead(true);
|
task.setRead(true);
|
||||||
task.setModified(Instant.now());
|
task.setModified(Instant.now());
|
||||||
taskMapper.update(task);
|
taskMapper.update(task);
|
||||||
result = getTask(taskId);
|
LOGGER.debug("Method setTaskRead() set read property of Task '{}' to {} ", task, isRead);
|
||||||
LOGGER.debug("Method setTaskRead() set read property of Task '{}' to {} ", result, isRead);
|
return task;
|
||||||
return result;
|
|
||||||
} finally {
|
} finally {
|
||||||
taskanaEngine.returnConnection();
|
taskanaEngine.returnConnection();
|
||||||
LOGGER.debug("exit from setTaskRead(taskId, isRead). Returning result {} ", result);
|
LOGGER.debug("exit from setTaskRead(taskId, isRead). Returning result {} ", task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,6 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
||||||
throws InvalidWorkbasketException, NotAuthorizedException {
|
throws InvalidWorkbasketException, NotAuthorizedException {
|
||||||
LOGGER.debug("entry to createtWorkbasket(workbasket)", newWorkbasket);
|
LOGGER.debug("entry to createtWorkbasket(workbasket)", newWorkbasket);
|
||||||
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
|
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
|
||||||
Workbasket result = null;
|
|
||||||
WorkbasketImpl workbasket = (WorkbasketImpl) newWorkbasket;
|
WorkbasketImpl workbasket = (WorkbasketImpl) newWorkbasket;
|
||||||
try {
|
try {
|
||||||
taskanaEngine.openConnection();
|
taskanaEngine.openConnection();
|
||||||
|
|
@ -147,11 +146,10 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
||||||
|
|
||||||
workbasketMapper.insert(workbasket);
|
workbasketMapper.insert(workbasket);
|
||||||
LOGGER.debug("Method createWorkbasket() created Workbasket '{}'", workbasket);
|
LOGGER.debug("Method createWorkbasket() created Workbasket '{}'", workbasket);
|
||||||
result = workbasketMapper.findById(workbasket.getId());
|
return workbasket;
|
||||||
return result;
|
|
||||||
} finally {
|
} finally {
|
||||||
taskanaEngine.returnConnection();
|
taskanaEngine.returnConnection();
|
||||||
LOGGER.debug("exit from createWorkbasket(workbasket). Returning result {} ", result);
|
LOGGER.debug("exit from createWorkbasket(workbasket). Returning result {} ", workbasket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -161,18 +159,16 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
||||||
LOGGER.debug("entry to updateWorkbasket(workbasket)", workbasketToUpdate);
|
LOGGER.debug("entry to updateWorkbasket(workbasket)", workbasketToUpdate);
|
||||||
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
|
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
|
||||||
|
|
||||||
Workbasket result = null;
|
|
||||||
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketToUpdate;
|
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketToUpdate;
|
||||||
try {
|
try {
|
||||||
taskanaEngine.openConnection();
|
taskanaEngine.openConnection();
|
||||||
workbasket.setModified(Instant.now());
|
workbasket.setModified(Instant.now());
|
||||||
workbasketMapper.update(workbasket);
|
workbasketMapper.update(workbasket);
|
||||||
LOGGER.debug("Method updateWorkbasket() updated workbasket '{}'", workbasket.getId());
|
LOGGER.debug("Method updateWorkbasket() updated workbasket '{}'", workbasket.getId());
|
||||||
result = workbasketMapper.findById(workbasket.getId());
|
return workbasket;
|
||||||
return result;
|
|
||||||
} finally {
|
} finally {
|
||||||
taskanaEngine.returnConnection();
|
taskanaEngine.returnConnection();
|
||||||
LOGGER.debug("exit from updateWorkbasket(). Returning result {} ", result);
|
LOGGER.debug("exit from updateWorkbasket(). Returning result {} ", workbasket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -335,7 +335,7 @@ public class WorkbasketServiceImplTest {
|
||||||
verify(taskanaEngineImplMock, times(2)).getConfiguration();
|
verify(taskanaEngineImplMock, times(2)).getConfiguration();
|
||||||
verify(taskanaEngineConfigurationMock, times(2)).isSecurityEnabled();
|
verify(taskanaEngineConfigurationMock, times(2)).isSecurityEnabled();
|
||||||
verify(workbasketMapperMock, times(1)).insert(expectedWb);
|
verify(workbasketMapperMock, times(1)).insert(expectedWb);
|
||||||
verify(workbasketMapperMock, times(4)).findById(expectedWb.getId());
|
verify(workbasketMapperMock, times(3)).findById(expectedWb.getId());
|
||||||
verify(workbasketMapperMock, times(1)).update(any());
|
verify(workbasketMapperMock, times(1)).update(any());
|
||||||
verify(taskanaEngineImplMock, times(5)).returnConnection();
|
verify(taskanaEngineImplMock, times(5)).returnConnection();
|
||||||
verify(taskanaEngineImplMock, times(2)).checkRoleMembership(any());
|
verify(taskanaEngineImplMock, times(2)).checkRoleMembership(any());
|
||||||
|
|
@ -371,7 +371,7 @@ public class WorkbasketServiceImplTest {
|
||||||
verify(cutSpy, times(distTargetAmount + 1)).getWorkbasket(any());
|
verify(cutSpy, times(distTargetAmount + 1)).getWorkbasket(any());
|
||||||
verify(distributionTargetMapperMock, times(1)).deleteAllDistributionTargetsBySourceId(any());
|
verify(distributionTargetMapperMock, times(1)).deleteAllDistributionTargetsBySourceId(any());
|
||||||
verify(distributionTargetMapperMock, times(distTargetAmount)).insert(any(), any());
|
verify(distributionTargetMapperMock, times(distTargetAmount)).insert(any(), any());
|
||||||
verify(workbasketMapperMock, times(4)).findById(any());
|
verify(workbasketMapperMock, times(1)).findById(any());
|
||||||
verify(workbasketMapperMock, times(1)).update(any());
|
verify(workbasketMapperMock, times(1)).update(any());
|
||||||
verify(taskanaEngineImplMock, times(5)).returnConnection();
|
verify(taskanaEngineImplMock, times(5)).returnConnection();
|
||||||
verify(taskanaEngineImplMock, times(4)).checkRoleMembership(any());
|
verify(taskanaEngineImplMock, times(4)).checkRoleMembership(any());
|
||||||
|
|
@ -401,7 +401,7 @@ public class WorkbasketServiceImplTest {
|
||||||
} catch (WorkbasketNotFoundException e) {
|
} catch (WorkbasketNotFoundException e) {
|
||||||
verify(taskanaEngineImplMock, times(3)).openConnection();
|
verify(taskanaEngineImplMock, times(3)).openConnection();
|
||||||
verify(workbasketMapperMock, times(1)).insert(expectedWb);
|
verify(workbasketMapperMock, times(1)).insert(expectedWb);
|
||||||
verify(workbasketMapperMock, times(2)).findById(any());
|
verify(workbasketMapperMock, times(1)).findById(any());
|
||||||
verify(cutSpy, times(1)).getWorkbasket(any());
|
verify(cutSpy, times(1)).getWorkbasket(any());
|
||||||
verify(taskanaEngineImplMock, times(3)).returnConnection();
|
verify(taskanaEngineImplMock, times(3)).returnConnection();
|
||||||
verify(taskanaEngineImplMock, times(2)).checkRoleMembership(any());
|
verify(taskanaEngineImplMock, times(2)).checkRoleMembership(any());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue