diff --git a/meveo-admin/ejbs/src/main/java/org/hibernate/util/JoinedAutoStaleObjectEvictingPersister.java b/meveo-admin/ejbs/src/main/java/org/hibernate/util/JoinedAutoStaleObjectEvictingPersister.java index 655675a6d..d041512af 100644 --- a/meveo-admin/ejbs/src/main/java/org/hibernate/util/JoinedAutoStaleObjectEvictingPersister.java +++ b/meveo-admin/ejbs/src/main/java/org/hibernate/util/JoinedAutoStaleObjectEvictingPersister.java @@ -26,7 +26,7 @@ */ public class JoinedAutoStaleObjectEvictingPersister extends JoinedSubclassEntityPersister { - private Logger log = LoggerFactory.getLogger(this.getClass()); + private static Logger log = LoggerFactory.getLogger(JoinedAutoStaleObjectEvictingPersister.class); public JoinedAutoStaleObjectEvictingPersister(PersistentClass persistentClass, EntityDataAccess cacheAccessStrategy, NaturalIdDataAccess naturalIdRegionAccessStrategy, PersisterCreationContext creationContext) throws HibernateException { diff --git a/meveo-admin/ejbs/src/main/java/org/hibernate/util/SingleAutoStaleObjectEvictingPersister.java b/meveo-admin/ejbs/src/main/java/org/hibernate/util/SingleAutoStaleObjectEvictingPersister.java index 63dd61b8a..cc2c1d9e5 100644 --- a/meveo-admin/ejbs/src/main/java/org/hibernate/util/SingleAutoStaleObjectEvictingPersister.java +++ b/meveo-admin/ejbs/src/main/java/org/hibernate/util/SingleAutoStaleObjectEvictingPersister.java @@ -26,7 +26,7 @@ */ public class SingleAutoStaleObjectEvictingPersister extends SingleTableEntityPersister { - private Logger log = LoggerFactory.getLogger(this.getClass()); + private static Logger log = LoggerFactory.getLogger(SingleAutoStaleObjectEvictingPersister.class); public SingleAutoStaleObjectEvictingPersister(PersistentClass persistentClass, EntityDataAccess cacheAccessStrategy, NaturalIdDataAccess naturalIdRegionAccessStrategy, PersisterCreationContext creationContext) throws HibernateException { diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/admin/async/FlatFileProcessingAsync.java b/meveo-admin/ejbs/src/main/java/org/meveo/admin/async/FlatFileProcessingAsync.java index f15ea6a1a..075d6f0b9 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/admin/async/FlatFileProcessingAsync.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/admin/async/FlatFileProcessingAsync.java @@ -35,6 +35,7 @@ import org.meveo.service.script.ScriptInterface; import org.meveo.util.ApplicationProvider; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Asynchronous FlatFile processing. @@ -50,8 +51,7 @@ public class FlatFileProcessingAsync { private static final String THREAD_POOL_SIZE = FlatFileProcessingJob.FLAT_FILE_PROCESSING_JOB_THREAD_POOL_SIZE; /** The log. */ - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(FlatFileProcessingAsync.class); /** The unit flat file processing job bean. */ @Inject diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/admin/ftp/MeveoDefaultFtplet.java b/meveo-admin/ejbs/src/main/java/org/meveo/admin/ftp/MeveoDefaultFtplet.java index 5d878ee7a..8c9e7dbff 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/admin/ftp/MeveoDefaultFtplet.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/admin/ftp/MeveoDefaultFtplet.java @@ -20,14 +20,16 @@ import org.meveo.model.mediation.MeveoFtpFile; import org.meveo.service.admin.impl.UserService; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @Stateless public class MeveoDefaultFtplet extends DefaultFtplet { - @Inject - private Logger log; + + private static Logger log = LoggerFactory.getLogger(MeveoDefaultFtplet.class); @Inject @FileUpload + private Event upload; @Inject diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/admin/ftp/MeveoFtpUserManager.java b/meveo-admin/ejbs/src/main/java/org/meveo/admin/ftp/MeveoFtpUserManager.java index ca2cd8021..08063ba0d 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/admin/ftp/MeveoFtpUserManager.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/admin/ftp/MeveoFtpUserManager.java @@ -35,7 +35,7 @@ public class MeveoFtpUserManager extends AbstractUserManager { private static final int HOUR = 60 * 60; private static final String ADMINISTRATOR = "administrateur"; - private Logger log = LoggerFactory.getLogger(MeveoFtpUserManager.class); + private static Logger log = LoggerFactory.getLogger(MeveoFtpUserManager.class); private UserService userService; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/admin/ftp/MeveoMinaFTPListener.java b/meveo-admin/ejbs/src/main/java/org/meveo/admin/ftp/MeveoMinaFTPListener.java index 6b12aba7d..c4afd6620 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/admin/ftp/MeveoMinaFTPListener.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/admin/ftp/MeveoMinaFTPListener.java @@ -20,6 +20,7 @@ import org.meveo.commons.utils.StringUtils; import org.meveo.service.admin.impl.UserService; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @@ -31,8 +32,9 @@ // @Startup @Singleton public class MeveoMinaFTPListener { - @Inject - private Logger log; + + private static Logger log = LoggerFactory.getLogger(MeveoMinaFTPListener.class); + @Inject private UserService userService; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/FileProcessingJobBean.java b/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/FileProcessingJobBean.java index 2554adbca..9e47007ef 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/FileProcessingJobBean.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/FileProcessingJobBean.java @@ -13,6 +13,7 @@ import org.meveo.service.script.ScriptInterface; import org.meveo.util.ApplicationProvider; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.ejb.Stateless; import javax.ejb.TransactionAttribute; @@ -31,8 +32,7 @@ public class FileProcessingJobBean { /** The log. */ - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(FileProcessingJobBean.class); /** The script instance service. */ @Inject diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/FilteringJobBean.java b/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/FilteringJobBean.java index b37e174c0..fa423c993 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/FilteringJobBean.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/FilteringJobBean.java @@ -31,6 +31,7 @@ import org.meveo.service.script.ScriptInstanceService; import org.meveo.service.script.ScriptInterface; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * The FilteringJobBean have 2 mains inputs :ScriptInstance and Filter. For each filtered entity the scriptInstance are executed. @@ -41,8 +42,7 @@ @Stateless public class FilteringJobBean { - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(FilteringJobBean.class); @Inject private FilterService filterService; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/FlatFileProcessingJobBean.java b/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/FlatFileProcessingJobBean.java index 27dbe19bb..95d3dec46 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/FlatFileProcessingJobBean.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/FlatFileProcessingJobBean.java @@ -32,6 +32,7 @@ import org.meveo.service.script.ScriptInstanceService; import org.meveo.service.script.ScriptInterface; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * The Class FlatFileProcessingJobBean. @@ -44,8 +45,7 @@ public class FlatFileProcessingJobBean { /** The log. */ - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(FlatFileProcessingJobBean.class); /** The script instance service. */ @Inject diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/FtpAdapterJobBean.java b/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/FtpAdapterJobBean.java index 5bbc4abac..8c6575fcc 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/FtpAdapterJobBean.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/FtpAdapterJobBean.java @@ -38,6 +38,7 @@ import org.meveo.service.job.FtpImportedFileService; import org.meveo.service.job.JobExecutionService; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * The Class FtpAdapterJobBean. @@ -49,8 +50,7 @@ public class FtpAdapterJobBean { /** The log. */ - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(FtpAdapterJobBean.class); /** The ftp imported file service. */ @Inject diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/GenerateMediationImport.java b/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/GenerateMediationImport.java index a8d79b6ba..8a68d1637 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/GenerateMediationImport.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/GenerateMediationImport.java @@ -11,6 +11,7 @@ import org.meveo.commons.utils.StringUtils; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author Edward P. Legaspi @@ -31,8 +32,7 @@ public static void main(String args[]) { new GenerateMediationImport(); } - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(GenerateMediationImport.class); public GenerateMediationImport() { System.out.println("start creating mediation file..."); diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/ReportExtractJobBean.java b/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/ReportExtractJobBean.java index fe85b7925..aa169032c 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/ReportExtractJobBean.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/ReportExtractJobBean.java @@ -24,6 +24,7 @@ import org.meveo.service.crm.impl.CustomFieldInstanceService; import org.meveo.service.finance.ReportExtractService; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * List all ReportExtract and dispatched for asynch execution. @@ -38,8 +39,7 @@ public class ReportExtractJobBean implements Serializable { private static final long serialVersionUID = 9159856207913605563L; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(ReportExtractJobBean.class); @Inject private CustomFieldInstanceService customFieldInstanceService; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/ScriptingJobBean.java b/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/ScriptingJobBean.java index 795be175c..987a48b3b 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/ScriptingJobBean.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/ScriptingJobBean.java @@ -18,11 +18,11 @@ import org.meveo.service.script.ScriptInstanceService; import org.meveo.service.script.ScriptInterface; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ScriptingJobBean { - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(ScriptingJobBean.class); @Inject private ScriptInstanceService scriptInstanceService; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/UnitReportExtractJobBean.java b/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/UnitReportExtractJobBean.java index 84f736cb9..ee156e782 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/UnitReportExtractJobBean.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/UnitReportExtractJobBean.java @@ -18,6 +18,7 @@ import org.meveo.service.finance.ReportExtractService; import org.meveo.service.script.finance.ReportExtractScript; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Extension class for JobExtractReport to start a new transaction. @@ -31,8 +32,7 @@ public class UnitReportExtractJobBean { private ParamBean paramBean = ParamBean.getInstance(); - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(UnitReportExtractJobBean.class); @Inject private ReportExtractService reportExtractService; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/UnitWorkflowJobBean.java b/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/UnitWorkflowJobBean.java index eba8db758..d778f39b6 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/UnitWorkflowJobBean.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/UnitWorkflowJobBean.java @@ -14,6 +14,7 @@ import org.meveo.model.wf.Workflow; import org.meveo.service.wf.WorkflowService; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @@ -23,8 +24,7 @@ @Stateless public class UnitWorkflowJobBean { - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(UnitWorkflowJobBean.class); @Inject private WorkflowService workflowService; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/WorkflowJobBean.java b/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/WorkflowJobBean.java index b6744d760..d99c458a4 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/WorkflowJobBean.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/WorkflowJobBean.java @@ -27,12 +27,12 @@ import org.meveo.service.filter.FilterService; import org.meveo.service.wf.WorkflowService; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @Stateless public class WorkflowJobBean { - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(WorkflowJobBean.class); @Inject private FilterService filterService; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/dwh/DWHQueryBean.java b/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/dwh/DWHQueryBean.java index 96c63c63b..7a0f2bf74 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/dwh/DWHQueryBean.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/dwh/DWHQueryBean.java @@ -41,6 +41,7 @@ import org.neo4j.driver.v1.StatementResult; import org.neo4j.driver.v1.Transaction; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @Stateless public class DWHQueryBean { @@ -55,8 +56,7 @@ public class DWHQueryBean { @MeveoJpa private EntityManagerWrapper emWrapper; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(DWHQueryBean.class); @Inject private JobExecutionService jobExecutionService; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/logging/JobLoggingInterceptor.java b/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/logging/JobLoggingInterceptor.java index d362e23a1..f1dbc5e1d 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/logging/JobLoggingInterceptor.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/admin/job/logging/JobLoggingInterceptor.java @@ -20,7 +20,7 @@ public class JobLoggingInterceptor implements Serializable{ * */ private static final long serialVersionUID = 8509493016090519457L; - private Logger log = LoggerFactory.getLogger(this.getClass()); + private static Logger log = LoggerFactory.getLogger(JobLoggingInterceptor.class); @AroundInvoke public Object aroundInvoke(InvocationContext invocationContext) diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/admin/listener/ApplicationInitializer.java b/meveo-admin/ejbs/src/main/java/org/meveo/admin/listener/ApplicationInitializer.java index f46a10cb1..f6361ff93 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/admin/listener/ApplicationInitializer.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/admin/listener/ApplicationInitializer.java @@ -23,6 +23,7 @@ import org.meveo.service.script.ScriptInstanceService; import org.primefaces.model.SortOrder; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Takes care of initializing/loading various application services/data @@ -52,8 +53,7 @@ public class ApplicationInitializer { @Inject private EntityManagerProvider entityManagerProvider; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(ApplicationInitializer.class); @Inject private NotificationCacheContainerProvider notifCache; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/admin/listener/StartupListener.java b/meveo-admin/ejbs/src/main/java/org/meveo/admin/listener/StartupListener.java index a215567e4..b41e6b663 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/admin/listener/StartupListener.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/admin/listener/StartupListener.java @@ -67,6 +67,7 @@ import org.meveo.service.storage.RemoteRepositoryService; import org.meveo.service.storage.RepositoryService; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author Edward P. Legaspi | czetsuya@gmail.com @@ -92,8 +93,7 @@ public class StartupListener { @Inject private RemoteRepositoryService remoteRepositoryService; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(StartupListener.class); @Inject @MeveoJpa diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/admin/patches/PatchExecutionService.java b/meveo-admin/ejbs/src/main/java/org/meveo/admin/patches/PatchExecutionService.java index c0ac2dd57..8e1961a61 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/admin/patches/PatchExecutionService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/admin/patches/PatchExecutionService.java @@ -16,6 +16,7 @@ import org.meveo.jpa.MeveoJpa; import org.meveo.model.patch.PatchExecution; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Service to execute patches @@ -34,8 +35,7 @@ public class PatchExecutionService implements MeveoInitializer { @Any private Instance patches; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(PatchExecutionService.class); /** * Execute every non-executed patch diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/admin/util/LoggerProducer.java b/meveo-admin/ejbs/src/main/java/org/meveo/admin/util/LoggerProducer.java deleted file mode 100644 index 94bc2f193..000000000 --- a/meveo-admin/ejbs/src/main/java/org/meveo/admin/util/LoggerProducer.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.meveo.admin.util; - -import javax.enterprise.inject.Produces; -import javax.enterprise.inject.spi.InjectionPoint; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author Edward P. Legaspi - **/ -public class LoggerProducer { - - @Produces - public Logger createLogger(InjectionPoint injectionPoint) { - return LoggerFactory.getLogger(injectionPoint.getMember() - .getDeclaringClass().getName()); - } - -} diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/audit/logging/writer/AuditEventDBWriter.java b/meveo-admin/ejbs/src/main/java/org/meveo/audit/logging/writer/AuditEventDBWriter.java index 212593c16..e1531ab2c 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/audit/logging/writer/AuditEventDBWriter.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/audit/logging/writer/AuditEventDBWriter.java @@ -9,13 +9,16 @@ import org.meveo.commons.utils.StringUtils; import org.meveo.model.audit.logging.AuditLog; import org.meveo.service.base.PersistenceService; +import org.meveo.service.custom.CustomEntityTemplateService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author Edward P. Legaspi **/ @Stateless public class AuditEventDBWriter extends PersistenceService { - + public void write(AuditEvent auditEvent) throws BusinessException { AuditLog auditLog = new AuditLog(); auditLog.setAction(auditEvent.getAction()); diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/commons/utils/CsvBuilder.java b/meveo-admin/ejbs/src/main/java/org/meveo/commons/utils/CsvBuilder.java index bfdd3d1c5..71db5de9d 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/commons/utils/CsvBuilder.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/commons/utils/CsvBuilder.java @@ -33,7 +33,7 @@ public class CsvBuilder { - private Logger log = LoggerFactory.getLogger(CsvBuilder.class); + private static Logger log = LoggerFactory.getLogger(CsvBuilder.class); /** Creates a new instance of CsvBuilder */ private final static String BREAK_LINE = "\r\n"; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/commons/utils/ParamBeanFactory.java b/meveo-admin/ejbs/src/main/java/org/meveo/commons/utils/ParamBeanFactory.java index f1fb9688e..7ff3ff2a7 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/commons/utils/ParamBeanFactory.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/commons/utils/ParamBeanFactory.java @@ -6,6 +6,7 @@ import org.meveo.security.CurrentUser; import org.meveo.security.MeveoUser; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @@ -16,8 +17,7 @@ @Stateless public class ParamBeanFactory { - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(ParamBeanFactory.class); @Inject @CurrentUser diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/commons/utils/RunCallable.java b/meveo-admin/ejbs/src/main/java/org/meveo/commons/utils/RunCallable.java index 4804e32bd..91783a5c1 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/commons/utils/RunCallable.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/commons/utils/RunCallable.java @@ -25,7 +25,7 @@ public class RunCallable implements Runnable { - private Logger log = LoggerFactory.getLogger(RunCallable.class); + private static Logger log = LoggerFactory.getLogger(RunCallable.class); Callable callable; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/event/monitoring/ClusterEventMonitor.java b/meveo-admin/ejbs/src/main/java/org/meveo/event/monitoring/ClusterEventMonitor.java index abaa3c8d6..9fa5ea42d 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/event/monitoring/ClusterEventMonitor.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/event/monitoring/ClusterEventMonitor.java @@ -31,6 +31,7 @@ import org.meveo.service.job.JobInstanceService; import org.meveo.service.script.ScriptInstanceService; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * A Message Driven Bean to handle data synchronization between cluster nodes. Messages are read from a topic "topic/CLUSTEREVENTTOPIC". @@ -44,8 +45,7 @@ @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge") }) public class ClusterEventMonitor implements MessageListener { - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(ClusterEventMonitor.class); @Inject private JobInstanceService jobInstanceService; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/event/monitoring/ClusterEventPublisher.java b/meveo-admin/ejbs/src/main/java/org/meveo/event/monitoring/ClusterEventPublisher.java index 5e74fd3f5..3e6250e5f 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/event/monitoring/ClusterEventPublisher.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/event/monitoring/ClusterEventPublisher.java @@ -18,6 +18,7 @@ import org.meveo.security.CurrentUser; import org.meveo.security.MeveoUser; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @JMSDestinationDefinitions(value = { @JMSDestinationDefinition(name = "java:/topic/CLUSTEREVENTTOPIC", interfaceName = "javax.jms.Topic", destinationName = "ClusterEventTopic") }) @Stateless @@ -25,8 +26,7 @@ public class ClusterEventPublisher implements Serializable { private static final long serialVersionUID = 4434372450314613654L; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(ClusterEventPublisher.class); @Inject private JMSContext context; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/export/EntityExportImportService.java b/meveo-admin/ejbs/src/main/java/org/meveo/export/EntityExportImportService.java index 45a4e6149..05cfec033 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/export/EntityExportImportService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/export/EntityExportImportService.java @@ -122,6 +122,7 @@ import org.reflections.Reflections; import org.reflections.scanners.ResourcesScanner; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.thoughtworks.xstream.MarshallingStrategy; import com.thoughtworks.xstream.XStream; @@ -172,8 +173,7 @@ public class EntityExportImportService implements Serializable { @ApplicationProvider protected Provider appProvider; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(EntityExportImportService.class); @Inject private NotificationCacheContainerProvider notificationCacheContainerProvider; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/export/ExportImportConfig.java b/meveo-admin/ejbs/src/main/java/org/meveo/export/ExportImportConfig.java index 2deeaf7e6..744921e6b 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/export/ExportImportConfig.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/export/ExportImportConfig.java @@ -48,7 +48,7 @@ public class ExportImportConfig { */ private Map, String[]> exportIdMapping; - private Logger log = LoggerFactory.getLogger(this.getClass()); + private static Logger log = LoggerFactory.getLogger(ExportImportConfig.class); public ExportImportConfig() { diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/export/IEntityClassConverter.java b/meveo-admin/ejbs/src/main/java/org/meveo/export/IEntityClassConverter.java index d8cef9986..1accf5908 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/export/IEntityClassConverter.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/export/IEntityClassConverter.java @@ -26,7 +26,7 @@ */ public class IEntityClassConverter extends ReflectionConverter { - private Logger log = LoggerFactory.getLogger(this.getClass()); + private static Logger log = LoggerFactory.getLogger(IEntityClassConverter.class); private boolean preserveId; private MeveoUser currentUser; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/export/IEntityExportIdentifierConverter.java b/meveo-admin/ejbs/src/main/java/org/meveo/export/IEntityExportIdentifierConverter.java index ce73f34cb..957ec3f13 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/export/IEntityExportIdentifierConverter.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/export/IEntityExportIdentifierConverter.java @@ -50,7 +50,7 @@ public class IEntityExportIdentifierConverter implements Converter { private boolean ignoreNotFoundFK; private Provider forceToProvider; private IEntityClassConverter iEntityClassConverter; - private Logger log = LoggerFactory.getLogger(this.getClass()); + private static Logger log = LoggerFactory.getLogger(IEntityExportIdentifierConverter.class); /** * diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/export/IEntityHibernateProxyConverter.java b/meveo-admin/ejbs/src/main/java/org/meveo/export/IEntityHibernateProxyConverter.java index 7a841d07e..5ac4f664d 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/export/IEntityHibernateProxyConverter.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/export/IEntityHibernateProxyConverter.java @@ -22,7 +22,7 @@ public class IEntityHibernateProxyConverter implements Converter { private ExportImportConfig exportImportConfig; - private Logger log = LoggerFactory.getLogger(this.getClass()); + private static Logger log = LoggerFactory.getLogger(IEntityHibernateProxyConverter.class); public IEntityHibernateProxyConverter(ExportImportConfig exportImportConfig) { this.exportImportConfig = exportImportConfig; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/interceptor/PerformanceInterceptor.java b/meveo-admin/ejbs/src/main/java/org/meveo/interceptor/PerformanceInterceptor.java index 4dc39b137..dc6d0b85d 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/interceptor/PerformanceInterceptor.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/interceptor/PerformanceInterceptor.java @@ -11,7 +11,7 @@ **/ public class PerformanceInterceptor { - private Logger log = LoggerFactory.getLogger(PerformanceInterceptor.class); + private static Logger log = LoggerFactory.getLogger(PerformanceInterceptor.class); @AroundInvoke Object measureTime(InvocationContext ctx) throws Exception { diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/jpa/EntityManagerProvider.java b/meveo-admin/ejbs/src/main/java/org/meveo/jpa/EntityManagerProvider.java index 1acd8633d..afc751103 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/jpa/EntityManagerProvider.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/jpa/EntityManagerProvider.java @@ -24,7 +24,6 @@ import javax.annotation.Resource; import javax.ejb.Stateless; -import javax.enterprise.context.ApplicationScoped; import javax.enterprise.context.RequestScoped; import javax.enterprise.inject.Disposes; import javax.enterprise.inject.Produces; @@ -41,6 +40,7 @@ import org.meveo.commons.utils.ParamBean; import org.meveo.security.keycloak.CurrentUserProvider; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Handles Entity manager instantiation. Based on https://www.tomas-dvorak.cz/posts/jpa-multitenancy/ @@ -59,8 +59,7 @@ public class EntityManagerProvider { @Inject private CurrentUserProvider currentUserProvider; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(EntityManagerProvider.class); @Resource(lookup = "java:jboss/infinispan/cache/meveo/meveo-multiTenant-cache") private Cache entityManagerFactories; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/jpa/JpaAmpNewTxInterceptor.java b/meveo-admin/ejbs/src/main/java/org/meveo/jpa/JpaAmpNewTxInterceptor.java index b1e9bccae..f9957e1ee 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/jpa/JpaAmpNewTxInterceptor.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/jpa/JpaAmpNewTxInterceptor.java @@ -27,9 +27,6 @@ public class JpaAmpNewTxInterceptor implements Serializable { @Inject private EntityManagerProvider entityManagerProvider; - @Inject - private Logger log; - /** * Instantiate a new EM if EM is application managed persistence context * diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/keycloak/client/KeycloakAdminClientService.java b/meveo-admin/ejbs/src/main/java/org/meveo/keycloak/client/KeycloakAdminClientService.java index cc0e60208..0e21c9c23 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/keycloak/client/KeycloakAdminClientService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/keycloak/client/KeycloakAdminClientService.java @@ -47,6 +47,7 @@ import org.meveo.security.CurrentUser; import org.meveo.security.MeveoUser; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author Clément Bareth @@ -58,8 +59,7 @@ @Stateless public class KeycloakAdminClientService { - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(KeycloakAdminClientService.class); @Inject @CurrentUser diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/persistence/CrossStorageService.java b/meveo-admin/ejbs/src/main/java/org/meveo/persistence/CrossStorageService.java index 876294969..a42bc3041 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/persistence/CrossStorageService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/persistence/CrossStorageService.java @@ -33,7 +33,6 @@ import javax.inject.Inject; import javax.persistence.PersistenceException; -import org.hibernate.Session; import org.meveo.admin.exception.BusinessException; import org.meveo.admin.exception.IllegalTransitionException; import org.meveo.admin.util.pagination.PaginationConfiguration; @@ -70,6 +69,7 @@ import org.meveo.service.storage.FileSystemService; import org.meveo.util.PersistenceUtils; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** @@ -100,8 +100,7 @@ public class CrossStorageService implements CustomPersistenceService { @Inject private CustomFieldInstanceService customFieldInstanceService; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(CrossStorageService.class); @Inject private CustomEntityTemplateService customEntityTemplateService; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/persistence/CrossStorageTransaction.java b/meveo-admin/ejbs/src/main/java/org/meveo/persistence/CrossStorageTransaction.java index b7918b308..a9e61dc4b 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/persistence/CrossStorageTransaction.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/persistence/CrossStorageTransaction.java @@ -18,6 +18,7 @@ import org.meveo.persistence.impl.SQLStorageImpl; import org.neo4j.driver.v1.Transaction; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Bean that handles the transactions for the cross storage @@ -43,8 +44,7 @@ public class CrossStorageTransaction { private List storages; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(CrossStorageTransaction.class); private int stackedCalls = 0; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/persistence/impl/Neo4jStorageImpl.java b/meveo-admin/ejbs/src/main/java/org/meveo/persistence/impl/Neo4jStorageImpl.java index b4920ead6..ce1fb0ffa 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/persistence/impl/Neo4jStorageImpl.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/persistence/impl/Neo4jStorageImpl.java @@ -51,6 +51,7 @@ import org.neo4j.driver.v1.Transaction; import org.neo4j.driver.v1.exceptions.NoSuchRecordException; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @RequestScoped public class Neo4jStorageImpl implements StorageImpl { @@ -79,8 +80,7 @@ public class Neo4jStorageImpl implements StorageImpl { @Inject private CustomFieldTemplateService cftService; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(Neo4jStorageImpl.class); @Override public String findEntityIdByValues(Repository repository, CustomEntityInstance cei) { diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/persistence/impl/SQLStorageImpl.java b/meveo-admin/ejbs/src/main/java/org/meveo/persistence/impl/SQLStorageImpl.java index 4ae6b4c62..ace6de13a 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/persistence/impl/SQLStorageImpl.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/persistence/impl/SQLStorageImpl.java @@ -15,7 +15,6 @@ import java.util.stream.Collectors; import javax.annotation.PreDestroy; -import javax.enterprise.context.RequestScoped; import javax.enterprise.event.Event; import javax.inject.Inject; import javax.naming.InitialContext; @@ -27,7 +26,6 @@ import javax.transaction.SystemException; import javax.transaction.UserTransaction; -import org.apache.commons.collections.CollectionUtils; import org.meveo.admin.exception.BusinessException; import org.meveo.admin.util.pagination.PaginationConfiguration; import org.meveo.api.exception.BusinessApiException; @@ -36,7 +34,6 @@ import org.meveo.event.qualifier.Created; import org.meveo.event.qualifier.Updated; import org.meveo.model.crm.CustomFieldTemplate; -import org.meveo.model.crm.custom.CustomFieldStorageTypeEnum; import org.meveo.model.crm.custom.CustomFieldTypeEnum; import org.meveo.model.crm.custom.CustomFieldValues; import org.meveo.model.customEntities.CustomEntityInstance; @@ -61,8 +58,7 @@ import org.meveo.service.storage.FileSystemService; import org.meveo.util.PersistenceUtils; import org.slf4j.Logger; - -import liquibase.pro.packaged.S; +import org.slf4j.LoggerFactory; @RequestScoped public class SQLStorageImpl implements StorageImpl { @@ -74,8 +70,7 @@ public class SQLStorageImpl implements StorageImpl { @Inject private SQLConnectionProvider sqlConnectionProvider; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(SQLStorageImpl.class); @Inject private CustomTableRelationService customTableRelationService; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/persistence/neo4j/helper/CypherHelper.java b/meveo-admin/ejbs/src/main/java/org/meveo/persistence/neo4j/helper/CypherHelper.java index 6385ecc82..e6bcc14ee 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/persistence/neo4j/helper/CypherHelper.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/persistence/neo4j/helper/CypherHelper.java @@ -27,6 +27,7 @@ import org.neo4j.driver.v1.StatementResult; import org.neo4j.driver.v1.Transaction; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class CypherHelper { @@ -36,8 +37,7 @@ public class CypherHelper { @Inject private RepositoryService repositoryService; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(CypherHelper.class); @SuppressWarnings("javadoc") public T execute( diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/persistence/neo4j/service/graphql/GraphQLService.java b/meveo-admin/ejbs/src/main/java/org/meveo/persistence/neo4j/service/graphql/GraphQLService.java index f22fdda22..61fe4ece2 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/persistence/neo4j/service/graphql/GraphQLService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/persistence/neo4j/service/graphql/GraphQLService.java @@ -62,6 +62,7 @@ import org.meveo.service.custom.CustomRelationshipTemplateService; import org.meveo.service.neo4j.Neo4jConfigurationService; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.fasterxml.jackson.core.type.TypeReference; @@ -72,8 +73,7 @@ public class GraphQLService { @Inject private Neo4jDao neo4jDao; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(GraphQLService.class); @Inject private CustomEntityTemplateService customEntityTemplateService; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/persistence/sql/SQLConnectionProvider.java b/meveo-admin/ejbs/src/main/java/org/meveo/persistence/sql/SQLConnectionProvider.java index fb0743530..d697719b4 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/persistence/sql/SQLConnectionProvider.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/persistence/sql/SQLConnectionProvider.java @@ -30,6 +30,7 @@ import org.meveo.model.sql.SqlConfiguration; import org.meveo.security.PasswordUtils; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author Edward P. Legaspi | czetsuya@gmail.com @@ -48,8 +49,7 @@ public class SQLConnectionProvider { @PersistenceUnit(unitName = "MeveoAdmin") private EntityManagerFactory emf; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(SQLConnectionProvider.class); private SqlConfiguration defaultSqlConfiguration = new SqlConfiguration(); private static final Map configurationMap = new ConcurrentHashMap<>(); diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/persistence/sql/SqlConfigurationService.java b/meveo-admin/ejbs/src/main/java/org/meveo/persistence/sql/SqlConfigurationService.java index b65f57642..093e90d49 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/persistence/sql/SqlConfigurationService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/persistence/sql/SqlConfigurationService.java @@ -36,6 +36,8 @@ import org.meveo.service.custom.CustomEntityTemplateService; import org.meveo.service.custom.CustomRelationshipTemplateService; import org.meveo.service.custom.CustomTableCreatorService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author Edward P. Legaspi | czetsuya@gmail.com @@ -45,6 +47,8 @@ @Stateless public class SqlConfigurationService extends BusinessService { + private static Logger log = LoggerFactory.getLogger(SqlConfigurationService.class); + @Inject private SQLConnectionProvider sqlConnectionProvider; @@ -339,4 +343,9 @@ private void setDbSchema(SqlConfiguration entity) { } } } + + @Override + public Logger getLogger() { + return log; + } } diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/admin/impl/GenericModuleService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/admin/impl/GenericModuleService.java index 06e497777..f1fdf6e3f 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/admin/impl/GenericModuleService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/admin/impl/GenericModuleService.java @@ -66,12 +66,14 @@ import org.meveo.service.script.module.ModuleScriptInterface; import org.meveo.service.script.module.ModuleScriptService; import org.meveo.service.storage.RepositoryService; - -import com.github.javaparser.utils.Log; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @Stateless public class GenericModuleService extends BusinessService { + private static Logger log = LoggerFactory.getLogger(GenericModuleService.class); + @Inject private CustomFieldTemplateService customFieldTemplateService; @@ -483,4 +485,9 @@ public List listInstalled() { } } + @Override + public Logger getLogger() { + return log; + } + } \ No newline at end of file diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/admin/impl/MeveoModuleHelper.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/admin/impl/MeveoModuleHelper.java index 35e148849..abcb082f1 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/admin/impl/MeveoModuleHelper.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/admin/impl/MeveoModuleHelper.java @@ -3,7 +3,6 @@ */ package org.meveo.service.admin.impl; -import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @@ -12,16 +11,15 @@ import org.meveo.admin.exception.BusinessException; import org.meveo.model.BusinessEntity; import org.meveo.model.module.MeveoModule; -import org.meveo.model.module.MeveoModuleItem; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class MeveoModuleHelper { @Inject private MeveoModuleService moduleService; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(MeveoModuleHelper.class); @SuppressWarnings("unchecked") public List getEntities(MeveoModule module, Class entityClass) { diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/admin/impl/MeveoModuleService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/admin/impl/MeveoModuleService.java index 74795aabd..1e3ac2c4d 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/admin/impl/MeveoModuleService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/admin/impl/MeveoModuleService.java @@ -37,7 +37,6 @@ import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.Set; import java.util.jar.JarOutputStream; import java.util.stream.Collectors; @@ -71,7 +70,6 @@ import org.meveo.api.dto.ActionStatusEnum; import org.meveo.api.dto.BusinessEntityDto; import org.meveo.api.dto.module.MeveoModuleDto; -import org.meveo.api.dto.module.ModuleDependencyDto; import org.meveo.api.dto.module.ModuleReleaseDto; import org.meveo.api.dto.response.module.MeveoModuleDtosResponse; import org.meveo.api.exception.EntityDoesNotExistsException; @@ -110,6 +108,8 @@ import org.meveo.service.job.JobExecutionService; import org.meveo.service.job.JobInstanceService; import org.meveo.service.script.ScriptInstanceService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * EJB for managing MeveoModule entities @@ -120,6 +120,8 @@ @Stateless public class MeveoModuleService extends GenericModuleService { + private static Logger log = LoggerFactory.getLogger(MeveoModuleService.class); + @Inject private MeveoInstanceService meveoInstanceService; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/admin/impl/ModuleObserver.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/admin/impl/ModuleObserver.java index 8f578c0aa..fc00c2f4c 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/admin/impl/ModuleObserver.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/admin/impl/ModuleObserver.java @@ -26,6 +26,7 @@ import org.meveo.service.base.BusinessService; import org.meveo.service.base.BusinessServiceFinder; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @RequestScoped public class ModuleObserver { @@ -33,8 +34,7 @@ public class ModuleObserver { @PersistenceUnit(unitName = "MeveoAdmin") private EntityManagerFactory emf; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(ModuleObserver.class); @SuppressWarnings({ "rawtypes", "unchecked" }) @Transactional(value = TxType.REQUIRES_NEW) diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/admin/impl/PermissionService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/admin/impl/PermissionService.java index 5c1b7bb5b..945fb7097 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/admin/impl/PermissionService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/admin/impl/PermissionService.java @@ -32,6 +32,8 @@ import org.meveo.model.security.Permission; import org.meveo.model.security.Role; import org.meveo.service.base.PersistenceService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author Edward P. Legaspi @@ -40,6 +42,8 @@ @Stateless public class PermissionService extends PersistenceService { + private static Logger log = LoggerFactory.getLogger(PermissionService.class); + @Inject private RoleService roleService; @@ -112,6 +116,11 @@ public Permission createIfAbsent(String permission, String... rolesToAddTo) thro return permissionEntity; } + + @Override + public Logger getLogger() { + return log; + } } diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/admin/impl/RoleService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/admin/impl/RoleService.java index 1ea1517ea..cf73ee239 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/admin/impl/RoleService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/admin/impl/RoleService.java @@ -33,6 +33,9 @@ import org.meveo.model.security.Role; import org.meveo.security.keycloak.CurrentUserProvider; import org.meveo.service.base.PersistenceService; +import org.meveo.service.custom.CustomEntityTemplateService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * User Role service implementation. @@ -40,6 +43,8 @@ @Stateless public class RoleService extends PersistenceService { + private static Logger log = LoggerFactory.getLogger(RoleService.class); + @Inject private CurrentUserProvider currentUserProvider; @@ -93,4 +98,9 @@ public void remove(Role role) throws BusinessException { clusterEventPublisher.publishEvent(role, CrudActionEnum.remove); } + + @Override + public Logger getLogger() { + return log; + } } \ No newline at end of file diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/admin/impl/UserService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/admin/impl/UserService.java index 31e45aa36..f8cff6ad2 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/admin/impl/UserService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/admin/impl/UserService.java @@ -41,8 +41,11 @@ import org.meveo.model.security.Role; import org.meveo.model.storage.Repository; import org.meveo.service.base.PersistenceService; +import org.meveo.service.custom.CustomEntityTemplateService; import org.meveo.service.hierarchy.impl.UserHierarchyLevelService; import org.meveo.service.storage.RepositoryService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * User service implementation. @@ -56,6 +59,8 @@ public class UserService extends PersistenceService { static User systemUser = null; + private static Logger log = LoggerFactory.getLogger(UserService.class); + @Inject private UserHierarchyLevelService userHierarchyLevelService; @@ -286,4 +291,9 @@ public List findAssignedRepositories(UserHierarchyLevel rootNode) { List userLevels = userHierarchyLevelService.buildHierarchy(rootNode); return repositoryService.findByUserHierarchyLevels(userLevels); } + + @Override + public Logger getLogger() { + return log; + } } diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/api/EntityToDtoConverter.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/api/EntityToDtoConverter.java index 08cf71a38..40d56b862 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/api/EntityToDtoConverter.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/api/EntityToDtoConverter.java @@ -33,12 +33,12 @@ import org.meveo.service.custom.CustomEntityInstanceService; import org.meveo.util.ApplicationProvider; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @Stateless public class EntityToDtoConverter { - @Inject - private Logger logger; + private static Logger logger = LoggerFactory.getLogger(EntityToDtoConverter.class); @Inject private CustomFieldTemplateService customFieldTemplateService; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/base/BaseService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/base/BaseService.java index 78eaa952d..b91b34297 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/base/BaseService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/base/BaseService.java @@ -35,7 +35,7 @@ public abstract class BaseService { private static final Random RANDOM = new Random(); - + @Inject @CurrentUser protected MeveoUser currentUser; @@ -44,8 +44,6 @@ public abstract class BaseService { @ApplicationProvider protected Provider appProvider; - protected Logger log = LoggerFactory.getLogger(getClass()); - @Inject @Default private BeanManager beanManager; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/base/BusinessService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/base/BusinessService.java index 188bb8f7e..1c009c7e7 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/base/BusinessService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/base/BusinessService.java @@ -21,7 +21,6 @@ import java.io.File; import java.io.IOException; -import java.nio.file.Files; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -61,6 +60,8 @@ import org.meveo.service.git.GitHelper; import org.meveo.service.git.GitRepositoryService; import org.meveo.service.git.MeveoRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author phung @@ -116,7 +117,7 @@ public P findByCode(String code) { // try { // return query.getSingleResult(); // } catch (NoResultException e) { -// log.debug("No {} of code {} found", getEntityClass().getSimpleName(), code); +// getLogger().debug("No {} of code {} found", getEntityClass().getSimpleName(), code); // return null; // } } @@ -164,10 +165,10 @@ protected P findByCode(String code, List fetchFields, String additionalS return (P) qb.getQuery(getEntityManager()).getSingleResult(); } catch (NoResultException e) { - log.debug("No {} of code {} found", getEntityClass().getSimpleName(), code); + getLogger().debug("No {} of code {} found", getEntityClass().getSimpleName(), code); return null; } catch (NonUniqueResultException e) { - log.error("More than one entity of type {} with code {} found. A first entry is returned.", entityClass, code); + getLogger().error("More than one entity of type {} with code {} found. A first entry is returned.", entityClass, code); return (P) qb.getQuery(getEntityManager()).getResultList().get(0); } } @@ -219,10 +220,10 @@ public BusinessEntity findByEntityClassAndCode(Class clazz, String code) { try { return (BusinessEntity) qb.getQuery(getEntityManager()).getSingleResult(); } catch (NoResultException e) { - log.debug("No {} of code {} found", getEntityClass().getSimpleName(), code); + getLogger().debug("No {} of code {} found", getEntityClass().getSimpleName(), code); return null; } catch (NonUniqueResultException e) { - log.error("More than one entity of type {} with code {} found", entityClass, code); + getLogger().error("More than one entity of type {} with code {} found", entityClass, code); return null; } } @@ -325,7 +326,7 @@ public void afterUpdateOrCreate(P entity) throws BusinessException { if(module != null && entity.getClass().getAnnotation(ModuleItem.class) != null) { addFilesToModule(entity, module); } else if (module != null) { - log.info("Ignore module file, as this entity is not a moduleItem " + entity.getClass()); + getLogger().info("Ignore module file, as this entity is not a moduleItem " + entity.getClass()); } } @@ -356,7 +357,7 @@ public void addFilesToModule(P entity, MeveoModule module) throws BusinessExcept try { message+=" "+commitMessageBean.getCommitMessage(); } catch (ContextNotActiveException e) { - log.warn("No active session found for getting commit message when "+message+" to "+module.getCode()); + getLogger().warn("No active session found for getting commit message when "+message+" to "+module.getCode()); } gitClient.commitFiles(gitRepository, Collections.singletonList(newDir), message); } diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/base/NativePersistenceService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/base/NativePersistenceService.java index d1e972239..06921bf77 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/base/NativePersistenceService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/base/NativePersistenceService.java @@ -89,7 +89,6 @@ import org.meveo.model.sql.SqlConfiguration; import org.meveo.model.transformer.AliasToEntityOrderedMapResultTransformer; import org.meveo.persistence.CrossStorageTransaction; -import org.meveo.persistence.impl.SQLStorageImpl; import org.meveo.persistence.sql.SQLConnectionProvider; import org.meveo.persistence.sql.SqlConfigurationService; import org.meveo.service.crm.impl.CustomFieldTemplateService; @@ -97,6 +96,8 @@ import org.meveo.service.custom.CustomTableService; import org.meveo.service.custom.PostgresReserverdKeywords; import org.meveo.util.MeveoParamBean; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Generic implementation that provides the default implementation for @@ -108,6 +109,8 @@ */ public class NativePersistenceService extends BaseService { + private static Logger log = LoggerFactory.getLogger(NativePersistenceService.class); + @FunctionalInterface public static interface SqlAction { void doWork(PreparedStatement ps) throws Exception; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/base/PersistenceService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/base/PersistenceService.java index 8da36cc78..474a6cce2 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/base/PersistenceService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/base/PersistenceService.java @@ -84,9 +84,10 @@ import org.meveo.model.transformer.AliasToEntityOrderedMapResultTransformer; import org.meveo.service.admin.impl.MeveoModuleItemService; import org.meveo.service.admin.impl.MeveoModuleService; -import org.meveo.service.admin.impl.ModuleInstallationContext; import org.meveo.service.base.local.IPersistenceService; import org.meveo.service.crm.impl.CustomFieldInstanceService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Generic implementation that provides the default implementation for @@ -100,7 +101,9 @@ */ public abstract class PersistenceService extends BaseService implements IPersistenceService { protected Class entityClass; - + + private static Logger DEFAULT_LOG = LoggerFactory.getLogger(PersistenceService.class); + /** * Entity list search parameter name - parameter's value contains entity class */ @@ -225,7 +228,7 @@ public Class getEntityClass() { * @return Updated entity */ public E updateNoCheck(E entity) { - log.debug("start of update {} entity (id={}) ..", entity.getClass().getSimpleName(), entity.getId()); + getLogger().debug("start of update {} entity (id={}) ..", entity.getClass().getSimpleName(), entity.getId()); updateAudit(entity); return getEntityManager().merge(entity); } @@ -236,7 +239,7 @@ public E updateNoCheck(E entity) { @Override public E findById(Long id) { - log.trace("Find {}/{} by id", entityClass.getSimpleName(), id); + getLogger().trace("Find {}/{} by id", entityClass.getSimpleName(), id); return getEntityManager().find(entityClass, id); } @@ -246,15 +249,15 @@ public E findById(Long id) { */ @Override public E findById(Long id, boolean refresh) { - log.trace("start of find {}/{} by id ..", entityClass.getSimpleName(), id); + getLogger().trace("start of find {}/{} by id ..", entityClass.getSimpleName(), id); E e = getEntityManager().find(entityClass, id); if (e != null) { if (refresh) { - log.debug("refreshing loaded entity"); + getLogger().debug("refreshing loaded entity"); getEntityManager().refresh(e); } } - log.trace("end of find {}/{} by id. Result found={}.", entityClass.getSimpleName(), id, e != null); + getLogger().trace("end of find {}/{} by id. Result found={}.", entityClass.getSimpleName(), id, e != null); return e; } @@ -275,7 +278,7 @@ public E findById(Long id, List fetchFields) { @Override @SuppressWarnings("unchecked") public E findById(Long id, List fetchFields, boolean refresh) { - log.debug("start of find {}/{} by id ..", getEntityClass().getSimpleName(), id); + getLogger().debug("start of find {}/{} by id ..", getEntityClass().getSimpleName(), id); final Class productClass = getEntityClass(); StringBuilder queryString = new StringBuilder("from " + productClass.getName() + " a"); if (fetchFields != null && !fetchFields.isEmpty()) { @@ -292,11 +295,11 @@ public E findById(Long id, List fetchFields, boolean refresh) { if (!results.isEmpty()) { e = results.get(0); if (refresh) { - log.debug("refreshing loaded entity"); + getLogger().debug("refreshing loaded entity"); getEntityManager().refresh(e); } } - log.trace("end of find {}/{} by id. Result found={}.", getEntityClass().getSimpleName(), id, e != null); + getLogger().trace("end of find {}/{} by id. Result found={}.", getEntityClass().getSimpleName(), id, e != null); return e; } @@ -327,11 +330,11 @@ public void preDisable(E entity) { public E disable(E entity) throws BusinessException { if (entity instanceof EnableEntity && ((EnableEntity) entity).isActive()) { - log.debug("start of disable {} entity (id={}) ..", getEntityClass().getSimpleName(), entity.getId()); + getLogger().debug("start of disable {} entity (id={}) ..", getEntityClass().getSimpleName(), entity.getId()); preDisable(entity); entity = getEntityManager().merge(entity); postDisable(entity); - log.trace("end of disable {} entity (id={}).", entity.getClass().getSimpleName(), entity.getId()); + getLogger().trace("end of disable {} entity (id={}).", entity.getClass().getSimpleName(), entity.getId()); } return entity; } @@ -339,10 +342,10 @@ public E disable(E entity) throws BusinessException { public E disableNoMerge(E entity) throws BusinessException { if (entity instanceof EnableEntity && ((EnableEntity) entity).isActive()) { - log.debug("start of disable {} entity (id={}) ..", getEntityClass().getSimpleName(), entity.getId()); + getLogger().debug("start of disable {} entity (id={}) ..", getEntityClass().getSimpleName(), entity.getId()); preDisable(entity); postDisable(entity); - log.trace("end of disable {} entity (id={}).", entity.getClass().getSimpleName(), entity.getId()); + getLogger().trace("end of disable {} entity (id={}).", entity.getClass().getSimpleName(), entity.getId()); } return entity; } @@ -374,13 +377,13 @@ public E enable(Long id) throws BusinessException { @Override public E enable(E entity) throws BusinessException { if (entity instanceof EnableEntity && ((EnableEntity) entity).isDisabled()) { - log.debug("start of enable {} entity (id={}) ..", getEntityClass().getSimpleName(), entity.getId()); + getLogger().debug("start of enable {} entity (id={}) ..", getEntityClass().getSimpleName(), entity.getId()); ((EnableEntity) entity).setDisabled(false); ((IAuditable) entity).updateAudit(currentUser); if (entity instanceof BaseEntity && entity.getClass().isAnnotationPresent(ObservableEntity.class)) { entityEnabledEventProducer.fire((BaseEntity) entity); } - log.trace("end of enable {} entity (id={}).", entity.getClass().getSimpleName(), entity.getId()); + getLogger().trace("end of enable {} entity (id={}).", entity.getClass().getSimpleName(), entity.getId()); } return entity; } @@ -389,7 +392,7 @@ public E enable(E entity) throws BusinessException { @Override public void remove(E entity) throws BusinessException { - log.debug("start of remove {} entity (id={}) ..", getEntityClass().getSimpleName(), entity.getId()); + getLogger().debug("start of remove {} entity (id={}) ..", getEntityClass().getSimpleName(), entity.getId()); entity = findById((Long) entity.getId()); if (entity != null) { @@ -425,12 +428,12 @@ public void remove(E entity) throws BusinessException { ImageUploadEventHandler imageUploadEventHandler = new ImageUploadEventHandler<>(currentUser.getProviderCode()); imageUploadEventHandler.deleteImage(entity); } catch (IOException e) { - log.error("Failed deleting image file"); + getLogger().error("Failed deleting image file"); } } } - log.trace("end of remove {} entity (id={}).", getEntityClass().getSimpleName(), entity != null ? entity.getId() : ""); + getLogger().trace("end of remove {} entity (id={}).", getEntityClass().getSimpleName(), entity != null ? entity.getId() : ""); } /** @@ -496,7 +499,7 @@ public E update(E entity) throws BusinessException { @Override public E update(E entity, boolean asyncEvent) throws BusinessException { - log.debug("start of update {} entity (id={}) ..", entity.getClass().getSimpleName(), entity.getId()); + getLogger().debug("start of update {} entity (id={}) ..", entity.getClass().getSimpleName(), entity.getId()); preUpdate(entity, asyncEvent); @@ -514,14 +517,14 @@ public E update(E entity, boolean asyncEvent) throws BusinessException { afterUpdateOrCreate(entity); - log.trace("end of update {} entity (id={}).", entity.getClass().getSimpleName(), entity.getId()); + getLogger().trace("end of update {} entity (id={}).", entity.getClass().getSimpleName(), entity.getId()); return entity; } public E updateNoMerge(E entity) throws BusinessException { - log.debug("start of update {} entity (id={}) ..", entity.getClass().getSimpleName(), entity.getId()); + getLogger().debug("start of update {} entity (id={}) ..", entity.getClass().getSimpleName(), entity.getId()); preUpdate(entity); @@ -529,7 +532,7 @@ public E updateNoMerge(E entity) throws BusinessException { afterUpdateOrCreate(entity); - log.trace("end of update {} entity (id={}).", entity.getClass().getSimpleName(), entity.getId()); + getLogger().trace("end of update {} entity (id={}).", entity.getClass().getSimpleName(), entity.getId()); return entity; } @@ -543,7 +546,7 @@ protected void postUpdate(E entity) { */ @Override public void create(E entity) throws BusinessException { - log.debug("Start creation of entity {}", entity.getClass().getSimpleName()); + getLogger().debug("Start creation of entity {}", entity.getClass().getSimpleName()); beforeUpdateOrCreate(entity); @@ -570,7 +573,7 @@ public void create(E entity) throws BusinessException { afterUpdateOrCreate(entity); - log.trace("end of create {}. entity id={}.", entity.getClass().getSimpleName(), entity.getId()); + getLogger().trace("end of create {}. entity id={}.", entity.getClass().getSimpleName(), entity.getId()); } /** @@ -697,7 +700,7 @@ public E refreshOrRetrieve(E entity) { } if (getEntityManager().contains(entity)) { - log.trace("Entity {}/{} will be refreshed) ..", getEntityClass().getSimpleName(), entity.getId()); + getLogger().trace("Entity {}/{} will be refreshed) ..", getEntityClass().getSimpleName(), entity.getId()); getEntityManager().refresh(entity); return entity; } else { @@ -1040,7 +1043,7 @@ public QueryBuilder getQuery(PaginationConfiguration config) { try { classes.add(Class.forName((String) classNameOrClass)); } catch (ClassNotFoundException e) { - log.error("Search by a type will be ignored - unknown class {}", classNameOrClass); + getLogger().error("Search by a type will be ignored - unknown class {}", classNameOrClass); } } } @@ -1066,7 +1069,7 @@ public QueryBuilder getQuery(PaginationConfiguration config) { queryBuilder.addSqlCriterion("type(a) != :typeClass", "typeClass", Class.forName((String) filterValue)); } } catch (ClassNotFoundException e) { - log.error("Search by a type will be ignored - unknown class {}", filterValue); + getLogger().error("Search by a type will be ignored - unknown class {}", filterValue); } } @@ -1357,5 +1360,9 @@ public E refreshDetached(E entity) { public E findByCode(String code) { throw new UnsupportedOperationException(); } + + public Logger getLogger() { + return DEFAULT_LOG; + } } \ No newline at end of file diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/billing/impl/CounterInstanceService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/billing/impl/CounterInstanceService.java index ee3dfe962..526e44dab 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/billing/impl/CounterInstanceService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/billing/impl/CounterInstanceService.java @@ -18,6 +18,21 @@ */ package org.meveo.service.billing.impl; +import java.math.BigDecimal; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.ejb.Stateless; +import javax.ejb.TransactionAttribute; +import javax.ejb.TransactionAttributeType; +import javax.inject.Inject; +import javax.persistence.EntityManager; +import javax.persistence.NoResultException; +import javax.persistence.Query; +import javax.persistence.TemporalType; + import org.meveo.admin.exception.BusinessException; import org.meveo.commons.utils.QueryBuilder; import org.meveo.commons.utils.StringUtils; @@ -30,25 +45,15 @@ import org.meveo.model.catalog.CounterTemplate; import org.meveo.model.catalog.CounterTypeEnum; import org.meveo.model.notification.Notification; -import org.meveo.service.base.PersistenceService; import org.meveo.service.base.MeveoValueExpressionWrapper; - -import javax.ejb.Stateless; -import javax.ejb.TransactionAttribute; -import javax.ejb.TransactionAttributeType; -import javax.inject.Inject; -import javax.persistence.EntityManager; -import javax.persistence.NoResultException; -import javax.persistence.Query; -import javax.persistence.TemporalType; -import java.math.BigDecimal; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import org.meveo.service.base.PersistenceService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @Stateless public class CounterInstanceService extends PersistenceService { + + private static Logger log = LoggerFactory.getLogger(CounterInstanceService.class); @Inject private CounterPeriodService counterPeriodService; @@ -395,4 +400,9 @@ public BigDecimal incrementCounterValue(Long periodId, BigDecimal incrementBy) t return counterPeriod.getValue(); } } + + @Override + public Logger getLogger() { + return log; + } } \ No newline at end of file diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/communication/impl/MeveoInstanceService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/communication/impl/MeveoInstanceService.java index 684d9146b..60e18ca4e 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/communication/impl/MeveoInstanceService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/communication/impl/MeveoInstanceService.java @@ -26,6 +26,7 @@ import javax.ws.rs.client.Entity; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; + import org.apache.commons.httpclient.util.HttpURLConnection; import org.apache.http.conn.ssl.TrustSelfSignedStrategy; import org.apache.http.ssl.SSLContextBuilder; @@ -43,6 +44,8 @@ import org.meveo.model.communication.MeveoInstance; import org.meveo.security.PasswordUtils; import org.meveo.service.base.BusinessService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * MeveoInstance service implementation. @@ -53,6 +56,8 @@ @Stateless public class MeveoInstanceService extends BusinessService { + private static Logger log = LoggerFactory.getLogger(MeveoInstanceService.class); + @Inject private Event event; @@ -208,4 +213,9 @@ public Response getRemoteRepositories(String url, MeveoInstance meveoInstance) t throw new BusinessException("Failed to communicate " + meveoInstance.getCode() + ". Error " + e.getMessage()); } } + + @Override + public Logger getLogger() { + return log; + } } diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/communication/impl/SseManager.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/communication/impl/SseManager.java index 314ec9784..eda7e50f7 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/communication/impl/SseManager.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/communication/impl/SseManager.java @@ -26,6 +26,7 @@ import org.meveo.service.base.MeveoValueExpressionWrapper; import org.meveo.service.notification.WebNotificationService; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This class allow web client to subscribe to WebNotifications and publish @@ -35,8 +36,7 @@ @Singleton public class SseManager { - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(SseManager.class); @Inject private WebNotificationService webNotificationService; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/communication/impl/WebsocketNotifManager.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/communication/impl/WebsocketNotifManager.java index 7293392a6..99ff1531c 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/communication/impl/WebsocketNotifManager.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/communication/impl/WebsocketNotifManager.java @@ -1,172 +1,173 @@ -package org.meveo.service.communication.impl; - -import java.io.IOException; -import java.security.Principal; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import javax.ejb.Singleton; -import javax.inject.Inject; -import javax.websocket.CloseReason; -import javax.websocket.EndpointConfig; -import javax.websocket.OnClose; -import javax.websocket.OnError; -import javax.websocket.OnMessage; -import javax.websocket.OnOpen; -import javax.websocket.Session; -import javax.websocket.CloseReason.CloseCodes; -import javax.websocket.server.PathParam; -import javax.websocket.server.ServerEndpoint; - -import org.meveo.model.notification.WebNotification; -import org.meveo.service.base.MeveoValueExpressionWrapper; -import org.meveo.service.notification.WebNotificationService; -import org.slf4j.Logger; - -@ServerEndpoint("/wsnotif/{notif-name}") -@Singleton -public class WebsocketNotifManager { - - @Inject - private Logger log; - - @Inject - private WebNotificationService webNotificationService; - - private Map> notifSessions = new ConcurrentHashMap<>(); - - @OnMessage - public String onMessage(Session session, String message) { - Map context = new HashMap<>(); - context.put("PUBLICATION_MESSAGE", message); - context.put("PUBLICATION_AUTHOR", session.getUserProperties().get("username")); - sendMessage("", (String) session.getUserProperties().get("notifname"), message, context); - return "message sent"; - } - - @OnOpen - public void onOpen(Session session, EndpointConfig config, @PathParam("notif-name") String notifName) { - try { - String username = null; - Principal principal = session.getUserPrincipal(); - if (principal != null) { - username = principal.getName(); - } - if (notifName == null) { - throw new IllegalStateException("No web notification name set."); - } - WebNotification webNotification = webNotificationService.findByCode(notifName); - if (webNotification == null) { - throw new IllegalStateException("web notification not found."); - } - if (!webNotification.isActive()) { - throw new IllegalStateException("web notification not active."); - } - - List sessions = notifSessions.get(notifName); - if (sessions == null) { - sessions = new ArrayList<>(); - notifSessions.put(webNotification.getCode(), sessions); - } - String filterEL = null; - if (session.getRequestParameterMap().containsKey("filter")) { - filterEL = session.getRequestParameterMap().get("filter").get(0); - session.getUserProperties().put("filterEL", filterEL); - } - session.getUserProperties().put("username", username); - session.getUserProperties().put("notifname", notifName); - sessions.add(session); - log.info("username={} notif={} with session={} has been successfully registered", username, notifName, - session.getId()); - } catch (Exception e) { - try { - session.close(new CloseReason(CloseCodes.UNEXPECTED_CONDITION, e.getMessage())); - } catch (IOException ex) { - log.error("error while trying to close the websocket", ex); - throw new RuntimeException(e); - } - } - } - - private void removeSession(Session session) { - String notifName = (String) session.getUserProperties().get("notifname"); - List sessions = notifSessions.get(notifName); - if (sessions != null && sessions.contains(session)) { - sessions.remove(session); - } - } - - @OnClose - public void onClose(Session session, CloseReason reason) { - log.info("WebSocket connection closed with CloseCode: " + reason.getCloseCode()); - removeSession(session); - } - - @OnError - public void error(Session session, Throwable t) { - log.error("error in session {} : {}", session.getId(), t.getMessage()); - removeSession(session); - } - - public void sendMessage(String id, String name, String data, Map context) { - List sessions = notifSessions.get(name); - List listeningSessions = new ArrayList<>(); - List sessionsToRemove = new ArrayList<>(); - for (Session session : sessions) { - if (session.isOpen()) { - if (session.getUserProperties().get("filterEL") == null - || ((String) session.getUserProperties().get("filterEL")).isEmpty()) { - listeningSessions.add(session); - } else { - try { - Object res = MeveoValueExpressionWrapper.evaluateExpression( - (String) session.getUserProperties().get("filterEL"), context, Boolean.class); - boolean result = (Boolean) res; - if (result) { - listeningSessions.add(session); - } - - } catch (Exception e) { - throw new IllegalStateException("Expression " + session.getUserProperties().get("filterEL") - + " do not evaluate to boolean"); - } - } - } else { - sessionsToRemove.add(session); - } - } - if (listeningSessions.size() > 0) { - String txtMessage = "{\"id\":\"" + id + "\",\"name\":\"" + name + "\",\"data\":\"" + data + "\"}"; - for (Session session : listeningSessions) { - if (session.isOpen()) { - session.getAsyncRemote().sendText(txtMessage); - } else { - sessionsToRemove.add(session); - } - } - } - if (sessionsToRemove.size() > 0) { - sessions.removeAll(sessionsToRemove); - } - } - - public void removeNotification(String notificationCode) { - List sessions = notifSessions.get(notificationCode); - if (sessions == null) { - log.debug("remove notification: no one was listening"); - return; - } - - for (Session session : sessions) { - try { - session.close(); - } catch (IOException e) { - log.debug("exception while closing websocket :{}", e.getMessage()); - } - } - notifSessions.remove(notificationCode); - } -} +package org.meveo.service.communication.impl; + +import java.io.IOException; +import java.security.Principal; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import javax.ejb.Singleton; +import javax.inject.Inject; +import javax.websocket.CloseReason; +import javax.websocket.CloseReason.CloseCodes; +import javax.websocket.EndpointConfig; +import javax.websocket.OnClose; +import javax.websocket.OnError; +import javax.websocket.OnMessage; +import javax.websocket.OnOpen; +import javax.websocket.Session; +import javax.websocket.server.PathParam; +import javax.websocket.server.ServerEndpoint; + +import org.meveo.model.notification.WebNotification; +import org.meveo.service.base.MeveoValueExpressionWrapper; +import org.meveo.service.notification.WebNotificationService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@ServerEndpoint("/wsnotif/{notif-name}") +@Singleton +public class WebsocketNotifManager { + + @Inject + private static Logger log = LoggerFactory.getLogger(WebsocketNotifManager.class); + + @Inject + private WebNotificationService webNotificationService; + + private Map> notifSessions = new ConcurrentHashMap<>(); + + @OnMessage + public String onMessage(Session session, String message) { + Map context = new HashMap<>(); + context.put("PUBLICATION_MESSAGE", message); + context.put("PUBLICATION_AUTHOR", session.getUserProperties().get("username")); + sendMessage("", (String) session.getUserProperties().get("notifname"), message, context); + return "message sent"; + } + + @OnOpen + public void onOpen(Session session, EndpointConfig config, @PathParam("notif-name") String notifName) { + try { + String username = null; + Principal principal = session.getUserPrincipal(); + if (principal != null) { + username = principal.getName(); + } + if (notifName == null) { + throw new IllegalStateException("No web notification name set."); + } + WebNotification webNotification = webNotificationService.findByCode(notifName); + if (webNotification == null) { + throw new IllegalStateException("web notification not found."); + } + if (!webNotification.isActive()) { + throw new IllegalStateException("web notification not active."); + } + + List sessions = notifSessions.get(notifName); + if (sessions == null) { + sessions = new ArrayList<>(); + notifSessions.put(webNotification.getCode(), sessions); + } + String filterEL = null; + if (session.getRequestParameterMap().containsKey("filter")) { + filterEL = session.getRequestParameterMap().get("filter").get(0); + session.getUserProperties().put("filterEL", filterEL); + } + session.getUserProperties().put("username", username); + session.getUserProperties().put("notifname", notifName); + sessions.add(session); + log.info("username={} notif={} with session={} has been successfully registered", username, notifName, + session.getId()); + } catch (Exception e) { + try { + session.close(new CloseReason(CloseCodes.UNEXPECTED_CONDITION, e.getMessage())); + } catch (IOException ex) { + log.error("error while trying to close the websocket", ex); + throw new RuntimeException(e); + } + } + } + + private void removeSession(Session session) { + String notifName = (String) session.getUserProperties().get("notifname"); + List sessions = notifSessions.get(notifName); + if (sessions != null && sessions.contains(session)) { + sessions.remove(session); + } + } + + @OnClose + public void onClose(Session session, CloseReason reason) { + log.info("WebSocket connection closed with CloseCode: " + reason.getCloseCode()); + removeSession(session); + } + + @OnError + public void error(Session session, Throwable t) { + log.error("error in session {} : {}", session.getId(), t.getMessage()); + removeSession(session); + } + + public void sendMessage(String id, String name, String data, Map context) { + List sessions = notifSessions.get(name); + List listeningSessions = new ArrayList<>(); + List sessionsToRemove = new ArrayList<>(); + for (Session session : sessions) { + if (session.isOpen()) { + if (session.getUserProperties().get("filterEL") == null + || ((String) session.getUserProperties().get("filterEL")).isEmpty()) { + listeningSessions.add(session); + } else { + try { + Object res = MeveoValueExpressionWrapper.evaluateExpression( + (String) session.getUserProperties().get("filterEL"), context, Boolean.class); + boolean result = (Boolean) res; + if (result) { + listeningSessions.add(session); + } + + } catch (Exception e) { + throw new IllegalStateException("Expression " + session.getUserProperties().get("filterEL") + + " do not evaluate to boolean"); + } + } + } else { + sessionsToRemove.add(session); + } + } + if (listeningSessions.size() > 0) { + String txtMessage = "{\"id\":\"" + id + "\",\"name\":\"" + name + "\",\"data\":\"" + data + "\"}"; + for (Session session : listeningSessions) { + if (session.isOpen()) { + session.getAsyncRemote().sendText(txtMessage); + } else { + sessionsToRemove.add(session); + } + } + } + if (sessionsToRemove.size() > 0) { + sessions.removeAll(sessionsToRemove); + } + } + + public void removeNotification(String notificationCode) { + List sessions = notifSessions.get(notificationCode); + if (sessions == null) { + log.debug("remove notification: no one was listening"); + return; + } + + for (Session session : sessions) { + try { + session.close(); + } catch (IOException e) { + log.debug("exception while closing websocket :{}", e.getMessage()); + } + } + notifSessions.remove(notificationCode); + } +} diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/config/impl/MavenConfigurationService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/config/impl/MavenConfigurationService.java index 4bcebbc70..6faf01083 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/config/impl/MavenConfigurationService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/config/impl/MavenConfigurationService.java @@ -1,7 +1,6 @@ package org.meveo.service.config.impl; import java.io.File; -import java.io.FileWriter; import java.io.IOException; import java.io.Serializable; import java.nio.file.Files; @@ -80,6 +79,7 @@ import org.meveo.service.storage.RemoteRepositoryService; import org.meveo.util.Version; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Manage the maven configuration. @@ -124,8 +124,7 @@ public class MavenConfigurationService implements Serializable { @Inject private GitRepositoryService gitRepositoryService; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(MavenConfigurationService.class); @Inject private RemoteRepositoryService remoteRepositoryService; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/crm/impl/CustomFieldInstanceService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/crm/impl/CustomFieldInstanceService.java index 1d2827666..a8f55ce61 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/crm/impl/CustomFieldInstanceService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/crm/impl/CustomFieldInstanceService.java @@ -3,13 +3,28 @@ import java.math.BigDecimal; import java.math.BigInteger; import java.time.Instant; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; import java.util.Map.Entry; -import java.util.stream.Collectors; +import java.util.Optional; +import java.util.Set; import javax.annotation.Resource; -import javax.ejb.*; +import javax.ejb.Stateless; +import javax.ejb.Timeout; import javax.ejb.Timer; +import javax.ejb.TimerConfig; +import javax.ejb.TimerService; +import javax.ejb.TransactionAttribute; +import javax.ejb.TransactionAttributeType; import javax.enterprise.context.Conversation; import javax.enterprise.event.Event; import javax.inject.Inject; @@ -18,7 +33,6 @@ import org.apache.commons.lang3.StringUtils; import org.meveo.admin.exception.BusinessException; -import org.meveo.admin.util.pagination.PaginationConfiguration; import org.meveo.api.exception.EntityDoesNotExistsException; import org.meveo.api.persistence.CrossStorageApi; import org.meveo.commons.utils.JpaUtils; @@ -26,7 +40,11 @@ import org.meveo.event.CFEndPeriodEvent; import org.meveo.jpa.EntityManagerWrapper; import org.meveo.jpa.MeveoJpa; -import org.meveo.model.*; +import org.meveo.model.BaseEntity; +import org.meveo.model.BusinessEntity; +import org.meveo.model.DatePeriod; +import org.meveo.model.ICustomFieldEntity; +import org.meveo.model.IEntity; import org.meveo.model.admin.User; import org.meveo.model.crm.CustomFieldTemplate; import org.meveo.model.crm.EntityReferenceWrapper; @@ -40,7 +58,6 @@ import org.meveo.model.customEntities.CustomEntityTemplate; import org.meveo.model.persistence.DBStorageType; import org.meveo.model.persistence.JacksonUtil; -import org.meveo.model.sql.SqlConfiguration; import org.meveo.model.storage.Repository; import org.meveo.model.util.CustomFieldUtils; import org.meveo.persistence.CrossStorageService; @@ -53,6 +70,8 @@ import org.meveo.service.custom.CustomTableService; import org.meveo.service.storage.RepositoryService; import org.meveo.util.PersistenceUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -65,6 +84,8 @@ */ @Stateless public class CustomFieldInstanceService extends BaseService { + + private static Logger log = LoggerFactory.getLogger(CustomFieldInstanceService.class); @Inject private CustomFieldTemplateService cfTemplateService; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/crm/impl/CustomFieldTemplateService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/crm/impl/CustomFieldTemplateService.java index a28a88322..0e294d6b7 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/crm/impl/CustomFieldTemplateService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/crm/impl/CustomFieldTemplateService.java @@ -60,6 +60,8 @@ import org.meveo.service.storage.FileSystemService; import org.meveo.util.EntityCustomizationUtils; import org.meveo.util.PersistenceUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author Wassim Drira @@ -70,6 +72,8 @@ @Stateless public class CustomFieldTemplateService extends BusinessService { + private static Logger log = LoggerFactory.getLogger(CustomFieldTemplateService.class); + @Inject private CustomFieldsCacheContainerProvider customFieldsCache; @@ -849,4 +853,9 @@ public void addFilesToModule(CustomFieldTemplate entity, MeveoModule module) thr gitClient.commitFiles(gitRepository, Collections.singletonList(newDir), message); } + @Override + public Logger getLogger() { + return log; + } + } \ No newline at end of file diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/crm/impl/EmailService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/crm/impl/EmailService.java index 8e05f9574..c06cb0c08 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/crm/impl/EmailService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/crm/impl/EmailService.java @@ -46,6 +46,8 @@ import org.meveo.model.communication.MessageSenderConfig; import org.meveo.model.crm.Email; import org.meveo.service.base.PersistenceService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Email service implementation. @@ -53,6 +55,8 @@ @Stateless public class EmailService extends PersistenceService { + private static Logger log = LoggerFactory.getLogger(EmailService.class); + @Inject private MailerSessionFactory mailerSessionFactory; @@ -178,4 +182,9 @@ public HashMap> getMediaConfig() { } return result; } + + @Override + public Logger getLogger() { + return log; + } } diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/crm/impl/JSONSchemaIntoJavaClassParser.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/crm/impl/JSONSchemaIntoJavaClassParser.java index f38a53668..677c73e62 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/crm/impl/JSONSchemaIntoJavaClassParser.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/crm/impl/JSONSchemaIntoJavaClassParser.java @@ -26,6 +26,7 @@ import org.meveo.model.persistence.DBStorageType; import org.meveo.service.custom.CustomEntityTemplateService; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; @@ -60,8 +61,7 @@ public class JSONSchemaIntoJavaClassParser { @Inject private CustomFieldTemplateService customFieldService; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(JSONSchemaIntoJavaClassParser.class); private Map jsonMap; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/crm/impl/ProviderService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/crm/impl/ProviderService.java index d0ed94729..740912af4 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/crm/impl/ProviderService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/crm/impl/ProviderService.java @@ -39,6 +39,8 @@ import org.meveo.keycloak.client.KeycloakAdminClientService; import org.meveo.model.crm.Provider; import org.meveo.service.base.PersistenceService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Provider service implementation. @@ -51,6 +53,8 @@ @Stateless public class ProviderService extends PersistenceService { + private static Logger log = LoggerFactory.getLogger(ProviderService.class); + /** * The tenant registry to add or remove a new tenant. */ @@ -178,4 +182,9 @@ private void createProviderUser(Provider provider) { } } + + @Override + public Logger getLogger() { + return log; + } } \ No newline at end of file diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/crm/impl/TenantRegistry.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/crm/impl/TenantRegistry.java index 4c16ebaba..dca5dd12c 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/crm/impl/TenantRegistry.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/crm/impl/TenantRegistry.java @@ -15,6 +15,7 @@ import org.meveo.jpa.EntityManagerProvider; import org.meveo.model.crm.Provider; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Manages providers connection to DB. @@ -36,8 +37,7 @@ public class TenantRegistry { @Resource private TimerService timerService; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(TenantRegistry.class); /** * Unregister a tenant/provider. diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/CustomEntityInstanceService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/CustomEntityInstanceService.java index b9f6cde3b..e4e7a6b78 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/CustomEntityInstanceService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/CustomEntityInstanceService.java @@ -2,8 +2,6 @@ import java.io.File; import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; import java.time.Instant; import java.util.ArrayList; import java.util.Collection; @@ -19,7 +17,6 @@ import java.util.stream.Collectors; import javax.ejb.Stateless; -import javax.enterprise.event.Observes; import javax.inject.Inject; import javax.persistence.NoResultException; @@ -35,7 +32,6 @@ import org.meveo.commons.utils.QueryBuilder; import org.meveo.elresolver.ELException; import org.meveo.model.ModuleItem; -import org.meveo.model.ModulePostUninstall; import org.meveo.model.crm.CustomFieldTemplate; import org.meveo.model.crm.EntityReferenceWrapper; import org.meveo.model.crm.custom.CustomFieldValues; @@ -44,13 +40,10 @@ import org.meveo.model.module.MeveoModule; import org.meveo.model.persistence.CEIUtils; import org.meveo.model.persistence.DBStorageType; -import org.meveo.model.persistence.JacksonUtil; import org.meveo.model.sql.SqlConfiguration; import org.meveo.model.wf.WFAction; import org.meveo.model.wf.WFTransition; import org.meveo.model.wf.Workflow; -import org.meveo.service.admin.impl.MeveoModuleHelper; -import org.meveo.service.admin.impl.ModuleUninstall; import org.meveo.service.base.BusinessService; import org.meveo.service.base.MeveoValueExpressionWrapper; import org.meveo.service.crm.impl.CustomFieldInstanceService; @@ -59,6 +52,8 @@ import org.meveo.service.wf.WFActionService; import org.meveo.service.wf.WFTransitionService; import org.meveo.service.wf.WorkflowService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.ibm.icu.math.BigDecimal; @@ -71,6 +66,8 @@ @Stateless public class CustomEntityInstanceService extends BusinessService { + private static Logger log = LoggerFactory.getLogger(CustomEntityInstanceService.class); + @Inject private CustomFieldsCacheContainerProvider cetCache; @@ -519,4 +516,9 @@ public void addFilesToModule(CustomEntityInstance entity, MeveoModule module) th gitClient.commitFiles(module.getGitRepository(), Collections.singletonList(newDir), message); } + @Override + public Logger getLogger() { + return log; + } + } \ No newline at end of file diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/CustomEntityTemplateCompiler.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/CustomEntityTemplateCompiler.java index 835db9e26..e6aa25b3b 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/CustomEntityTemplateCompiler.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/CustomEntityTemplateCompiler.java @@ -1,132 +1,131 @@ -/** - * - */ -package org.meveo.service.custom; - -import java.io.File; -import java.io.IOException; -import java.nio.charset.StandardCharsets; - -import javax.inject.Inject; - -import org.apache.commons.io.FileUtils; -import org.meveo.admin.exception.BusinessException; -import org.meveo.model.ModuleItem; -import org.meveo.model.customEntities.CustomEntityTemplate; -import org.meveo.model.customEntities.CustomRelationshipTemplate; -import org.meveo.model.git.GitRepository; -import org.meveo.model.module.MeveoModule; -import org.meveo.security.CurrentUser; -import org.meveo.security.MeveoUser; -import org.meveo.service.base.BusinessService; -import org.meveo.service.base.BusinessServiceFinder; -import org.meveo.service.crm.impl.JSONSchemaGenerator; -import org.meveo.service.crm.impl.JSONSchemaIntoJavaClassParser; -import org.meveo.service.git.GitHelper; -import org.meveo.service.git.MeveoRepository; -import org.slf4j.Logger; - -import com.github.javaparser.ast.CompilationUnit; - -/** - * Service for generating and compiling CET source file - * - * @author clement.bareth - * @since 6.10.0 - * @version 6.10.0 - */ -public class CustomEntityTemplateCompiler { - - @Inject - @MeveoRepository - private GitRepository meveoRepository; - - @Inject - private BusinessServiceFinder businessServiceFinder; - - @Inject - private JSONSchemaIntoJavaClassParser jsonSchemaIntoJavaClassParser; - - @Inject - private JSONSchemaGenerator jsonSchemaGenerator; - - @Inject - @CurrentUser - private MeveoUser currentUser; - - @Inject - private CustomRelationshipTemplateService customRelationshipTemplateService; - - @Inject - private Logger log; - - public String getTemplateSchema(CustomEntityTemplate cet) { - String schema = jsonSchemaGenerator.generateSchema(cet.getCode(), cet); - return schema.replaceAll("#/definitions", "."); - } - - public String getTemplateSchema(CustomRelationshipTemplate crt) { - String schema = jsonSchemaGenerator.generateSchema(crt.getCode(), crt); - return schema.replaceAll("#/definitions", "."); - } - - /** - * Create the java source file for a given CRT - * - * @param templateSchema the json schema of the CRT - * @param cet The custom entity template - * @return the java source file - * @throws BusinessException if the file can't be written - */ - public File generateCRTSourceFile(String templateSchema, CustomRelationshipTemplate crt) throws BusinessException { - log.info("Generating source file for {}", crt); - - final File cetDirJava = customRelationshipTemplateService.getCrtDir(crt, "java"); - final CompilationUnit compilationUnit = jsonSchemaIntoJavaClassParser.parseJsonContentIntoJavaFile(templateSchema, crt); - File javaFile = new File(cetDirJava, crt.getCode() + ".java"); - if (javaFile.exists()) { - javaFile.delete(); - } - - try { - FileUtils.write(javaFile, compilationUnit.toString(), StandardCharsets.UTF_8); - } catch (IOException e) { - throw new BusinessException("Can't write to file", e); - } - - return javaFile; - } - - /** - * @return the directory where custom entity templates source files are stored - */ - @SuppressWarnings({ "rawtypes", "unchecked" }) - public File getJsonCetDir(CustomEntityTemplate cet, MeveoModule module) { - String path; - File repositoryDir; - BusinessService businessService = businessServiceFinder.find(cet); - if (module == null) { - repositoryDir = GitHelper.getRepositoryDir(currentUser, meveoRepository.getCode() + "/facets/json/"); - path = ""; - } else { - repositoryDir = GitHelper.getRepositoryDir(currentUser, module.getGitRepository().getCode() + "/facets/json/"); - path = ""; - } - return new File(repositoryDir, path); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - public File getJavaCetDir(CustomEntityTemplate cet, MeveoModule module) { - String path; - File repositoryDir; - BusinessService businessService = businessServiceFinder.find(cet); - if (module == null) { - repositoryDir = GitHelper.getRepositoryDir(currentUser, meveoRepository.getCode() + "/facets/java/"); - path = "org/meveo/model/customEntities";//+ cet.getClass().getAnnotation(ModuleItem.class).path(); - } else { - repositoryDir = GitHelper.getRepositoryDir(currentUser, module.getGitRepository().getCode() + "/facets/java"); - path = "org/meveo/model/customEntities";// + cet.getClass().getAnnotation(ModuleItem.class).path(); - } - return new File(repositoryDir, path); - } -} +/** + * + */ +package org.meveo.service.custom; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; + +import javax.inject.Inject; + +import org.apache.commons.io.FileUtils; +import org.meveo.admin.exception.BusinessException; +import org.meveo.model.customEntities.CustomEntityTemplate; +import org.meveo.model.customEntities.CustomRelationshipTemplate; +import org.meveo.model.git.GitRepository; +import org.meveo.model.module.MeveoModule; +import org.meveo.security.CurrentUser; +import org.meveo.security.MeveoUser; +import org.meveo.service.base.BusinessService; +import org.meveo.service.base.BusinessServiceFinder; +import org.meveo.service.crm.impl.JSONSchemaGenerator; +import org.meveo.service.crm.impl.JSONSchemaIntoJavaClassParser; +import org.meveo.service.git.GitHelper; +import org.meveo.service.git.MeveoRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.github.javaparser.ast.CompilationUnit; + +/** + * Service for generating and compiling CET source file + * + * @author clement.bareth + * @since 6.10.0 + * @version 6.10.0 + */ +public class CustomEntityTemplateCompiler { + + @Inject + @MeveoRepository + private GitRepository meveoRepository; + + @Inject + private BusinessServiceFinder businessServiceFinder; + + @Inject + private JSONSchemaIntoJavaClassParser jsonSchemaIntoJavaClassParser; + + @Inject + private JSONSchemaGenerator jsonSchemaGenerator; + + @Inject + @CurrentUser + private MeveoUser currentUser; + + @Inject + private CustomRelationshipTemplateService customRelationshipTemplateService; + + private static Logger log = LoggerFactory.getLogger(CustomEntityTemplateCompiler.class); + + public String getTemplateSchema(CustomEntityTemplate cet) { + String schema = jsonSchemaGenerator.generateSchema(cet.getCode(), cet); + return schema.replaceAll("#/definitions", "."); + } + + public String getTemplateSchema(CustomRelationshipTemplate crt) { + String schema = jsonSchemaGenerator.generateSchema(crt.getCode(), crt); + return schema.replaceAll("#/definitions", "."); + } + + /** + * Create the java source file for a given CRT + * + * @param templateSchema the json schema of the CRT + * @param cet The custom entity template + * @return the java source file + * @throws BusinessException if the file can't be written + */ + public File generateCRTSourceFile(String templateSchema, CustomRelationshipTemplate crt) throws BusinessException { + log.info("Generating source file for {}", crt); + + final File cetDirJava = customRelationshipTemplateService.getCrtDir(crt, "java"); + final CompilationUnit compilationUnit = jsonSchemaIntoJavaClassParser.parseJsonContentIntoJavaFile(templateSchema, crt); + File javaFile = new File(cetDirJava, crt.getCode() + ".java"); + if (javaFile.exists()) { + javaFile.delete(); + } + + try { + FileUtils.write(javaFile, compilationUnit.toString(), StandardCharsets.UTF_8); + } catch (IOException e) { + throw new BusinessException("Can't write to file", e); + } + + return javaFile; + } + + /** + * @return the directory where custom entity templates source files are stored + */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + public File getJsonCetDir(CustomEntityTemplate cet, MeveoModule module) { + String path; + File repositoryDir; + BusinessService businessService = businessServiceFinder.find(cet); + if (module == null) { + repositoryDir = GitHelper.getRepositoryDir(currentUser, meveoRepository.getCode() + "/facets/json/"); + path = ""; + } else { + repositoryDir = GitHelper.getRepositoryDir(currentUser, module.getGitRepository().getCode() + "/facets/json/"); + path = ""; + } + return new File(repositoryDir, path); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + public File getJavaCetDir(CustomEntityTemplate cet, MeveoModule module) { + String path; + File repositoryDir; + BusinessService businessService = businessServiceFinder.find(cet); + if (module == null) { + repositoryDir = GitHelper.getRepositoryDir(currentUser, meveoRepository.getCode() + "/facets/java/"); + path = "org/meveo/model/customEntities";//+ cet.getClass().getAnnotation(ModuleItem.class).path(); + } else { + repositoryDir = GitHelper.getRepositoryDir(currentUser, module.getGitRepository().getCode() + "/facets/java"); + path = "org/meveo/model/customEntities";// + cet.getClass().getAnnotation(ModuleItem.class).path(); + } + return new File(repositoryDir, path); + } +} diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/CustomEntityTemplateService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/CustomEntityTemplateService.java index 17ed14127..7b1d3c2e7 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/CustomEntityTemplateService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/CustomEntityTemplateService.java @@ -92,6 +92,8 @@ import org.meveo.service.git.MeveoRepository; import org.meveo.service.script.ScriptInstanceService; import org.meveo.util.EntityCustomizationUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.fasterxml.jackson.databind.ObjectMapper; import com.github.javaparser.ast.CompilationUnit; @@ -110,7 +112,8 @@ public class CustomEntityTemplateService extends BusinessService { + private static Logger log = LoggerFactory.getLogger(CustomRelationshipTemplateService.class); + @Inject private CustomFieldTemplateService customFieldTemplateService; @@ -476,4 +480,9 @@ protected BaseEntityDto getDto(CustomRelationshipTemplate entity) throws Busines dto.setFields(null); return dto; } + + @Override + public Logger getLogger() { + return log; + } } \ No newline at end of file diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/CustomTableCreatorService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/CustomTableCreatorService.java index 30db27683..9592756d9 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/CustomTableCreatorService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/CustomTableCreatorService.java @@ -49,9 +49,9 @@ import org.meveo.model.storage.Repository; import org.meveo.persistence.sql.SQLConnectionProvider; import org.meveo.persistence.sql.SqlConfigurationService; -import org.meveo.service.admin.impl.ModuleInstallationContext; import org.meveo.util.PersistenceUtils; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import liquibase.Contexts; import liquibase.LabelExpression; @@ -82,7 +82,6 @@ import liquibase.database.jvm.JdbcConnection; import liquibase.exception.DatabaseException; import liquibase.exception.MigrationFailedException; -import liquibase.precondition.core.NotPrecondition; import liquibase.precondition.core.PreconditionContainer; import liquibase.precondition.core.PreconditionContainer.ErrorOption; import liquibase.precondition.core.PreconditionContainer.FailOption; @@ -106,8 +105,7 @@ public class CustomTableCreatorService implements Serializable { @Inject private EntityManagerProvider entityManagerProvider; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(CustomTableCreatorService.class); @Inject private CustomEntityTemplateService customEntityTemplateService; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/CustomTableService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/CustomTableService.java index 7c3cda648..f7e52e7fc 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/CustomTableService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/CustomTableService.java @@ -68,6 +68,8 @@ import org.meveo.service.base.NativePersistenceService; import org.meveo.service.crm.impl.CustomFieldInstanceService; import org.meveo.service.crm.impl.CustomFieldTemplateService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.fasterxml.jackson.core.JsonGenerator.Feature; import com.fasterxml.jackson.databind.MappingIterator; @@ -90,6 +92,8 @@ public class CustomTableService extends NativePersistenceService { * File prefix indicating that imported data should be appended to exiting data */ public static final String FILE_APPEND = "_append"; + + private static Logger log = LoggerFactory.getLogger(CustomTableService.class); @Inject private CustomFieldTemplateService customFieldTemplateService; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/EntityCustomActionService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/EntityCustomActionService.java index e653a8921..1ccfea63f 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/EntityCustomActionService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/EntityCustomActionService.java @@ -31,10 +31,14 @@ import org.meveo.service.crm.impl.CustomFieldException; import org.meveo.service.crm.impl.CustomFieldTemplateUtils; import org.meveo.service.git.GitHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @Stateless public class EntityCustomActionService extends BusinessService { + private static Logger log = LoggerFactory.getLogger(EntityCustomActionService.class); + @Inject CommitMessageBean commitMessageBean; @@ -142,4 +146,9 @@ public void addFilesToModule(EntityCustomAction entity, MeveoModule module) thro } gitClient.commitFiles(gitRepository, Collections.singletonList(newDir), message); } + + @Override + public Logger getLogger() { + return log; + } } \ No newline at end of file diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/event/CustomEntityInstanceObserver.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/event/CustomEntityInstanceObserver.java index 505402d92..ec496fdf4 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/event/CustomEntityInstanceObserver.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/event/CustomEntityInstanceObserver.java @@ -27,6 +27,7 @@ import org.meveo.service.base.BusinessServiceFinder; import org.meveo.service.custom.CustomEntityInstanceAuditService; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author Edward P. Legaspi | czetsuya@gmail.com @@ -38,8 +39,7 @@ @Lock(LockType.READ) public class CustomEntityInstanceObserver { - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(CustomEntityInstanceObserver.class); @Inject private CustomEntityInstanceAuditService customEntityInstanceAuditService; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/event/CustomEntityTemplateObserver.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/event/CustomEntityTemplateObserver.java index ee258e86f..4cceedb4f 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/event/CustomEntityTemplateObserver.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/event/CustomEntityTemplateObserver.java @@ -24,6 +24,7 @@ import org.meveo.service.custom.CustomTableCreatorService; import org.meveo.service.storage.RepositoryService; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author Edward P. Legaspi | edward.legaspi@manaty.net @@ -35,8 +36,7 @@ @Lock(LockType.READ) public class CustomEntityTemplateObserver { - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(CustomEntityTemplateObserver.class); @Inject private CustomTableCreatorService customTableCreatorService; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/event/CustomRelationshipTemplateObserver.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/event/CustomRelationshipTemplateObserver.java index 9965bf4a1..6e8a18a25 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/event/CustomRelationshipTemplateObserver.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/custom/event/CustomRelationshipTemplateObserver.java @@ -26,6 +26,7 @@ import org.meveo.service.custom.CustomTableCreatorService; import org.meveo.service.storage.RepositoryService; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author Edward P. Legaspi | czetsuya@gmail.com @@ -37,8 +38,7 @@ @Lock(LockType.READ) public class CustomRelationshipTemplateObserver { - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(CustomRelationshipTemplateObserver.class); @Inject private CustomTableCreatorService customTableCreatorService; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/filter/FilterService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/filter/FilterService.java index 501f6dacf..5dab6763c 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/filter/FilterService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/filter/FilterService.java @@ -42,6 +42,8 @@ import org.meveo.service.crm.impl.CustomFieldException; import org.meveo.service.crm.impl.CustomFieldTemplateService; import org.meveo.service.crm.impl.CustomFieldTemplateUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.XStreamException; @@ -61,6 +63,8 @@ @Stateless public class FilterService extends BusinessService { + private static Logger log = LoggerFactory.getLogger(FilterService.class); + @Inject protected CustomFieldTemplateService customFieldTemplateService; @@ -517,4 +521,9 @@ private FilteredQueryBuilder getFilteredQueryBuilder(Filter filter) throws Busin return filteredQueryBuilder; } + + @Override + public Logger getLogger() { + return log; + } } diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/filter/processor/PrimitiveFilterProcessorFactory.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/filter/processor/PrimitiveFilterProcessorFactory.java index 16388f90f..5e1784728 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/filter/processor/PrimitiveFilterProcessorFactory.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/filter/processor/PrimitiveFilterProcessorFactory.java @@ -11,7 +11,7 @@ public class PrimitiveFilterProcessorFactory { - private Logger logger = LoggerFactory.getLogger(PrimitiveFilterProcessorFactory.class); + private static Logger logger = LoggerFactory.getLogger(PrimitiveFilterProcessorFactory.class); private List processors; private PrimitiveFilterProcessor defaultProcessor; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/finance/ReportExtractService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/finance/ReportExtractService.java index 2247254d1..514ed948e 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/finance/ReportExtractService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/finance/ReportExtractService.java @@ -20,8 +20,11 @@ import org.meveo.model.shared.DateUtils; import org.meveo.service.base.BusinessService; import org.meveo.service.base.MeveoValueExpressionWrapper; +import org.meveo.service.custom.CustomEntityTemplateService; import org.meveo.service.script.ScriptInstanceService; import org.meveo.service.script.finance.ReportExtractScript; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Service for managing ReportExtract entity. @@ -34,6 +37,8 @@ @Stateless public class ReportExtractService extends BusinessService { + private static Logger log = LoggerFactory.getLogger(ReportExtractService.class); + @Inject private ScriptInstanceService scriptInstanceService; @@ -174,4 +179,9 @@ private String evaluateStringExpression(String expression, ReportExtract re) thr return result; } + @Override + public Logger getLogger() { + return log; + } + } diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/git/GitClient.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/git/GitClient.java index 0a5c19e74..92b8ffb9a 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/git/GitClient.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/git/GitClient.java @@ -35,8 +35,8 @@ import org.eclipse.jgit.api.AddCommand; import org.eclipse.jgit.api.CloneCommand; import org.eclipse.jgit.api.CreateBranchCommand; -import org.eclipse.jgit.api.FetchCommand; import org.eclipse.jgit.api.CreateBranchCommand.SetupUpstreamMode; +import org.eclipse.jgit.api.FetchCommand; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.ListBranchCommand.ListMode; import org.eclipse.jgit.api.PullCommand; @@ -82,6 +82,7 @@ import org.meveo.security.MeveoUser; import org.meveo.synchronization.KeyLock; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Git client class to manipulate repositories @@ -122,8 +123,7 @@ public class GitClient { private KeyLock keyLock; @Inject - private Logger log; - + private static Logger log = LoggerFactory.getLogger(GitClient.class); /** diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/git/GitRepositoryService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/git/GitRepositoryService.java index 803477ad3..de2083038 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/git/GitRepositoryService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/git/GitRepositoryService.java @@ -40,6 +40,7 @@ import org.meveo.security.MeveoUser; import org.meveo.service.base.BusinessService; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Persistence class for GitRepository @@ -70,8 +71,7 @@ public class GitRepositoryService extends BusinessService { @Inject private GitClient gitClient; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(GitRepositoryService.class); @Inject @CurrentUser diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/job/JobExecutionService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/job/JobExecutionService.java index f2cdd106c..a7a5a8aef 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/job/JobExecutionService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/job/JobExecutionService.java @@ -41,6 +41,8 @@ import org.meveo.security.MeveoUser; import org.meveo.security.keycloak.CurrentUserProvider; import org.meveo.service.base.PersistenceService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * The Class JobExecutionService. @@ -52,6 +54,8 @@ @Stateless public class JobExecutionService extends PersistenceService { + private static Logger log = LoggerFactory.getLogger(JobExecutionService.class); + /** * job instance service. */ @@ -382,4 +386,9 @@ public JobExecutionResultImpl findLastExecutionByInstance(JobInstance jobInstanc return null; } } + + @Override + public Logger getLogger() { + return log; + } } \ No newline at end of file diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/job/JobInstanceService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/job/JobInstanceService.java index 64c506d48..719403433 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/job/JobInstanceService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/job/JobInstanceService.java @@ -1,388 +1,395 @@ -/* - * (C) Copyright 2015-2016 Opencell SAS (http://opencellsoft.com/) and contributors. - * (C) Copyright 2009-2014 Manaty SARL (http://manaty.net/) and contributors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * This program is not suitable for any direct or indirect application in MILITARY industry - * See the GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package org.meveo.service.job; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.ejb.ScheduleExpression; -import javax.ejb.Stateless; -import javax.ejb.Timer; -import javax.inject.Inject; -import javax.naming.InitialContext; -import javax.naming.NamingException; - -import org.apache.commons.collections.CollectionUtils; -import org.meveo.admin.exception.BusinessException; -import org.meveo.cache.CacheKeyLong; -import org.meveo.cache.JobCacheContainerProvider; -import org.meveo.commons.utils.EjbUtils; -import org.meveo.commons.utils.ParamBean; -import org.meveo.commons.utils.QueryBuilder; -import org.meveo.commons.utils.ReflectionUtils; -import org.meveo.event.monitoring.ClusterEventDto.CrudActionEnum; -import org.meveo.event.monitoring.ClusterEventPublisher; -import org.meveo.model.crm.CustomFieldTemplate; -import org.meveo.model.jobs.JobCategoryEnum; -import org.meveo.model.jobs.JobExecutionResultImpl; -import org.meveo.model.jobs.JobInstance; -import org.meveo.model.jobs.TimerEntity; -import org.meveo.security.CurrentUser; -import org.meveo.security.MeveoUser; -import org.meveo.service.admin.impl.ModuleInstallationContext; -import org.meveo.service.base.BusinessService; -import org.meveo.service.crm.impl.CustomFieldTemplateService; -import org.meveo.util.EntityCustomizationUtils; - -@Stateless -public class JobInstanceService extends BusinessService { - - @Inject - private ClusterEventPublisher clusterEventPublisher; - - @Inject - @CurrentUser - private MeveoUser currentUser; - - @Inject - private CustomFieldTemplateService customFieldTemplateService; - - @Inject - private JobCacheContainerProvider jobCacheContainerProvider; - - @Inject - private ModuleInstallationContext moduleInstallationContext; - - private static Map>> jobClasses = new HashMap<>(); - private static Map jobTimers = new HashMap<>(); - - private static ParamBean paramBean = ParamBean.getInstance(); - - - /** - * Register job classes and schedule active job instances - */ - public void registerJobs() { - - Set> classes = ReflectionUtils.getSubclasses(Job.class); - - for (Class jobClass : classes) { - Job job = (Job) EjbUtils.getServiceInterface(jobClass.getSimpleName()); - registerJob(job); - } - } - - /** - * Register job class and schedule active job instances. - * - * @param job job to be registered. - */ - private void registerJob(Job job) { - - if(job == null) { - return; - } - - boolean clearTimers = false; - synchronized (jobTimers) { - - if (!jobClasses.containsKey(job.getJobCategory())) { - jobClasses.put(job.getJobCategory(), new ArrayList<>()); - } - if (!jobClasses.get(job.getJobCategory()).contains(job.getClass())) { - jobClasses.get(job.getJobCategory()).add(job.getClass()); - clearTimers = true; - } - - Map cfts = job.getCustomFields(); - if (cfts != null && !cfts.isEmpty()) { - try { - customFieldTemplateService.createMissingTemplates(EntityCustomizationUtils.getAppliesTo(job.getClass(), null), cfts.values()); - } catch (BusinessException e) { - log.error("Failed to registed missing CF templates for job " + job.getClass()); - } - } - - log.debug("Registered a job {} of category {}", job.getClass(), job.getJobCategory()); - } - startTimers(job, clearTimers); - } - - /** - * Register timers for applicable job instances of a given job class. - * - * @param job Job class to register timers for - * @param clearTimers Should previous timers be removed - used to remove old timers at application startup - */ - @SuppressWarnings("unchecked") - private void startTimers(Job job, boolean clearTimers) { - - if (clearTimers) { - job.cleanTimers(); - } - - List jobInstances = getEntityManager().createQuery("from JobInstance ji LEFT JOIN FETCH ji.followingJob where ji.jobTemplate=:jobName") - .setParameter("jobName", ReflectionUtils.getCleanClassName(job.getClass().getSimpleName())).getResultList(); - - int started = 0; - - for (JobInstance jobInstance : jobInstances) { - if (scheduleJob(jobInstance, job)) { - started++; - } - } - log.debug("Found {} job instances for {}, started {}", jobInstances.size(), ReflectionUtils.getCleanClassName(job.getClass().getSimpleName()), started); - - } - - public Job getJobByName(String jobName) { - Job result = null; - try { - InitialContext ic = new InitialContext(); - result = (Job) ic.lookup("java:global/" + paramBean.getProperty("meveo.moduleName", "meveo") + "/" + jobName); - } catch (NamingException e) { - log.error("Failed to get job by name {}", jobName, e); - } - return result; - } - - /** - * Retrieve jobs filtered by type, parametres and category - * - * @param type Template of the job - * @param parameters Parametres of the job - * @param categoryEnum Cateogry of the job - * @return the list of matching jobs - */ - public List findJobsByTypeAndParameters(String type, String parameters, JobCategoryEnum categoryEnum) { - return new QueryBuilder(JobInstance.class, "job") - .addCriterionEnum("jobCategoryEnum", categoryEnum) - .addCriterion("parametres", "=", parameters, true) - .addCriterion("jobTemplate", "=", type, true) - .getTypedQuery(this.getEntityManager(), JobInstance.class) - .getResultList(); - } - - public List getJobs() { - List jobs = new ArrayList<>(); - - for (List> jobList : jobClasses.values()) { - for (Class jobClass : jobList) { - Job job = getJobByName(ReflectionUtils.getCleanClassName(jobClass.getSimpleName())); - jobs.add(job); - } - } - return jobs; - } - - public List getJobNames() { - List jobs = new ArrayList(); - - for (List> jobList : jobClasses.values()) { - for (Class jobClass : jobList) { - jobs.add(ReflectionUtils.getCleanClassName(jobClass.getSimpleName())); - } - } - return jobs; - } - - public List getJobNames(JobCategoryEnum jobCategory) { - List jobs = new ArrayList(); - - if (jobClasses.containsKey(jobCategory)) { - for (Class jobClass : jobClasses.get(jobCategory)) { - jobs.add(ReflectionUtils.getCleanClassName(jobClass.getSimpleName())); - } - } - return jobs; - } - - @Override - public void create(JobInstance jobInstance) throws BusinessException { - super.create(jobInstance); - jobCacheContainerProvider.addUpdateJobInstance(jobInstance.getId()); - - moduleInstallationContext.registerOrExecutePostInstallAction(() -> scheduleJob(jobInstance, null)); - - clusterEventPublisher.publishEvent(jobInstance, CrudActionEnum.create); - //TODO call afterCreateOrUpdate from PersistenceService - } - - @Override - public JobInstance update(JobInstance jobInstance) throws BusinessException { - super.update(jobInstance); - jobCacheContainerProvider.addUpdateJobInstance(jobInstance.getId()); - scheduleUnscheduleJob(jobInstance); - - clusterEventPublisher.publishEvent(jobInstance, CrudActionEnum.update); - - //TODO call afterCreateOrUpdate from PersistenceService - return jobInstance; - } - - @Override - public void remove(JobInstance jobInstance) throws BusinessException { - - log.info("remove jobInstance {}, id={}", jobInstance.getJobTemplate(), jobInstance.getId()); - - String providerCode = currentUser.getProviderCode(); - if (jobInstance.getId() == null) { - log.info("removing jobInstance entity with null id, something is wrong"); - - } else if (jobTimers.containsKey(new CacheKeyLong(providerCode, jobInstance.getId()))) { - try { - Timer timer = jobTimers.get(new CacheKeyLong(providerCode, jobInstance.getId())); - timer.cancel(); - } catch (Exception ex) { - log.info("cannot cancel timer " + ex); - } - jobTimers.remove(new CacheKeyLong(providerCode, jobInstance.getId())); - } else { - log.info("jobInstance timer not found, cannot remove it"); - } - super.remove(jobInstance); - - jobCacheContainerProvider.removeJobInstance(jobInstance.getId()); - - clusterEventPublisher.publishEvent(jobInstance, CrudActionEnum.remove); - } - - @Override - public JobInstance enable(JobInstance jobInstance) throws BusinessException { - jobInstance = super.enable(jobInstance); - - log.info("Enabling jobInstance {}, id={}", jobInstance.getJobTemplate(), jobInstance.getId()); - scheduleUnscheduleJob(jobInstance); - - clusterEventPublisher.publishEvent(jobInstance, CrudActionEnum.enable); - - return jobInstance; - } - - @Override - public JobInstance disable(JobInstance jobInstance) throws BusinessException { - jobInstance = super.disable(jobInstance); - - log.info("Disabling jobInstance {}, id={}", jobInstance.getJobTemplate(), jobInstance.getId()); - scheduleUnscheduleJob(jobInstance); - - clusterEventPublisher.publishEvent(jobInstance, CrudActionEnum.disable); - - return jobInstance; - } - - private void unscheduleJob(Long jobInstanceId) { - - String providerCode = currentUser.getProviderCode(); - - if (jobInstanceId != null && jobTimers.containsKey(new CacheKeyLong(providerCode, jobInstanceId))) { - try { - Timer timer = jobTimers.get(new CacheKeyLong(providerCode, jobInstanceId)); - timer.cancel(); - jobTimers.remove(new CacheKeyLong(providerCode, jobInstanceId)); - log.info("Cancelled timer id={}", jobInstanceId); - - } catch (Exception ex) { - log.error("Failed to cancel timer id={}", jobInstanceId, ex); - } - } - } - - /** - * Schedule a job - * - * @param jobInstance Job instance to schedule - * @param job Job type. Will be looked up from job instance properties if not provided. - * @return True if job instance was scheduled - */ - private boolean scheduleJob(JobInstance jobInstance, Job job) { - - String currentNode = EjbUtils.getCurrentClusterNode(); - - if (jobInstance.isActive() && jobInstance.getTimerEntity() != null && jobInstance.isRunnableOnNode(currentNode)) { - if (job == null) { - job = getJobByName(jobInstance.getJobTemplate()); - } - - ScheduleExpression scheduleExpression = getScheduleExpression(jobInstance.getTimerEntity()); - log.info("Scheduling job {} of type {} for {}", jobInstance.getCode(), jobInstance.getJobTemplate(), scheduleExpression); - - // detach(jobInstance); - jobTimers.put(new CacheKeyLong(currentUser.getProviderCode(), jobInstance.getId()), job.createTimer(scheduleExpression, jobInstance)); - return true; - - } else { - log.info("Job {} of type {} is inactive, has no timer or is not destined to run on node {} and will not be scheduled", jobInstance.getCode(), - jobInstance.getJobTemplate(), currentNode); - } - - return false; - } - - /** - * Reschedule a job - * - * @param jobInstance Job instance to reschedule - */ - private void scheduleUnscheduleJob(JobInstance jobInstance) { - - unscheduleJob(jobInstance.getId()); - scheduleJob(jobInstance, null); - } - - /** - * Reschedule a job. - * - * @param jobInstanceId id of job instance need to be scheduled. - */ - public void scheduleUnscheduleJob(Long jobInstanceId) { - - JobInstance jobInstance = findById(jobInstanceId, Arrays.asList("timerEntity")); - if (jobInstance == null) { - unscheduleJob(jobInstanceId); - } else { - scheduleUnscheduleJob(jobInstance); - } - } - - private ScheduleExpression getScheduleExpression(TimerEntity timerEntity) { - ScheduleExpression expression = new ScheduleExpression(); - expression.dayOfMonth(timerEntity.getDayOfMonth()); - expression.dayOfWeek(timerEntity.getDayOfWeek()); - expression.end(timerEntity.getEnd()); - expression.hour(timerEntity.getHour()); - expression.minute(timerEntity.getMinute()); - expression.month(timerEntity.getMonth()); - expression.second(timerEntity.getSecond()); - expression.start(timerEntity.getStart()); - expression.year(timerEntity.getYear()); - expression.timezone(timerEntity.getTimezone()); - return expression; - } - - @Override - public JobInstance findById(Long id, List fetchFields) { - getEntityManager().clear(); - return super.findById(id, fetchFields); - } +/* + * (C) Copyright 2015-2016 Opencell SAS (http://opencellsoft.com/) and contributors. + * (C) Copyright 2009-2014 Manaty SARL (http://manaty.net/) and contributors. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * This program is not suitable for any direct or indirect application in MILITARY industry + * See the GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.meveo.service.job; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.ejb.ScheduleExpression; +import javax.ejb.Stateless; +import javax.ejb.Timer; +import javax.inject.Inject; +import javax.naming.InitialContext; +import javax.naming.NamingException; + +import org.meveo.admin.exception.BusinessException; +import org.meveo.cache.CacheKeyLong; +import org.meveo.cache.JobCacheContainerProvider; +import org.meveo.commons.utils.EjbUtils; +import org.meveo.commons.utils.ParamBean; +import org.meveo.commons.utils.QueryBuilder; +import org.meveo.commons.utils.ReflectionUtils; +import org.meveo.event.monitoring.ClusterEventDto.CrudActionEnum; +import org.meveo.event.monitoring.ClusterEventPublisher; +import org.meveo.model.crm.CustomFieldTemplate; +import org.meveo.model.jobs.JobCategoryEnum; +import org.meveo.model.jobs.JobInstance; +import org.meveo.model.jobs.TimerEntity; +import org.meveo.security.CurrentUser; +import org.meveo.security.MeveoUser; +import org.meveo.service.admin.impl.ModuleInstallationContext; +import org.meveo.service.base.BusinessService; +import org.meveo.service.crm.impl.CustomFieldTemplateService; +import org.meveo.util.EntityCustomizationUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@Stateless +public class JobInstanceService extends BusinessService { + + private static Logger log = LoggerFactory.getLogger(JobInstanceService.class); + + @Inject + private ClusterEventPublisher clusterEventPublisher; + + @Inject + @CurrentUser + private MeveoUser currentUser; + + @Inject + private CustomFieldTemplateService customFieldTemplateService; + + @Inject + private JobCacheContainerProvider jobCacheContainerProvider; + + @Inject + private ModuleInstallationContext moduleInstallationContext; + + private static Map>> jobClasses = new HashMap<>(); + private static Map jobTimers = new HashMap<>(); + + private static ParamBean paramBean = ParamBean.getInstance(); + + + /** + * Register job classes and schedule active job instances + */ + public void registerJobs() { + + Set> classes = ReflectionUtils.getSubclasses(Job.class); + + for (Class jobClass : classes) { + Job job = (Job) EjbUtils.getServiceInterface(jobClass.getSimpleName()); + registerJob(job); + } + } + + /** + * Register job class and schedule active job instances. + * + * @param job job to be registered. + */ + private void registerJob(Job job) { + + if(job == null) { + return; + } + + boolean clearTimers = false; + synchronized (jobTimers) { + + if (!jobClasses.containsKey(job.getJobCategory())) { + jobClasses.put(job.getJobCategory(), new ArrayList<>()); + } + if (!jobClasses.get(job.getJobCategory()).contains(job.getClass())) { + jobClasses.get(job.getJobCategory()).add(job.getClass()); + clearTimers = true; + } + + Map cfts = job.getCustomFields(); + if (cfts != null && !cfts.isEmpty()) { + try { + customFieldTemplateService.createMissingTemplates(EntityCustomizationUtils.getAppliesTo(job.getClass(), null), cfts.values()); + } catch (BusinessException e) { + log.error("Failed to registed missing CF templates for job " + job.getClass()); + } + } + + log.debug("Registered a job {} of category {}", job.getClass(), job.getJobCategory()); + } + startTimers(job, clearTimers); + } + + /** + * Register timers for applicable job instances of a given job class. + * + * @param job Job class to register timers for + * @param clearTimers Should previous timers be removed - used to remove old timers at application startup + */ + @SuppressWarnings("unchecked") + private void startTimers(Job job, boolean clearTimers) { + + if (clearTimers) { + job.cleanTimers(); + } + + List jobInstances = getEntityManager().createQuery("from JobInstance ji LEFT JOIN FETCH ji.followingJob where ji.jobTemplate=:jobName") + .setParameter("jobName", ReflectionUtils.getCleanClassName(job.getClass().getSimpleName())).getResultList(); + + int started = 0; + + for (JobInstance jobInstance : jobInstances) { + if (scheduleJob(jobInstance, job)) { + started++; + } + } + log.debug("Found {} job instances for {}, started {}", jobInstances.size(), ReflectionUtils.getCleanClassName(job.getClass().getSimpleName()), started); + + } + + public Job getJobByName(String jobName) { + Job result = null; + try { + InitialContext ic = new InitialContext(); + result = (Job) ic.lookup("java:global/" + paramBean.getProperty("meveo.moduleName", "meveo") + "/" + jobName); + } catch (NamingException e) { + log.error("Failed to get job by name {}", jobName, e); + } + return result; + } + + /** + * Retrieve jobs filtered by type, parametres and category + * + * @param type Template of the job + * @param parameters Parametres of the job + * @param categoryEnum Cateogry of the job + * @return the list of matching jobs + */ + public List findJobsByTypeAndParameters(String type, String parameters, JobCategoryEnum categoryEnum) { + return new QueryBuilder(JobInstance.class, "job") + .addCriterionEnum("jobCategoryEnum", categoryEnum) + .addCriterion("parametres", "=", parameters, true) + .addCriterion("jobTemplate", "=", type, true) + .getTypedQuery(this.getEntityManager(), JobInstance.class) + .getResultList(); + } + + public List getJobs() { + List jobs = new ArrayList<>(); + + for (List> jobList : jobClasses.values()) { + for (Class jobClass : jobList) { + Job job = getJobByName(ReflectionUtils.getCleanClassName(jobClass.getSimpleName())); + jobs.add(job); + } + } + return jobs; + } + + public List getJobNames() { + List jobs = new ArrayList(); + + for (List> jobList : jobClasses.values()) { + for (Class jobClass : jobList) { + jobs.add(ReflectionUtils.getCleanClassName(jobClass.getSimpleName())); + } + } + return jobs; + } + + public List getJobNames(JobCategoryEnum jobCategory) { + List jobs = new ArrayList(); + + if (jobClasses.containsKey(jobCategory)) { + for (Class jobClass : jobClasses.get(jobCategory)) { + jobs.add(ReflectionUtils.getCleanClassName(jobClass.getSimpleName())); + } + } + return jobs; + } + + @Override + public void create(JobInstance jobInstance) throws BusinessException { + super.create(jobInstance); + jobCacheContainerProvider.addUpdateJobInstance(jobInstance.getId()); + + moduleInstallationContext.registerOrExecutePostInstallAction(() -> scheduleJob(jobInstance, null)); + + clusterEventPublisher.publishEvent(jobInstance, CrudActionEnum.create); + //TODO call afterCreateOrUpdate from PersistenceService + } + + @Override + public JobInstance update(JobInstance jobInstance) throws BusinessException { + super.update(jobInstance); + jobCacheContainerProvider.addUpdateJobInstance(jobInstance.getId()); + scheduleUnscheduleJob(jobInstance); + + clusterEventPublisher.publishEvent(jobInstance, CrudActionEnum.update); + + //TODO call afterCreateOrUpdate from PersistenceService + return jobInstance; + } + + @Override + public void remove(JobInstance jobInstance) throws BusinessException { + + log.info("remove jobInstance {}, id={}", jobInstance.getJobTemplate(), jobInstance.getId()); + + String providerCode = currentUser.getProviderCode(); + if (jobInstance.getId() == null) { + log.info("removing jobInstance entity with null id, something is wrong"); + + } else if (jobTimers.containsKey(new CacheKeyLong(providerCode, jobInstance.getId()))) { + try { + Timer timer = jobTimers.get(new CacheKeyLong(providerCode, jobInstance.getId())); + timer.cancel(); + } catch (Exception ex) { + log.info("cannot cancel timer " + ex); + } + jobTimers.remove(new CacheKeyLong(providerCode, jobInstance.getId())); + } else { + log.info("jobInstance timer not found, cannot remove it"); + } + super.remove(jobInstance); + + jobCacheContainerProvider.removeJobInstance(jobInstance.getId()); + + clusterEventPublisher.publishEvent(jobInstance, CrudActionEnum.remove); + } + + @Override + public JobInstance enable(JobInstance jobInstance) throws BusinessException { + jobInstance = super.enable(jobInstance); + + log.info("Enabling jobInstance {}, id={}", jobInstance.getJobTemplate(), jobInstance.getId()); + scheduleUnscheduleJob(jobInstance); + + clusterEventPublisher.publishEvent(jobInstance, CrudActionEnum.enable); + + return jobInstance; + } + + @Override + public JobInstance disable(JobInstance jobInstance) throws BusinessException { + jobInstance = super.disable(jobInstance); + + log.info("Disabling jobInstance {}, id={}", jobInstance.getJobTemplate(), jobInstance.getId()); + scheduleUnscheduleJob(jobInstance); + + clusterEventPublisher.publishEvent(jobInstance, CrudActionEnum.disable); + + return jobInstance; + } + + private void unscheduleJob(Long jobInstanceId) { + + String providerCode = currentUser.getProviderCode(); + + if (jobInstanceId != null && jobTimers.containsKey(new CacheKeyLong(providerCode, jobInstanceId))) { + try { + Timer timer = jobTimers.get(new CacheKeyLong(providerCode, jobInstanceId)); + timer.cancel(); + jobTimers.remove(new CacheKeyLong(providerCode, jobInstanceId)); + log.info("Cancelled timer id={}", jobInstanceId); + + } catch (Exception ex) { + log.error("Failed to cancel timer id={}", jobInstanceId, ex); + } + } + } + + /** + * Schedule a job + * + * @param jobInstance Job instance to schedule + * @param job Job type. Will be looked up from job instance properties if not provided. + * @return True if job instance was scheduled + */ + private boolean scheduleJob(JobInstance jobInstance, Job job) { + + String currentNode = EjbUtils.getCurrentClusterNode(); + + if (jobInstance.isActive() && jobInstance.getTimerEntity() != null && jobInstance.isRunnableOnNode(currentNode)) { + if (job == null) { + job = getJobByName(jobInstance.getJobTemplate()); + } + + ScheduleExpression scheduleExpression = getScheduleExpression(jobInstance.getTimerEntity()); + log.info("Scheduling job {} of type {} for {}", jobInstance.getCode(), jobInstance.getJobTemplate(), scheduleExpression); + + // detach(jobInstance); + jobTimers.put(new CacheKeyLong(currentUser.getProviderCode(), jobInstance.getId()), job.createTimer(scheduleExpression, jobInstance)); + return true; + + } else { + log.info("Job {} of type {} is inactive, has no timer or is not destined to run on node {} and will not be scheduled", jobInstance.getCode(), + jobInstance.getJobTemplate(), currentNode); + } + + return false; + } + + /** + * Reschedule a job + * + * @param jobInstance Job instance to reschedule + */ + private void scheduleUnscheduleJob(JobInstance jobInstance) { + + unscheduleJob(jobInstance.getId()); + scheduleJob(jobInstance, null); + } + + /** + * Reschedule a job. + * + * @param jobInstanceId id of job instance need to be scheduled. + */ + public void scheduleUnscheduleJob(Long jobInstanceId) { + + JobInstance jobInstance = findById(jobInstanceId, Arrays.asList("timerEntity")); + if (jobInstance == null) { + unscheduleJob(jobInstanceId); + } else { + scheduleUnscheduleJob(jobInstance); + } + } + + private ScheduleExpression getScheduleExpression(TimerEntity timerEntity) { + ScheduleExpression expression = new ScheduleExpression(); + expression.dayOfMonth(timerEntity.getDayOfMonth()); + expression.dayOfWeek(timerEntity.getDayOfWeek()); + expression.end(timerEntity.getEnd()); + expression.hour(timerEntity.getHour()); + expression.minute(timerEntity.getMinute()); + expression.month(timerEntity.getMonth()); + expression.second(timerEntity.getSecond()); + expression.start(timerEntity.getStart()); + expression.year(timerEntity.getYear()); + expression.timezone(timerEntity.getTimezone()); + return expression; + } + + @Override + public JobInstance findById(Long id, List fetchFields) { + getEntityManager().clear(); + return super.findById(id, fetchFields); + } + + @Override + public Logger getLogger() { + return log; + } } \ No newline at end of file diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/notification/DefaultObserver.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/notification/DefaultObserver.java index 21a043991..ce85203fc 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/notification/DefaultObserver.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/notification/DefaultObserver.java @@ -17,7 +17,10 @@ import javax.inject.Inject; import org.meveo.admin.exception.BusinessException; -import org.meveo.admin.ftp.event.*; +import org.meveo.admin.ftp.event.FileDelete; +import org.meveo.admin.ftp.event.FileDownload; +import org.meveo.admin.ftp.event.FileRename; +import org.meveo.admin.ftp.event.FileUpload; import org.meveo.audit.logging.annotations.MeveoAudit; import org.meveo.commons.utils.ParamBeanFactory; import org.meveo.commons.utils.StringUtils; @@ -33,10 +36,10 @@ import org.meveo.event.qualifier.Disabled; import org.meveo.event.qualifier.Enabled; import org.meveo.event.qualifier.InboundRequestReceived; +import org.meveo.event.qualifier.PostRemoved; import org.meveo.event.qualifier.Processed; import org.meveo.event.qualifier.Rejected; import org.meveo.event.qualifier.Removed; -import org.meveo.event.qualifier.PostRemoved; import org.meveo.event.qualifier.Terminated; import org.meveo.event.qualifier.Updated; import org.meveo.event.qualifier.UpdatedAfterTx; @@ -73,6 +76,7 @@ import org.meveo.service.script.ConcreteFunctionService; import org.meveo.service.script.Script; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Default observer for all the events. @@ -86,8 +90,7 @@ @Lock(LockType.READ) public class DefaultObserver { - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(DefaultObserver.class); @Inject private BeanManager manager; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/notification/EmailNotifier.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/notification/EmailNotifier.java index 640d9b7aa..07be18f1c 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/notification/EmailNotifier.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/notification/EmailNotifier.java @@ -20,6 +20,7 @@ import org.meveo.service.base.MeveoValueExpressionWrapper; import org.meveo.service.communication.impl.EmailSender; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author phung @@ -31,8 +32,7 @@ public class EmailNotifier { @Inject NotificationHistoryService notificationHistoryService; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(EmailNotifier.class); @Inject private EmailSender emailSender; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/notification/JobTriggerLauncher.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/notification/JobTriggerLauncher.java index 334c35bd5..960001138 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/notification/JobTriggerLauncher.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/notification/JobTriggerLauncher.java @@ -14,6 +14,7 @@ import org.meveo.service.job.JobExecutionService; import org.meveo.service.job.JobInstanceService; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Lauch a jobInstance and create a notificationHistory @@ -34,8 +35,7 @@ public class JobTriggerLauncher { @Inject private JobInstanceService jobInstanceService; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(JobTriggerLauncher.class); @Inject private CurrentUserProvider currentUserProvider; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/notification/RemoteInstanceNotifier.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/notification/RemoteInstanceNotifier.java index 33e2eb398..ea70afda4 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/notification/RemoteInstanceNotifier.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/notification/RemoteInstanceNotifier.java @@ -8,9 +8,6 @@ @SuppressWarnings("deprecation") @Stateless public class RemoteInstanceNotifier { - - @Inject - private Logger log; public void invoke(String input,String url) { /* diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/notification/WebNotificationService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/notification/WebNotificationService.java index 1a7fa1e5f..176259f76 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/notification/WebNotificationService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/notification/WebNotificationService.java @@ -3,6 +3,9 @@ import org.meveo.admin.exception.BusinessException; import org.meveo.model.notification.WebNotification; import org.meveo.service.communication.impl.SseManager; +import org.meveo.service.custom.CustomEntityTemplateService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.ejb.Stateless; import javax.inject.Inject; @@ -10,6 +13,8 @@ @Stateless public class WebNotificationService extends NotificationInstanceService { + private static Logger log = LoggerFactory.getLogger(WebNotificationService.class); + @Inject private SseManager sseManager; @@ -22,4 +27,9 @@ public void remove(WebNotification entity) throws BusinessException { } super.remove(entity); } + + @Override + public Logger getLogger() { + return log; + } } diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/notification/WebNotifier.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/notification/WebNotifier.java index e4cb300ff..7d903ef57 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/notification/WebNotifier.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/notification/WebNotifier.java @@ -18,12 +18,12 @@ import org.meveo.service.communication.impl.SseManager; import org.meveo.service.communication.impl.WebsocketNotifManager; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @Stateless class WebNotifier { - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(WebNotifier.class); @Inject private SseManager sseManager; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/script/CustomScriptService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/script/CustomScriptService.java index baba86a4e..fcff697ff 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/script/CustomScriptService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/script/CustomScriptService.java @@ -252,7 +252,7 @@ protected void validate(T script) throws BusinessException { compileScript(script, true); } if (script.getError() != null && script.isError()) { - log.error("Failed compiling with error={}", script.getScriptErrors()); + staticLogger.error("Failed compiling with error={}", script.getScriptErrors()); throw new BusinessException(resourceMessages.getString("scriptInstance.compilationFailed") + "\n " + org.apache.commons.lang3.StringUtils.join( script.getScriptErrors(), "\n") ); } } @@ -311,7 +311,7 @@ public void setParameters(T script, ScriptInterface scriptInstance, Map scripts) { loadClassInCache(script.getCode()); } } catch (Exception e) { - log.error("", e); + staticLogger.error("", e); } } @@ -614,7 +614,7 @@ public Class compileScript(T script, boolean testCompile) { if(scriptErrors==null || scriptErrors.isEmpty()){ if (script.getSourceTypeEnum() == ScriptSourceTypeEnum.JAVA) { - log.debug("Compile script {}", script.getCode()); + staticLogger.debug("Compile script {}", script.getCode()); try { if (!testCompile) { @@ -625,7 +625,7 @@ public Class compileScript(T script, boolean testCompile) { compiledScript = compileJavaSource(script.getScript(), testCompile); } catch (CharSequenceCompilerException e) { - log.error("Failed to compile script {}. Compilation errors:", script.getCode()); + staticLogger.error("Failed to compile script {}. Compilation errors:", script.getCode()); List> diagnosticList = e.getDiagnostics().getDiagnostics(); for (Diagnostic diagnostic : diagnosticList) { @@ -641,12 +641,12 @@ public Class compileScript(T script, boolean testCompile) { } scriptErrors.add(scriptInstanceError); - log.warn("{} script {} location {}:{}: {}", diagnostic.getKind().name(), script.getCode(), diagnostic.getLineNumber(), diagnostic.getColumnNumber(), diagnostic.getMessage(Locale.getDefault())); + staticLogger.warn("{} script {} location {}:{}: {}", diagnostic.getKind().name(), script.getCode(), diagnostic.getLineNumber(), diagnostic.getColumnNumber(), diagnostic.getMessage(Locale.getDefault())); } } } catch (Exception e) { - log.error("Failed while compiling script", e); + staticLogger.error("Failed while compiling script", e); scriptErrors = new ArrayList<>(); ScriptInstanceError scriptInstanceError = new ScriptInstanceError(); scriptInstanceError.setMessage(e.getMessage() != null ? e.getMessage() : e.getClass().getSimpleName()); @@ -699,14 +699,14 @@ public List addMavenLibrariesToClassPath(Collection addMavenLibrariesToClassPath(Collection new RemoteRepository.Builder(repoId, "default", e).build()) .collect(Collectors.toList()); - log.debug("Found {} repositories", remoteRepositories.size()); + staticLogger.debug("Found {} repositories", remoteRepositories.size()); Map> resolvedDependencies = new HashMap<>(); for(MavenDependency mavenDependency:dependenciesToResolve){ Set resolvedDependency = getMavenDependencies(mavenDependency,remoteRepositories); @@ -727,7 +727,7 @@ public List addMavenLibrariesToClassPath(Collection addMavenLibrariesToClassPath(Collection getMavenDependencies(MavenDependency e, List remoteRepositories) { Set result = null; - log.info("Resolving artifacts for {}", e); + staticLogger.info("Resolving artifacts for {}", e); List artifacts; DefaultArtifact rootArtifact = new DefaultArtifact(e.getGroupId(), e.getArtifactId(), e.getClassifier(), "jar", e.getVersion()); @@ -770,7 +770,7 @@ private Set getMavenDependencies(MavenDependency e, List getMavenDependencies(MavenDependency e, List { return artifact.getArtifact().getFile().getPath(); @@ -813,7 +813,7 @@ protected void beforeUpdateOrCreate(T script) throws BusinessException { try { compilationUnit = JavaParser.parse(script.getScript()); } catch (Exception e) { - // Skip getter and setters parsing. We don't need to log errors as they will be + // Skip getter and setters parsing. We don't need to staticLogger errors as they will be // logged later in code. return; } @@ -883,7 +883,7 @@ protected void beforeUpdateOrCreate(T script) throws BusinessException { getters.addAll(extendedScript.getGetters()); setters.addAll(extendedScript.getSetters()); } else { - log.warn("Class / script not found for type " + type.getNameAsString() + ", getters & setters won't be inferred."); + staticLogger.warn("Class / script not found for type " + type.getNameAsString() + ", getters & setters won't be inferred."); } } @@ -911,12 +911,12 @@ public void loadClassInCache(String scriptCode) { var bean = MeveoBeanManager.getInstance().createBean(compiledScript); final Class scriptClass = compiledScript; - log.debug("Compiled script {} added to compiled interface map", scriptCode); + staticLogger.debug("Compiled script {} added to compiled interface map", scriptCode); return () -> MeveoBeanManager.getInstance().getInstance(bean, scriptClass); } ); } catch (Exception e) { - log.error("Failed to load class {}", scriptCode, e); + staticLogger.error("Failed to load class {}", scriptCode, e); } } @@ -1005,7 +1005,7 @@ protected ScriptInterfaceSupplier getScriptInterfaceWCompile(String scriptCode) List fetchFields = Arrays.asList("mavenDependencies"); T script = findByCode(scriptCode, fetchFields); if (script == null) { - log.debug("ScriptInstance with {} does not exist", scriptCode); + staticLogger.debug("ScriptInstance with {} does not exist", scriptCode); throw new ElementNotFoundException(scriptCode, getEntityClass().getName()); } @@ -1018,7 +1018,7 @@ protected ScriptInterfaceSupplier getScriptInterfaceWCompile(String scriptCode) } if (script.isError()) { - log.debug("ScriptInstance {} failed to compile. Errors: {}", scriptCode, script.getScriptErrors()); + staticLogger.debug("ScriptInstance {} failed to compile. Errors: {}", scriptCode, script.getScriptErrors()); throw new InvalidScriptException(scriptCode, getEntityClass().getName()); } @@ -1027,7 +1027,7 @@ protected ScriptInterfaceSupplier getScriptInterfaceWCompile(String scriptCode) } if (result == null) { - log.debug("ScriptInstance with {} does not exist", scriptCode); + staticLogger.debug("ScriptInstance with {} does not exist", scriptCode); throw new ElementNotFoundException(scriptCode, getEntityClass().getName()); } @@ -1046,7 +1046,7 @@ public synchronized ScriptInterface getScriptInstance(String scriptCode) throws try { return getScriptInterface(scriptCode); } catch (Exception e) { - log.error("Failed to instantiate script {}", scriptCode, e); + staticLogger.error("Failed to instantiate script {}", scriptCode, e); throw new InvalidScriptException(scriptCode, getEntityClass().getName()); } } @@ -1156,7 +1156,7 @@ public void onScriptRemoved(@Observes @Removed ScriptInstance scriptInstance) th try { message+=" "+commitMessageBean.getCommitMessage(); } catch (ContextNotActiveException e) { - log.warn("No active session found for getting commit message when "+message+" to "+module.getCode()); + staticLogger.warn("No active session found for getting commit message when "+message+" to "+module.getCode()); } gitClient.commitFiles(meveoRepository, Collections.singletonList(file), message); } diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/script/FunctionService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/script/FunctionService.java index 7f43a17fb..8f8dd8e41 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/script/FunctionService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/script/FunctionService.java @@ -48,6 +48,8 @@ import org.meveo.model.storage.Repository; import org.meveo.service.base.BusinessService; import org.meveo.service.job.JobInstanceService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @param Type of function (service, script ...) @@ -62,6 +64,8 @@ public abstract class FunctionService> ALL_LOGS = new ConcurrentHashMap<>(); public static final String FUNCTION_TEST_JOB = "FunctionTestJob"; + + private static Logger log = LoggerFactory.getLogger(FunctionService.class); @Inject private ClusterEventPublisher clusterEventPublisher; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/script/ScriptInstanceService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/script/ScriptInstanceService.java index 80c1e1666..b25a8f048 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/script/ScriptInstanceService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/script/ScriptInstanceService.java @@ -1,385 +1,394 @@ -/* - * (C) Copyright 2018-2019 Webdrone SAS (https://www.webdrone.fr/) and contributors. - * (C) Copyright 2015-2018 Opencell SAS (http://opencellsoft.com/) and contributors. - * (C) Copyright 2009-2014 Manaty SARL (http://manaty.net/) and contributors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * This program is not suitable for any direct or indirect application in MILITARY industry - * See the GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package org.meveo.service.script; - -import java.io.File; -import java.io.IOException; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - -import javax.annotation.Priority; -import javax.ejb.Stateless; -import javax.ejb.TransactionAttribute; -import javax.ejb.TransactionAttributeType; -import javax.enterprise.event.Observes; -import javax.enterprise.inject.Default; -import javax.inject.Inject; -import javax.persistence.NoResultException; - -import org.jboss.weld.contexts.ContextNotActiveException; -import org.meveo.admin.exception.BusinessException; -import org.meveo.admin.exception.ElementNotFoundException; -import org.meveo.admin.exception.InvalidPermissionException; -import org.meveo.admin.exception.InvalidScriptException; -import org.meveo.admin.exception.ScriptExecutionException; -import org.meveo.admin.listener.CommitMessageBean; -import org.meveo.api.dto.BaseEntityDto; -import org.meveo.api.dto.ScriptInstanceDto; -import org.meveo.commons.utils.EjbUtils; -import org.meveo.commons.utils.MeveoFileUtils; -import org.meveo.commons.utils.ReflectionUtils; -import org.meveo.jpa.JpaAmpNewTx; -import org.meveo.model.ModulePostInstall; -import org.meveo.model.git.GitRepository; -import org.meveo.model.module.MeveoModule; -import org.meveo.model.scripts.CustomScript; -import org.meveo.model.scripts.FunctionServiceFor; -import org.meveo.model.scripts.MavenDependency; -import org.meveo.model.scripts.ScriptInstance; -import org.meveo.model.scripts.ScriptSourceTypeEnum; -import org.meveo.model.scripts.ScriptTransactionType; -import org.meveo.model.security.Role; -import org.meveo.service.admin.impl.ModuleInstallationContext; -import org.meveo.service.base.BusinessService; -import org.meveo.service.git.GitClient; -import org.meveo.service.git.GitHelper; -import org.meveo.service.git.MeveoRepository; - -/** - * @author Edward P. Legaspi | czetsuya@gmail.com - * @version 6.10 - **/ -@FunctionServiceFor(ScriptInstance.TYPE) -@Stateless -@Default -public class ScriptInstanceService extends CustomScriptService { - - @Inject - private ModuleInstallationContext moduleInstallationContext; - - @Inject - private MavenDependencyService mdService; - - @Inject - private ScriptInstanceExecutor scriptExecutor; - - @Inject - private GitClient gitClient; - - @Inject - @MeveoRepository - private GitRepository meveoRepository; - - @Inject - private CommitMessageBean commitMessageBean; - - @Override - protected void beforeUpdateOrCreate(ScriptInstance script) throws BusinessException { - super.beforeUpdateOrCreate(script); - - // Fetch maven dependencies - Set mavenDependencies = new HashSet<>(); - for(MavenDependency md : script.getMavenDependenciesNullSafe()) { - MavenDependency persistentMd = mdService.find(md.getBuiltCoordinates()); - if(persistentMd != null) { - mavenDependencies.add(persistentMd); - } else { - getEntityManager().persist(md); - mavenDependencies.add(md); - } - } - script.setMavenDependencies(mavenDependencies); - } - - @Override - public void afterUpdateOrCreate(ScriptInstance script) throws BusinessException { - super.afterUpdateOrCreate(script); - - mdService.removeOrphans(script); - } - - - - /** - * Get all ScriptInstances with error. - * - * @return list of custom script. - */ - public List getScriptInstancesWithError() { - return getEntityManager().createNamedQuery("CustomScript.getScriptInstanceOnError", CustomScript.class).setParameter("isError", Boolean.TRUE) - .getResultList(); - } - - /** - * Count scriptInstances with error. - * - * @return number of script instances with error. - */ - public long countScriptInstancesWithError() { - return getEntityManager().createNamedQuery("CustomScript.countScriptInstanceOnError", Long.class).setParameter("isError", Boolean.TRUE).getSingleResult(); - } - - /** - * Compile all scriptInstances. - */ - public void compileAll() { - - List scriptInstances = findByType(ScriptSourceTypeEnum.JAVA); - compile(scriptInstances); - } - - /** - * Execute the script identified by a script code. No init nor finalize methods are called. - * - * @param scriptCode ScriptInstanceCode - * @param context Context parameters (optional) - * @return Context parameters. Will not be null even if "context" parameter is null. - * @throws org.meveo.admin.exception.InvalidPermissionException Insufficient access to run the script - * @throws org.meveo.admin.exception.ElementNotFoundException Script not found - * @throws org.meveo.admin.exception.BusinessException Any execution exception - */ - @Override - @TransactionAttribute(TransactionAttributeType.SUPPORTS) - public Map execute(String scriptCode, Map context) throws BusinessException { - if(scriptCode == null) { - throw new IllegalArgumentException("Script code should not be null"); - } - - ScriptInstance scriptInstance = findByCode(scriptCode, List.of("executionRoles")); - - if(scriptInstance == null) { - throw new ElementNotFoundException( scriptCode, "ScriptInstance"); - } - // Check access to the script - isUserHasExecutionRole(scriptInstance); - - - ScriptInterface executionEngine = getExecutionEngine(scriptInstance, context); - return super.execute(executionEngine, context); - } - - /** - * Wrap the logger and execute script. - * - * @param scriptCode code of script - * @param context context used in execution of script. - */ - public void test(String scriptCode, Map context) { - - try { - execute(scriptCode, context); - } catch (BusinessException e) { - log.error("Script test execution failed", e); - } - } - - /** - * Only users having a role in executionRoles can execute the script, not having the role should throw an InvalidPermission exception that extends businessException. A script - * with no executionRoles can be executed by any user. - * - * @param scriptInstance instance of script - * @throws org.meveo.admin.exception.InvalidPermissionException invalid permission exception. - */ - public void isUserHasExecutionRole(ScriptInstance scriptInstance) throws InvalidPermissionException { - if (scriptInstance != null && scriptInstance.getExecutionRolesNullSafe() != null && !scriptInstance.getExecutionRolesNullSafe().isEmpty()) { - Set execRoles = scriptInstance.getExecutionRolesNullSafe(); - for (Role role : execRoles) { - if (currentUser.hasRole(role.getName())) { - return; - } - } - throw new InvalidPermissionException(); - } - } - - /** - * @param scriptInstance instance of script - * @return true if user have the souring role. - */ - public boolean isUserHasSourcingRole(ScriptInstance scriptInstance) { - if (scriptInstance != null && scriptInstance.getSourcingRolesNullSafe() != null && !scriptInstance.getSourcingRolesNullSafe().isEmpty()) { - Set sourcingRoles = scriptInstance.getSourcingRolesNullSafe(); - for (Role role : sourcingRoles) { - if (currentUser.hasRole(role.getName())) { - return true; - } - } - return false; - } - return true; - } - - /** - * This is used to invoke a method in a new transaction from a script.
- * This will prevent DB errors in the script from affecting notification history creation. - * - * @param workerName The name of the API or service that will be invoked. - * @param methodName The name of the method that will be invoked. - * @param parameters The array of parameters accepted by the method. They must be specified in exactly the same order as the target method. - * @throws org.meveo.admin.exception.BusinessException business exception. - */ - @JpaAmpNewTx - @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) - public void callWithNewTransaction(String workerName, String methodName, Object... parameters) throws BusinessException { - try { - Object worker = EjbUtils.getServiceInterface(workerName); - String workerClassName = ReflectionUtils.getCleanClassName(worker.getClass().getName()); - Class workerClass = Class.forName(workerClassName); - Method method = null; - if (parameters.length < 1) { - method = workerClass.getDeclaredMethod(methodName); - } else { - String className = null; - Object parameter = null; - Class[] parameterTypes = new Class[parameters.length]; - for (int i = 0; i < parameters.length; i++) { - parameter = parameters[i]; - className = ReflectionUtils.getCleanClassName(parameter.getClass().getName()); - parameterTypes[i] = Class.forName(className); - } - method = workerClass.getDeclaredMethod(methodName, parameterTypes); - } - method.setAccessible(true); - method.invoke(worker, parameters); - } catch (Exception e) { - if (e.getCause() != null) { - throw new BusinessException(e.getCause()); - } else { - throw new BusinessException(e); - } - } - } - - /** - * Get all script interfaces with compiling those that are not compiled yet - * - * @return the allScriptInterfaces - */ - public List getAllScriptInterfacesWCompile() { - - List scriptInterfaces = new ArrayList<>(); - - List scriptInstances = findByType(ScriptSourceTypeEnum.JAVA); - for (ScriptInstance scriptInstance : scriptInstances) { - try { - scriptInterfaces.add(getScriptInterfaceWCompile(scriptInstance.getCode())); - } catch (ElementNotFoundException | InvalidScriptException e) { - // Ignore errors here as they were logged in a call before - } - } - - return scriptInterfaces; - } - - @Override - protected void executeEngine(ScriptInterface engine, Map context) throws ScriptExecutionException { - ScriptTransactionType txType; - - try { - txType = getEntityManager() - .createQuery("SELECT transactionType FROM ScriptInstance WHERE code = :code", ScriptTransactionType.class) - .setParameter("code", engine.getClass().getName()) - .getSingleResult(); - } catch (NoResultException e) { - txType = ScriptTransactionType.SAME; - } - - switch(txType) { - case MANUAL: - scriptExecutor.executeManualTx(engine, context); - break; - case NEW: - scriptExecutor.executeInNewTx(engine, context); - break; - case NONE: - scriptExecutor.executeNoTx(engine, context); - break; - case SAME: - default: - super.executeEngine(engine, context); - } - } - - /** - * Compile the scripts the has been installed with the module - * - * @param module installed module - * @throws InvalidScriptException if one of the script can't be compiled - */ - public void postModuleInstall(@Observes @ModulePostInstall @Priority(2) MeveoModule module) throws InvalidScriptException { - reCompileAll(module); - } - - public void reCompileAll(MeveoModule module) throws InvalidScriptException { - var scripts = module.getModuleItems().stream() - .filter(item -> item.getItemClass().equals(ScriptInstance.class.getName())) - .map(item -> findByCode(item.getItemCode())) - .collect(Collectors.toList()); - - if (!scripts.isEmpty()) { - compileScripts(scripts); - } - } - - /** - * see java-doc {@link BusinessService#addFilesToModule(org.meveo.model.BusinessEntity, MeveoModule)} - */ - @Override - public void addFilesToModule(ScriptInstance entity, MeveoModule module) throws BusinessException { - super.addFilesToModule(entity, module); - String extension = entity.getSourceTypeEnum() == ScriptSourceTypeEnum.ES5 ? ".js" : ".java"; - if (extension == ".java") { - String path = entity.getCode().replaceAll("\\.", "/"); - - File gitDirectory = GitHelper.getRepositoryDir(currentUser, module.getCode() + "/facets/java/"); - String pathNewFile = path + ".java"; - - File newFile = new File(gitDirectory, pathNewFile); - - try { - MeveoFileUtils.writeAndPreserveCharset(entity.getScript(), newFile); - } catch (IOException e) { - throw new BusinessException("File cannot be write", e); - } - - String message = "Add the script File : " + entity.getCode() + "in the module : " + module.getCode(); - try { - message+=" "+commitMessageBean.getCommitMessage(); - } catch (ContextNotActiveException e) { - log.warn("No active session found for getting commit message when "+message+" to "+module.getCode()); - } - gitClient.commitFiles(module.getGitRepository(), Collections.singletonList(newFile), message); - } - } - - @Override - protected BaseEntityDto getDto(ScriptInstance entity) throws BusinessException { - ScriptInstanceDto dto = (ScriptInstanceDto) super.getDto(entity); - dto.setScript(null); - return dto; - } - +/* + * (C) Copyright 2018-2019 Webdrone SAS (https://www.webdrone.fr/) and contributors. + * (C) Copyright 2015-2018 Opencell SAS (http://opencellsoft.com/) and contributors. + * (C) Copyright 2009-2014 Manaty SARL (http://manaty.net/) and contributors. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * This program is not suitable for any direct or indirect application in MILITARY industry + * See the GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.meveo.service.script; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +import javax.annotation.Priority; +import javax.ejb.Stateless; +import javax.ejb.TransactionAttribute; +import javax.ejb.TransactionAttributeType; +import javax.enterprise.event.Observes; +import javax.enterprise.inject.Default; +import javax.inject.Inject; +import javax.persistence.NoResultException; + +import org.jboss.weld.contexts.ContextNotActiveException; +import org.meveo.admin.exception.BusinessException; +import org.meveo.admin.exception.ElementNotFoundException; +import org.meveo.admin.exception.InvalidPermissionException; +import org.meveo.admin.exception.InvalidScriptException; +import org.meveo.admin.exception.ScriptExecutionException; +import org.meveo.admin.listener.CommitMessageBean; +import org.meveo.api.dto.BaseEntityDto; +import org.meveo.api.dto.ScriptInstanceDto; +import org.meveo.commons.utils.EjbUtils; +import org.meveo.commons.utils.MeveoFileUtils; +import org.meveo.commons.utils.ReflectionUtils; +import org.meveo.jpa.JpaAmpNewTx; +import org.meveo.model.ModulePostInstall; +import org.meveo.model.git.GitRepository; +import org.meveo.model.module.MeveoModule; +import org.meveo.model.scripts.CustomScript; +import org.meveo.model.scripts.FunctionServiceFor; +import org.meveo.model.scripts.MavenDependency; +import org.meveo.model.scripts.ScriptInstance; +import org.meveo.model.scripts.ScriptSourceTypeEnum; +import org.meveo.model.scripts.ScriptTransactionType; +import org.meveo.model.security.Role; +import org.meveo.service.admin.impl.ModuleInstallationContext; +import org.meveo.service.base.BusinessService; +import org.meveo.service.git.GitClient; +import org.meveo.service.git.GitHelper; +import org.meveo.service.git.MeveoRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Edward P. Legaspi | czetsuya@gmail.com + * @version 6.10 + **/ +@FunctionServiceFor(ScriptInstance.TYPE) +@Stateless +@Default +public class ScriptInstanceService extends CustomScriptService { + + private static Logger log = LoggerFactory.getLogger(ScriptInstanceService.class); + + @Inject + private ModuleInstallationContext moduleInstallationContext; + + @Inject + private MavenDependencyService mdService; + + @Inject + private ScriptInstanceExecutor scriptExecutor; + + @Inject + private GitClient gitClient; + + @Inject + @MeveoRepository + private GitRepository meveoRepository; + + @Inject + private CommitMessageBean commitMessageBean; + + @Override + protected void beforeUpdateOrCreate(ScriptInstance script) throws BusinessException { + super.beforeUpdateOrCreate(script); + + // Fetch maven dependencies + Set mavenDependencies = new HashSet<>(); + for(MavenDependency md : script.getMavenDependenciesNullSafe()) { + MavenDependency persistentMd = mdService.find(md.getBuiltCoordinates()); + if(persistentMd != null) { + mavenDependencies.add(persistentMd); + } else { + getEntityManager().persist(md); + mavenDependencies.add(md); + } + } + script.setMavenDependencies(mavenDependencies); + } + + @Override + public void afterUpdateOrCreate(ScriptInstance script) throws BusinessException { + super.afterUpdateOrCreate(script); + + mdService.removeOrphans(script); + } + + + + /** + * Get all ScriptInstances with error. + * + * @return list of custom script. + */ + public List getScriptInstancesWithError() { + return getEntityManager().createNamedQuery("CustomScript.getScriptInstanceOnError", CustomScript.class).setParameter("isError", Boolean.TRUE) + .getResultList(); + } + + /** + * Count scriptInstances with error. + * + * @return number of script instances with error. + */ + public long countScriptInstancesWithError() { + return getEntityManager().createNamedQuery("CustomScript.countScriptInstanceOnError", Long.class).setParameter("isError", Boolean.TRUE).getSingleResult(); + } + + /** + * Compile all scriptInstances. + */ + public void compileAll() { + + List scriptInstances = findByType(ScriptSourceTypeEnum.JAVA); + compile(scriptInstances); + } + + /** + * Execute the script identified by a script code. No init nor finalize methods are called. + * + * @param scriptCode ScriptInstanceCode + * @param context Context parameters (optional) + * @return Context parameters. Will not be null even if "context" parameter is null. + * @throws org.meveo.admin.exception.InvalidPermissionException Insufficient access to run the script + * @throws org.meveo.admin.exception.ElementNotFoundException Script not found + * @throws org.meveo.admin.exception.BusinessException Any execution exception + */ + @Override + @TransactionAttribute(TransactionAttributeType.SUPPORTS) + public Map execute(String scriptCode, Map context) throws BusinessException { + if(scriptCode == null) { + throw new IllegalArgumentException("Script code should not be null"); + } + + ScriptInstance scriptInstance = findByCode(scriptCode, List.of("executionRoles")); + + if(scriptInstance == null) { + throw new ElementNotFoundException( scriptCode, "ScriptInstance"); + } + // Check access to the script + isUserHasExecutionRole(scriptInstance); + + + ScriptInterface executionEngine = getExecutionEngine(scriptInstance, context); + return super.execute(executionEngine, context); + } + + /** + * Wrap the logger and execute script. + * + * @param scriptCode code of script + * @param context context used in execution of script. + */ + public void test(String scriptCode, Map context) { + + try { + execute(scriptCode, context); + } catch (BusinessException e) { + log.error("Script test execution failed", e); + } + } + + /** + * Only users having a role in executionRoles can execute the script, not having the role should throw an InvalidPermission exception that extends businessException. A script + * with no executionRoles can be executed by any user. + * + * @param scriptInstance instance of script + * @throws org.meveo.admin.exception.InvalidPermissionException invalid permission exception. + */ + public void isUserHasExecutionRole(ScriptInstance scriptInstance) throws InvalidPermissionException { + if (scriptInstance != null && scriptInstance.getExecutionRolesNullSafe() != null && !scriptInstance.getExecutionRolesNullSafe().isEmpty()) { + Set execRoles = scriptInstance.getExecutionRolesNullSafe(); + for (Role role : execRoles) { + if (currentUser.hasRole(role.getName())) { + return; + } + } + throw new InvalidPermissionException(); + } + } + + /** + * @param scriptInstance instance of script + * @return true if user have the souring role. + */ + public boolean isUserHasSourcingRole(ScriptInstance scriptInstance) { + if (scriptInstance != null && scriptInstance.getSourcingRolesNullSafe() != null && !scriptInstance.getSourcingRolesNullSafe().isEmpty()) { + Set sourcingRoles = scriptInstance.getSourcingRolesNullSafe(); + for (Role role : sourcingRoles) { + if (currentUser.hasRole(role.getName())) { + return true; + } + } + return false; + } + return true; + } + + /** + * This is used to invoke a method in a new transaction from a script.
+ * This will prevent DB errors in the script from affecting notification history creation. + * + * @param workerName The name of the API or service that will be invoked. + * @param methodName The name of the method that will be invoked. + * @param parameters The array of parameters accepted by the method. They must be specified in exactly the same order as the target method. + * @throws org.meveo.admin.exception.BusinessException business exception. + */ + @JpaAmpNewTx + @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) + public void callWithNewTransaction(String workerName, String methodName, Object... parameters) throws BusinessException { + try { + Object worker = EjbUtils.getServiceInterface(workerName); + String workerClassName = ReflectionUtils.getCleanClassName(worker.getClass().getName()); + Class workerClass = Class.forName(workerClassName); + Method method = null; + if (parameters.length < 1) { + method = workerClass.getDeclaredMethod(methodName); + } else { + String className = null; + Object parameter = null; + Class[] parameterTypes = new Class[parameters.length]; + for (int i = 0; i < parameters.length; i++) { + parameter = parameters[i]; + className = ReflectionUtils.getCleanClassName(parameter.getClass().getName()); + parameterTypes[i] = Class.forName(className); + } + method = workerClass.getDeclaredMethod(methodName, parameterTypes); + } + method.setAccessible(true); + method.invoke(worker, parameters); + } catch (Exception e) { + if (e.getCause() != null) { + throw new BusinessException(e.getCause()); + } else { + throw new BusinessException(e); + } + } + } + + /** + * Get all script interfaces with compiling those that are not compiled yet + * + * @return the allScriptInterfaces + */ + public List getAllScriptInterfacesWCompile() { + + List scriptInterfaces = new ArrayList<>(); + + List scriptInstances = findByType(ScriptSourceTypeEnum.JAVA); + for (ScriptInstance scriptInstance : scriptInstances) { + try { + scriptInterfaces.add(getScriptInterfaceWCompile(scriptInstance.getCode())); + } catch (ElementNotFoundException | InvalidScriptException e) { + // Ignore errors here as they were logged in a call before + } + } + + return scriptInterfaces; + } + + @Override + protected void executeEngine(ScriptInterface engine, Map context) throws ScriptExecutionException { + ScriptTransactionType txType; + + try { + txType = getEntityManager() + .createQuery("SELECT transactionType FROM ScriptInstance WHERE code = :code", ScriptTransactionType.class) + .setParameter("code", engine.getClass().getName()) + .getSingleResult(); + } catch (NoResultException e) { + txType = ScriptTransactionType.SAME; + } + + switch(txType) { + case MANUAL: + scriptExecutor.executeManualTx(engine, context); + break; + case NEW: + scriptExecutor.executeInNewTx(engine, context); + break; + case NONE: + scriptExecutor.executeNoTx(engine, context); + break; + case SAME: + default: + super.executeEngine(engine, context); + } + } + + /** + * Compile the scripts the has been installed with the module + * + * @param module installed module + * @throws InvalidScriptException if one of the script can't be compiled + */ + public void postModuleInstall(@Observes @ModulePostInstall @Priority(2) MeveoModule module) throws InvalidScriptException { + reCompileAll(module); + } + + public void reCompileAll(MeveoModule module) throws InvalidScriptException { + var scripts = module.getModuleItems().stream() + .filter(item -> item.getItemClass().equals(ScriptInstance.class.getName())) + .map(item -> findByCode(item.getItemCode())) + .collect(Collectors.toList()); + + if (!scripts.isEmpty()) { + compileScripts(scripts); + } + } + + /** + * see java-doc {@link BusinessService#addFilesToModule(org.meveo.model.BusinessEntity, MeveoModule)} + */ + @Override + public void addFilesToModule(ScriptInstance entity, MeveoModule module) throws BusinessException { + super.addFilesToModule(entity, module); + String extension = entity.getSourceTypeEnum() == ScriptSourceTypeEnum.ES5 ? ".js" : ".java"; + if (extension == ".java") { + String path = entity.getCode().replaceAll("\\.", "/"); + + File gitDirectory = GitHelper.getRepositoryDir(currentUser, module.getCode() + "/facets/java/"); + String pathNewFile = path + ".java"; + + File newFile = new File(gitDirectory, pathNewFile); + + try { + MeveoFileUtils.writeAndPreserveCharset(entity.getScript(), newFile); + } catch (IOException e) { + throw new BusinessException("File cannot be write", e); + } + + String message = "Add the script File : " + entity.getCode() + "in the module : " + module.getCode(); + try { + message+=" "+commitMessageBean.getCommitMessage(); + } catch (ContextNotActiveException e) { + log.warn("No active session found for getting commit message when "+message+" to "+module.getCode()); + } + gitClient.commitFiles(module.getGitRepository(), Collections.singletonList(newFile), message); + } + } + + @Override + protected BaseEntityDto getDto(ScriptInstance entity) throws BusinessException { + ScriptInstanceDto dto = (ScriptInstanceDto) super.getDto(entity); + dto.setScript(null); + return dto; + } + + @Override + public Logger getLogger() { + return log; + } + } \ No newline at end of file diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/script/maven/MavenClassPathInitializer.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/script/maven/MavenClassPathInitializer.java index 80618144b..b48531371 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/script/maven/MavenClassPathInitializer.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/script/maven/MavenClassPathInitializer.java @@ -6,16 +6,14 @@ import java.util.List; import javax.inject.Inject; -import javax.transaction.Transactional; import org.meveo.admin.listener.MeveoInitializer; import org.meveo.admin.listener.StartupListener; -import org.meveo.jpa.EntityManagerWrapper; -import org.meveo.jpa.MeveoJpa; import org.meveo.model.scripts.MavenDependency; import org.meveo.service.script.MavenDependencyService; import org.meveo.service.script.ScriptInstanceService; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Add all defined maven libaries to class path.
@@ -34,8 +32,7 @@ public class MavenClassPathInitializer implements MeveoInitializer { @Inject private MavenDependencyService mavenDependencyService; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(MavenClassPathInitializer.class); @Override public void init() throws Exception { diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/storage/FileSystemService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/storage/FileSystemService.java index 04b26b317..4153dd1b7 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/storage/FileSystemService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/storage/FileSystemService.java @@ -32,6 +32,7 @@ import org.meveo.security.CurrentUser; import org.meveo.security.MeveoUser; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author Edward P. Legaspi @@ -50,8 +51,7 @@ public class FileSystemService { @Inject private RepositoryService repositoryService; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(FileSystemService.class); /** * Remove the folders corresponding to a given field diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/technicalservice/TechnicalServiceService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/technicalservice/TechnicalServiceService.java index 5eeea2474..f8321ae92 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/technicalservice/TechnicalServiceService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/technicalservice/TechnicalServiceService.java @@ -47,6 +47,8 @@ import org.meveo.model.technicalservice.TechnicalService; import org.meveo.service.script.FunctionService; import org.meveo.service.script.technicalservice.TechnicalServiceEngine; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Technical service persistence service. @@ -56,6 +58,8 @@ */ public abstract class TechnicalServiceService extends FunctionService> { + private static Logger log = LoggerFactory.getLogger(TechnicalServiceService.class); + @Override public List getInputs(T function) throws BusinessException { try { diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/technicalservice/endpoint/ESGeneratorService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/technicalservice/endpoint/ESGeneratorService.java index a13a7c9e0..dd8c5188f 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/technicalservice/endpoint/ESGeneratorService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/technicalservice/endpoint/ESGeneratorService.java @@ -21,6 +21,7 @@ import org.meveo.service.script.ScriptUtils; import org.meveo.service.technicalservice.endpoint.schema.EndpointSchemaService; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This service is use to build the endpoint interface from a template file. The @@ -45,8 +46,7 @@ public class ESGeneratorService { @Inject private ESGeneratorService esGeneratorService; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(ESGeneratorService.class); /** * Generates an endpoint interface in js code using a template file. diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/technicalservice/endpoint/EndpointCacheContainer.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/technicalservice/endpoint/EndpointCacheContainer.java index 1b2f1a242..0064f226d 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/technicalservice/endpoint/EndpointCacheContainer.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/technicalservice/endpoint/EndpointCacheContainer.java @@ -57,6 +57,7 @@ import org.meveo.service.script.weld.MeveoBeanManager; import org.meveo.service.technicalservice.endpoint.pool.ScriptInterfacePoolFactory; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author Clément Bareth * @@ -67,9 +68,8 @@ @Startup public class EndpointCacheContainer { - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(EndpointCacheContainer.class); @Resource(lookup = "java:jboss/infinispan/cache/meveo/endpoints-results") private Cache pendingExecutions; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/technicalservice/endpoint/EndpointService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/technicalservice/endpoint/EndpointService.java index 1d844c73c..8023d387b 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/technicalservice/endpoint/EndpointService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/technicalservice/endpoint/EndpointService.java @@ -44,9 +44,12 @@ import org.meveo.model.technicalservice.endpoint.Endpoint; import org.meveo.service.admin.impl.PermissionService; import org.meveo.service.base.BusinessService; +import org.meveo.service.custom.CustomEntityTemplateService; import org.meveo.service.git.GitClient; import org.meveo.service.git.GitHelper; import org.meveo.service.git.MeveoRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * EJB for managing technical services endpoints @@ -61,6 +64,8 @@ public class EndpointService extends BusinessService { public static final String EXECUTE_ENDPOINT_TEMPLATE = "Execute_Endpoint_%s"; + private static Logger log = LoggerFactory.getLogger(EndpointService.class); + @Inject private GitClient gitClient; @@ -262,4 +267,9 @@ private void validatePath(Endpoint entity) throws BusinessException { } } } + + @Override + public Logger getLogger() { + return log; + } } \ No newline at end of file diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/technicalservice/endpoint/README.md b/meveo-admin/ejbs/src/main/java/org/meveo/service/technicalservice/endpoint/README.md index 21833fe12..d126de905 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/technicalservice/endpoint/README.md +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/technicalservice/endpoint/README.md @@ -221,7 +221,7 @@ import org.slf4j.Logger; public class PooledScriptExample extends Script { - private Logger log = LoggerFactory.getLogger(PooledScriptExample.class); + private static Logger log = LoggerFactory.getLogger(PooledScriptExample.class); private String uuid; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/technicalservice/event/EndpointEventListener.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/technicalservice/event/EndpointEventListener.java index 02a4f0081..bcde5c7c9 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/technicalservice/event/EndpointEventListener.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/technicalservice/event/EndpointEventListener.java @@ -18,7 +18,6 @@ import javax.enterprise.event.TransactionPhase; import javax.inject.Inject; -import jnr.ffi.annotations.In; import org.apache.commons.io.FileUtils; import org.jboss.weld.contexts.ContextNotActiveException; import org.meveo.admin.exception.BusinessException; @@ -27,7 +26,6 @@ import org.meveo.event.qualifier.Created; import org.meveo.event.qualifier.Removed; import org.meveo.event.qualifier.Updated; -import org.meveo.model.ModuleItem; import org.meveo.model.git.GitRepository; import org.meveo.model.module.MeveoModule; import org.meveo.model.technicalservice.endpoint.Endpoint; @@ -39,6 +37,7 @@ import org.meveo.service.technicalservice.endpoint.ESGeneratorService; import org.meveo.service.technicalservice.endpoint.EndpointService; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Process CRUD events generated by {@link Endpoint}. @@ -56,8 +55,7 @@ public class EndpointEventListener { @CurrentUser protected MeveoUser currentUser; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(EndpointEventListener.class); @Inject private EndpointService endpointService; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/technicalservice/wsendpoint/WebsocketServerEndpoint.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/technicalservice/wsendpoint/WebsocketServerEndpoint.java index 6b5d57373..038e734a7 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/technicalservice/wsendpoint/WebsocketServerEndpoint.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/technicalservice/wsendpoint/WebsocketServerEndpoint.java @@ -2,21 +2,26 @@ import java.io.IOException; import java.security.Principal; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; import javax.ejb.Stateless; import javax.inject.Inject; -import javax.websocket.server.PathParam; -import javax.websocket.server.ServerEndpoint; import javax.websocket.CloseReason; +import javax.websocket.CloseReason.CloseCodes; import javax.websocket.EndpointConfig; import javax.websocket.OnClose; import javax.websocket.OnError; import javax.websocket.OnMessage; import javax.websocket.OnOpen; import javax.websocket.Session; -import javax.websocket.CloseReason.CloseCodes; +import javax.websocket.server.PathParam; +import javax.websocket.server.ServerEndpoint; import org.meveo.admin.exception.BusinessException; import org.meveo.cache.UserMessageCacheContainerProvider; @@ -27,13 +32,14 @@ import org.meveo.service.script.FunctionService; import org.meveo.service.script.ScriptInterface; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @ServerEndpoint("/ws/{endpoint-name}") @Stateless public class WebsocketServerEndpoint { - @Inject - private Logger log; - + + private static Logger log = LoggerFactory.getLogger(WebsocketServerEndpoint.class); + @Inject private WSEndpointService wsEndpointService; diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/wf/WFDecisionRuleService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/wf/WFDecisionRuleService.java index 9ff23485f..99721ad89 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/wf/WFDecisionRuleService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/wf/WFDecisionRuleService.java @@ -25,10 +25,15 @@ import org.meveo.model.wf.WFDecisionRule; import org.meveo.service.base.PersistenceService; +import org.meveo.service.custom.CustomEntityTemplateService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @Stateless public class WFDecisionRuleService extends PersistenceService { + private static Logger log = LoggerFactory.getLogger(WFDecisionRuleService.class); + @SuppressWarnings("unchecked") public List getDistinctNameWFTransitionRules() { try { @@ -95,4 +100,9 @@ public WFDecisionRule getWFDecisionRuleByName(String name) { } return wfDecisionRule; } + + @Override + public Logger getLogger() { + return log; + } } diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/wf/WFTransitionService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/wf/WFTransitionService.java index 7efb828d2..4f1d06105 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/wf/WFTransitionService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/wf/WFTransitionService.java @@ -35,10 +35,15 @@ import org.meveo.model.wf.WFTransition; import org.meveo.model.wf.Workflow; import org.meveo.service.base.PersistenceService; +import org.meveo.service.custom.CustomEntityTemplateService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @Stateless public class WFTransitionService extends PersistenceService { + private static Logger log = LoggerFactory.getLogger(WFTransitionService.class); + @Inject private WFActionService wfActionService; @@ -146,4 +151,9 @@ public WFTransition update(WFTransition entity) throws BusinessException { public void remove(WFTransition entity) throws BusinessException { super.remove(entity); } + + @Override + public Logger getLogger() { + return log; + } } diff --git a/meveo-admin/ejbs/src/main/java/org/meveo/service/wf/WorkflowService.java b/meveo-admin/ejbs/src/main/java/org/meveo/service/wf/WorkflowService.java index 8fe4d72df..8d2e83394 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveo/service/wf/WorkflowService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveo/service/wf/WorkflowService.java @@ -56,10 +56,14 @@ import org.meveo.service.base.MeveoValueExpressionWrapper; import org.meveo.service.script.ScriptInstanceService; import org.meveo.service.script.ScriptInterfaceSupplier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @Stateless public class WorkflowService extends BusinessService { + private static Logger log = LoggerFactory.getLogger(WorkflowService.class); + @Inject private ScriptInstanceService scriptInstanceService; @@ -427,4 +431,9 @@ public void create(Workflow entity) throws BusinessException { public Workflow update(Workflow entity) throws BusinessException { return super.update(entity); } + + @Override + public Logger getLogger() { + return log; + } } diff --git a/meveo-admin/ejbs/src/main/java/org/meveocrm/services/dwh/MeasurableQuantityService.java b/meveo-admin/ejbs/src/main/java/org/meveocrm/services/dwh/MeasurableQuantityService.java index 9639e6312..b870064d9 100644 --- a/meveo-admin/ejbs/src/main/java/org/meveocrm/services/dwh/MeasurableQuantityService.java +++ b/meveo-admin/ejbs/src/main/java/org/meveocrm/services/dwh/MeasurableQuantityService.java @@ -10,10 +10,14 @@ import org.meveo.commons.utils.StringUtils; import org.meveo.model.dwh.MeasurableQuantity; import org.meveo.service.base.BusinessService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @Stateless public class MeasurableQuantityService extends BusinessService { + private static Logger log = LoggerFactory.getLogger(MeasurableQuantityService.class); + public Object[] executeMeasurableQuantitySQL(MeasurableQuantity mq) { try { Query q = getEntityManager().createNativeQuery(mq.getSqlQuery()); @@ -69,4 +73,9 @@ public List listByCodeAndDim(String measurableQuantityCode, Query query = queryBuilder.getQuery(getEntityManager()); return query.getResultList(); } + + @Override + public Logger getLogger() { + return log; + } } diff --git a/meveo-admin/web/src/main/java/org/jboss/seam/international/locale/DefaultLocaleProducer.java b/meveo-admin/web/src/main/java/org/jboss/seam/international/locale/DefaultLocaleProducer.java index 8bfcbcd69..7e427a92a 100644 --- a/meveo-admin/web/src/main/java/org/jboss/seam/international/locale/DefaultLocaleProducer.java +++ b/meveo-admin/web/src/main/java/org/jboss/seam/international/locale/DefaultLocaleProducer.java @@ -34,7 +34,7 @@ public class DefaultLocaleProducer implements Serializable { private static final long serialVersionUID = -4534087316489937649L; - private Logger log = LoggerFactory.getLogger(DefaultLocaleProducer.class); + private static Logger log = LoggerFactory.getLogger(DefaultLocaleProducer.class); @Inject @DefaultLocale diff --git a/meveo-admin/web/src/main/java/org/jboss/seam/international/status/MessagesImpl.java b/meveo-admin/web/src/main/java/org/jboss/seam/international/status/MessagesImpl.java index e30b541fd..c3398a056 100644 --- a/meveo-admin/web/src/main/java/org/jboss/seam/international/status/MessagesImpl.java +++ b/meveo-admin/web/src/main/java/org/jboss/seam/international/status/MessagesImpl.java @@ -38,8 +38,6 @@ public class MessagesImpl implements Messages { @Inject private MessageFactory factory; - // private Logger log = LoggerFactory.getLogger(this.getClass()); - public void clear() { Iterator it = FacesContext.getCurrentInstance().getMessages(); while (it.hasNext()) { diff --git a/meveo-admin/web/src/main/java/org/meveo/admin/action/DefaultImageStreamer.java b/meveo-admin/web/src/main/java/org/meveo/admin/action/DefaultImageStreamer.java index 49621872f..cfc836a85 100644 --- a/meveo-admin/web/src/main/java/org/meveo/admin/action/DefaultImageStreamer.java +++ b/meveo-admin/web/src/main/java/org/meveo/admin/action/DefaultImageStreamer.java @@ -19,6 +19,7 @@ import org.primefaces.model.DefaultStreamedContent; import org.primefaces.model.StreamedContent; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author Edward P. Legaspi @@ -29,8 +30,7 @@ @ApplicationScoped public class DefaultImageStreamer { - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(DefaultImageStreamer.class); @Inject @ApplicationProvider diff --git a/meveo-admin/web/src/main/java/org/meveo/admin/action/admin/DocumentBean.java b/meveo-admin/web/src/main/java/org/meveo/admin/action/admin/DocumentBean.java index 96f2347a3..7ca2c9856 100644 --- a/meveo-admin/web/src/main/java/org/meveo/admin/action/admin/DocumentBean.java +++ b/meveo-admin/web/src/main/java/org/meveo/admin/action/admin/DocumentBean.java @@ -48,6 +48,7 @@ import org.meveo.model.crm.Provider; import org.meveo.util.ApplicationProvider; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @Named @ConversationScoped @@ -55,8 +56,7 @@ public class DocumentBean implements Serializable { private static final long serialVersionUID = 1L; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(DocumentBean.class); private List documents; diff --git a/meveo-admin/web/src/main/java/org/meveo/admin/action/admin/EntityExportImportBean.java b/meveo-admin/web/src/main/java/org/meveo/admin/action/admin/EntityExportImportBean.java index e2d95684f..effdd5faa 100644 --- a/meveo-admin/web/src/main/java/org/meveo/admin/action/admin/EntityExportImportBean.java +++ b/meveo-admin/web/src/main/java/org/meveo/admin/action/admin/EntityExportImportBean.java @@ -37,6 +37,7 @@ import org.primefaces.model.LazyDataModel; import org.primefaces.model.SortOrder; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @Named @ViewScoped @@ -47,8 +48,7 @@ public class EntityExportImportBean implements Serializable { private static String FILTER_TEMPLATENAME = "templateName"; private static String FILTER_COMPLEX = "complex"; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(EntityExportImportBean.class); /** Search filters. */ protected Map filters = new HashMap(); diff --git a/meveo-admin/web/src/main/java/org/meveo/admin/action/admin/LogViewerBean.java b/meveo-admin/web/src/main/java/org/meveo/admin/action/admin/LogViewerBean.java index 5ead0153a..6247689d0 100644 --- a/meveo-admin/web/src/main/java/org/meveo/admin/action/admin/LogViewerBean.java +++ b/meveo-admin/web/src/main/java/org/meveo/admin/action/admin/LogViewerBean.java @@ -18,6 +18,7 @@ import org.meveo.commons.utils.ParamBean; import org.primefaces.PrimeFaces; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.unix4j.Unix4j; import org.unix4j.unix.grep.GrepOption; import org.unix4j.unix.grep.GrepOptions; @@ -35,7 +36,7 @@ public class LogViewerBean implements Serializable { private static final long serialVersionUID = 3761175276890871506L; @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(LogViewerBean.class); @Inject protected Messages messages; diff --git a/meveo-admin/web/src/main/java/org/meveo/admin/action/admin/custom/CustomEntityInstanceBean.java b/meveo-admin/web/src/main/java/org/meveo/admin/action/admin/custom/CustomEntityInstanceBean.java index f5a89eef4..b5ba4eb6e 100644 --- a/meveo-admin/web/src/main/java/org/meveo/admin/action/admin/custom/CustomEntityInstanceBean.java +++ b/meveo-admin/web/src/main/java/org/meveo/admin/action/admin/custom/CustomEntityInstanceBean.java @@ -56,6 +56,7 @@ import org.primefaces.PrimeFaces; import org.primefaces.model.LazyDataModel; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author Edward P. Legaspi | czetsuya@gmail.com @@ -67,8 +68,7 @@ public class CustomEntityInstanceBean extends CustomFieldBean customFieldTemplateList = new ArrayList<>(); diff --git a/meveo-admin/web/src/main/java/org/meveo/admin/action/admin/custom/CustomFieldDataEntryBean.java b/meveo-admin/web/src/main/java/org/meveo/admin/action/admin/custom/CustomFieldDataEntryBean.java index 74fd17473..8101cc75e 100644 --- a/meveo-admin/web/src/main/java/org/meveo/admin/action/admin/custom/CustomFieldDataEntryBean.java +++ b/meveo-admin/web/src/main/java/org/meveo/admin/action/admin/custom/CustomFieldDataEntryBean.java @@ -108,7 +108,7 @@ public class CustomFieldDataEntryBean implements Serializable { private static final long serialVersionUID = 2587695185934268809L; /** Logger. */ - protected Logger log = LoggerFactory.getLogger(this.getClass()); + protected static Logger log = LoggerFactory.getLogger(CustomFieldDataEntryBean.class); /** * Custom field templates grouped into tabs and field groups diff --git a/meveo-admin/web/src/main/java/org/meveo/admin/action/audit/AuditConfigurationBean.java b/meveo-admin/web/src/main/java/org/meveo/admin/action/audit/AuditConfigurationBean.java index 2557c6d3a..da96693e7 100644 --- a/meveo-admin/web/src/main/java/org/meveo/admin/action/audit/AuditConfigurationBean.java +++ b/meveo-admin/web/src/main/java/org/meveo/admin/action/audit/AuditConfigurationBean.java @@ -24,6 +24,7 @@ import org.meveo.service.base.local.IPersistenceService; import org.primefaces.model.DualListModel; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author Edward P. Legaspi @@ -34,8 +35,7 @@ public class AuditConfigurationBean implements Serializable { private static final long serialVersionUID = -2288050777565855090L; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(AuditConfigurationBean.class); @Inject private Messages messages; diff --git a/meveo-admin/web/src/main/java/org/meveo/admin/action/frontend/FrontendServlet.java b/meveo-admin/web/src/main/java/org/meveo/admin/action/frontend/FrontendServlet.java index 171190787..2687be5cb 100644 --- a/meveo-admin/web/src/main/java/org/meveo/admin/action/frontend/FrontendServlet.java +++ b/meveo-admin/web/src/main/java/org/meveo/admin/action/frontend/FrontendServlet.java @@ -22,6 +22,7 @@ import org.meveo.commons.utils.ParamBeanFactory; import org.meveo.service.crm.impl.ProviderService; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /* originally from @author BalusC in LGPL licence ** @link http://balusc.blogspot.com/2009/02/fileservlet-supporting-resume-and.html @@ -37,8 +38,7 @@ public class FrontendServlet extends HttpServlet { private static final long DEFAULT_EXPIRE_TIME = 604800000L; // ..ms = 1 week. private static final String MULTIPART_BOUNDARY = "MULTIPART_BYTERANGES"; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(FrontendServlet.class); @Inject ProviderService providerService; diff --git a/meveo-admin/web/src/main/java/org/meveo/admin/action/frontend/RessourceServlet.java b/meveo-admin/web/src/main/java/org/meveo/admin/action/frontend/RessourceServlet.java index 17e094737..9b3d24df0 100644 --- a/meveo-admin/web/src/main/java/org/meveo/admin/action/frontend/RessourceServlet.java +++ b/meveo-admin/web/src/main/java/org/meveo/admin/action/frontend/RessourceServlet.java @@ -21,6 +21,7 @@ import org.meveo.commons.utils.ParamBeanFactory; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /* originally from @author BalusC in LGPL licence ** @link http://balusc.blogspot.com/2009/02/fileservlet-supporting-resume-and.html @@ -36,8 +37,7 @@ public class RessourceServlet extends HttpServlet { private static final long DEFAULT_EXPIRE_TIME = 604800000L; // ..ms = 1 week. private static final String MULTIPART_BOUNDARY = "MULTIPART_BYTERANGES"; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(RessourceServlet.class); /** paramBeanFactory */ @Inject diff --git a/meveo-admin/web/src/main/java/org/meveo/admin/action/storage/GitRepositoryBean.java b/meveo-admin/web/src/main/java/org/meveo/admin/action/storage/GitRepositoryBean.java index a4f43ef1b..7ab9e3e66 100644 --- a/meveo-admin/web/src/main/java/org/meveo/admin/action/storage/GitRepositoryBean.java +++ b/meveo-admin/web/src/main/java/org/meveo/admin/action/storage/GitRepositoryBean.java @@ -22,7 +22,6 @@ import org.meveo.api.BaseCrudApi; import org.meveo.api.dto.git.GitRepositoryDto; import org.meveo.api.dto.module.ModuleDependencyDto; -import org.meveo.api.exception.MeveoApiException; import org.meveo.api.exception.MissingModuleException; import org.meveo.api.git.GitRepositoryApi; import org.meveo.api.module.MeveoModuleApi; @@ -43,6 +42,7 @@ import org.primefaces.model.StreamedContent; import org.primefaces.model.UploadedFile; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Controller for managing git repository model. @@ -69,8 +69,7 @@ public class GitRepositoryBean extends BaseCrudBean contexts; diff --git a/meveo-admin/web/src/main/java/org/meveo/admin/web/interceptor/BackingBeanActionMethodInterceptor.java b/meveo-admin/web/src/main/java/org/meveo/admin/web/interceptor/BackingBeanActionMethodInterceptor.java index f87f7689a..5c6e09dc4 100644 --- a/meveo-admin/web/src/main/java/org/meveo/admin/web/interceptor/BackingBeanActionMethodInterceptor.java +++ b/meveo-admin/web/src/main/java/org/meveo/admin/web/interceptor/BackingBeanActionMethodInterceptor.java @@ -34,7 +34,7 @@ public class BackingBeanActionMethodInterceptor implements Serializable { private static final long serialVersionUID = -8361765042326423662L; - private Logger log = LoggerFactory.getLogger(this.getClass()); + private static Logger log = LoggerFactory.getLogger(BackingBeanActionMethodInterceptor.class); @Inject protected Messages messages; diff --git a/meveo-admin/web/src/main/java/org/meveo/admin/web/servlet/MavenFileServlet.java b/meveo-admin/web/src/main/java/org/meveo/admin/web/servlet/MavenFileServlet.java index a55674574..3987a98d7 100644 --- a/meveo-admin/web/src/main/java/org/meveo/admin/web/servlet/MavenFileServlet.java +++ b/meveo-admin/web/src/main/java/org/meveo/admin/web/servlet/MavenFileServlet.java @@ -27,7 +27,6 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; -import org.apache.commons.io.IOUtils; import org.meveo.commons.utils.ParamBean; import org.meveo.model.module.MeveoModule; import org.meveo.security.CurrentUser; @@ -35,6 +34,7 @@ import org.meveo.service.admin.impl.MeveoModuleService; import org.meveo.service.config.impl.MavenConfigurationService; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Allows the user to download a jar file from Meveo. Directory hierarchy is @@ -64,8 +64,7 @@ public class MavenFileServlet extends HttpServlet { @Inject private MeveoModuleService moduleService; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(MavenFileServlet.class); private String userPath; diff --git a/meveo-admin/web/src/main/java/org/meveo/util/view/CrossStorageDataModel.java b/meveo-admin/web/src/main/java/org/meveo/util/view/CrossStorageDataModel.java index 08cafae14..a4d3091dc 100644 --- a/meveo-admin/web/src/main/java/org/meveo/util/view/CrossStorageDataModel.java +++ b/meveo-admin/web/src/main/java/org/meveo/util/view/CrossStorageDataModel.java @@ -42,7 +42,7 @@ public abstract class CrossStorageDataModel extends LazyDataModel pages; private String pagesDirectory; diff --git a/meveo-api/src/main/java/org/meveo/api/git/MeveoGitServlet.java b/meveo-api/src/main/java/org/meveo/api/git/MeveoGitServlet.java index 4835afca7..c06f2501b 100644 --- a/meveo-api/src/main/java/org/meveo/api/git/MeveoGitServlet.java +++ b/meveo-api/src/main/java/org/meveo/api/git/MeveoGitServlet.java @@ -16,13 +16,32 @@ package org.meveo.api.git; +import static org.eclipse.jgit.transport.SideBandOutputStream.CH_ERROR; +import static org.eclipse.jgit.transport.SideBandOutputStream.MAX_BUF; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.Collections; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.enterprise.event.Event; +import javax.inject.Inject; +import javax.servlet.ServletConfig; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.ServletOutputStream; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + import org.eclipse.jgit.http.server.GitServlet; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.transport.PacketLineOut; import org.eclipse.jgit.transport.SideBandOutputStream; -import org.keycloak.KeycloakPrincipal; -import org.keycloak.representations.AccessToken; import org.meveo.admin.exception.BusinessException; import org.meveo.event.qualifier.git.CommitEvent; import org.meveo.event.qualifier.git.CommitReceived; @@ -35,22 +54,7 @@ import org.meveo.service.git.GitRepositoryService; import org.meveo.service.git.MeveoRepository; import org.slf4j.Logger; - -import javax.enterprise.event.Event; -import javax.inject.Inject; -import javax.servlet.ServletConfig; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.ServletOutputStream; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.*; - -import static org.eclipse.jgit.transport.SideBandOutputStream.CH_ERROR; -import static org.eclipse.jgit.transport.SideBandOutputStream.MAX_BUF; +import org.slf4j.LoggerFactory; /** * Servlet enabling git through HTTP(s) @@ -81,8 +85,7 @@ public class MeveoGitServlet extends GitServlet { @Inject private GitRepositoryService gitRepositoryService; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(MeveoGitServlet.class); @Inject @CommitReceived diff --git a/meveo-api/src/main/java/org/meveo/api/logging/WsRestApiInterceptor.java b/meveo-api/src/main/java/org/meveo/api/logging/WsRestApiInterceptor.java index 2f428d5d9..499bf3430 100644 --- a/meveo-api/src/main/java/org/meveo/api/logging/WsRestApiInterceptor.java +++ b/meveo-api/src/main/java/org/meveo/api/logging/WsRestApiInterceptor.java @@ -22,7 +22,7 @@ public class WsRestApiInterceptor { @CurrentUser private MeveoUser currentUser; - private Logger log = LoggerFactory.getLogger(this.getClass()); + private static Logger log = LoggerFactory.getLogger(WsRestApiInterceptor.class); @AroundInvoke public Object aroundInvoke(InvocationContext invocationContext) throws Exception { diff --git a/meveo-api/src/main/java/org/meveo/api/module/MeveoModuleItemInstaller.java b/meveo-api/src/main/java/org/meveo/api/module/MeveoModuleItemInstaller.java index 163646714..d7663f885 100644 --- a/meveo-api/src/main/java/org/meveo/api/module/MeveoModuleItemInstaller.java +++ b/meveo-api/src/main/java/org/meveo/api/module/MeveoModuleItemInstaller.java @@ -1,6 +1,5 @@ package org.meveo.api.module; -import java.io.IOException; import java.sql.SQLException; import java.util.ArrayList; import java.util.Collection; @@ -33,7 +32,6 @@ import org.meveo.api.CustomFieldTemplateApi; import org.meveo.api.EntityCustomActionApi; import org.meveo.api.dto.BaseEntityDto; -import org.meveo.api.dto.BusinessEntityDto; import org.meveo.api.dto.CustomEntityInstanceDto; import org.meveo.api.dto.CustomEntityTemplateDto; import org.meveo.api.dto.CustomFieldTemplateDto; @@ -43,9 +41,7 @@ import org.meveo.api.dto.module.MeveoModuleDto; import org.meveo.api.dto.module.MeveoModuleItemDto; import org.meveo.api.exception.ActionForbiddenException; -import org.meveo.api.exception.BusinessApiException; import org.meveo.api.exception.EntityAlreadyExistsException; -import org.meveo.api.exception.EntityDoesNotExistsException; import org.meveo.api.exception.MeveoApiException; import org.meveo.api.exceptions.ModuleInstallFail; import org.meveo.commons.utils.MvCollectionUtils; @@ -56,7 +52,6 @@ import org.meveo.model.IEntity; import org.meveo.model.ModuleInstall; import org.meveo.model.ModuleItemOrder; -import org.meveo.model.ModulePostInstall; import org.meveo.model.ModulePostUninstall; import org.meveo.model.VersionedEntity; import org.meveo.model.crm.CustomFieldTemplate; @@ -69,10 +64,8 @@ import org.meveo.model.persistence.CEIUtils; import org.meveo.model.persistence.DBStorageType; import org.meveo.model.persistence.JacksonUtil; -import org.meveo.model.scripts.Function; import org.meveo.model.scripts.ScriptInstance; import org.meveo.model.storage.Repository; -import org.meveo.model.technicalservice.endpoint.Endpoint; import org.meveo.persistence.CrossStorageService; import org.meveo.service.admin.impl.MeveoModuleService; import org.meveo.service.admin.impl.MeveoModuleUtils; @@ -87,6 +80,7 @@ import org.meveo.service.script.module.ModuleScriptInterface; import org.meveo.service.script.module.ModuleScriptService; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Meveo module installer. @@ -105,8 +99,7 @@ public class MeveoModuleItemInstaller { @Inject private EntityCustomActionApi entityCustomActionApi; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(MeveoModuleItemInstaller.class); @Inject private MeveoModuleService meveoModuleService; diff --git a/meveo-api/src/main/java/org/meveo/api/rest/impl/BaseCrudRs.java b/meveo-api/src/main/java/org/meveo/api/rest/impl/BaseCrudRs.java index 819296db4..6a04efc88 100644 --- a/meveo-api/src/main/java/org/meveo/api/rest/impl/BaseCrudRs.java +++ b/meveo-api/src/main/java/org/meveo/api/rest/impl/BaseCrudRs.java @@ -17,26 +17,26 @@ */ package org.meveo.api.rest.impl; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; + +import javax.ws.rs.BadRequestException; +import javax.ws.rs.ServerErrorException; +import javax.ws.rs.core.MediaType; + import org.jboss.resteasy.plugins.providers.multipart.InputPart; import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput; import org.meveo.admin.exception.BusinessException; import org.meveo.api.BaseCrudApi; import org.meveo.api.dto.BaseEntityDto; import org.meveo.api.dto.response.PagingAndFiltering; -import org.meveo.api.exception.InvalidParameterException; import org.meveo.api.exception.MeveoApiException; import org.meveo.api.rest.IBaseBaseCrudRs; import org.meveo.model.IEntity; import org.slf4j.Logger; - -import javax.inject.Inject; -import javax.ws.rs.BadRequestException; -import javax.ws.rs.ServerErrorException; -import javax.ws.rs.core.MediaType; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; +import org.slf4j.LoggerFactory; /** @@ -50,8 +50,7 @@ */ public abstract class BaseCrudRs extends BaseRs implements IBaseBaseCrudRs { - @Inject - private Logger logger; + private static Logger logger = LoggerFactory.getLogger(BaseCrudRs.class); public abstract BaseCrudApi getBaseCrudApi(); diff --git a/meveo-api/src/main/java/org/meveo/api/rest/persistence/PersistenceRs.java b/meveo-api/src/main/java/org/meveo/api/rest/persistence/PersistenceRs.java index 2f36e50e0..ceb6f0461 100644 --- a/meveo-api/src/main/java/org/meveo/api/rest/persistence/PersistenceRs.java +++ b/meveo-api/src/main/java/org/meveo/api/rest/persistence/PersistenceRs.java @@ -160,8 +160,7 @@ public class PersistenceRs { @Inject private CrossStorageTransaction crossStorageTx; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(PersistenceRs.class); @Inject private CustomEntityInstanceService customEntityInstanceService; diff --git a/meveo-api/src/main/java/org/meveo/api/security/filter/SecureMethodResultFilterFactory.java b/meveo-api/src/main/java/org/meveo/api/security/filter/SecureMethodResultFilterFactory.java index 57c909256..bdf93646b 100644 --- a/meveo-api/src/main/java/org/meveo/api/security/filter/SecureMethodResultFilterFactory.java +++ b/meveo-api/src/main/java/org/meveo/api/security/filter/SecureMethodResultFilterFactory.java @@ -11,6 +11,7 @@ import javax.inject.Singleton; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This factory encapsulates the creation and retrieval of @@ -29,8 +30,7 @@ public class SecureMethodResultFilterFactory implements Serializable { @Inject private Instance filters; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(SecureMethodResultFilterFactory.class); private Map, SecureMethodResultFilter> filterMap = new HashMap<>(); diff --git a/meveo-model/src/main/java/org/meveo/commons/utils/XStreamCDATAConverter.java b/meveo-model/src/main/java/org/meveo/commons/utils/XStreamCDATAConverter.java index fa643094f..f5b5a4f5b 100644 --- a/meveo-model/src/main/java/org/meveo/commons/utils/XStreamCDATAConverter.java +++ b/meveo-model/src/main/java/org/meveo/commons/utils/XStreamCDATAConverter.java @@ -15,7 +15,7 @@ **/ public class XStreamCDATAConverter implements Converter { - private Logger log = LoggerFactory.getLogger(this.getClass()); + private static Logger log = LoggerFactory.getLogger(XStreamCDATAConverter.class); public static final String CDATA_START = ""; diff --git a/meveo-model/src/main/java/org/meveo/model/scripts/JPAtoCDIListener.java b/meveo-model/src/main/java/org/meveo/model/scripts/JPAtoCDIListener.java index 5a3a3f77d..843af5ecf 100644 --- a/meveo-model/src/main/java/org/meveo/model/scripts/JPAtoCDIListener.java +++ b/meveo-model/src/main/java/org/meveo/model/scripts/JPAtoCDIListener.java @@ -30,8 +30,6 @@ */ public class JPAtoCDIListener { - private Logger log = LoggerFactory.getLogger(JPAtoCDIListener.class); - @Inject @Created protected Event entityCreatedEventProducer; diff --git a/meveo-security/src/main/java/org/meveo/security/keycloak/AuthenticationProvider.java b/meveo-security/src/main/java/org/meveo/security/keycloak/AuthenticationProvider.java index 5f1219cba..2b1e004f1 100644 --- a/meveo-security/src/main/java/org/meveo/security/keycloak/AuthenticationProvider.java +++ b/meveo-security/src/main/java/org/meveo/security/keycloak/AuthenticationProvider.java @@ -16,7 +16,7 @@ public class AuthenticationProvider { @Inject private HttpServletRequest httpRequest; - private Logger log = LoggerFactory.getLogger(this.getClass()); + private static Logger log = LoggerFactory.getLogger(AuthenticationProvider.class); public String logout() { try { diff --git a/meveo-security/src/main/java/org/meveo/security/keycloak/CurrentUserProvider.java b/meveo-security/src/main/java/org/meveo/security/keycloak/CurrentUserProvider.java index 2c65d241f..1d990350f 100644 --- a/meveo-security/src/main/java/org/meveo/security/keycloak/CurrentUserProvider.java +++ b/meveo-security/src/main/java/org/meveo/security/keycloak/CurrentUserProvider.java @@ -1,7 +1,6 @@ package org.meveo.security.keycloak; import java.time.Instant; -import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.HashSet; @@ -35,6 +34,7 @@ import org.meveo.security.MeveoUser; import org.meveo.security.UserAuthTimeCache; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.slf4j.MDC; @Stateless @@ -51,8 +51,7 @@ public class CurrentUserProvider { @Inject private UserAuthTimeCache userAuthTimeCache; - @Inject - private Logger log; + private static Logger log = LoggerFactory.getLogger(CurrentUserProvider.class); @Inject private BeanManager beanManager;