From 751856c18491f9863d68f9abfacebe2cf276117c Mon Sep 17 00:00:00 2001
From: tpylak <tpylak>
Date: Fri, 23 Apr 2010 08:03:41 +0000
Subject: [PATCH] yeastx archiving: rollback transaction in case of exception

SVN: 15593
---
 .../java/ch/systemsx/cisd/yeastx/etl/MLArchiverTask.java  | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

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 2489c04fde2..3d491715ad6 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
@@ -85,11 +85,13 @@ public class MLArchiverTask extends AbstractArchiverProcessingPlugin
     @Override
     protected void unarchive(DatasetDescription dataset) throws UserFailureException
     {
+        ML2DatabaseUploader databaseUploader = null;
         try
         {
             Sample sample = null;
             if (dataset.getSampleCode() != null)
             {
+                // NOTE: we assume that it is not a shared sample
                 SampleIdentifier sampleIdentifier =
                         new SampleIdentifier(new SpaceIdentifier(dataset.getDatabaseInstanceCode(),
                                 dataset.getGroupCode()), dataset.getSampleCode());
@@ -102,12 +104,16 @@ public class MLArchiverTask extends AbstractArchiverProcessingPlugin
                             .getGroupCode(), dataset.getProjectCode(), dataset.getExperimentCode());
             Experiment experiment =
                     ServiceProvider.getOpenBISService().tryToGetExperiment(experimentIdentifier);
-            ML2DatabaseUploader databaseUploader = new ML2DatabaseUploader(properties);
+            databaseUploader = new ML2DatabaseUploader(properties);
             databaseUploader.upload(getDataFile(dataset), sample, experiment, dataset
                     .getDatasetCode());
             databaseUploader.commit();
         } catch (Exception ex)
         {
+            if (databaseUploader != null)
+            {
+                databaseUploader.rollback();
+            }
             throw new UserFailureException(ex.getMessage());
         }
     }
-- 
GitLab