diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/plugins/DeleteFromArchiveMaintenanceTask.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/plugins/DeleteFromArchiveMaintenanceTask.java index 63abb4c4c158aaf3bd16d9f1eb25c791f403de3f..776ae4463a3b97020a61b9a96986eaad4f29a55b 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/plugins/DeleteFromArchiveMaintenanceTask.java +++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/plugins/DeleteFromArchiveMaintenanceTask.java @@ -125,7 +125,7 @@ public class DeleteFromArchiveMaintenanceTask extends List<DeletedDataSet> result = new ArrayList<DeletedDataSet>(); for (DeletedDataSet dataset : datasets) { if (dataset.getIdentifier() != null - && false == dataset.getIdentifier().equals(dataset.getLocation())) + && false == dataset.getIdentifier().equals(dataset.getLocationOrNull())) { result.add(dataset); } @@ -138,7 +138,10 @@ public class DeleteFromArchiveMaintenanceTask extends ArrayList<DatasetLocation> result = new ArrayList<DatasetLocation>(datasets.size()); for (DeletedDataSet deletedDS : datasets) { - result.add(toDataSetLocations(deletedDS)); + if (deletedDS.getLocationOrNull() != null) + { + result.add(toDataSetLocations(deletedDS)); + } } return result; } @@ -147,7 +150,7 @@ public class DeleteFromArchiveMaintenanceTask extends { DatasetLocation dsLocation = new DatasetLocation(); dsLocation.setDatasetCode(deletedDS.getIdentifier()); - dsLocation.setDataSetLocation(deletedDS.getLocation()); + dsLocation.setDataSetLocation(deletedDS.getLocationOrNull()); return dsLocation; } } diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/postregistration/ArchivingPostRegistrationTask.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/postregistration/ArchivingPostRegistrationTask.java index fc33bdd172131388a4dd94abc5be385f6e0941c0..503a04b7045f3f97e4ba8488386cd4c3ec16eae6 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/postregistration/ArchivingPostRegistrationTask.java +++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/postregistration/ArchivingPostRegistrationTask.java @@ -209,7 +209,7 @@ public class ArchivingPostRegistrationTask extends AbstractPostRegistrationTask IArchiverPlugin archiver = ServiceProvider.getDataStoreService().getArchiverPlugin(); DatasetDescription dataSet = tryGetDatasetWithLocation(dataSetCode, openBISService); - if (archiver != null && dataSet != null) + if (archiver != null && dataSet != null && dataSet.getDataSetLocation() != null) { DatasetLocation dataset = new DatasetLocation(); dataset.setDatasetCode(dataSetCode); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/EventDAO.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/EventDAO.java index 091e696ac18174aac4bd9adc4cb6ce37f76f15ba..462fc87e0ef82b2e80b744c3dffe46b30bded1f3 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/EventDAO.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/EventDAO.java @@ -17,9 +17,10 @@ package ch.systemsx.cisd.openbis.generic.server.dataaccess.db; import java.util.ArrayList; -import java.util.Arrays; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.apache.log4j.Logger; import org.hibernate.Criteria; @@ -29,7 +30,6 @@ import org.hibernate.criterion.MatchMode; import org.hibernate.criterion.Restrictions; import org.springframework.jdbc.support.JdbcAccessor; -import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; import ch.systemsx.cisd.common.logging.LogCategory; import ch.systemsx.cisd.common.logging.LogFactory; import ch.systemsx.cisd.common.utilities.MethodUtils; @@ -53,8 +53,8 @@ public class EventDAO extends AbstractGenericEntityDAO<EventPE> implements IEven * This logger does not output any SQL statement. If you want to do so, you had better set an * appropriate debugging level for class {@link JdbcAccessor}. </p> */ - private static final Logger operationLog = - LogFactory.getLogger(LogCategory.OPERATION, EventPE.class); + private static final Logger operationLog = LogFactory.getLogger(LogCategory.OPERATION, + EventPE.class); public EventDAO(SessionFactory sessionFactory, DatabaseInstancePE databaseInstance) { @@ -108,21 +108,11 @@ public class EventDAO extends AbstractGenericEntityDAO<EventPE> implements IEven ArrayList<DeletedDataSet> result = new ArrayList<DeletedDataSet>(); for (EventPE event : list) { + Map<String, String> map = createIdentifierToLocationMap(event.getDescription()); List<String> identifiers = event.getIdentifiers(); - List<String> locations = - Arrays.asList(event.getDescription().split(EventPE.IDENTIFIER_SEPARATOR)); - if (identifiers.size() != locations.size()) + for (String dataSetCode : identifiers) { - throw EnvironmentFailureException.fromTemplate( - "Number of deleted dataset codes %s does not match " - + "the number of deleted data set locations %s in eventId='%s'", - identifiers.size(), locations.size(), event.getId()); - } - int pos = 0; - for (pos = 0; pos < identifiers.size(); pos++) - { - String dataSetCode = identifiers.get(pos); - String dataSetLocation = locations.get(pos); + String dataSetLocation = map.get(dataSetCode); DeletedDataSet deletedDataSet = new DeletedDataSet(dataSetCode, dataSetLocation, event.getId()); result.add(deletedDataSet); @@ -130,4 +120,17 @@ public class EventDAO extends AbstractGenericEntityDAO<EventPE> implements IEven } return result; } + + private Map<String, String> createIdentifierToLocationMap(String locations) + { + Map<String, String> result = new HashMap<String, String>(); + for (String location : locations.split(EventPE.IDENTIFIER_SEPARATOR)) + { + int lastIndexOfSlash = location.lastIndexOf('/'); + String identifier = + lastIndexOfSlash < 0 ? location : location.substring(lastIndexOfSlash + 1); + result.put(identifier, location); + } + return result; + } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/DeletedDataSet.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/DeletedDataSet.java index 24a97d495c4f965208aa52d12f1bc523e52c3e8b..10041d38bc96ffcf7313870696278f98bcc046e2 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/DeletedDataSet.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/DeletedDataSet.java @@ -34,18 +34,19 @@ public class DeletedDataSet implements Serializable, ICodeHolder private final long eventId; - private final String location; // the location where the data set existed before deletion + private final String locationOrNull; // the location where the data set existed before deletion + // or null if it was a container data set - public DeletedDataSet(String identifier, String location, long eventId) + public DeletedDataSet(String identifier, String locationOrNull, long eventId) { this.eventId = eventId; this.identifier = identifier; - this.location = location; + this.locationOrNull = locationOrNull; } - public String getLocation() + public String getLocationOrNull() { - return location; + return locationOrNull; } public String getCode()