diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DataStoreService.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DataStoreService.java index b986343df1225e22a7acd0d10956651b0124d629..eb2274f75b11aa61a3907405f9b222d0fccddeb0 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DataStoreService.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DataStoreService.java @@ -37,8 +37,8 @@ import ch.systemsx.cisd.common.mail.MailClientParameters; import ch.systemsx.cisd.common.spring.AbstractServiceWithLogger; import ch.systemsx.cisd.common.spring.IInvocationLoggerContext; import ch.systemsx.cisd.common.utilities.IInitializable; -import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.ArchiverTaskContext; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.ArchiverPluginFactory; +import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.ArchiverTaskContext; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.IArchiverPlugin; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.IProcessingPluginTask; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.IReportingPluginTask; @@ -352,7 +352,7 @@ public class DataStoreService extends AbstractServiceWithLogger<IDataStoreServic private IArchiverPlugin createArchiver() { ArchiverPluginFactory factory = pluginTaskParameters.getArchiverTaskFactory(); - return factory.createInstance(storeRoot, commandExecutor); + return factory.createInstance(storeRoot); } private void scheduleTask(String sessionToken, String description, @@ -424,6 +424,11 @@ public class DataStoreService extends AbstractServiceWithLogger<IDataStoreServic return task.createLink(dataSet); } + public IDataSetCommandExecutor getDataSetCommandExecutor() + { + return commandExecutor; + } + private IShareIdManager getShareIdManager() { if (shareIdManager == null) diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/IDataSetCommandExecutor.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/IDataSetCommandExecutor.java index e05d54176df78421d6c62cdf923c8006a2b15180..bbe4781700bdca7a3352eae6d9daeaa2deb8e6b7 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/IDataSetCommandExecutor.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/IDataSetCommandExecutor.java @@ -21,6 +21,7 @@ import java.util.Map; import ch.systemsx.cisd.common.mail.MailClientParameters; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.IProcessingPluginTask; +import ch.systemsx.cisd.openbis.dss.generic.shared.IDataSetDeleter; import ch.systemsx.cisd.openbis.generic.shared.Constants; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatastoreServiceDescription; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExternalData; @@ -33,7 +34,7 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.DatasetDescription; * * @author Franz-Josef Elmer */ -public interface IDataSetCommandExecutor +public interface IDataSetCommandExecutor extends IDataSetDeleter { /** * Starts up executor. diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/demo/DemoArchiver.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/demo/DemoArchiver.java index b942465059750b19823222fb21501084a6e6f881..259e3a3f01eb9f13cad801d8aa9959a0a6f4e4cf 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/demo/DemoArchiver.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/demo/DemoArchiver.java @@ -25,7 +25,6 @@ import java.util.Set; import ch.systemsx.cisd.common.exceptions.Status; import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.common.filesystem.BooleanStatus; -import ch.systemsx.cisd.openbis.dss.generic.server.IDataSetCommandExecutor; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.standard.AbstractArchiverProcessingPlugin; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.ArchiverTaskContext; import ch.systemsx.cisd.openbis.generic.shared.dto.DatasetDescription; @@ -39,10 +38,9 @@ public class DemoArchiver extends AbstractArchiverProcessingPlugin private final static Set<String/* data set code */> archiveContents = new HashSet<String>(); - public DemoArchiver(Properties properties, File storeRoot, - IDataSetCommandExecutor commandExecutor) + public DemoArchiver(Properties properties, File storeRoot) { - super(properties, storeRoot, commandExecutor, null, null); + super(properties, storeRoot, null, null); } @Override diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/AbstractArchiverProcessingPlugin.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/AbstractArchiverProcessingPlugin.java index 7bf9c34921f71b8f505190660bcaf47ce488da26..a44a92d4c98c3bf0c8491ae3cd24f83dced02ecf 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/AbstractArchiverProcessingPlugin.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/AbstractArchiverProcessingPlugin.java @@ -30,11 +30,11 @@ import java.util.Properties; import ch.systemsx.cisd.common.collections.CollectionUtils; import ch.systemsx.cisd.common.exceptions.Status; import ch.systemsx.cisd.common.filesystem.BooleanStatus; -import ch.systemsx.cisd.openbis.dss.generic.server.IDataSetCommandExecutor; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.ArchiverTaskContext; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.IArchiverPlugin; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.ProcessingStatus; import ch.systemsx.cisd.openbis.dss.generic.shared.QueueingDataSetStatusUpdaterService; +import ch.systemsx.cisd.openbis.dss.generic.shared.ServiceProvider; import ch.systemsx.cisd.openbis.dss.generic.shared.dto.DataSetCodesWithStatus; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetArchivingStatus; import ch.systemsx.cisd.openbis.generic.shared.dto.DatasetDescription; @@ -55,14 +55,10 @@ public abstract class AbstractArchiverProcessingPlugin extends AbstractDatastore private final IStatusChecker unarchivePrerequisiteOrNull; - private final IDataSetCommandExecutor commandExecutor; - public AbstractArchiverProcessingPlugin(Properties properties, File storeRoot, - IDataSetCommandExecutor commandExecutor, IStatusChecker archivePrerequisiteOrNull, IStatusChecker unarchivePrerequisiteOrNull) { super(properties, storeRoot); - this.commandExecutor = commandExecutor; this.archivePrerequisiteOrNull = archivePrerequisiteOrNull; this.unarchivePrerequisiteOrNull = unarchivePrerequisiteOrNull; } @@ -153,7 +149,7 @@ public abstract class AbstractArchiverProcessingPlugin extends AbstractDatastore ArchiverTaskContext context) { // the deletion will happen at a later point in time - commandExecutor.scheduleDeletionOfDataSets(datasets); + ServiceProvider.getDataSetDeleter().scheduleDeletionOfDataSets(datasets); } public ProcessingStatus unarchive(List<DatasetDescription> datasets, diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/RsyncArchiver.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/RsyncArchiver.java index 968fe01e44f5bc88af713ec81766546de576b7fd..147908ddc278f3a1bce5c5626b6d2b992af7efc8 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/RsyncArchiver.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/RsyncArchiver.java @@ -24,7 +24,6 @@ import ch.rinn.restrictions.Private; import ch.systemsx.cisd.common.exceptions.Status; import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.common.filesystem.BooleanStatus; -import ch.systemsx.cisd.openbis.dss.generic.server.IDataSetCommandExecutor; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.ArchiverTaskContext; import ch.systemsx.cisd.openbis.generic.shared.dto.DatasetDescription; @@ -50,19 +49,17 @@ public class RsyncArchiver extends AbstractArchiverProcessingPlugin private final ISshCommandExecutorFactory sshCommandExecutorFactory; - public RsyncArchiver(Properties properties, File storeRoot, - IDataSetCommandExecutor commandExecutor) + public RsyncArchiver(Properties properties, File storeRoot) { - this(properties, storeRoot, commandExecutor, new RsyncCopierFactory(), - new SshCommandExecutorFactory()); + this(properties, storeRoot, new RsyncCopierFactory(), new SshCommandExecutorFactory()); } @Private - RsyncArchiver(Properties properties, File storeRoot, IDataSetCommandExecutor commandExecutor, + RsyncArchiver(Properties properties, File storeRoot, IPathCopierFactory pathCopierFactory, ISshCommandExecutorFactory sshCommandExecutorFactory) { - super(properties, storeRoot, commandExecutor, null, null); + super(properties, storeRoot, null, null); this.pathCopierFactory = pathCopierFactory; this.sshCommandExecutorFactory = sshCommandExecutorFactory; } diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/tasks/ArchiverPluginFactory.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/tasks/ArchiverPluginFactory.java index 0a399668baaf4c97851943314ace0a310e1f6757..17db868e1f40f4e3c080ebb4620c2908b93cc63b 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/tasks/ArchiverPluginFactory.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/tasks/ArchiverPluginFactory.java @@ -28,7 +28,6 @@ import ch.systemsx.cisd.common.logging.LogCategory; import ch.systemsx.cisd.common.logging.LogFactory; import ch.systemsx.cisd.common.utilities.ClassUtils; import ch.systemsx.cisd.common.utilities.PropertyParametersUtil.SectionProperties; -import ch.systemsx.cisd.openbis.dss.generic.server.IDataSetCommandExecutor; /** * Factory of Archiver Tasks. @@ -59,7 +58,7 @@ public class ArchiverPluginFactory return className != null; } - public IArchiverPlugin createInstance(File storeRoot, IDataSetCommandExecutor commandExecutor) + public IArchiverPlugin createInstance(File storeRoot) { if (isArchiverConfigured() == false) { @@ -68,7 +67,7 @@ public class ArchiverPluginFactory try { return ClassUtils.create(IArchiverPlugin.class, className, archiverProperties, - storeRoot, commandExecutor); + storeRoot); } catch (ConfigurationFailureException ex) { throw ex; // rethrow the exception without changing the message diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/IDataSetDeleter.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/IDataSetDeleter.java new file mode 100644 index 0000000000000000000000000000000000000000..b308f48b56a23a87e5ae463e0ebbb30a761f41c2 --- /dev/null +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/IDataSetDeleter.java @@ -0,0 +1,34 @@ +/* + * Copyright 2011 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.dss.generic.shared; + +import java.util.List; + +import ch.systemsx.cisd.openbis.generic.shared.dto.DatasetDescription; + +/** + * @author Kaloyan Enimanev + */ +public interface IDataSetDeleter +{ + + /** + * Schedules deletion of all specified data sets. + */ + void scheduleDeletionOfDataSets(List<DatasetDescription> dataSets); + +} diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/ServiceProvider.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/ServiceProvider.java index 776ff22fe97ff476d2f5cbe67180f4f12cde1218..a01c01780582a846509f22f9d169836aaa3bf5ea 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/ServiceProvider.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/ServiceProvider.java @@ -16,12 +16,18 @@ package ch.systemsx.cisd.openbis.dss.generic.shared; +import org.apache.log4j.Logger; +import org.springframework.aop.framework.Advised; import org.springframework.beans.factory.BeanFactory; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter; import com.marathon.util.spring.StreamSupportingHttpInvokerServiceExporter; +import ch.systemsx.cisd.common.logging.LogCategory; +import ch.systemsx.cisd.common.logging.LogFactory; +import ch.systemsx.cisd.openbis.dss.generic.server.DataStoreService; + /** * Provider of remote service onto openBIS. * @@ -29,6 +35,9 @@ import com.marathon.util.spring.StreamSupportingHttpInvokerServiceExporter; */ public class ServiceProvider { + private static final Logger operationLog = LogFactory.getLogger(LogCategory.OPERATION, + ServiceProvider.class); + // applicationContex it lazily initialized private static BeanFactory applicationContext = null; @@ -82,6 +91,20 @@ public class ServiceProvider return ((DataSourceProvider) getApplicationContext().getBean("data-source-provider")); } + public static IDataSetDeleter getDataSetDeleter() + { + Advised advised = (Advised) getApplicationContext().getBean("data-store-service"); + try + { + DataStoreService dssService = (DataStoreService) advised.getTargetSource().getTarget(); + return dssService.getDataSetCommandExecutor(); + } catch (Exception ex) + { + operationLog.error("Cannot get IDataSetDeleter instance :" + ex.getMessage(), ex); + return null; + } + } + private ServiceProvider() { } diff --git a/rtd_yeastx/source/java/ch/systemsx/cisd/yeastx/etl/MLArchiverTask.java b/rtd_yeastx/source/java/ch/systemsx/cisd/yeastx/etl/MLArchiverTask.java index 23dba3c5aa5ce74aa9eac7fa44ad0d8a4b624ed3..2d14a42b4179933ead6baa6ede4a1a482cb7b30e 100644 --- a/rtd_yeastx/source/java/ch/systemsx/cisd/yeastx/etl/MLArchiverTask.java +++ b/rtd_yeastx/source/java/ch/systemsx/cisd/yeastx/etl/MLArchiverTask.java @@ -26,7 +26,6 @@ import ch.systemsx.cisd.common.exceptions.Status; import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.common.filesystem.BooleanStatus; import ch.systemsx.cisd.common.utilities.PropertyUtils; -import ch.systemsx.cisd.openbis.dss.generic.server.IDataSetCommandExecutor; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.standard.AbstractArchiverProcessingPlugin; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.standard.HighWaterMarkChecker; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.standard.IStatusChecker; @@ -59,10 +58,9 @@ public class MLArchiverTask extends AbstractArchiverProcessingPlugin private final String dataSourceName; - public MLArchiverTask(Properties properties, File storeRoot, - IDataSetCommandExecutor commandExecutor) + public MLArchiverTask(Properties properties, File storeRoot) { - super(properties, storeRoot, commandExecutor, null, tryCreateUnarchivingStatusChecker( + super(properties, storeRoot, null, tryCreateUnarchivingStatusChecker( properties, storeRoot)); dataSourceName = DataSourceProvider.extractDataSourceName(properties); // Check if given data source exists