use of pro.taskana.exceptions.InvalidArgumentException in project taskana by Taskana.
the class TaskMonitorServiceImpl method getCustomFieldValueReport.
@Override
public CustomFieldValueReport getCustomFieldValueReport(List<String> workbasketIds, List<TaskState> states, List<String> categories, List<String> domains, CustomField customField, List<String> customFieldValues, List<TimeIntervalColumnHeader> columnHeaders, boolean inWorkingDays) throws InvalidArgumentException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("entry to getCustomFieldValueReport(workbasketIds = {}, states = {}, categories = {}, " + "domains = {}, customField = {}, customFieldValues = {}, columnHeaders = {}, " + "inWorkingDays = {})", LoggerUtils.listToString(workbasketIds), LoggerUtils.listToString(states), LoggerUtils.listToString(categories), LoggerUtils.listToString(domains), customField, LoggerUtils.listToString(customFieldValues), LoggerUtils.listToString(columnHeaders), inWorkingDays);
}
try {
taskanaEngineImpl.openConnection();
if (customField == null) {
throw new InvalidArgumentException("CustomField can´t be used as NULL-Parameter");
}
configureDaysToWorkingDaysConverter();
CustomFieldValueReport report = new CustomFieldValueReport(columnHeaders);
List<MonitorQueryItem> monitorQueryItems = taskMonitorMapper.getTaskCountOfCustomFieldValues(workbasketIds, states, categories, domains, customField, customFieldValues);
report.addItems(monitorQueryItems, new DaysToWorkingDaysPreProcessor<>(columnHeaders, inWorkingDays));
return report;
} finally {
taskanaEngineImpl.returnConnection();
LOGGER.debug("exit from getCustomFieldValueReport().");
}
}
use of pro.taskana.exceptions.InvalidArgumentException in project taskana by Taskana.
the class TaskServiceImpl method completeTasks.
@Override
public BulkOperationResults<String, TaskanaException> completeTasks(List<String> taskIds) throws InvalidArgumentException {
try {
LOGGER.debug("entry to completeTasks(taskIds = {})", taskIds);
taskanaEngine.openConnection();
// Check pre-conditions with throwing Exceptions
if (taskIds == null) {
throw new InvalidArgumentException("TaskIds can´t be used as NULL-Parameter.");
}
// process bulk-complete
BulkOperationResults<String, TaskanaException> bulkLog = new BulkOperationResults<>();
if (!taskIds.isEmpty()) {
// remove null/empty taskIds with message
Iterator<String> taskIdIterator = taskIds.iterator();
while (taskIdIterator.hasNext()) {
String currentTaskId = taskIdIterator.next();
if (currentTaskId == null || currentTaskId.isEmpty()) {
bulkLog.addError("", new InvalidArgumentException("IDs with EMPTY or NULL value are not allowed and invalid."));
taskIdIterator.remove();
}
}
// query for existing tasks, modify values and LOG missing ones.
List<TaskSummary> taskSummaries = this.createTaskQuery().idIn(taskIds.toArray(new String[0])).list();
Instant now = Instant.now();
taskIdIterator = taskIds.iterator();
while (taskIdIterator.hasNext()) {
String currentTaskId = taskIdIterator.next();
TaskSummaryImpl taskSummary = (TaskSummaryImpl) taskSummaries.stream().filter(ts -> currentTaskId.equals(ts.getTaskId())).findFirst().orElse(null);
if (taskSummary == null) {
bulkLog.addError(currentTaskId, new TaskNotFoundException(currentTaskId, "task with id " + currentTaskId + " was not found."));
taskIdIterator.remove();
} else if (taskSummary.getClaimed() == null || taskSummary.getState() != TaskState.CLAIMED) {
bulkLog.addError(currentTaskId, new InvalidStateException(currentTaskId));
taskIdIterator.remove();
} else if (!CurrentUserContext.getAccessIds().contains(taskSummary.getOwner())) {
bulkLog.addError(currentTaskId, new InvalidOwnerException("TaskOwner is" + taskSummary.getOwner() + ", but current User is " + CurrentUserContext.getUserid()));
taskIdIterator.remove();
} else {
taskSummary.setCompleted(now);
taskSummary.setModified(now);
taskSummary.setState(TaskState.COMPLETED);
}
}
if (!taskIds.isEmpty() && !taskSummaries.isEmpty()) {
taskMapper.updateCompleted(taskIds, (TaskSummaryImpl) taskSummaries.get(0));
}
}
return bulkLog;
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from to completeTasks(taskIds = {})", taskIds);
}
}
use of pro.taskana.exceptions.InvalidArgumentException in project taskana by Taskana.
the class UpdateTaskAccTest method testThrowsExceptionIfMandatoryPrimaryObjectReferenceIsNotSetOrIncomplete.
@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testThrowsExceptionIfMandatoryPrimaryObjectReferenceIsNotSetOrIncomplete() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, ConcurrencyException, AttachmentPersistenceException {
TaskService taskService = taskanaEngine.getTaskService();
Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
task.setPrimaryObjRef(null);
try {
taskService.updateTask(task);
fail("update() should have thrown InvalidArgumentException.");
} catch (InvalidArgumentException ex) {
// nothing to do
}
task.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", null));
try {
taskService.updateTask(task);
fail("update() should have thrown InvalidArgumentException.");
} catch (InvalidArgumentException ex) {
// nothing to do
}
task.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", null, "1234567"));
try {
taskService.updateTask(task);
fail("update() should have thrown InvalidArgumentException.");
} catch (InvalidArgumentException ex) {
// nothing to do
}
task.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", null, "VNR", "1234567"));
try {
taskService.updateTask(task);
fail("update() should have thrown InvalidArgumentException.");
} catch (InvalidArgumentException ex) {
// nothing to do
}
task.setPrimaryObjRef(createObjectReference("COMPANY_A", null, "INSTANCE_A", "VNR", "1234567"));
try {
taskService.updateTask(task);
fail("update() should have thrown InvalidArgumentException.");
} catch (InvalidArgumentException ex) {
// nothing to do
}
task.setPrimaryObjRef(createObjectReference(null, "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
try {
taskService.updateTask(task);
fail("update() should have thrown InvalidArgumentException.");
} catch (InvalidArgumentException ex) {
// nothing to do
}
}
use of pro.taskana.exceptions.InvalidArgumentException in project taskana by Taskana.
the class DeleteWorkbasketAccTest method testCreateAndDeleteWorkbasket.
@WithAccessId(userName = "user_1_2", groupNames = { "businessadmin" })
@Test
public void testCreateAndDeleteWorkbasket() throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, InvalidWorkbasketException, WorkbasketAlreadyExistException, DomainNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
int before = workbasketService.createWorkbasketQuery().domainIn("DOMAIN_A").list().size();
Workbasket workbasket = workbasketService.newWorkbasket("NT1234", "DOMAIN_A");
workbasket.setName("TheUltimate");
workbasket.setType(WorkbasketType.GROUP);
workbasket.setOrgLevel1("company");
workbasket = workbasketService.createWorkbasket(workbasket);
try {
workbasketService.deleteWorkbasket(workbasket.getId());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of pro.taskana.exceptions.InvalidArgumentException in project taskana by Taskana.
the class CreateTaskAccTest method testThrowsExceptionIfAttachmentIsInvalid.
@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testThrowsExceptionIfAttachmentIsInvalid() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException {
TaskService taskService = taskanaEngine.getTaskService();
Task newTask = makeNewTask(taskService);
newTask.addAttachment(createAttachment("DOCTYPE_DEFAULT", null, "E-MAIL", "2018-01-15", createSimpleCustomProperties(3)));
try {
taskService.createTask(newTask);
fail("Should have thrown an InvalidArgumentException, becasue Attachment-ObjRef is null.");
} catch (InvalidArgumentException ex) {
// nothing to do
}
newTask = makeNewTask(taskService);
newTask.addAttachment(createAttachment("DOCTYPE_DEFAULT", createObjectReference("COMPANY_A", "SYSTEM_B", "INSTANCE_B", "ArchiveId", null), "E-MAIL", "2018-01-15", createSimpleCustomProperties(3)));
try {
taskService.createTask(newTask);
fail("Should have thrown an InvalidArgumentException, becasue ObjRef-Value is null.");
} catch (InvalidArgumentException ex) {
// nothing to do
}
newTask = makeNewTask(taskService);
newTask.addAttachment(createAttachment("DOCTYPE_DEFAULT", createObjectReference("COMPANY_A", "SYSTEM_B", "INSTANCE_B", null, "12345678901234567890123456789012345678901234567890"), "E-MAIL", "2018-01-15", createSimpleCustomProperties(3)));
try {
taskService.createTask(newTask);
fail("Should have thrown an InvalidArgumentException, becasue ObjRef-Type is null.");
} catch (InvalidArgumentException ex) {
// nothing to do
}
newTask = makeNewTask(taskService);
newTask.addAttachment(createAttachment("DOCTYPE_DEFAULT", createObjectReference("COMPANY_A", "SYSTEM_B", null, "ArchiveId", "12345678901234567890123456789012345678901234567890"), "E-MAIL", "2018-01-15", createSimpleCustomProperties(3)));
try {
taskService.createTask(newTask);
fail("Should have thrown an InvalidArgumentException, becasue ObjRef-SystemInstance is null.");
} catch (InvalidArgumentException ex) {
// nothing to do
}
newTask = makeNewTask(taskService);
newTask.addAttachment(createAttachment("DOCTYPE_DEFAULT", createObjectReference("COMPANY_A", null, "INSTANCE_B", "ArchiveId", "12345678901234567890123456789012345678901234567890"), "E-MAIL", "2018-01-15", createSimpleCustomProperties(3)));
try {
taskService.createTask(newTask);
fail("Should have thrown an InvalidArgumentException, becasue ObjRef-System is null.");
} catch (InvalidArgumentException ex) {
// nothing to do
}
newTask = makeNewTask(taskService);
newTask.addAttachment(createAttachment("DOCTYPE_DEFAULT", createObjectReference(null, "SYSTEM_B", "INSTANCE_B", "ArchiveId", "12345678901234567890123456789012345678901234567890"), "E-MAIL", "2018-01-15", createSimpleCustomProperties(3)));
try {
taskService.createTask(newTask);
fail("Should have thrown an InvalidArgumentException, becasue ObjRef-Company is null.");
} catch (InvalidArgumentException ex) {
// nothing to do
}
}
Aggregations