diff --git a/lib/taskana-core/src/main/java/pro/taskana/configuration/DbSchemaCreator.java b/lib/taskana-core/src/main/java/pro/taskana/configuration/DbSchemaCreator.java index 8f64a515c..611991e00 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/configuration/DbSchemaCreator.java +++ b/lib/taskana-core/src/main/java/pro/taskana/configuration/DbSchemaCreator.java @@ -46,12 +46,13 @@ public class DbSchemaCreator { runner.setStopOnError(true); runner.setLogWriter(logWriter); runner.setErrorLogWriter(errorLogWriter); - - if (!isSchemaPreexisting(runner)) { - runner.runScript(new InputStreamReader(this.getClass().getResourceAsStream(DB_SCHEMA))); + try { + if (!isSchemaPreexisting(runner)) { + runner.runScript(new InputStreamReader(this.getClass().getResourceAsStream(DB_SCHEMA))); + } + } finally { + runner.closeConnection(); } - runner.closeConnection(); - LOGGER.debug(outWriter.toString()); if (!errorWriter.toString().trim().isEmpty()) { LOGGER.error(errorWriter.toString()); diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/TaskanaEngineImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/TaskanaEngineImpl.java index a6c004e4e..ae73215f8 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/TaskanaEngineImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/TaskanaEngineImpl.java @@ -222,6 +222,8 @@ public class TaskanaEngineImpl implements TaskanaEngine { String databaseProductName; try (Connection con = taskanaEngineConfiguration.getDatasource().getConnection()) { databaseProductName = con.getMetaData().getDatabaseProductName(); + databaseProductName = con.getMetaData() + .getDatabaseProductName(); if (databaseProductName.contains("DB2")) { configuration.setDatabaseId("db2"); } else if (databaseProductName.contains("H2")) { diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketServiceImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketServiceImpl.java index 8a0a3f4e9..39e6fe25d 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketServiceImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketServiceImpl.java @@ -108,7 +108,7 @@ public class WorkbasketServiceImpl implements WorkbasketService { for (String accessId : CurrentUserContext.getAccessIds()) { workbaskets.addAll(workbasketMapper.findByPermission(permissions, accessId)); } - result = new ArrayList(); + result = new ArrayList<>(); result.addAll(workbaskets); return result; } finally { @@ -135,7 +135,7 @@ public class WorkbasketServiceImpl implements WorkbasketService { } finally { taskanaEngine.returnConnection(); if (LOGGER.isDebugEnabled()) { - int numberOfResultObjects = workbaskets == null ? 0 : workbaskets.size(); + int numberOfResultObjects = workbaskets.size(); LOGGER.debug("exit from getWorkbaskets(). Returning {} resulting Objects: {} ", numberOfResultObjects, LoggerUtils.listToString(workbaskets)); } @@ -388,7 +388,7 @@ public class WorkbasketServiceImpl implements WorkbasketService { } finally { taskanaEngine.returnConnection(); if (LOGGER.isDebugEnabled()) { - int numberOfResultObjects = result == null ? 0 : result.size(); + int numberOfResultObjects = result.size(); LOGGER.debug("exit from getDistributionTargets(workbasketId). Returning {} resulting Objects: {} ", numberOfResultObjects, LoggerUtils.listToString(result)); } @@ -427,7 +427,7 @@ public class WorkbasketServiceImpl implements WorkbasketService { taskanaEngine.returnConnection(); if (LOGGER.isDebugEnabled()) { LOGGER.debug("setDistributionTargets set {} distribution targets to source workbasket {} ", - targetWorkbasketIds.size(), sourceWorkbasketId); + targetWorkbasketIds == null ? 0 : targetWorkbasketIds.size(), sourceWorkbasketId); } } @@ -526,7 +526,8 @@ public class WorkbasketServiceImpl implements WorkbasketService { List accessIds = CurrentUserContext.getAccessIds(); LOGGER.debug("checkAuthorization: Verifying that {} has the permission {} on workbasket {}", - CurrentUserContext.getUserid(), workbasketAuthorization.name(), workbasketKey); + CurrentUserContext.getUserid(), + workbasketAuthorization == null ? "null" : workbasketAuthorization.name(), workbasketKey); List accessItems; diff --git a/lib/taskana-core/src/test/java/pro/taskana/impl/integration/WorkbasketServiceImplIntAutocommitTest.java b/lib/taskana-core/src/test/java/pro/taskana/impl/integration/WorkbasketServiceImplIntAutocommitTest.java index 3f570c716..d47c32de0 100644 --- a/lib/taskana-core/src/test/java/pro/taskana/impl/integration/WorkbasketServiceImplIntAutocommitTest.java +++ b/lib/taskana-core/src/test/java/pro/taskana/impl/integration/WorkbasketServiceImplIntAutocommitTest.java @@ -193,6 +193,7 @@ public class WorkbasketServiceImplIntAutocommitTest { workbasket2 = workBasketService.createWorkbasket(workbasket2); createWorkbasketWithSecurity(workbasket2, "Elena", true, true, false, false); List distTargets = new ArrayList<>(Arrays.asList(workbasket0.getId(), workbasket1.getId())); + Thread.sleep(20L); workBasketService.setDistributionTargets(workbasket2.getId(), distTargets); String id3 = IdGenerator.generateWithPrefix("TWB"); @@ -202,6 +203,7 @@ public class WorkbasketServiceImplIntAutocommitTest { createWorkbasketWithSecurity(workbasket3, "Elena", true, true, false, false); List newDistTargets = new ArrayList<>(Arrays.asList(workbasket3.getId())); + Thread.sleep(20L); workBasketService.setDistributionTargets(workbasket2.getId(), newDistTargets); Workbasket foundBasket = workBasketService.getWorkbasket(workbasket2.getId()); @@ -210,10 +212,8 @@ public class WorkbasketServiceImplIntAutocommitTest { Assert.assertEquals(1, distributionTargets.size()); Assert.assertEquals(id3, distributionTargets.get(0).getId()); - // Question: should we update the modfied timestamp on the source workbasket if we change its - // distributiontargets? - // Assert.assertNotEquals(workBasketService.getWorkbasket(id2).getCreated(), - // workBasketService.getWorkbasket(id2).getModified()); + Assert.assertNotEquals(workBasketService.getWorkbasket(id2).getCreated(), + workBasketService.getWorkbasket(id2).getModified()); Assert.assertEquals(workBasketService.getWorkbasket(id1).getCreated(), workBasketService.getWorkbasket(id1).getModified()); Assert.assertEquals(workBasketService.getWorkbasket(id3).getCreated(), diff --git a/lib/taskana-core/src/test/java/pro/taskana/impl/integration/WorkbasketServiceImplIntExplicitTest.java b/lib/taskana-core/src/test/java/pro/taskana/impl/integration/WorkbasketServiceImplIntExplicitTest.java index 89adaacf7..08ad3d43b 100644 --- a/lib/taskana-core/src/test/java/pro/taskana/impl/integration/WorkbasketServiceImplIntExplicitTest.java +++ b/lib/taskana-core/src/test/java/pro/taskana/impl/integration/WorkbasketServiceImplIntExplicitTest.java @@ -186,7 +186,6 @@ public class WorkbasketServiceImplIntExplicitTest { String id2 = IdGenerator.generateWithPrefix("TWB"); Workbasket workbasket2 = createTestWorkbasket(id2, "key2", "novatec", "Hyperbasket", WorkbasketType.GROUP); - // workbasket2 = workBasketService.createWorkbasket(workbasket2); createWorkbasketWithSecurity(workbasket2, "Elena", true, true, false, false); @@ -221,6 +220,7 @@ public class WorkbasketServiceImplIntExplicitTest { createWorkbasketWithSecurity(workbasket2, "Elena", true, true, false, false); List distTargets = new ArrayList<>(Arrays.asList(workbasket0.getId(), workbasket1.getId())); + Thread.sleep(20L); workBasketService.setDistributionTargets(workbasket2.getId(), distTargets); String id3 = IdGenerator.generateWithPrefix("TWB"); @@ -230,6 +230,7 @@ public class WorkbasketServiceImplIntExplicitTest { createWorkbasketWithSecurity(workbasket3, "Elena", true, true, false, false); List newDistTargets = new ArrayList<>(Arrays.asList(workbasket3.getId())); + Thread.sleep(20L); workBasketService.setDistributionTargets(workbasket2.getId(), newDistTargets); Workbasket foundBasket = workBasketService.getWorkbasket(workbasket2.getId()); @@ -237,10 +238,8 @@ public class WorkbasketServiceImplIntExplicitTest { List distributionTargets = workBasketService.getDistributionTargets(foundBasket.getId()); Assert.assertEquals(1, distributionTargets.size()); Assert.assertEquals(workbasket3.getId(), distributionTargets.get(0).getId()); - // Question: should we update the modfied timestamp on the source workbasket if we change its - // distributiontargets? - // Assert.assertNotEquals(workBasketService.getWorkbasket(id2).getCreated(), - // workBasketService.getWorkbasket(id2).getModified()); + Assert.assertNotEquals(workBasketService.getWorkbasket(id2).getCreated(), + workBasketService.getWorkbasket(id2).getModified()); Assert.assertEquals(workBasketService.getWorkbasket(id1).getCreated(), workBasketService.getWorkbasket(id1).getModified()); Assert.assertEquals(workBasketService.getWorkbasket(id3).getCreated(),