From 4f2b4363ce0d96856b20c51f0aa06e98e4c07234 Mon Sep 17 00:00:00 2001 From: CRoberto1926 <3205022+CRoberto1926@users.noreply.github.com> Date: Fri, 15 Nov 2024 17:07:37 +0100 Subject: [PATCH] Lazy Logging + SLF4J best practices OpenRewrite recipe --- .../kadai/sampledata/SampleDataGenerator.java | 34 ++- .../internal/logging/LoggingAspect.java | 49 +-- .../security/CurrentUserContextImpl.java | 16 +- .../configuration/DbSchemaCreator.java | 58 ++-- .../internal/persistence/MapTypeHandler.java | 6 +- .../impl/LogfileHistoryServiceImpl.java | 69 +++-- .../impl/jobs/HistoryCleanupJob.java | 4 +- .../io/kadai/KadaiCdiTestRestController.java | 2 +- .../internal/ClassificationServiceImpl.java | 93 +++--- .../jobs/ClassificationChangedJob.java | 17 +- .../internal/ConfigurationServiceImpl.java | 12 +- .../kadai/common/internal/JobServiceImpl.java | 32 +- .../common/internal/KadaiEngineImpl.java | 14 +- .../kadai/common/internal/jobs/JobRunner.java | 4 +- .../WorkingDaysToDaysReportConverter.java | 4 +- .../history/internal/HistoryEventManager.java | 16 +- .../internal/PriorityServiceManager.java | 21 +- .../routing/internal/TaskRoutingManager.java | 20 +- .../internal/AfterRequestChangesManager.java | 9 +- .../internal/AfterRequestReviewManager.java | 9 +- .../internal/BeforeRequestChangesManager.java | 9 +- .../internal/BeforeRequestReviewManager.java | 4 +- .../CreateTaskPreprocessorManager.java | 4 +- .../task/internal/ReviewRequiredManager.java | 9 +- .../TaskEndstatePreprocessorManager.java | 4 +- .../task/internal/AttachmentHandler.java | 36 +-- .../task/internal/ObjectReferenceHandler.java | 37 +-- .../task/internal/ServiceLevelHandler.java | 8 +- .../task/internal/TaskCommentQueryImpl.java | 7 +- .../task/internal/TaskCommentServiceImpl.java | 22 +- .../io/kadai/task/internal/TaskQueryImpl.java | 13 +- .../kadai/task/internal/TaskServiceImpl.java | 285 ++++++++---------- .../task/internal/jobs/TaskCleanupJob.java | 20 +- .../kadai/user/internal/UserServiceImpl.java | 28 +- .../internal/WorkbasketServiceImpl.java | 135 ++++----- .../internal/jobs/WorkbasketCleanupJob.java | 9 +- .../wildfly/KadaiWildflyConfiguration.java | 5 +- .../wildfly/security/ElytronToJaasFilter.java | 3 + .../wildfly/security/LogoutController.java | 6 +- .../rest/test/SpringSecurityToJaasFilter.java | 48 +-- .../rest/SpringSecurityToJaasFilter.java | 48 +-- .../io/kadai/common/rest/ldap/LdapClient.java | 269 +++++++++-------- .../kadai/user/jobs/UserInfoRefreshJob.java | 40 +-- .../workbasket/rest/WorkbasketController.java | 10 +- ...sificationDefinitionControllerIntTest.java | 11 +- .../dmn/service/DmnConverterService.java | 4 +- .../dmn/spi/internal/DmnValidatorManager.java | 5 +- 47 files changed, 750 insertions(+), 818 deletions(-) diff --git a/common/kadai-common-data/src/main/java/io/kadai/sampledata/SampleDataGenerator.java b/common/kadai-common-data/src/main/java/io/kadai/sampledata/SampleDataGenerator.java index 589949fdb..b62f4002a 100644 --- a/common/kadai-common-data/src/main/java/io/kadai/sampledata/SampleDataGenerator.java +++ b/common/kadai-common-data/src/main/java/io/kadai/sampledata/SampleDataGenerator.java @@ -103,13 +103,21 @@ private List parseScripts(Stream scripts) { private void runScripts(Consumer consumer) { try (Connection connection = dataSource.getConnection()) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "Generating sample data for database of type '{}' with url '{}' and schema '{}'.", - DB.getDB(connection).dbProductName, - connection.getMetaData().getURL(), - schema); - } + LOGGER + .atDebug() + .setMessage( + "Generating sample data for database of type '{}' with url '{}' and schema '{}'.") + .addArgument(() -> DB.getDB(connection).dbProductName) + .addArgument( + () -> { + try { + return connection.getMetaData().getURL(); + } catch (SQLException e) { + throw new RuntimeSqlException("Failed to get URL for database.", e); + } + }) + .addArgument(() -> schema) + .log(); StringWriter outWriter = new StringWriter(); StringWriter errorWriter = new StringWriter(); @@ -117,14 +125,10 @@ private void runScripts(Consumer consumer) { ScriptRunner runner = getScriptRunner(connection, outWriter, errorWriter); consumer.accept(runner); - if (LOGGER.isTraceEnabled()) { - LOGGER.trace(outWriter.toString()); - } - if (LOGGER.isErrorEnabled()) { - String trimmedErrorString = errorWriter.toString().trim(); - if (!trimmedErrorString.isEmpty()) { - LOGGER.error(trimmedErrorString); - } + LOGGER.atTrace().setMessage(outWriter::toString).log(); + + if (!errorWriter.getBuffer().isEmpty()) { + LOGGER.atError().setMessage(() -> errorWriter.toString().trim()).log(); } } catch (SQLException e) { throw new RuntimeSqlException("Failed to execute script.", e); diff --git a/common/kadai-common-logging/src/main/java/io/kadai/common/internal/logging/LoggingAspect.java b/common/kadai-common-logging/src/main/java/io/kadai/common/internal/logging/LoggingAspect.java index f922363f6..6b732ec14 100644 --- a/common/kadai-common-logging/src/main/java/io/kadai/common/internal/logging/LoggingAspect.java +++ b/common/kadai-common-logging/src/main/java/io/kadai/common/internal/logging/LoggingAspect.java @@ -44,22 +44,6 @@ public static boolean isLoggingAspectEnabled() { return LazyHolder.LOGGING_ASPECT_ENABLED; } - private static String mapParametersNameValue(String[] parameterNames, Object[] values) { - Map parametersNameToValue = new HashMap<>(); - - if (parameterNames.length > 0) { - for (int i = 0; i < parameterNames.length; i++) { - parametersNameToValue.put(parameterNames[i], values[i]); - } - } - - StringBuilder stringBuilder = new StringBuilder(); - for (Entry parameter : parametersNameToValue.entrySet()) { - stringBuilder.append(parameter.getKey()).append(" = ").append(parameter.getValue()); - } - return stringBuilder.toString(); - } - @Pointcut( "!@annotation(io.kadai.common.internal.logging.NoLogging)" + " && !within(@io.kadai.common.internal.logging.NoLogging *)" @@ -80,14 +64,12 @@ public void beforeMethodExecuted(JoinPoint joinPoint) { Logger currentLogger = CLASS_TO_LOGGER.computeIfAbsent(declaringTypeName, LoggerFactory::getLogger); - if (currentLogger.isTraceEnabled()) { - String methodName = methodSignature.getName(); - Object[] values = joinPoint.getArgs(); - String[] parameterNames = methodSignature.getParameterNames(); - String parametersValues = mapParametersNameValue(parameterNames, values); - - currentLogger.trace("entry to {}({})", methodName, parametersValues); - } + currentLogger + .atTrace() + .setMessage("entry to {}({})") + .addArgument(methodSignature::getName) + .addArgument(() -> mapParametersNameValue(joinPoint)) + .log(); } } @@ -115,6 +97,25 @@ public void afterMethodExecuted(JoinPoint joinPoint, Object returnedObject) { } } + private static String mapParametersNameValue(JoinPoint joinPoint) { + Object[] values = joinPoint.getArgs(); + MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); + String[] parameterNames = methodSignature.getParameterNames(); + Map parametersNameToValue = new HashMap<>(); + + if (parameterNames.length > 0) { + for (int i = 0; i < parameterNames.length; i++) { + parametersNameToValue.put(parameterNames[i], values[i]); + } + } + + StringBuilder stringBuilder = new StringBuilder(); + for (Entry parameter : parametersNameToValue.entrySet()) { + stringBuilder.append(parameter.getKey()).append(" = ").append(parameter.getValue()); + } + return stringBuilder.toString(); + } + // This Initialization-on-demand holder idiom is necessary so that the retrieval of the system // property will be executed during the execution of the first JointPoint. // This allows us to set the system property during test execution BEFORE retrieving the system diff --git a/common/kadai-common-security/src/main/java/io/kadai/common/internal/security/CurrentUserContextImpl.java b/common/kadai-common-security/src/main/java/io/kadai/common/internal/security/CurrentUserContextImpl.java index 0781df1eb..55b4b53b2 100644 --- a/common/kadai-common-security/src/main/java/io/kadai/common/internal/security/CurrentUserContextImpl.java +++ b/common/kadai-common-security/src/main/java/io/kadai/common/internal/security/CurrentUserContextImpl.java @@ -48,14 +48,10 @@ public CurrentUserContextImpl(boolean shouldUseLowerCaseForAccessIds) { this.shouldUseLowerCaseForAccessIds = shouldUseLowerCaseForAccessIds; try { Class.forName(WSSUBJECT_CLASSNAME); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("WSSubject detected. Assuming that Kadai runs on IBM WebSphere."); - } + LOGGER.debug("WSSubject detected. Assuming that Kadai runs on IBM WebSphere."); runningOnWebSphere = true; } catch (ClassNotFoundException e) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("No WSSubject detected. Using JAAS subject further on."); - } + LOGGER.debug("No WSSubject detected. Using JAAS subject further on."); runningOnWebSphere = false; } } @@ -103,14 +99,10 @@ private String getUserIdFromWsSubject() { Method getCallerSubjectMethod = wsSubjectClass.getMethod(GET_CALLER_SUBJECT_METHOD, (Class[]) null); Subject callerSubject = (Subject) getCallerSubjectMethod.invoke(null, (Object[]) null); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Subject of caller: {}", callerSubject); - } + LOGGER.debug("Subject of caller: {}", callerSubject); if (callerSubject != null) { Set publicCredentials = callerSubject.getPublicCredentials(); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Public credentials of caller: {}", publicCredentials); - } + LOGGER.debug("Public credentials of caller: {}", publicCredentials); return publicCredentials.stream() .map( // we could use CheckedFunction#wrap here, but this either requires a dependency diff --git a/common/kadai-common/src/main/java/io/kadai/common/internal/configuration/DbSchemaCreator.java b/common/kadai-common/src/main/java/io/kadai/common/internal/configuration/DbSchemaCreator.java index 9fb84521c..d0bed9038 100644 --- a/common/kadai-common/src/main/java/io/kadai/common/internal/configuration/DbSchemaCreator.java +++ b/common/kadai-common/src/main/java/io/kadai/common/internal/configuration/DbSchemaCreator.java @@ -61,13 +61,20 @@ public DbSchemaCreator(DataSource dataSource, String schema) { */ public boolean run() throws SQLException { try (Connection connection = dataSource.getConnection()) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "Using database of type {} with url '{}'", - DB.getDB(connection).dbProductName, - connection.getMetaData().getURL()); - } DB db = DB.getDB(connection); + LOGGER + .atDebug() + .setMessage("Using database of type {} with url '{}'") + .addArgument(db.dbProductName) + .addArgument( + () -> { + try { + return connection.getMetaData().getURL(); + } catch (SQLException e) { + throw new RuntimeException(e); + } + }) + .log(); ScriptRunner runner = getScriptRunnerInstance(connection); @@ -80,11 +87,9 @@ public boolean run() throws SQLException { return true; } } - if (LOGGER.isDebugEnabled()) { - LOGGER.debug(outWriter.toString()); - } - if (!errorWriter.toString().trim().isEmpty()) { - LOGGER.error(errorWriter.toString()); + LOGGER.atDebug().setMessage(outWriter::toString).log(); + if (!errorWriter.getBuffer().isEmpty()) { + LOGGER.atError().setMessage(errorWriter::toString).log(); } return false; } @@ -93,9 +98,18 @@ public boolean isValidSchemaVersion(String expectedMinVersion) { try (Connection connection = dataSource.getConnection()) { connection.setSchema(this.schemaName); SqlRunner runner = new SqlRunner(connection); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("{}", connection.getMetaData()); - } + LOGGER + .atDebug() + .setMessage("{}") + .addArgument( + () -> { + try { + return connection.getMetaData(); + } catch (SQLException e) { + throw new RuntimeException(e); + } + }) + .log(); String query = "select VERSION from KADAI_SCHEMA_VERSION where " @@ -113,9 +127,7 @@ public boolean isValidSchemaVersion(String expectedMinVersion) { expectedMinVersion); return false; } else { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Schema version is valid."); - } + LOGGER.debug("Schema version is valid."); return true; } @@ -154,17 +166,13 @@ private boolean isSchemaPreexisting(Connection connection, DB db) { BufferedReader reader = new BufferedReader(inputReader)) { runner.runScript(getSqlSchemaNameParsed(reader)); } catch (RuntimeSqlException | IOException e) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Schema does not exist."); - if (!errorWriter.toString().trim().isEmpty()) { - LOGGER.debug(errorWriter.toString()); - } + LOGGER.debug("Schema does not exist."); + if (!errorWriter.getBuffer().isEmpty()) { + LOGGER.atDebug().setMessage(errorWriter::toString).log(); } return false; } - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Schema does exist."); - } + LOGGER.debug("Schema does exist."); return true; } diff --git a/common/kadai-common/src/main/java/io/kadai/common/internal/persistence/MapTypeHandler.java b/common/kadai-common/src/main/java/io/kadai/common/internal/persistence/MapTypeHandler.java index 5ea0bfdc8..6ff0776c6 100644 --- a/common/kadai-common/src/main/java/io/kadai/common/internal/persistence/MapTypeHandler.java +++ b/common/kadai-common/src/main/java/io/kadai/common/internal/persistence/MapTypeHandler.java @@ -39,10 +39,8 @@ public class MapTypeHandler extends BaseTypeHandler> { public void setNonNullParameter( PreparedStatement ps, int i, Map parameter, JdbcType jdbcType) throws SQLException { - if (parameter != null && parameter.size() > 0) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Input-Map before serializing: {}", parameter); - } + if (parameter != null && !parameter.isEmpty()) { + LOGGER.debug("Input-Map before serializing: {}", parameter); // Convert Map to JSON string JSONObject jsonObj = new JSONObject(parameter); ps.setString(i, jsonObj.toString()); diff --git a/history/kadai-loghistory-provider/src/main/java/io/kadai/loghistory/impl/LogfileHistoryServiceImpl.java b/history/kadai-loghistory-provider/src/main/java/io/kadai/loghistory/impl/LogfileHistoryServiceImpl.java index 74fdea36d..33eb65972 100644 --- a/history/kadai-loghistory-provider/src/main/java/io/kadai/loghistory/impl/LogfileHistoryServiceImpl.java +++ b/history/kadai-loghistory-provider/src/main/java/io/kadai/loghistory/impl/LogfileHistoryServiceImpl.java @@ -50,46 +50,59 @@ public void initialize(KadaiEngine kadaiEngine) { historyLogger = LOGGER; } - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "LogfileHistoryServiceProvider initialized with name: {} ", historyLogger.getName()); - } + LOGGER + .atDebug() + .setMessage("LogfileHistoryServiceProvider initialized with name: {} ") + .addArgument(() -> historyLogger.getName()) + .log(); } @Override public void create(TaskHistoryEvent event) { - - try { - if (historyLogger.isInfoEnabled()) { - historyLogger.info(objectMapper.writeValueAsString(event)); - } - } catch (JsonProcessingException e) { - throw new SystemException("Caught exception while serializing history event to JSON ", e); - } + historyLogger + .atInfo() + .setMessage( + () -> { + try { + return objectMapper.writeValueAsString(event); + } catch (JsonProcessingException e) { + throw new SystemException( + "Caught exception while serializing history event to JSON ", e); + } + }) + .log(); } @Override public void create(WorkbasketHistoryEvent event) { - - try { - if (historyLogger.isInfoEnabled()) { - historyLogger.info(objectMapper.writeValueAsString(event)); - } - } catch (JsonProcessingException e) { - throw new SystemException("Caught exception while serializing history event to JSON ", e); - } + historyLogger + .atInfo() + .setMessage( + () -> { + try { + return objectMapper.writeValueAsString(event); + } catch (JsonProcessingException e) { + throw new SystemException( + "Caught exception while serializing history event to JSON ", e); + } + }) + .log(); } @Override public void create(ClassificationHistoryEvent event) { - - try { - if (historyLogger.isInfoEnabled()) { - historyLogger.info(objectMapper.writeValueAsString(event)); - } - } catch (JsonProcessingException e) { - throw new SystemException("Caught exception while serializing history event to JSON ", e); - } + historyLogger + .atInfo() + .setMessage( + () -> { + try { + return objectMapper.writeValueAsString(event); + } catch (JsonProcessingException e) { + throw new SystemException( + "Caught exception while serializing history event to JSON ", e); + } + }) + .log(); } @Override diff --git a/history/kadai-simplehistory-provider/src/main/java/io/kadai/simplehistory/impl/jobs/HistoryCleanupJob.java b/history/kadai-simplehistory-provider/src/main/java/io/kadai/simplehistory/impl/jobs/HistoryCleanupJob.java index fd4a706d9..bfc7c3b27 100644 --- a/history/kadai-simplehistory-provider/src/main/java/io/kadai/simplehistory/impl/jobs/HistoryCleanupJob.java +++ b/history/kadai-simplehistory-provider/src/main/java/io/kadai/simplehistory/impl/jobs/HistoryCleanupJob.java @@ -198,9 +198,7 @@ private int deleteEvents(List taskIdsToDeleteHistoryEventsFor) simpleHistoryService.deleteHistoryEventsByTaskIds(taskIdsToDeleteHistoryEventsFor); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("{} events deleted.", deletedTasksCount); - } + LOGGER.debug("{} events deleted.", deletedTasksCount); return deletedTasksCount; } diff --git a/lib/kadai-cdi/src/test/java/io/kadai/KadaiCdiTestRestController.java b/lib/kadai-cdi/src/test/java/io/kadai/KadaiCdiTestRestController.java index eef44b236..f955a1ad8 100644 --- a/lib/kadai-cdi/src/test/java/io/kadai/KadaiCdiTestRestController.java +++ b/lib/kadai-cdi/src/test/java/io/kadai/KadaiCdiTestRestController.java @@ -80,7 +80,7 @@ public Response startTask() throws Exception { Task result = kadaiEjb.getTaskService().createTask(task); - LOGGER.info(result.getId() + ":" + result.getOwner()); + LOGGER.info("{}:{}", result.getId(), result.getOwner()); return Response.status(200).entity(result.getId()).build(); } diff --git a/lib/kadai-core/src/main/java/io/kadai/classification/internal/ClassificationServiceImpl.java b/lib/kadai-core/src/main/java/io/kadai/classification/internal/ClassificationServiceImpl.java index eca91b8fb..4b9f77dde 100644 --- a/lib/kadai-core/src/main/java/io/kadai/classification/internal/ClassificationServiceImpl.java +++ b/lib/kadai-core/src/main/java/io/kadai/classification/internal/ClassificationServiceImpl.java @@ -82,24 +82,6 @@ public ClassificationServiceImpl( this.historyEventManager = kadaiEngine.getHistoryEventManager(); } - private static void validateServiceLevel(Classification classification) - throws MalformedServiceLevelException { - String serviceLevel = classification.getServiceLevel(); - Duration duration; - - try { - duration = Duration.parse(serviceLevel); - } catch (Exception e) { - throw new MalformedServiceLevelException( - serviceLevel, classification.getKey(), classification.getDomain()); - } - - if (duration.isNegative()) { - throw new MalformedServiceLevelException( - serviceLevel, classification.getKey(), classification.getDomain()); - } - } - @Override public Classification getClassification(String key, String domain) throws ClassificationNotFoundException { @@ -258,11 +240,11 @@ public Classification createClassification(Classification classification) details)); } - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "Method createClassification created classification {}.", - LogSanitizer.stripLineBreakingChars(classificationImpl)); - } + LOGGER + .atDebug() + .setMessage("Method createClassification created classification {}.") + .addArgument(() -> LogSanitizer.stripLineBreakingChars(classificationImpl)) + .log(); if (!classification.getDomain().isEmpty()) { addClassificationToMasterDomain(classificationImpl); @@ -320,11 +302,11 @@ public Classification updateClassification(Classification classification) kadaiEngine.getEngine().getCurrentUserContext().getUserid(), details)); } - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "Method updateClassification() updated the classification {}.", - LogSanitizer.stripLineBreakingChars(classificationImpl)); - } + LOGGER + .atDebug() + .setMessage("Method updateClassification() updated the classification {}.") + .addArgument(() -> LogSanitizer.stripLineBreakingChars(classificationImpl)) + .log(); return classification; } finally { kadaiEngine.returnConnection(); @@ -345,6 +327,24 @@ public Classification newClassification(String key, String domain, String type) return classification; } + private static void validateServiceLevel(Classification classification) + throws MalformedServiceLevelException { + String serviceLevel = classification.getServiceLevel(); + Duration duration; + + try { + duration = Duration.parse(serviceLevel); + } catch (Exception e) { + throw new MalformedServiceLevelException( + serviceLevel, classification.getKey(), classification.getDomain()); + } + + if (duration.isNegative()) { + throw new MalformedServiceLevelException( + serviceLevel, classification.getKey(), classification.getDomain()); + } + } + private void validateAndPopulateParentInformation(ClassificationImpl classificationImpl) throws InvalidArgumentException { try { @@ -398,24 +398,26 @@ private void addClassificationToMasterDomain(ClassificationImpl classification) this.getClassification(masterClassification.getKey(), masterClassification.getDomain()); throw new ClassificationAlreadyExistException(masterClassification); } catch (ClassificationNotFoundException e) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "Method createClassification: Classification does not " - + "exist in master domain. Classification {}.", - masterClassification); - } + LOGGER.debug( + """ + Method createClassification: Classification does not \ + exist in master domain. Classification {}.""", + masterClassification); classificationMapper.insert(masterClassification); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "Method createClassification: Classification created in " - + "master-domain, too. Classification {}.", - masterClassification); - } + LOGGER.debug( + """ + Method createClassification: Classification created in \ + master-domain, too. Classification {}.""", + masterClassification); } catch (ClassificationAlreadyExistException ex) { - LOGGER.warn( - "Method createClassification: Classification does already exist " - + "in master domain. Classification {}.", - LogSanitizer.stripLineBreakingChars(masterClassification)); + LOGGER + .atWarn() + .setMessage( + """ + Method createClassification: Classification does already exist \ + in master domain. Classification {}.""") + .addArgument(() -> LogSanitizer.stripLineBreakingChars(masterClassification)) + .log(); } } } @@ -514,8 +516,7 @@ private boolean doesClassificationExist(String key, String domain) { } private boolean isReferentialIntegrityConstraintViolation(PersistenceException e) { - return isH2OrPostgresIntegrityConstraintViolation(e) - || isDb2IntegrityConstraintViolation(e); + return isH2OrPostgresIntegrityConstraintViolation(e) || isDb2IntegrityConstraintViolation(e); } private boolean isDb2IntegrityConstraintViolation(PersistenceException e) { diff --git a/lib/kadai-core/src/main/java/io/kadai/classification/internal/jobs/ClassificationChangedJob.java b/lib/kadai-core/src/main/java/io/kadai/classification/internal/jobs/ClassificationChangedJob.java index 0f65b0766..331059358 100644 --- a/lib/kadai-core/src/main/java/io/kadai/classification/internal/jobs/ClassificationChangedJob.java +++ b/lib/kadai-core/src/main/java/io/kadai/classification/internal/jobs/ClassificationChangedJob.java @@ -83,14 +83,15 @@ private void scheduleTaskRefreshJobs(List affectedTaskIds) { int batchSize = kadaiEngineImpl.getConfiguration().getJobBatchSize(); Collection> affectedTaskBatches = CollectionUtil.partitionBasedOnSize(affectedTaskIds, batchSize); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "Creating {} TaskRefreshJobs out of {} affected tasks " - + "with a maximum number of {} tasks each. ", - affectedTaskBatches.size(), - affectedTaskIds.size(), - batchSize); - } + LOGGER + .atDebug() + .setMessage( + "Creating {} TaskRefreshJobs out of {} affected tasks " + + "with a maximum number of {} tasks each. ") + .addArgument(affectedTaskBatches::size) + .addArgument(affectedTaskIds::size) + .addArgument(batchSize) + .log(); for (List taskIdBatch : affectedTaskBatches) { Map args = new HashMap<>(); if (!taskIdBatch.isEmpty()) { diff --git a/lib/kadai-core/src/main/java/io/kadai/common/internal/ConfigurationServiceImpl.java b/lib/kadai-core/src/main/java/io/kadai/common/internal/ConfigurationServiceImpl.java index 608cf8c12..d8a7104f8 100644 --- a/lib/kadai-core/src/main/java/io/kadai/common/internal/ConfigurationServiceImpl.java +++ b/lib/kadai-core/src/main/java/io/kadai/common/internal/ConfigurationServiceImpl.java @@ -59,9 +59,7 @@ public void setupDefaultCustomAttributes() { CheckedRunnable.wrap( () -> { if (mapper.getAllCustomAttributes(true) == null) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("custom attributes are not set. Setting default value"); - } + LOGGER.debug("custom attributes are not set. Setting default value"); setAllCustomAttributes(generateDefaultCustomAttributes()); } })); @@ -86,16 +84,12 @@ public Optional getValue(String attribute) { private void initializeSecurityEnabled(boolean securityEnabled) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Security-mode is not yet set. Setting security flag to {}", securityEnabled); - } + LOGGER.debug("Security-mode is not yet set. Setting security flag to {}", securityEnabled); Boolean isStillSecurityEnabled = mapper.isSecurityEnabled(true); if (isStillSecurityEnabled == null) { mapper.setSecurityEnabled(securityEnabled); isStillSecurityEnabled = Boolean.valueOf(securityEnabled); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Successfully set security mode to {}", securityEnabled); - } + LOGGER.debug("Successfully set security mode to {}", securityEnabled); } if (isStillSecurityEnabled && !securityEnabled) { LOGGER.error("Tried to start KADAI in unsecured mode while secured mode is enforced!"); diff --git a/lib/kadai-core/src/main/java/io/kadai/common/internal/JobServiceImpl.java b/lib/kadai-core/src/main/java/io/kadai/common/internal/JobServiceImpl.java index 620c48560..b2e2090f2 100644 --- a/lib/kadai-core/src/main/java/io/kadai/common/internal/JobServiceImpl.java +++ b/lib/kadai-core/src/main/java/io/kadai/common/internal/JobServiceImpl.java @@ -48,17 +48,13 @@ public ScheduledJob createJob(ScheduledJob job) { initializeDefaultJobProperties(job); Integer id = kadaiEngineImpl.executeInDatabaseConnection(() -> jobMapper.insertJob(job)); job.setJobId(id); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Created job {}", job); - } + LOGGER.debug("Created job {}", job); return job; } public void deleteJobs(String jobType) { kadaiEngineImpl.executeInDatabaseConnection(() -> jobMapper.deleteMultiple(jobType)); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Deleted jobs of type: {}", jobType); - } + LOGGER.debug("Deleted jobs of type: {}", jobType); } public ScheduledJob lockJob(ScheduledJob job, String owner) { @@ -80,32 +76,30 @@ public ScheduledJob lockJob(ScheduledJob job, String owner) { jobClass, KadaiConfiguration.class)); } catch (InvocationTargetException | IllegalAccessException e) { throw new SystemException( - String.format( - "Caught Exception while invoking method 'getLockExpirationPeriod' by reflection")); + "Caught Exception while invoking method 'getLockExpirationPeriod' by reflection"); } job.setRetryCount(job.getRetryCount() - 1); kadaiEngineImpl.executeInDatabaseConnection(() -> jobMapper.update(job)); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Job {} locked. Remaining retries: {}", job.getJobId(), job.getRetryCount()); - } + LOGGER + .atDebug() + .setMessage("Job {} locked. Remaining retries: {}") + .addArgument(job::getJobId) + .addArgument(job::getRetryCount) + .log(); return job; } public List findJobsToRun() { List availableJobs = kadaiEngineImpl.executeInDatabaseConnection(() -> jobMapper.findJobsToRun(Instant.now())); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Found available jobs: {}", availableJobs); - } + LOGGER.debug("Found available jobs: {}", availableJobs); return availableJobs; } public void deleteJob(ScheduledJob job) { kadaiEngineImpl.executeInDatabaseConnection(() -> jobMapper.delete(job)); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Deleted job: {}", job); - } + LOGGER.debug("Deleted job: {}", job); } private void initializeDefaultJobProperties(ScheduledJob job) { @@ -117,8 +111,6 @@ private void initializeDefaultJobProperties(ScheduledJob job) { job.setDue(now); } job.setRetryCount(kadaiEngineImpl.getEngine().getConfiguration().getMaxNumberOfJobRetries()); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Job after initialization: {}", job); - } + LOGGER.debug("Job after initialization: {}", job); } } diff --git a/lib/kadai-core/src/main/java/io/kadai/common/internal/KadaiEngineImpl.java b/lib/kadai-core/src/main/java/io/kadai/common/internal/KadaiEngineImpl.java index 762656560..70ca55196 100644 --- a/lib/kadai-core/src/main/java/io/kadai/common/internal/KadaiEngineImpl.java +++ b/lib/kadai-core/src/main/java/io/kadai/common/internal/KadaiEngineImpl.java @@ -368,13 +368,13 @@ public boolean isUserInRole(KadaiRole... roles) { @Override public void checkRoleMembership(KadaiRole... roles) throws NotAuthorizedException { if (!isUserInRole(roles)) { - if (LOGGER.isDebugEnabled()) { - String rolesAsString = Arrays.toString(roles); - LOGGER.debug( - "Throwing NotAuthorizedException because accessIds {} are not member of roles {}", - currentUserContext.getAccessIds(), - rolesAsString); - } + LOGGER + .atDebug() + .setMessage( + "Throwing NotAuthorizedException because accessIds {} are not member of roles {}") + .addArgument(currentUserContext::getAccessIds) + .addArgument(() -> Arrays.toString(roles)) + .log(); throw new NotAuthorizedException(currentUserContext.getUserid(), roles); } } diff --git a/lib/kadai-core/src/main/java/io/kadai/common/internal/jobs/JobRunner.java b/lib/kadai-core/src/main/java/io/kadai/common/internal/jobs/JobRunner.java index f023acbbc..8ff359fe4 100644 --- a/lib/kadai-core/src/main/java/io/kadai/common/internal/jobs/JobRunner.java +++ b/lib/kadai-core/src/main/java/io/kadai/common/internal/jobs/JobRunner.java @@ -80,9 +80,7 @@ private ScheduledJob lockJob(ScheduledJob job) { String owner = hostAddress + " - " + Thread.currentThread().getName(); job.setLockedBy(owner); ScheduledJob lockedJob = jobService.lockJob(job, owner); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Locked job: {}", lockedJob); - } + LOGGER.debug("Locked job: {}", lockedJob); return lockedJob; } diff --git a/lib/kadai-core/src/main/java/io/kadai/monitor/internal/preprocessor/WorkingDaysToDaysReportConverter.java b/lib/kadai-core/src/main/java/io/kadai/monitor/internal/preprocessor/WorkingDaysToDaysReportConverter.java index 96bbe8c6e..82822b636 100644 --- a/lib/kadai-core/src/main/java/io/kadai/monitor/internal/preprocessor/WorkingDaysToDaysReportConverter.java +++ b/lib/kadai-core/src/main/java/io/kadai/monitor/internal/preprocessor/WorkingDaysToDaysReportConverter.java @@ -81,9 +81,7 @@ public static WorkingDaysToDaysReportConverter initialize( WorkingTimeCalculator workingTimeCalculator, Instant referenceDate) throws InvalidArgumentException { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Initialize WorkingDaysToDaysConverter with columnHeaders: {}", columnHeaders); - } + LOGGER.debug("Initialize WorkingDaysToDaysConverter with columnHeaders: {}", columnHeaders); if (workingTimeCalculator == null) { throw new InvalidArgumentException("WorkingDaysToDaysConverter can't be null"); diff --git a/lib/kadai-core/src/main/java/io/kadai/spi/history/internal/HistoryEventManager.java b/lib/kadai-core/src/main/java/io/kadai/spi/history/internal/HistoryEventManager.java index 584f27b83..d9aed9f13 100644 --- a/lib/kadai-core/src/main/java/io/kadai/spi/history/internal/HistoryEventManager.java +++ b/lib/kadai-core/src/main/java/io/kadai/spi/history/internal/HistoryEventManager.java @@ -51,31 +51,23 @@ public boolean isEnabled() { } public void createEvent(TaskHistoryEvent event) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Sending event to history service providers: {}", event); - } + LOGGER.debug("Sending event to history service providers: {}", event); kadaiHistories.forEach(CheckedConsumer.wrap(historyProvider -> historyProvider.create(event))); } public void createEvent(WorkbasketHistoryEvent event) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Sending event to history service providers: {}", event); - } + LOGGER.debug("Sending event to history service providers: {}", event); kadaiHistories.forEach(CheckedConsumer.wrap(historyProvider -> historyProvider.create(event))); } public void createEvent(ClassificationHistoryEvent event) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Sending event to history service providers: {}", event); - } + LOGGER.debug("Sending event to history service providers: {}", event); kadaiHistories.forEach(CheckedConsumer.wrap(historyProvider -> historyProvider.create(event))); } public void deleteEvents(List taskIds) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Sending taskIds to history service providers: {}", taskIds); - } + LOGGER.debug("Sending taskIds to history service providers: {}", taskIds); kadaiHistories.forEach( CheckedConsumer.wrap( diff --git a/lib/kadai-core/src/main/java/io/kadai/spi/priority/internal/PriorityServiceManager.java b/lib/kadai-core/src/main/java/io/kadai/spi/priority/internal/PriorityServiceManager.java index 652cc175b..5242818b4 100644 --- a/lib/kadai-core/src/main/java/io/kadai/spi/priority/internal/PriorityServiceManager.java +++ b/lib/kadai-core/src/main/java/io/kadai/spi/priority/internal/PriorityServiceManager.java @@ -54,16 +54,11 @@ public boolean isEnabled() { public OptionalInt calculatePriorityOfTask(TaskSummary task) { if (task.isManualPriorityActive()) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "Skip using PriorityServiceProviders because the Task is prioritised manually: {}", - task); - } + LOGGER.debug( + "Skip using PriorityServiceProviders because the Task is prioritised manually: {}", task); return OptionalInt.empty(); } - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Sending Task to PriorityServiceProviders: {}", task); - } + LOGGER.debug("Sending Task to PriorityServiceProviders: {}", task); Set priorities = priorityServiceProviders.stream() @@ -73,10 +68,12 @@ public OptionalInt calculatePriorityOfTask(TaskSummary task) { if (priorities.size() == 1) { return priorities.iterator().next(); - } else if (!priorities.isEmpty() && LOGGER.isErrorEnabled()) { - LOGGER.error( - "The PriorityServiceProviders determined more than one priority for Task {}.", - LogSanitizer.stripLineBreakingChars(task)); + } else if (!priorities.isEmpty()) { + LOGGER + .atError() + .setMessage("The PriorityServiceProviders determined more than one priority for Task {}.") + .addArgument(() -> LogSanitizer.stripLineBreakingChars(task)) + .log(); } return OptionalInt.empty(); diff --git a/lib/kadai-core/src/main/java/io/kadai/spi/routing/internal/TaskRoutingManager.java b/lib/kadai-core/src/main/java/io/kadai/spi/routing/internal/TaskRoutingManager.java index 16eebc5d6..e8ebbce9c 100644 --- a/lib/kadai-core/src/main/java/io/kadai/spi/routing/internal/TaskRoutingManager.java +++ b/lib/kadai-core/src/main/java/io/kadai/spi/routing/internal/TaskRoutingManager.java @@ -72,17 +72,17 @@ public String determineWorkbasketId(Task task) { .filter(Objects::nonNull) .collect(Collectors.toSet()); if (workbasketIds.isEmpty()) { - if (LOGGER.isErrorEnabled()) { - LOGGER.error( - "No TaskRouter determined a workbasket for task {}.", - LogSanitizer.stripLineBreakingChars(task)); - } + LOGGER + .atError() + .setMessage("No TaskRouter determined a workbasket for task {}.") + .addArgument(() -> LogSanitizer.stripLineBreakingChars(task)) + .log(); } else if (workbasketIds.size() > 1) { - if (LOGGER.isErrorEnabled()) { - LOGGER.error( - "The TaskRouters determined more than one workbasket for task {}", - LogSanitizer.stripLineBreakingChars(task)); - } + LOGGER + .atError() + .setMessage("The TaskRouters determined more than one workbasket for task {}") + .addArgument(() -> LogSanitizer.stripLineBreakingChars(task)) + .log(); } else { workbasketId = workbasketIds.iterator().next(); } diff --git a/lib/kadai-core/src/main/java/io/kadai/spi/task/internal/AfterRequestChangesManager.java b/lib/kadai-core/src/main/java/io/kadai/spi/task/internal/AfterRequestChangesManager.java index 9bf471b55..290a086bc 100644 --- a/lib/kadai-core/src/main/java/io/kadai/spi/task/internal/AfterRequestChangesManager.java +++ b/lib/kadai-core/src/main/java/io/kadai/spi/task/internal/AfterRequestChangesManager.java @@ -43,15 +43,14 @@ public AfterRequestChangesManager(KadaiEngine kadaiEngine) { } if (afterRequestChangesProviders.isEmpty()) { LOGGER.info( - "No AfterRequestChangesProvider service provider found. " - + "Running without any AfterRequestChangesProvider implementation."); + """ + No AfterRequestChangesProvider service provider found. \ + Running without any AfterRequestChangesProvider implementation."""); } } public Task afterRequestChanges(Task task) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Sending Task to AfterRequestChangesProvider service providers: {}", task); - } + LOGGER.debug("Sending Task to AfterRequestChangesProvider service providers: {}", task); for (AfterRequestChangesProvider serviceProvider : afterRequestChangesProviders) { try { task = serviceProvider.afterRequestChanges(task); diff --git a/lib/kadai-core/src/main/java/io/kadai/spi/task/internal/AfterRequestReviewManager.java b/lib/kadai-core/src/main/java/io/kadai/spi/task/internal/AfterRequestReviewManager.java index 9aa9e86c3..8476fc44c 100644 --- a/lib/kadai-core/src/main/java/io/kadai/spi/task/internal/AfterRequestReviewManager.java +++ b/lib/kadai-core/src/main/java/io/kadai/spi/task/internal/AfterRequestReviewManager.java @@ -43,15 +43,14 @@ public AfterRequestReviewManager(KadaiEngine kadaiEngine) { } if (afterRequestReviewProviders.isEmpty()) { LOGGER.info( - "No AfterRequestReviewProvider service provider found. " - + "Running without any AfterRequestReviewProvider implementation."); + """ + No AfterRequestReviewProvider service provider found. \ + Running without any AfterRequestReviewProvider implementation."""); } } public Task afterRequestReview(Task task) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Sending Task to AfterRequestReviewProvider service providers: {}", task); - } + LOGGER.debug("Sending Task to AfterRequestReviewProvider service providers: {}", task); for (AfterRequestReviewProvider serviceProvider : afterRequestReviewProviders) { try { task = serviceProvider.afterRequestReview(task); diff --git a/lib/kadai-core/src/main/java/io/kadai/spi/task/internal/BeforeRequestChangesManager.java b/lib/kadai-core/src/main/java/io/kadai/spi/task/internal/BeforeRequestChangesManager.java index 9fbfab7e4..e96b0a499 100644 --- a/lib/kadai-core/src/main/java/io/kadai/spi/task/internal/BeforeRequestChangesManager.java +++ b/lib/kadai-core/src/main/java/io/kadai/spi/task/internal/BeforeRequestChangesManager.java @@ -43,15 +43,14 @@ public BeforeRequestChangesManager(KadaiEngine kadaiEngine) { } if (beforeRequestChangesProviders.isEmpty()) { LOGGER.info( - "No BeforeRequestChangesProvider service provider found. " - + "Running without any BeforeRequestChangesProvider implementation."); + """ + No BeforeRequestChangesProvider service provider found. \ + Running without any BeforeRequestChangesProvider implementation."""); } } public Task beforeRequestChanges(Task task) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Sending Task to BeforeRequestChangesProvider service providers: {}", task); - } + LOGGER.debug("Sending Task to BeforeRequestChangesProvider service providers: {}", task); for (BeforeRequestChangesProvider serviceProvider : beforeRequestChangesProviders) { try { task = serviceProvider.beforeRequestChanges(task); diff --git a/lib/kadai-core/src/main/java/io/kadai/spi/task/internal/BeforeRequestReviewManager.java b/lib/kadai-core/src/main/java/io/kadai/spi/task/internal/BeforeRequestReviewManager.java index 88166c4da..77379559a 100644 --- a/lib/kadai-core/src/main/java/io/kadai/spi/task/internal/BeforeRequestReviewManager.java +++ b/lib/kadai-core/src/main/java/io/kadai/spi/task/internal/BeforeRequestReviewManager.java @@ -49,9 +49,7 @@ public BeforeRequestReviewManager(KadaiEngine kadaiEngine) { } public Task beforeRequestReview(Task task) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Sending Task to BeforeRequestReviewProvider service providers: {}", task); - } + LOGGER.debug("Sending Task to BeforeRequestReviewProvider service providers: {}", task); for (BeforeRequestReviewProvider serviceProvider : beforeRequestReviewProviders) { try { task = serviceProvider.beforeRequestReview(task); diff --git a/lib/kadai-core/src/main/java/io/kadai/spi/task/internal/CreateTaskPreprocessorManager.java b/lib/kadai-core/src/main/java/io/kadai/spi/task/internal/CreateTaskPreprocessorManager.java index 4eaffe438..6e290dc9e 100644 --- a/lib/kadai-core/src/main/java/io/kadai/spi/task/internal/CreateTaskPreprocessorManager.java +++ b/lib/kadai-core/src/main/java/io/kadai/spi/task/internal/CreateTaskPreprocessorManager.java @@ -44,9 +44,7 @@ public CreateTaskPreprocessorManager() { } public Task processTaskBeforeCreation(Task taskToProcess) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Sending task to CreateTaskPreprocessor providers: {}", taskToProcess); - } + LOGGER.debug("Sending task to CreateTaskPreprocessor providers: {}", taskToProcess); createTaskPreprocessors.forEach( wrap( createTaskPreprocessor -> diff --git a/lib/kadai-core/src/main/java/io/kadai/spi/task/internal/ReviewRequiredManager.java b/lib/kadai-core/src/main/java/io/kadai/spi/task/internal/ReviewRequiredManager.java index 3dd9b7ad7..ec1922d4d 100644 --- a/lib/kadai-core/src/main/java/io/kadai/spi/task/internal/ReviewRequiredManager.java +++ b/lib/kadai-core/src/main/java/io/kadai/spi/task/internal/ReviewRequiredManager.java @@ -42,15 +42,14 @@ public ReviewRequiredManager(KadaiEngine kadaiEngine) { } if (reviewRequiredProviders.isEmpty()) { LOGGER.info( - "No ReviewRequiredProvider service provider found. " - + "Running without any ReviewRequiredProvider implementation."); + """ + No ReviewRequiredProvider service provider found. \ + Running without any ReviewRequiredProvider implementation."""); } } public boolean reviewRequired(Task task) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Sending Task to ReviewRequiredProvider service providers: {}", task); - } + LOGGER.debug("Sending Task to ReviewRequiredProvider service providers: {}", task); return reviewRequiredProviders.stream() .anyMatch(serviceProvider -> serviceProvider.reviewRequired(task)); diff --git a/lib/kadai-core/src/main/java/io/kadai/spi/task/internal/TaskEndstatePreprocessorManager.java b/lib/kadai-core/src/main/java/io/kadai/spi/task/internal/TaskEndstatePreprocessorManager.java index 17e130def..b78e73df9 100644 --- a/lib/kadai-core/src/main/java/io/kadai/spi/task/internal/TaskEndstatePreprocessorManager.java +++ b/lib/kadai-core/src/main/java/io/kadai/spi/task/internal/TaskEndstatePreprocessorManager.java @@ -45,9 +45,7 @@ public TaskEndstatePreprocessorManager() { } public Task processTaskBeforeEndstate(Task taskToProcess) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Sending task to TaskEndstatePreprocessor providers: {}", taskToProcess); - } + LOGGER.debug("Sending task to TaskEndstatePreprocessor providers: {}", taskToProcess); taskEndstatePreprocessors.forEach( wrap( taskEndstatePreprocessor -> diff --git a/lib/kadai-core/src/main/java/io/kadai/task/internal/AttachmentHandler.java b/lib/kadai-core/src/main/java/io/kadai/task/internal/AttachmentHandler.java index 7ab6a57aa..6855fe8e2 100644 --- a/lib/kadai-core/src/main/java/io/kadai/task/internal/AttachmentHandler.java +++ b/lib/kadai-core/src/main/java/io/kadai/task/internal/AttachmentHandler.java @@ -86,12 +86,12 @@ void insertNewAttachmentsOnTaskCreation(TaskImpl task) try { attachmentMapper.insert(attachmentImpl); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "TaskService.createTask() for TaskId={} INSERTED an Attachment={}.", - task.getId(), - attachmentImpl); - } + LOGGER + .atDebug() + .setMessage("TaskService.createTask() for TaskId={} INSERTED an Attachment={}.") + .addArgument(task::getId) + .addArgument(attachmentImpl) + .log(); } catch (PersistenceException e) { throw new AttachmentPersistenceException(attachmentImpl.getId(), task.getId(), e); } @@ -151,12 +151,12 @@ private void deleteRemovedAttachmentsOnTaskUpdate(TaskImpl newTaskImpl, TaskImpl a -> { if (!newAttIds.contains(a.getId())) { attachmentMapper.delete(a.getId()); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "TaskService.updateTask() for TaskId={} DELETED an Attachment={}.", - newTaskImpl.getId(), - a); - } + LOGGER + .atDebug() + .setMessage("TaskService.updateTask() for TaskId={} DELETED an Attachment={}.") + .addArgument(newTaskImpl::getId) + .addArgument(a) + .log(); } }); } @@ -168,12 +168,12 @@ private void insertNewAttachmentOnTaskUpdate(TaskImpl newTaskImpl, Attachment at try { attachmentMapper.insert(attachmentImpl); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "TaskService.updateTask() for TaskId={} INSERTED an Attachment={}.", - newTaskImpl.getId(), - attachmentImpl); - } + LOGGER + .atDebug() + .setMessage("TaskService.updateTask() for TaskId={} INSERTED an Attachment={}.") + .addArgument(newTaskImpl::getId) + .addArgument(attachmentImpl) + .log(); } catch (PersistenceException e) { throw new AttachmentPersistenceException(attachmentImpl.getId(), newTaskImpl.getId(), e); } diff --git a/lib/kadai-core/src/main/java/io/kadai/task/internal/ObjectReferenceHandler.java b/lib/kadai-core/src/main/java/io/kadai/task/internal/ObjectReferenceHandler.java index e558a61a9..d7ae9431b 100644 --- a/lib/kadai-core/src/main/java/io/kadai/task/internal/ObjectReferenceHandler.java +++ b/lib/kadai-core/src/main/java/io/kadai/task/internal/ObjectReferenceHandler.java @@ -58,12 +58,12 @@ void insertNewSecondaryObjectReferencesOnTaskCreation(TaskImpl task) ObjectReferenceImpl.validate(objectReferenceImpl, "ObjectReference", "Task"); try { objectReferenceMapper.insert(objectReferenceImpl); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "TaskService.createTask() for TaskId={} INSERTED an object reference={}.", - task.getId(), - objectReference); - } + LOGGER + .atDebug() + .setMessage("TaskService.createTask() for TaskId={} INSERTED an object reference={}.") + .addArgument(task::getId) + .addArgument(objectReference) + .log(); } catch (PersistenceException e) { throw new ObjectReferencePersistenceException(objectReference.getId(), task.getId(), e); } @@ -140,12 +140,13 @@ private void deleteRemovedObjectReferencesOnTaskUpdate( o -> { if (!newObjRefIds.contains(o.getId())) { objectReferenceMapper.delete(o.getId()); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "TaskService.updateTask() for TaskId={} DELETED an ObjectReference={}.", - newTaskImpl.getId(), - o); - } + LOGGER + .atDebug() + .setMessage( + "TaskService.updateTask() for TaskId={} DELETED an ObjectReference={}.") + .addArgument(newTaskImpl::getId) + .addArgument(o) + .log(); } }); } @@ -157,12 +158,12 @@ private void insertNewObjectReferenceOnTaskUpdate( ObjectReferenceImpl objectReferenceImpl = (ObjectReferenceImpl) objectReference; try { objectReferenceMapper.insert(objectReferenceImpl); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "TaskService.updateTask() for TaskId={} INSERTED an ObjectReference={}.", - newTaskImpl.getId(), - objectReferenceImpl); - } + LOGGER + .atDebug() + .setMessage("TaskService.updateTask() for TaskId={} INSERTED an ObjectReference={}.") + .addArgument(newTaskImpl::getId) + .addArgument(objectReferenceImpl) + .log(); } catch (PersistenceException e) { throw new ObjectReferencePersistenceException( objectReferenceImpl.getId(), newTaskImpl.getId(), e); diff --git a/lib/kadai-core/src/main/java/io/kadai/task/internal/ServiceLevelHandler.java b/lib/kadai-core/src/main/java/io/kadai/task/internal/ServiceLevelHandler.java index 01f1fc48c..ae6cffbf9 100644 --- a/lib/kadai-core/src/main/java/io/kadai/task/internal/ServiceLevelHandler.java +++ b/lib/kadai-core/src/main/java/io/kadai/task/internal/ServiceLevelHandler.java @@ -105,14 +105,10 @@ public void refreshPriorityAndDueDatesOfTasks( BulkLog setPlannedPropertyOfTasksImpl(Instant planned, List tasks) { BulkLog bulkLog = new BulkLog(); List attachments = getAttachmentSummaries(tasks); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("found attachments {}.", attachments); - } + LOGGER.debug("found attachments {}.", attachments); List allInvolvedClassifications = findAllClassificationsReferencedByTasksAndAttachments(tasks, attachments); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("found involved classifications {}.", allInvolvedClassifications); - } + LOGGER.debug("found involved classifications {}.", allInvolvedClassifications); List allInvolvedClassificationsWithDuration = resolveDurationsInClassifications(allInvolvedClassifications); Map> durationToTaskIdsMap = diff --git a/lib/kadai-core/src/main/java/io/kadai/task/internal/TaskCommentQueryImpl.java b/lib/kadai-core/src/main/java/io/kadai/task/internal/TaskCommentQueryImpl.java index db68fa1cf..435da2d25 100644 --- a/lib/kadai-core/src/main/java/io/kadai/task/internal/TaskCommentQueryImpl.java +++ b/lib/kadai-core/src/main/java/io/kadai/task/internal/TaskCommentQueryImpl.java @@ -315,9 +315,7 @@ private void checkTaskPermission() { if (taskIdIn != null) { if (kadaiEngine.getEngine().isUserInRole(KadaiRole.ADMIN, KadaiRole.TASK_ADMIN)) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Skipping permissions check since user is in role ADMIN or TASK_ADMIN."); - } + LOGGER.debug("Skipping permissions check since user is in role ADMIN or TASK_ADMIN."); return; } @@ -330,8 +328,7 @@ private void checkTaskPermission() { throw new NotAuthorizedToQueryWorkbasketException( e.getMessage(), e.getErrorCode(), e); } catch (TaskNotFoundException e) { - LOGGER.warn( - String.format("The Task with the ID ' %s ' does not exist.", taskId), e); + LOGGER.warn("The Task with the ID ' {} ' does not exist.", taskId, e); } }); } diff --git a/lib/kadai-core/src/main/java/io/kadai/task/internal/TaskCommentServiceImpl.java b/lib/kadai-core/src/main/java/io/kadai/task/internal/TaskCommentServiceImpl.java index a8b159ce3..0d9ca4663 100644 --- a/lib/kadai-core/src/main/java/io/kadai/task/internal/TaskCommentServiceImpl.java +++ b/lib/kadai-core/src/main/java/io/kadai/task/internal/TaskCommentServiceImpl.java @@ -97,12 +97,12 @@ TaskComment updateTaskComment(TaskComment taskCommentToUpdate) taskCommentMapper.update(taskCommentImplToUpdate); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "Method updateTaskComment() updated taskComment '{}' for user '{}'.", - taskCommentImplToUpdate.getId(), - userId); - } + LOGGER + .atDebug() + .setMessage("Method updateTaskComment() updated taskComment '{}' for user '{}'.") + .addArgument(taskCommentImplToUpdate::getId) + .addArgument(userId) + .log(); } else { throw new NotAuthorizedOnTaskCommentException(userId, taskCommentImplToUpdate.getId()); @@ -162,9 +162,11 @@ void deleteTaskComment(String taskCommentId) taskCommentMapper.delete(taskCommentId); taskMapper.decrementNumberOfComments(taskCommentToDelete.getTaskId(), Instant.now()); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("taskComment {} deleted", taskCommentToDelete.getId()); - } + LOGGER + .atDebug() + .setMessage("taskComment {} deleted") + .addArgument(taskCommentToDelete::getId) + .log(); } else { throw new NotAuthorizedOnTaskCommentException(userId, taskCommentToDelete.getId()); @@ -186,7 +188,7 @@ List getTaskComments(String taskId) List taskComments = taskService.createTaskCommentQuery().taskIdIn(taskId).list(); - if (taskComments.isEmpty() && LOGGER.isDebugEnabled()) { + if (taskComments.isEmpty()) { LOGGER.debug("getTaskComments() found no comments for the provided taskId"); } diff --git a/lib/kadai-core/src/main/java/io/kadai/task/internal/TaskQueryImpl.java b/lib/kadai-core/src/main/java/io/kadai/task/internal/TaskQueryImpl.java index c03e35df5..48724bdcd 100644 --- a/lib/kadai-core/src/main/java/io/kadai/task/internal/TaskQueryImpl.java +++ b/lib/kadai-core/src/main/java/io/kadai/task/internal/TaskQueryImpl.java @@ -2268,9 +2268,7 @@ private void setupAccessIds() { private void checkOpenReadAndReadTasksPermissionForSpecifiedWorkbaskets() { if (kadaiEngine.getEngine().isUserInRole(KadaiRole.ADMIN, KadaiRole.TASK_ADMIN)) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Skipping permissions check since user is in role ADMIN or TASK_ADMIN."); - } + LOGGER.debug("Skipping permissions check since user is in role ADMIN or TASK_ADMIN."); return; } try { @@ -2303,8 +2301,7 @@ private void checkOpenReadAndReadTasksPermissionById(String workbasketId) WorkbasketPermission.READ, WorkbasketPermission.READTASKS); } catch (WorkbasketNotFoundException e) { - LOGGER.warn( - String.format("The workbasket with the ID ' %s ' does not exist.", workbasketId), e); + LOGGER.warn("The workbasket with the ID ' {} ' does not exist.", workbasketId, e); } } @@ -2322,9 +2319,9 @@ private void checkOpenReadAndReadTasksPermissionByKeyDomain(KeyDomain keyDomain) WorkbasketPermission.READTASKS); } catch (WorkbasketNotFoundException e) { LOGGER.warn( - String.format( - "The workbasket with the KEY ' %s ' and DOMAIN ' %s ' does not exist.", - keyDomain.getKey(), keyDomain.getDomain()), + "The workbasket with the KEY ' {} ' and DOMAIN ' {} ' does not exist.", + keyDomain.getKey(), + keyDomain.getDomain(), e); } } diff --git a/lib/kadai-core/src/main/java/io/kadai/task/internal/TaskServiceImpl.java b/lib/kadai-core/src/main/java/io/kadai/task/internal/TaskServiceImpl.java index b1846b822..e4e36748e 100644 --- a/lib/kadai-core/src/main/java/io/kadai/task/internal/TaskServiceImpl.java +++ b/lib/kadai-core/src/main/java/io/kadai/task/internal/TaskServiceImpl.java @@ -177,79 +177,6 @@ public TaskServiceImpl( this.objectReferenceHandler = new ObjectReferenceHandler(objectReferenceMapper); } - private static Predicate addErrorToBulkLog( - CheckedConsumer checkedConsumer, - BulkOperationResults bulkLog) { - return summary -> { - try { - checkedConsumer.accept(summary); - return true; - } catch (KadaiException e) { - bulkLog.addError(summary.getId(), e); - return false; - } - }; - } - - private static void terminateCancelCommonActions(TaskImpl task, TaskState targetState) { - Instant now = Instant.now(); - task.setModified(now); - task.setCompleted(now); - task.setState(targetState); - } - - private static void claimActionsOnTask( - TaskSummaryImpl task, String userId, String userLongName, Instant now) { - task.setOwner(userId); - task.setOwnerLongName(userLongName); - task.setModified(now); - task.setClaimed(now); - task.setRead(true); - if (Set.of(TaskState.READY_FOR_REVIEW, TaskState.IN_REVIEW).contains(task.getState())) { - task.setState(TaskState.IN_REVIEW); - } else { - task.setState(TaskState.CLAIMED); - } - } - - private static void cancelClaimActionsOnTask( - TaskSummaryImpl task, Instant now, boolean keepOwner) { - if (!keepOwner) { - task.setOwner(null); - task.setOwnerLongName(null); - } - task.setModified(now); - task.setClaimed(null); - task.setRead(true); - if (task.getState() == TaskState.IN_REVIEW) { - task.setState(TaskState.READY_FOR_REVIEW); - } else { - task.setState(TaskState.READY); - } - } - - private static void completeActionsOnTask(TaskSummaryImpl task, String userId, Instant now) { - task.setCompleted(now); - task.setModified(now); - task.setState(TaskState.COMPLETED); - task.setOwner(userId); - } - - private static boolean taskIsNotClaimed(TaskSummary task) { - return task.getClaimed() == null - || (task.getState() != TaskState.CLAIMED && task.getState() != TaskState.IN_REVIEW); - } - - private static void checkIfTaskIsTerminatedOrCancelled(TaskSummary task) - throws InvalidTaskStateException { - if (task.getState().in(TaskState.CANCELLED, TaskState.TERMINATED)) { - throw new InvalidTaskStateException( - task.getId(), - task.getState(), - EnumUtil.allValuesExceptFor(TaskState.CANCELLED, TaskState.TERMINATED)); - } - } - @Override public Task claim(String taskId) throws TaskNotFoundException, @@ -383,9 +310,12 @@ public Task createTask(Task taskToCreate) throw new InvalidArgumentException("taskId must be empty when creating a task"); } - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Task {} cannot be found, so it can be created.", task.getId()); - } + LOGGER + .atDebug() + .setMessage("Task {} cannot be found, so it can be created.") + .addArgument(task::getId) + .log(); + Workbasket workbasket; if (task.getWorkbasketSummary() != null && task.getWorkbasketSummary().getId() != null) { @@ -431,9 +361,7 @@ public Task createTask(Task taskToCreate) try { this.taskMapper.insert(task); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Method createTask() created Task '{}'.", task.getId()); - } + LOGGER.debug("Method createTask() created Task '{}'.", task.getId()); if (historyEventManager.isEnabled()) { String details = @@ -597,9 +525,7 @@ public Task setTaskRead(String taskId, boolean isRead) task.setRead(isRead); task.setModified(Instant.now()); taskMapper.update(task); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Method setTaskRead() set read property of Task '{}' to {} ", task, isRead); - } + LOGGER.debug("Method setTaskRead() set read property of Task '{}' to {} ", task, isRead); return task; } finally { kadaiEngine.returnConnection(); @@ -699,9 +625,12 @@ public Task updateTask(Task task) taskMapper.update(newTaskImpl); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Method updateTask() updated task '{}' for user '{}'.", task.getId(), userId); - } + LOGGER + .atDebug() + .setMessage("Method updateTask() updated task '{}' for user '{}'.") + .addArgument(task::getId) + .addArgument(userId) + .log(); if (historyEventManager.isEnabled()) { @@ -893,14 +822,10 @@ public List updateTasks( changedTasks = tasksWithPermissions.stream().map(TaskSummary::getId).collect(Collectors.toList()); taskMapper.updateTasks(changedTasks, updated, fieldSelector); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("updateTasks() updated the following tasks: {} ", changedTasks); - } + LOGGER.debug("updateTasks() updated the following tasks: {} ", changedTasks); } else { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("updateTasks() found no tasks for update "); - } + LOGGER.debug("updateTasks() found no tasks for update "); } return changedTasks; } finally { @@ -935,14 +860,10 @@ public List updateTasks( changedTasks = tasksWithPermissions.stream().map(TaskSummary::getId).collect(Collectors.toList()); taskMapper.updateTasks(changedTasks, updatedTask, fieldSelector); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("updateTasks() updated the following tasks: {} ", changedTasks); - } + LOGGER.debug("updateTasks() updated the following tasks: {} ", changedTasks); } else { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("updateTasks() found no tasks for update "); - } + LOGGER.debug("updateTasks() found no tasks for update "); } return changedTasks; } finally { @@ -1043,14 +964,16 @@ public BulkOperationResults setOwnerOfTasks( taskMapper.setOwnerOfTasks(owner, taskIdsToUpdate.getLeft(), Instant.now()); } - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "Received the Request to set owner on {} tasks, actually modified tasks = {}" - + ", could not set owner on {} tasks.", - taskIds.size(), - taskIdsToUpdate.getLeft().size(), - bulkLog.getFailedIds().size()); - } + LOGGER + .atDebug() + .setMessage( + """ + Received the Request to set owner on {} tasks, actually modified tasks = {}\ + , could not set owner on {} tasks.""") + .addArgument(taskIds::size) + .addArgument(() -> taskIdsToUpdate.getLeft().size()) + .addArgument(() -> bulkLog.getFailedIds().size()) + .log(); return bulkLog; } finally { @@ -1107,12 +1030,12 @@ public Task cancelTask(String taskId) cancelledTask = (TaskImpl) taskEndstatePreprocessorManager.processTaskBeforeEndstate(cancelledTask); taskMapper.update(cancelledTask); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "Task '{}' cancelled by user '{}'.", - taskId, - kadaiEngine.getEngine().getCurrentUserContext().getUserid()); - } + LOGGER + .atDebug() + .setMessage("Task '{}' cancelled by user '{}'.") + .addArgument(taskId) + .addArgument(() -> kadaiEngine.getEngine().getCurrentUserContext().getUserid()) + .log(); if (historyEventManager.isEnabled()) { historyEventManager.createEvent( new TaskCancelledEvent( @@ -1159,12 +1082,12 @@ public Task terminateTask(String taskId) terminatedTask = (TaskImpl) taskEndstatePreprocessorManager.processTaskBeforeEndstate(terminatedTask); taskMapper.update(terminatedTask); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "Task '{}' cancelled by user '{}'.", - taskId, - kadaiEngine.getEngine().getCurrentUserContext().getUserid()); - } + LOGGER + .atDebug() + .setMessage("Task '{}' cancelled by user '{}'.") + .addArgument(taskId) + .addArgument(() -> kadaiEngine.getEngine().getCurrentUserContext().getUserid()) + .log(); if (historyEventManager.isEnabled()) { historyEventManager.createEvent( new TaskTerminatedEvent( @@ -1211,12 +1134,10 @@ public List findTasksIdsAffectedByClassificationChange(String classifica .map(Pair::getLeft) .collect(Collectors.toList()); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "the following tasks are affected by the update of classification {} : {}", - classificationId, - affectedTaskIds); - } + LOGGER.debug( + "the following tasks are affected by the update of classification {} : {}", + classificationId, + affectedTaskIds); return affectedTaskIds; } @@ -1311,6 +1232,79 @@ List augmentTaskSummariesByContainedSummariesWithPartitioning( .collect(Collectors.toList()); } + private static Predicate addErrorToBulkLog( + CheckedConsumer checkedConsumer, + BulkOperationResults bulkLog) { + return summary -> { + try { + checkedConsumer.accept(summary); + return true; + } catch (KadaiException e) { + bulkLog.addError(summary.getId(), e); + return false; + } + }; + } + + private static void terminateCancelCommonActions(TaskImpl task, TaskState targetState) { + Instant now = Instant.now(); + task.setModified(now); + task.setCompleted(now); + task.setState(targetState); + } + + private static void claimActionsOnTask( + TaskSummaryImpl task, String userId, String userLongName, Instant now) { + task.setOwner(userId); + task.setOwnerLongName(userLongName); + task.setModified(now); + task.setClaimed(now); + task.setRead(true); + if (Set.of(TaskState.READY_FOR_REVIEW, TaskState.IN_REVIEW).contains(task.getState())) { + task.setState(TaskState.IN_REVIEW); + } else { + task.setState(TaskState.CLAIMED); + } + } + + private static void cancelClaimActionsOnTask( + TaskSummaryImpl task, Instant now, boolean keepOwner) { + if (!keepOwner) { + task.setOwner(null); + task.setOwnerLongName(null); + } + task.setModified(now); + task.setClaimed(null); + task.setRead(true); + if (task.getState() == TaskState.IN_REVIEW) { + task.setState(TaskState.READY_FOR_REVIEW); + } else { + task.setState(TaskState.READY); + } + } + + private static void completeActionsOnTask(TaskSummaryImpl task, String userId, Instant now) { + task.setCompleted(now); + task.setModified(now); + task.setState(TaskState.COMPLETED); + task.setOwner(userId); + } + + private static boolean taskIsNotClaimed(TaskSummary task) { + return task.getClaimed() == null + || (task.getState() != TaskState.CLAIMED && task.getState() != TaskState.IN_REVIEW); + } + + private static void checkIfTaskIsTerminatedOrCancelled(TaskSummary task) + throws InvalidTaskStateException { + if (task.getState().in(TaskState.CANCELLED, TaskState.TERMINATED)) { + throw new InvalidTaskStateException( + task.getId(), + task.getState(), + EnumUtil.allValuesExceptFor(TaskState.CANCELLED, TaskState.TERMINATED)); + } + } + private Pair, BulkLog> filterOutTasksWhichAreInInvalidState( Collection minimalTaskSummaries) { List filteredTasks = new ArrayList<>(minimalTaskSummaries.size()); @@ -1341,12 +1335,11 @@ private List appendComplexAttributesToTaskSummariesWithoutParti taskIds = null; } - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "augmentTaskSummariesByContainedSummariesWithoutPartitioning() with sublist {} " - + "about to query for attachmentSummaries ", - taskSummaries); - } + LOGGER.debug( + """ + augmentTaskSummariesByContainedSummariesWithoutPartitioning() with sublist {} \ + about to query for attachmentSummaries\s""", + taskSummaries); List attachmentSummaries = attachmentMapper.findAttachmentSummariesByTaskIds(taskIds); @@ -1478,9 +1471,7 @@ private Task claim(String taskId, boolean forceClaim) claimActionsOnTask(task, userId, userLongName, now); taskMapper.update(task); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Task '{}' claimed by user '{}'.", taskId, userId); - } + LOGGER.debug("Task '{}' claimed by user '{}'.", taskId, userId); if (historyEventManager.isEnabled()) { String changeDetails = ObjectAttributeChangeDetector.determineChangesInAttributes(oldTask, task); @@ -1529,9 +1520,7 @@ private Task requestReview(String taskId, boolean force) task.setModified(Instant.now()); taskMapper.requestReview(task); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Requested review for Task '{}' by user '{}'.", taskId, userId); - } + LOGGER.debug("Requested review for Task '{}' by user '{}'.", taskId, userId); if (historyEventManager.isEnabled()) { String changeDetails = ObjectAttributeChangeDetector.determineChangesInAttributes(oldTask, task); @@ -1581,9 +1570,7 @@ private Task requestChanges(String taskId, boolean force) task.setModified(Instant.now()); taskMapper.requestChanges(task); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Requested changes for Task '{}' by user '{}'.", taskId, userId); - } + LOGGER.debug("Requested changes for Task '{}' by user '{}'.", taskId, userId); if (historyEventManager.isEnabled()) { String changeDetails = ObjectAttributeChangeDetector.determineChangesInAttributes(oldTask, task); @@ -1677,9 +1664,7 @@ private Task cancelClaim(String taskId, boolean forceUnclaim, boolean keepOwner) Instant now = Instant.now(); cancelClaimActionsOnTask(task, now, keepOwner); taskMapper.update(task); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Task '{}' unclaimed by user '{}'.", taskId, userId); - } + LOGGER.debug("Task '{}' unclaimed by user '{}'.", taskId, userId); if (historyEventManager.isEnabled()) { String changeDetails = ObjectAttributeChangeDetector.determineChangesInAttributes(oldTask, task); @@ -1727,9 +1712,7 @@ private Task completeTask(String taskId, boolean isForced) completeActionsOnTask(task, userId, now); task = (TaskImpl) taskEndstatePreprocessorManager.processTaskBeforeEndstate(task); taskMapper.update(task); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Task '{}' completed by user '{}'.", taskId, userId); - } + LOGGER.debug("Task '{}' completed by user '{}'.", taskId, userId); if (historyEventManager.isEnabled()) { historyEventManager.createEvent( new TaskCompletedEvent( @@ -1782,9 +1765,7 @@ private void deleteTask(String taskId, boolean forceDelete) createTaskDeletedEvent(taskId); } - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Task {} deleted.", taskId); - } + LOGGER.debug("Task {} deleted.", taskId); } finally { kadaiEngine.returnConnection(); } @@ -2066,10 +2047,8 @@ private Map findClassificationForTaskImplAndAttac private List queryClassificationsForTasksAndAttachments( Set classificationIds) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "queryClassificationsForTasksAndAttachments() about to query classifications and exit"); - } + LOGGER.debug( + "queryClassificationsForTasksAndAttachments() about to query classifications and exit"); return this.classificationService .createClassificationQuery() .idIn(classificationIds.toArray(new String[0])) @@ -2078,9 +2057,7 @@ private List queryClassificationsForTasksAndAttachments( private List queryWorkbasketsForTasks(Set workbasketIds) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("queryWorkbasketsForTasks() about to query workbaskets and exit"); - } + LOGGER.debug("queryWorkbasketsForTasks() about to query workbaskets and exit"); // perform classification query return this.workbasketService .createWorkbasketQuery() diff --git a/lib/kadai-core/src/main/java/io/kadai/task/internal/jobs/TaskCleanupJob.java b/lib/kadai-core/src/main/java/io/kadai/task/internal/jobs/TaskCleanupJob.java index 4c4ff1786..c0b3b100d 100644 --- a/lib/kadai-core/src/main/java/io/kadai/task/internal/jobs/TaskCleanupJob.java +++ b/lib/kadai-core/src/main/java/io/kadai/task/internal/jobs/TaskCleanupJob.java @@ -156,16 +156,18 @@ private int deleteTasks(List tasksToBeDeleted) List tasksIdsToBeDeleted = tasksToBeDeleted.stream().map(TaskSummary::getId).toList(); BulkOperationResults results = kadaiEngineImpl.getTaskService().deleteTasks(tasksIdsToBeDeleted); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("{} tasks deleted.", tasksIdsToBeDeleted.size() - results.getFailedIds().size()); - } + LOGGER + .atDebug() + .setMessage("{} tasks deleted.") + .addArgument(() -> tasksIdsToBeDeleted.size() - results.getFailedIds().size()) + .log(); for (String failedId : results.getFailedIds()) { - if (LOGGER.isWarnEnabled()) { - LOGGER.warn( - "Task with id {} could not be deleted. Reason: {}", - LogSanitizer.stripLineBreakingChars(failedId), - LogSanitizer.stripLineBreakingChars(results.getErrorForId(failedId))); - } + LOGGER + .atWarn() + .setMessage("Task with id {} could not be deleted. Reason: {}") + .addArgument(() -> LogSanitizer.stripLineBreakingChars(failedId)) + .addArgument(() -> LogSanitizer.stripLineBreakingChars(results.getErrorForId(failedId))) + .log(); } return tasksIdsToBeDeleted.size() - results.getFailedIds().size(); } diff --git a/lib/kadai-core/src/main/java/io/kadai/user/internal/UserServiceImpl.java b/lib/kadai-core/src/main/java/io/kadai/user/internal/UserServiceImpl.java index 105975522..4def72be8 100644 --- a/lib/kadai-core/src/main/java/io/kadai/user/internal/UserServiceImpl.java +++ b/lib/kadai-core/src/main/java/io/kadai/user/internal/UserServiceImpl.java @@ -119,11 +119,11 @@ public User createUser(User userToCreate) insertIntoDatabase(userToCreate); ((UserImpl) userToCreate).setDomains(determineDomains(userToCreate)); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "Method createUser() created User '{}'.", - LogSanitizer.stripLineBreakingChars(userToCreate)); - } + LOGGER + .atDebug() + .setMessage("Method createUser() created User '{}'.") + .addArgument(() -> LogSanitizer.stripLineBreakingChars(userToCreate)) + .log(); return userToCreate; } @@ -149,11 +149,11 @@ public User updateUser(User userToUpdate) } ((UserImpl) userToUpdate).setDomains(determineDomains(userToUpdate)); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "Method updateUser() updated User '{}'.", - LogSanitizer.stripLineBreakingChars(userToUpdate)); - } + LOGGER + .atDebug() + .setMessage("Method updateUser() updated User '{}'.") + .addArgument(() -> LogSanitizer.stripLineBreakingChars(userToUpdate)) + .log(); return userToUpdate; } @@ -170,9 +170,11 @@ public void deleteUser(String id) userMapper.deleteGroups(id); userMapper.deletePermissions(id); }); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Method deleteUser() deleted User with id '{}'.", id); - } + LOGGER + .atDebug() + .setMessage("Method deleteUser() deleted User with id '{}'.") + .addArgument(() -> LogSanitizer.stripLineBreakingChars(id)) + .log(); } private Set determineDomains(User user) { diff --git a/lib/kadai-core/src/main/java/io/kadai/workbasket/internal/WorkbasketServiceImpl.java b/lib/kadai-core/src/main/java/io/kadai/workbasket/internal/WorkbasketServiceImpl.java index 91c8cf995..15f38d1d4 100644 --- a/lib/kadai-core/src/main/java/io/kadai/workbasket/internal/WorkbasketServiceImpl.java +++ b/lib/kadai-core/src/main/java/io/kadai/workbasket/internal/WorkbasketServiceImpl.java @@ -188,9 +188,7 @@ public Workbasket createWorkbasket(Workbasket newWorkbasket) kadaiEngine.getEngine().getCurrentUserContext().getUserid(), details)); } - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Method createWorkbasket() created Workbasket '{}'", workbasket); - } + LOGGER.debug("Method createWorkbasket() created Workbasket '{}'", workbasket); return workbasket; } finally { kadaiEngine.returnConnection(); @@ -249,10 +247,11 @@ public Workbasket updateWorkbasket(Workbasket workbasketToUpdate) details)); } - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "Method updateWorkbasket() updated workbasket '{}'", workbasketImplToUpdate.getId()); - } + LOGGER + .atDebug() + .setMessage("Method updateWorkbasket() updated workbasket '{}'") + .addArgument(() -> workbasketImplToUpdate.getId()) + .log(); return workbasketImplToUpdate; } finally { @@ -315,15 +314,11 @@ public WorkbasketAccessItem createWorkbasketAccessItem(WorkbasketAccessItem work kadaiEngine.getEngine().getCurrentUserContext().getUserid(), details)); } - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "Method createWorkbasketAccessItem() created workbaskteAccessItem {}", accessItem); - } + LOGGER.debug( + "Method createWorkbasketAccessItem() created workbaskteAccessItem {}", accessItem); } catch (PersistenceException e) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "when trying to insert WorkbasketAccessItem {} caught exception", accessItem, e); - } + LOGGER.debug( + "when trying to insert WorkbasketAccessItem {} caught exception", accessItem, e); Stream accessItemExistsIdentifier = Stream.of( "SQLCODE=-803", // DB2 @@ -378,10 +373,8 @@ public WorkbasketAccessItem updateWorkbasketAccessItem(WorkbasketAccessItem work details)); } - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "Method updateWorkbasketAccessItem() updated workbasketAccessItem {}", accessItem); - } + LOGGER.debug( + "Method updateWorkbasketAccessItem() updated workbasketAccessItem {}", accessItem); return accessItem; } finally { kadaiEngine.returnConnection(); @@ -416,11 +409,9 @@ public void deleteWorkbasketAccessItem(String accessItemId) throws NotAuthorized details)); } - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "Method deleteWorkbasketAccessItem() deleted workbasketAccessItem wit Id {}", - accessItemId); - } + LOGGER.debug( + "Method deleteWorkbasketAccessItem() deleted workbasketAccessItem wit Id {}", + accessItemId); } finally { kadaiEngine.returnConnection(); } @@ -658,13 +649,15 @@ public void setDistributionTargets(String sourceWorkbasketId, List targe // check for existence of target workbasket getWorkbasket(targetId); distributionTargetMapper.insert(sourceWorkbasketId, targetId); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "Method setDistributionTargets() created distribution target " - + "for source '{}' and target {}", - LogSanitizer.stripLineBreakingChars(sourceWorkbasketId), - LogSanitizer.stripLineBreakingChars(targetId)); - } + LOGGER + .atDebug() + .setMessage( + """ + Method setDistributionTargets() created distribution target \ + for source '{}' and target {}""") + .addArgument(() -> LogSanitizer.stripLineBreakingChars(sourceWorkbasketId)) + .addArgument(() -> LogSanitizer.stripLineBreakingChars(targetId)) + .log(); } if (historyEventManager.isEnabled() && !targetWorkbasketIds.isEmpty()) { @@ -684,12 +677,12 @@ public void setDistributionTargets(String sourceWorkbasketId, List targe } finally { kadaiEngine.returnConnection(); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "setDistributionTargets set {} distribution targets to source workbasket {} ", - targetWorkbasketIds == null ? 0 : targetWorkbasketIds.size(), - sourceWorkbasketId); - } + LOGGER + .atDebug() + .setMessage("setDistributionTargets set {} distribution targets to source workbasket {} ") + .addArgument(() -> targetWorkbasketIds == null ? 0 : targetWorkbasketIds.size()) + .addArgument(() -> LogSanitizer.stripLineBreakingChars(sourceWorkbasketId)) + .log(); } } @@ -711,11 +704,11 @@ public void addDistributionTarget(String sourceWorkbasketId, String targetWorkba distributionTargetMapper.getNumberOfDistributionTargets( sourceWorkbasketId, targetWorkbasketId); if (numOfDistTargets > 0) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "addDistributionTarget detected that the specified " - + "distribution target exists already. Doing nothing."); - } + LOGGER.debug( + """ + addDistributionTarget detected that the specified distribution\s + target exists already. \ + Doing nothing."""); } else { distributionTargetMapper.insert(sourceWorkbasketId, targetWorkbasketId); @@ -731,12 +724,10 @@ public void addDistributionTarget(String sourceWorkbasketId, String targetWorkba kadaiEngine.getEngine().getCurrentUserContext().getUserid(), details)); } - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "addDistributionTarget inserted distribution target sourceId = {}, targetId = {}", - sourceWorkbasketId, - targetWorkbasketId); - } + LOGGER.debug( + "addDistributionTarget inserted distribution target sourceId = {}, targetId = {}", + sourceWorkbasketId, + targetWorkbasketId); sourceWorkbasket.setModified(Instant.now()); workbasketMapper.update(sourceWorkbasket); } @@ -779,32 +770,30 @@ public void removeDistributionTarget(String sourceWorkbasketId, String targetWor details)); } } - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "removeDistributionTarget deleted distribution target sourceId = {}, targetId = {}", - sourceWorkbasketId, - targetWorkbasketId); - } + LOGGER + .atDebug() + .setMessage( + "removeDistributionTarget deleted distribution target sourceId = {}, targetId = {}") + .addArgument(() -> LogSanitizer.stripLineBreakingChars(sourceWorkbasketId)) + .addArgument(() -> LogSanitizer.stripLineBreakingChars(targetWorkbasketId)) + .log(); try { WorkbasketImpl sourceWorkbasket = (WorkbasketImpl) getWorkbasket(sourceWorkbasketId); sourceWorkbasket.setModified(Instant.now()); workbasketMapper.update(sourceWorkbasket); } catch (WorkbasketNotFoundException e) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "removeDistributionTarget found that the source workbasket {} " - + "doesn't exist. Ignoring the request... ", - sourceWorkbasketId); - } + LOGGER.debug( + """ + removeDistributionTarget found that the source workbasket {} \ + doesn't exist. Ignoring the request...\s""", + sourceWorkbasketId); } } else { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "removeDistributionTarget detected that the specified distribution " - + "target doesn't exist. Doing nothing..."); - } + LOGGER.debug( + "removeDistributionTarget detected that the specified distribution " + + "target doesn't exist. Doing nothing..."); } } finally { kadaiEngine.returnConnection(); @@ -829,9 +818,7 @@ public boolean deleteWorkbasket(String workbasketId) try { workbasketToDelete = this.getWorkbasket(workbasketId); } catch (WorkbasketNotFoundException ex) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Workbasket with workbasketId = {} is already deleted?", workbasketId); - } + LOGGER.debug("Workbasket with workbasketId = {} is already deleted?", workbasketId); throw ex; } @@ -1076,24 +1063,18 @@ private boolean skipAuthorizationCheck(WorkbasketPermission... requestedPermissi // Skip permission check if security is not enabled if (!kadaiEngine.getEngine().getConfiguration().isSecurityEnabled()) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Skipping permissions check since security is disabled."); - } + LOGGER.debug("Skipping permissions check since security is disabled."); return true; } if (Arrays.asList(requestedPermissions).contains(WorkbasketPermission.READ)) { if (kadaiEngine.getEngine().isUserInRole(KadaiRole.ADMIN)) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Skipping read permissions check since user is in role ADMIN"); - } + LOGGER.debug("Skipping read permissions check since user is in role ADMIN"); return true; } } else if (kadaiEngine.getEngine().isUserInRole(KadaiRole.ADMIN, KadaiRole.TASK_ADMIN)) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Skipping permissions check since user is in role ADMIN or TASK_ADMIN."); - } + LOGGER.debug("Skipping permissions check since user is in role ADMIN or TASK_ADMIN."); return true; } diff --git a/lib/kadai-core/src/main/java/io/kadai/workbasket/internal/jobs/WorkbasketCleanupJob.java b/lib/kadai-core/src/main/java/io/kadai/workbasket/internal/jobs/WorkbasketCleanupJob.java index 187a859b6..9c9219ac2 100644 --- a/lib/kadai-core/src/main/java/io/kadai/workbasket/internal/jobs/WorkbasketCleanupJob.java +++ b/lib/kadai-core/src/main/java/io/kadai/workbasket/internal/jobs/WorkbasketCleanupJob.java @@ -104,10 +104,11 @@ private int deleteWorkbaskets(List workbasketsToBeDeleted) BulkOperationResults results = kadaiEngineImpl.getWorkbasketService().deleteWorkbaskets(workbasketsToBeDeleted); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "{} workbasket deleted.", workbasketsToBeDeleted.size() - results.getFailedIds().size()); - } + LOGGER + .atDebug() + .setMessage("{} workbasket deleted.") + .addArgument(() -> workbasketsToBeDeleted.size() - results.getFailedIds().size()) + .log(); for (String failedId : results.getFailedIds()) { LOGGER.warn( "Workbasket with id {} could not be deleted. Reason:", diff --git a/rest/kadai-rest-spring-example-wildfly/src/main/java/io/kadai/example/wildfly/KadaiWildflyConfiguration.java b/rest/kadai-rest-spring-example-wildfly/src/main/java/io/kadai/example/wildfly/KadaiWildflyConfiguration.java index f6ca1bece..acd2051fb 100644 --- a/rest/kadai-rest-spring-example-wildfly/src/main/java/io/kadai/example/wildfly/KadaiWildflyConfiguration.java +++ b/rest/kadai-rest-spring-example-wildfly/src/main/java/io/kadai/example/wildfly/KadaiWildflyConfiguration.java @@ -75,8 +75,9 @@ public DataSource dataSource() throws Exception { return dataSource; } catch (Exception e) { LOGGER.error( - "Caught exception when attempting to start Kadai with Datasource " - + "from Jndi. Using default H2 datasource. ", + """ + Caught exception when attempting to start Kadai with Datasource from Jndi.\s + Using default H2 datasource.\s""", e); throw e; } diff --git a/rest/kadai-rest-spring-example-wildfly/src/main/java/io/kadai/example/wildfly/security/ElytronToJaasFilter.java b/rest/kadai-rest-spring-example-wildfly/src/main/java/io/kadai/example/wildfly/security/ElytronToJaasFilter.java index 28c534dc1..9fc21267c 100644 --- a/rest/kadai-rest-spring-example-wildfly/src/main/java/io/kadai/example/wildfly/security/ElytronToJaasFilter.java +++ b/rest/kadai-rest-spring-example-wildfly/src/main/java/io/kadai/example/wildfly/security/ElytronToJaasFilter.java @@ -67,6 +67,7 @@ private void applySecurityIdentityToSubject(SecurityIdentity securityIdentity) { roles.forEach(role -> subject.getPrincipals().add(new GroupPrincipal(role))); } if (logger.isDebugEnabled()) { + // This is not SLF4J! logger.debug("Current JAAS subject after applying Elytron SecurityIdentity: " + subject); } } @@ -77,6 +78,7 @@ private Subject obtainSubject() { // TODO replace with Subject.current() when migrating to newer Version than 17 Subject subject = Subject.getSubject(java.security.AccessController.getContext()); if (logger.isDebugEnabled()) { + // This is not SLF4J! logger.debug("Current JAAS subject: " + subject); } return subject; @@ -102,6 +104,7 @@ private SecurityIdentity getSecurityIdentity(ServletRequest request) { } } if (logger.isDebugEnabled()) { + // This is not SLF4J! logger.debug("Current Elytron SecurityIdentity: " + identity); } diff --git a/rest/kadai-rest-spring-example-wildfly/src/main/java/io/kadai/example/wildfly/security/LogoutController.java b/rest/kadai-rest-spring-example-wildfly/src/main/java/io/kadai/example/wildfly/security/LogoutController.java index 7aa32b332..555de6501 100644 --- a/rest/kadai-rest-spring-example-wildfly/src/main/java/io/kadai/example/wildfly/security/LogoutController.java +++ b/rest/kadai-rest-spring-example-wildfly/src/main/java/io/kadai/example/wildfly/security/LogoutController.java @@ -45,9 +45,7 @@ public RedirectView loginErrorPost(HttpServletRequest request) { public RedirectView logout(HttpServletRequest request) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Logging out..."); - } + LOGGER.debug("Logging out..."); if (request.getSession(false) != null) { request.getSession(false).invalidate(); // remove session. @@ -59,7 +57,7 @@ public RedirectView logout(HttpServletRequest request) { try { request.logout(); } catch (ServletException e) { - LOGGER.warn("Exception caught while logging out: {}", e.getMessage()); + LOGGER.warn("Exception caught while logging out: {}", e.getMessage(), e); } return new RedirectView("/", true); diff --git a/rest/kadai-rest-spring-test-lib/src/main/java/io/kadai/rest/test/SpringSecurityToJaasFilter.java b/rest/kadai-rest-spring-test-lib/src/main/java/io/kadai/rest/test/SpringSecurityToJaasFilter.java index 54bd77a95..db9a6b24a 100644 --- a/rest/kadai-rest-spring-test-lib/src/main/java/io/kadai/rest/test/SpringSecurityToJaasFilter.java +++ b/rest/kadai-rest-spring-test-lib/src/main/java/io/kadai/rest/test/SpringSecurityToJaasFilter.java @@ -47,9 +47,11 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha throws IOException, ServletException { Optional authentication = getCurrentAuthentication(); if (authentication.isPresent()) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Authentication found in Spring security context: {}", authentication); - } + LOGGER + .atDebug() + .setMessage("Authentication found in Spring security context: {}") + .addArgument(() -> authentication) + .log(); obtainSubject() .ifPresent( subject -> { @@ -57,10 +59,8 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha initializeGroupPrincipalsFromAuthentication(authentication.get(), subject); }); } else { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "No authentication found in Spring security context. Continuing unauthenticatic."); - } + LOGGER.debug( + "No authentication found in Spring security context. Continuing unauthenticatic."); } chain.doFilter(request, response); @@ -81,6 +81,7 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha protected Optional obtainSubject() { Optional authentication = getCurrentAuthentication(); if (logger.isDebugEnabled()) { + // This is not SLF4J! logger.debug("Attempting to obtainSubject using authentication : " + authentication); } if (authentication.isEmpty() || !authentication.get().isAuthenticated()) { @@ -97,17 +98,20 @@ Optional getCurrentAuthentication() { private void initializeUserPrincipalFromAuthentication( Authentication authentication, Subject subject) { if (subject.getPrincipals().isEmpty()) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "Setting the principal of the subject with {}.", authentication.getPrincipal()); - } + LOGGER + .atDebug() + .setMessage("Setting the principal of the subject with {}.") + .addArgument(authentication::getPrincipal) + .log(); subject .getPrincipals() .add(new UserPrincipal(((UserDetails) authentication.getPrincipal()).getUsername())); } else { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Principal of the subject is already set to {}.", subject.getPrincipals()); - } + LOGGER + .atDebug() + .setMessage("Principal of the subject is already set to {}.") + .addArgument(subject::getPrincipals) + .log(); throw new SystemException("Finding an existing principal is unexpected. Please investigate."); } } @@ -115,9 +119,11 @@ private void initializeUserPrincipalFromAuthentication( private void initializeGroupPrincipalsFromAuthentication( Authentication authentication, Subject subject) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Adding roles {} to subject.", authentication.getAuthorities()); - } + LOGGER + .atDebug() + .setMessage("Adding roles {} to subject.") + .addArgument(authentication::getAuthorities) + .log(); authentication .getAuthorities() @@ -125,8 +131,10 @@ private void initializeGroupPrincipalsFromAuthentication( grantedAuthority -> subject.getPrincipals().add(new GroupPrincipal(grantedAuthority.getAuthority()))); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("{}", subject.getPublicCredentials(GroupPrincipal.class)); - } + LOGGER + .atDebug() + .setMessage("{}") + .addArgument(() -> subject.getPublicCredentials(GroupPrincipal.class)) + .log(); } } diff --git a/rest/kadai-rest-spring/src/main/java/io/kadai/common/rest/SpringSecurityToJaasFilter.java b/rest/kadai-rest-spring/src/main/java/io/kadai/common/rest/SpringSecurityToJaasFilter.java index 157a1f4e4..facf581b7 100644 --- a/rest/kadai-rest-spring/src/main/java/io/kadai/common/rest/SpringSecurityToJaasFilter.java +++ b/rest/kadai-rest-spring/src/main/java/io/kadai/common/rest/SpringSecurityToJaasFilter.java @@ -46,9 +46,11 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha throws IOException, ServletException { Optional authentication = getCurrentAuthentication(); if (authentication.isPresent()) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Authentication found in Spring security context: {}", authentication); - } + LOGGER + .atDebug() + .setMessage("Authentication found in Spring security context: {}") + .addArgument(() -> authentication) + .log(); obtainSubject() .ifPresent( subject -> { @@ -56,10 +58,8 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha initializeGroupPrincipalsFromAuthentication(authentication.get(), subject); }); } else { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "No authentication found in Spring security context. Continuing unauthenticatic."); - } + LOGGER.debug( + "No authentication found in Spring security context. Continuing unauthenticatic."); } chain.doFilter(request, response); @@ -80,6 +80,7 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha protected Optional obtainSubject() { Optional authentication = getCurrentAuthentication(); if (logger.isDebugEnabled()) { + // This is not SLF4J! logger.debug("Attempting to obtainSubject using authentication : " + authentication); } if (authentication.isEmpty() || !authentication.get().isAuthenticated()) { @@ -96,17 +97,20 @@ Optional getCurrentAuthentication() { private void initializeUserPrincipalFromAuthentication( Authentication authentication, Subject subject) { if (subject.getPrincipals().isEmpty()) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "Setting the principal of the subject with {}.", authentication.getPrincipal()); - } + LOGGER + .atDebug() + .setMessage("Setting the principal of the subject with {}.") + .addArgument(authentication::getPrincipal) + .log(); subject .getPrincipals() .add(new UserPrincipal(((UserDetails) authentication.getPrincipal()).getUsername())); } else { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Principal of the subject is already set to {}.", subject.getPrincipals()); - } + LOGGER + .atDebug() + .setMessage("Principal of the subject is already set to {}.") + .addArgument(subject::getPrincipals) + .log(); throw new SystemException("Finding an existing principal is unexpected. Please investigate."); } } @@ -114,9 +118,11 @@ private void initializeUserPrincipalFromAuthentication( private void initializeGroupPrincipalsFromAuthentication( Authentication authentication, Subject subject) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Adding roles {} to subject.", authentication.getAuthorities()); - } + LOGGER + .atDebug() + .setMessage("Adding roles {} to subject.") + .addArgument(authentication::getAuthorities) + .log(); authentication .getAuthorities() @@ -124,8 +130,10 @@ private void initializeGroupPrincipalsFromAuthentication( grantedAuthority -> subject.getPrincipals().add(new GroupPrincipal(grantedAuthority.getAuthority()))); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("{}", subject.getPublicCredentials(GroupPrincipal.class)); - } + LOGGER + .atDebug() + .setMessage("{}") + .addArgument(() -> subject.getPublicCredentials(GroupPrincipal.class)) + .log(); } } diff --git a/rest/kadai-rest-spring/src/main/java/io/kadai/common/rest/ldap/LdapClient.java b/rest/kadai-rest-spring/src/main/java/io/kadai/common/rest/ldap/LdapClient.java index 814e743f7..614706d05 100644 --- a/rest/kadai-rest-spring/src/main/java/io/kadai/common/rest/ldap/LdapClient.java +++ b/rest/kadai-rest-spring/src/main/java/io/kadai/common/rest/ldap/LdapClient.java @@ -316,10 +316,13 @@ public AccessIdRepresentationModel searchAccessIdByDn(final String dn) // Therefore we have to remove the base name from the dn before performing the lookup String nameWithoutBaseDn = getNameWithoutBaseDn(dn).toLowerCase(); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "Removed baseDN {} from given DN. New DN to be used: {}", getBaseDn(), nameWithoutBaseDn); - } + LOGGER + .atDebug() + .setMessage("Removed baseDN {} from given DN. New DN to be used: {}") + .addArgument(this::getBaseDn) + .addArgument(nameWithoutBaseDn) + .log(); + return ldapTemplate.lookup( new LdapName(nameWithoutBaseDn), getLookUpUserAndGroupAndPermissionAttributesToReturn(), @@ -347,12 +350,12 @@ public List searchGroupsAccessIdIsMemberOf(final St final AndFilter andFilter2 = getPermissionsNotPresentAndFilter(andFilter); String[] userAttributesToReturn = {getUserIdAttribute(), getGroupNameAttribute()}; - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "Using filter '{}' for LDAP query with group search base {}.", - andFilter2, - getGroupSearchBase()); - } + LOGGER + .atDebug() + .setMessage("Using filter '{}' for LDAP query with group search base {}.") + .addArgument(andFilter2) + .addArgument(this::getGroupSearchBase) + .log(); return ldapTemplate.search( getGroupSearchBase(), @@ -389,12 +392,12 @@ public List searchPermissionsAccessIdHas(final Stri andFilter2.and(andFilter); String[] userAttributesToReturn = {getUserIdAttribute(), getUserPermissionsAttribute()}; - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "Using filter '{}' for LDAP query with group search base {}.", - andFilter2, - getPermissionSearchBase()); - } + LOGGER + .atDebug() + .setMessage("Using filter '{}' for LDAP query with group search base {}.") + .addArgument(andFilter2) + .addArgument(this::getPermissionSearchBase) + .log(); return ldapTemplate.search( getPermissionSearchBase(), @@ -424,101 +427,6 @@ public String searchDnForAccessId(String accessId) } } - private String searchDnForAccessIdIfAccessIdNameIsNotDn(String accessId) { - final List distinguishedNames = searchDnForUserAccessId(accessId); - if (distinguishedNames == null || distinguishedNames.isEmpty()) { - final List distinguishedNamesPermissions = searchDnForPermissionAccessId(accessId); - if (distinguishedNamesPermissions == null || distinguishedNamesPermissions.isEmpty()) { - final List distinguishedNamesGroups = searchDnForGroupAccessId(accessId); - if (distinguishedNamesGroups == null || distinguishedNamesGroups.isEmpty()) { - return null; - } else if (distinguishedNamesGroups.size() > 1) { - throw new InvalidArgumentException("Ambiguous access id found: " + accessId); - } else { - return distinguishedNamesGroups.get(0); - } - } else if (distinguishedNamesPermissions.size() > 1) { - throw new InvalidArgumentException("Ambiguous access id found: " + accessId); - } else { - return distinguishedNamesPermissions.get(0); - } - } else if (distinguishedNames.size() > 1) { - throw new InvalidArgumentException("Ambiguous access id found: " + accessId); - } else { - return distinguishedNames.get(0); - } - } - - private List searchDnForUserAccessId(String accessId) { - final AndFilter andFilter = new AndFilter(); - andFilter.and(new EqualsFilter(getUserSearchFilterName(), getUserSearchFilterValue())); - final OrFilter orFilter = new OrFilter(); - orFilter.or(new EqualsFilter(getUserIdAttribute(), accessId)); - andFilter.and(orFilter); - - LOGGER.debug( - "Using filter '{}' for LDAP query with user search base {}.", - andFilter, - getUserSearchBase()); - - return ldapTemplate.search( - getUserSearchBase(), - andFilter.encode(), - SearchControls.SUBTREE_SCOPE, - null, - new DnStringContextMapper()); - } - - private List searchDnForPermissionAccessId(String accessId) { - if (permissionsAreEmpty()) { - return Collections.emptyList(); - } - final AndFilter andFilter = new AndFilter(); - andFilter.and( - new EqualsFilter(getPermissionSearchFilterName(), getPermissionSearchFilterValue())); - final OrFilter orFilter = new OrFilter(); - orFilter.or(new EqualsFilter(getUserPermissionsAttribute(), accessId)); - final AndFilter andFilterPermission2 = new AndFilter(); - andFilter.and(new PresentFilter(getUserPermissionsAttribute())); - andFilter.and(orFilter); - andFilterPermission2.and(andFilter); - - LOGGER.debug( - "Using filter '{}' for LDAP query with user search base {}.", - andFilterPermission2, - getPermissionSearchBase()); - - return ldapTemplate.search( - getPermissionSearchBase(), - andFilterPermission2.encode(), - SearchControls.SUBTREE_SCOPE, - null, - new DnStringContextMapper()); - } - - private List searchDnForGroupAccessId(String accessId) { - final AndFilter andFilter = new AndFilter(); - andFilter.and(new EqualsFilter(getGroupSearchFilterName(), getGroupSearchFilterValue())); - final OrFilter orFilter = new OrFilter(); - orFilter.or(new EqualsFilter(getGroupNameAttribute(), accessId)); - final AndFilter andFilter2 = new AndFilter(); - andFilter2.and(new NotPresentFilter(getUserPermissionsAttribute())); - andFilter.and(orFilter); - andFilter2.and(andFilter); - - LOGGER.debug( - "Using filter '{}' for LDAP query with user search base {}.", - andFilter2, - getPermissionSearchBase()); - - return ldapTemplate.search( - getPermissionSearchBase(), - andFilter.encode(), - SearchControls.SUBTREE_SCOPE, - null, - new DnStringContextMapper()); - } - /** * Validates a given AccessId / name. * @@ -784,18 +692,18 @@ String[] getLookUpUserAttributesToReturn() { String[] getLookUpUserInfoAttributesToReturn() { if (permissionsAreEmpty()) { return new String[] { - getUserIdAttribute(), - getUserMemberOfGroupAttribute(), - getUserFirstnameAttribute(), - getUserLastnameAttribute(), - getUserFullnameAttribute(), - getUserPhoneAttribute(), - getUserMobilePhoneAttribute(), - getUserEmailAttribute(), - getUserOrgLevel1Attribute(), - getUserOrgLevel2Attribute(), - getUserOrgLevel3Attribute(), - getUserOrgLevel4Attribute() + getUserIdAttribute(), + getUserMemberOfGroupAttribute(), + getUserFirstnameAttribute(), + getUserLastnameAttribute(), + getUserFullnameAttribute(), + getUserPhoneAttribute(), + getUserMobilePhoneAttribute(), + getUserEmailAttribute(), + getUserOrgLevel1Attribute(), + getUserOrgLevel2Attribute(), + getUserOrgLevel3Attribute(), + getUserOrgLevel4Attribute() }; } return new String[] { @@ -862,6 +770,101 @@ void testMinSearchForLength(final String name) throws InvalidArgumentException { } } + private String searchDnForAccessIdIfAccessIdNameIsNotDn(String accessId) { + final List distinguishedNames = searchDnForUserAccessId(accessId); + if (distinguishedNames == null || distinguishedNames.isEmpty()) { + final List distinguishedNamesPermissions = searchDnForPermissionAccessId(accessId); + if (distinguishedNamesPermissions == null || distinguishedNamesPermissions.isEmpty()) { + final List distinguishedNamesGroups = searchDnForGroupAccessId(accessId); + if (distinguishedNamesGroups == null || distinguishedNamesGroups.isEmpty()) { + return null; + } else if (distinguishedNamesGroups.size() > 1) { + throw new InvalidArgumentException("Ambiguous access id found: " + accessId); + } else { + return distinguishedNamesGroups.get(0); + } + } else if (distinguishedNamesPermissions.size() > 1) { + throw new InvalidArgumentException("Ambiguous access id found: " + accessId); + } else { + return distinguishedNamesPermissions.get(0); + } + } else if (distinguishedNames.size() > 1) { + throw new InvalidArgumentException("Ambiguous access id found: " + accessId); + } else { + return distinguishedNames.get(0); + } + } + + private List searchDnForUserAccessId(String accessId) { + final AndFilter andFilter = new AndFilter(); + andFilter.and(new EqualsFilter(getUserSearchFilterName(), getUserSearchFilterValue())); + final OrFilter orFilter = new OrFilter(); + orFilter.or(new EqualsFilter(getUserIdAttribute(), accessId)); + andFilter.and(orFilter); + + LOGGER.debug( + "Using filter '{}' for LDAP query with user search base {}.", + andFilter, + getUserSearchBase()); + + return ldapTemplate.search( + getUserSearchBase(), + andFilter.encode(), + SearchControls.SUBTREE_SCOPE, + null, + new DnStringContextMapper()); + } + + private List searchDnForPermissionAccessId(String accessId) { + if (permissionsAreEmpty()) { + return Collections.emptyList(); + } + final AndFilter andFilter = new AndFilter(); + andFilter.and( + new EqualsFilter(getPermissionSearchFilterName(), getPermissionSearchFilterValue())); + final OrFilter orFilter = new OrFilter(); + orFilter.or(new EqualsFilter(getUserPermissionsAttribute(), accessId)); + final AndFilter andFilterPermission2 = new AndFilter(); + andFilter.and(new PresentFilter(getUserPermissionsAttribute())); + andFilter.and(orFilter); + andFilterPermission2.and(andFilter); + + LOGGER.debug( + "Using filter '{}' for LDAP query with user search base {}.", + andFilterPermission2, + getPermissionSearchBase()); + + return ldapTemplate.search( + getPermissionSearchBase(), + andFilterPermission2.encode(), + SearchControls.SUBTREE_SCOPE, + null, + new DnStringContextMapper()); + } + + private List searchDnForGroupAccessId(String accessId) { + final AndFilter andFilter = new AndFilter(); + andFilter.and(new EqualsFilter(getGroupSearchFilterName(), getGroupSearchFilterValue())); + final OrFilter orFilter = new OrFilter(); + orFilter.or(new EqualsFilter(getGroupNameAttribute(), accessId)); + final AndFilter andFilter2 = new AndFilter(); + andFilter2.and(new NotPresentFilter(getUserPermissionsAttribute())); + andFilter.and(orFilter); + andFilter2.and(andFilter); + + LOGGER.debug( + "Using filter '{}' for LDAP query with user search base {}.", + andFilter2, + getPermissionSearchBase()); + + return ldapTemplate.search( + getPermissionSearchBase(), + andFilter.encode(), + SearchControls.SUBTREE_SCOPE, + null, + new DnStringContextMapper()); + } + private String getUserFullnameAttribute() { return LdapSettings.KADAI_LDAP_USER_FULLNAME_ATTRIBUTE.getValueFromEnv(env); } @@ -916,10 +919,12 @@ private String getPermissionIdFromContext(final DirContextOperations context) { } private Set getPermissionIdsFromContext(final DirContextOperations context) { - boolean permissionsAreNotEmpty = !permissionsAreEmpty() - && context.getStringAttributes(getUserPermissionsAttribute()) != null; + boolean permissionsAreNotEmpty = + !permissionsAreEmpty() + && context.getStringAttributes(getUserPermissionsAttribute()) != null; Set permissions = - permissionsAreNotEmpty ? Set.of(context.getStringAttributes(getUserPermissionsAttribute())) + permissionsAreNotEmpty + ? Set.of(context.getStringAttributes(getUserPermissionsAttribute())) : Collections.emptySet(); if (useLowerCaseForAccessIds) { permissions = @@ -932,16 +937,17 @@ private Set getPermissionIdsFromContext(final DirContextOperations conte } private boolean permissionsAreEmpty() { - return getUserPermissionsAttribute() == null || getPermissionSearchFilterName() == null - || getUserPermissionsAttribute().isEmpty() || getPermissionSearchFilterName().isEmpty(); + return getUserPermissionsAttribute() == null + || getPermissionSearchFilterName() == null + || getUserPermissionsAttribute().isEmpty() + || getPermissionSearchFilterName().isEmpty(); } private AndFilter getPermissionsNotPresentAndFilter(AndFilter andFilter) { if (getUserPermissionsAttribute() == null || getUserPermissionsAttribute().isEmpty()) { return andFilter; } - final AndFilter - andFilter2 = new AndFilter(); + final AndFilter andFilter2 = new AndFilter(); andFilter2.and(new NotPresentFilter(getUserPermissionsAttribute())); andFilter2.and(andFilter); return andFilter2; @@ -1025,7 +1031,8 @@ public AccessIdRepresentationModel doMapFromContext(final DirContextOperations c String firstName = context.getStringAttribute(getUserFirstnameAttribute()); String lastName = context.getStringAttribute(getUserLastnameAttribute()); accessId.setName(String.format("%s, %s", lastName, firstName)); - } else if (getUserPermissionsAttribute() == null || getUserPermissionsAttribute().isEmpty() + } else if (getUserPermissionsAttribute() == null + || getUserPermissionsAttribute().isEmpty() || context.getStringAttribute(getUserPermissionsAttribute()) == null) { if (useDnForGroups()) { accessId.setAccessId(getDnFromContext(context)); // fully qualified dn diff --git a/rest/kadai-rest-spring/src/main/java/io/kadai/user/jobs/UserInfoRefreshJob.java b/rest/kadai-rest-spring/src/main/java/io/kadai/user/jobs/UserInfoRefreshJob.java index 9426e0e75..07ec3a2af 100644 --- a/rest/kadai-rest-spring/src/main/java/io/kadai/user/jobs/UserInfoRefreshJob.java +++ b/rest/kadai-rest-spring/src/main/java/io/kadai/user/jobs/UserInfoRefreshJob.java @@ -95,15 +95,11 @@ private void clearExistingUsersAndGroupsAndPermissions() { sqlConnectionRunner.runWithConnection( connection -> { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Trying to delete all users, groups and permissions"); - } + LOGGER.debug("Trying to delete all users, groups and permissions"); String sql = "DELETE FROM USER_INFO; DELETE FROM GROUP_INFO; DELETE FROM PERMISSION_INFO"; PreparedStatement statement = connection.prepareStatement(sql); statement.execute(); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Successfully deleted all users, groups and permissions"); - } + LOGGER.debug("Successfully deleted all users, groups and permissions"); if (!connection.getAutoCommit()) { connection.commit(); @@ -116,13 +112,9 @@ private void insertNewUsers(List users) { users.forEach( user -> { try { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Trying to insert user {}", user); - } + LOGGER.debug("Trying to insert user {}", user); kadaiEngineImpl.getUserService().createUser(user); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Successfully inserted user {}", user); - } + LOGGER.debug("Successfully inserted user {}", user); } catch (InvalidArgumentException | NotAuthorizedException | UserAlreadyExistException e) { @@ -139,26 +131,18 @@ private void addExistingConfigurationDataToUsers(List users) { String userData = kadaiEngineImpl.getUserService().getUser(user.getId()).getData(); if (userData != null) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Trying to set userData {} for user {}", userData, user); - } + LOGGER.debug("Trying to set userData {} for user {}", userData, user); user.setData(userData); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Successfully set userData {} for user {}", userData, user); - } + LOGGER.debug("Successfully set userData {} for user {}", userData, user); } } catch (UserNotFoundException e) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - String.format( - "Failed to fetch configuration data for User " - + "with ID '%s' because it doesn't exist", - user.getId())); - } + LOGGER.debug( + """ + Failed to fetch configuration data for User \ + with ID '{}' because it doesn't exist""", + user.getId()); } catch (InvalidArgumentException e) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Failed to fetch configuration data because userId was NULL or empty"); - } + LOGGER.debug("Failed to fetch configuration data because userId was NULL or empty"); } }); } diff --git a/rest/kadai-rest-spring/src/main/java/io/kadai/workbasket/rest/WorkbasketController.java b/rest/kadai-rest-spring/src/main/java/io/kadai/workbasket/rest/WorkbasketController.java index 4aac4c176..e6ccaccda 100644 --- a/rest/kadai-rest-spring/src/main/java/io/kadai/workbasket/rest/WorkbasketController.java +++ b/rest/kadai-rest-spring/src/main/java/io/kadai/workbasket/rest/WorkbasketController.java @@ -261,15 +261,11 @@ public ResponseEntity deleteWorkbasket( boolean workbasketDeleted = workbasketService.deleteWorkbasket(workbasketId); if (workbasketDeleted) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Workbasket successfully deleted."); - } + LOGGER.debug("Workbasket successfully deleted."); return ResponseEntity.noContent().build(); } else { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "Workbasket was only marked for deletion and will be physically deleted later on."); - } + LOGGER.debug( + "Workbasket was only marked for deletion and will be physically deleted later on."); return ResponseEntity.accepted().build(); } } diff --git a/rest/kadai-rest-spring/src/test/java/io/kadai/classification/rest/ClassificationDefinitionControllerIntTest.java b/rest/kadai-rest-spring/src/test/java/io/kadai/classification/rest/ClassificationDefinitionControllerIntTest.java index e43137dbe..eafc9e615 100644 --- a/rest/kadai-rest-spring/src/test/java/io/kadai/classification/rest/ClassificationDefinitionControllerIntTest.java +++ b/rest/kadai-rest-spring/src/test/java/io/kadai/classification/rest/ClassificationDefinitionControllerIntTest.java @@ -73,7 +73,8 @@ class ClassificationDefinitionControllerIntTest { new ParameterizedTypeReference< ClassificationDefinitionCollectionRepresentationModel>() {}; - private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationController.class); + private static final Logger LOGGER = + LoggerFactory.getLogger(ClassificationDefinitionControllerIntTest.class); private final RestHelper restHelper; private final ObjectMapper mapper; @@ -400,9 +401,7 @@ void should_OverrideExistingParentLinks_When_ImportLinksExistingClassificationsD ResponseEntity response = importRequest(clList); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT); Thread.sleep(10); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Wait 10 ms to give the system a chance to update"); - } + LOGGER.debug("Wait 10 ms to give the system a chance to update"); ClassificationRepresentationModel childWithNewParent = this.getClassificationWithKeyAndDomain("L110105", "DOMAIN_A"); @@ -434,9 +433,7 @@ private ClassificationRepresentationModel getClassificationWithKeyAndDomain( private ResponseEntity importRequest(ClassificationCollectionRepresentationModel clList) throws Exception { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Start Import"); - } + LOGGER.debug("Start Import"); File tmpFile = File.createTempFile("test", ".tmp"); try (FileOutputStream out = new FileOutputStream(tmpFile); OutputStreamWriter writer = new OutputStreamWriter(out, StandardCharsets.UTF_8)) { diff --git a/routing/kadai-routing-rest/src/main/java/io/kadai/routing/dmn/service/DmnConverterService.java b/routing/kadai-routing-rest/src/main/java/io/kadai/routing/dmn/service/DmnConverterService.java index 5a6b7c22f..9fc3b7cc9 100644 --- a/routing/kadai-routing-rest/src/main/java/io/kadai/routing/dmn/service/DmnConverterService.java +++ b/routing/kadai-routing-rest/src/main/java/io/kadai/routing/dmn/service/DmnConverterService.java @@ -96,9 +96,7 @@ public DmnModelInstance convertExcelToDmn(MultipartFile excelRoutingFile) DmnValidatorManager.getInstance(kadaiEngine).validate(patchedModel); } - if (LOGGER.isDebugEnabled()) { - LOGGER.debug(String.format("Persisting generated DMN table to %s", dmnUploadPath)); - } + LOGGER.debug("Persisting generated DMN table to {}", dmnUploadPath); File uploadDestinationFile = new File(dmnUploadPath); Dmn.writeModelToFile(uploadDestinationFile, patchedModel); diff --git a/routing/kadai-routing-rest/src/main/java/io/kadai/routing/dmn/spi/internal/DmnValidatorManager.java b/routing/kadai-routing-rest/src/main/java/io/kadai/routing/dmn/spi/internal/DmnValidatorManager.java index 6938cd373..023ab1b8d 100644 --- a/routing/kadai-routing-rest/src/main/java/io/kadai/routing/dmn/spi/internal/DmnValidatorManager.java +++ b/routing/kadai-routing-rest/src/main/java/io/kadai/routing/dmn/spi/internal/DmnValidatorManager.java @@ -60,9 +60,8 @@ public static boolean isDmnUploadProviderEnabled() { public void validate(DmnModelInstance dmnModelInstanceToValidate) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Sending DmnModelInstance to DmnValidators: {}", dmnModelInstanceToValidate); - } + LOGGER.debug("Sending DmnModelInstance to DmnValidators: {}", dmnModelInstanceToValidate); + serviceLoader.forEach( dmnValidator -> { try {