From 78b02c2b50e55b8fa9dfce3dac61fcadddc76e54 Mon Sep 17 00:00:00 2001
From: felmer <felmer>
Date: Mon, 16 May 2011 07:04:44 +0000
Subject: [PATCH] bug fixed: Allow renaming also in local mode.

SVN: 21296
---
 .../server/plugins/standard/Copier.java       | 28 +++++++++++++------
 1 file changed, 20 insertions(+), 8 deletions(-)

diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/Copier.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/Copier.java
index 0659f8579e8..a5e671f34c7 100644
--- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/Copier.java
+++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/Copier.java
@@ -128,15 +128,27 @@ public class Copier implements Serializable, IPostRegistrationDatasetHandler
         }
         if (renameToDataSetCode)
         {
-            String newFile = new File(destination, dataSetCode).getPath();
-            ProcessResult result =
-                    sshCommandExecutor.executeCommandRemotely("mv " + destinationFile.getPath()
-                            + " " + newFile, DataSetCopier.SSH_TIMEOUT_MILLIS);
-            if (result.isOK() == false)
+            File newFile = new File(destination, dataSetCode);
+            if (host == null)
+            {
+                if (destinationFile.renameTo(newFile))
+                {
+                    operationLog.error("Moving of '" + destinationFile.getPath() + "' to '"
+                            + newFile + "' failed.");
+                    return Status.createError("couldn't move");
+                }
+            } else
             {
-                operationLog.error("Remote move of '" + destinationFile.getPath() + "' to '"
-                        + newFile + "' failed with exit value: " + result.getExitValue());
-                return Status.createError("couldn't move");
+                String newFilePath = newFile.getPath();
+                ProcessResult result =
+                    sshCommandExecutor.executeCommandRemotely("mv " + destinationFile.getPath()
+                            + " " + newFilePath, DataSetCopier.SSH_TIMEOUT_MILLIS);
+                if (result.isOK() == false)
+                {
+                    operationLog.error("Remote move of '" + destinationFile.getPath() + "' to '"
+                            + newFilePath + "' failed with exit value: " + result.getExitValue());
+                    return Status.createError("couldn't move");
+                }
             }
         }
         return status;
-- 
GitLab