Author: sergiykarpenko
Date: 2010-08-30 03:29:51 -0400 (Mon, 30 Aug 2010)
New Revision: 3009
Added:
jcr/branches/1.12.x/exo.jcr.component.ftp/src/test/java/org/exoplatform/services/ftp/usecases/
jcr/branches/1.12.x/exo.jcr.component.ftp/src/test/java/org/exoplatform/services/ftp/usecases/TestCopyBetweenWorkspaces.java
Modified:
jcr/branches/1.12.x/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdRnFr.java
jcr/branches/1.12.x/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdRnTo.java
jcr/branches/1.12.x/exo.jcr.component.ftp/src/test/resources/conf/standalone/test-jcr-config.xml
Log:
EXOJCR-849: now RENAME_TO operation do ignores RENAME_FROM workspace name, test added
Modified:
jcr/branches/1.12.x/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdRnFr.java
===================================================================
---
jcr/branches/1.12.x/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdRnFr.java 2010-08-30
07:26:10 UTC (rev 3008)
+++
jcr/branches/1.12.x/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdRnFr.java 2010-08-30
07:29:51 UTC (rev 3009)
@@ -65,7 +65,7 @@
curSession.getItem(repoPath);
- clientSession().setPrevParamsEx(repoPath);
+ clientSession().setPrevParamsEx(resName);
reply(FtpConst.Replyes.REPLY_350);
return;
Modified:
jcr/branches/1.12.x/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdRnTo.java
===================================================================
---
jcr/branches/1.12.x/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdRnTo.java 2010-08-30
07:26:10 UTC (rev 3008)
+++
jcr/branches/1.12.x/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdRnTo.java 2010-08-30
07:29:51 UTC (rev 3009)
@@ -25,6 +25,7 @@
import java.io.IOException;
import java.util.ArrayList;
+import javax.jcr.Item;
import javax.jcr.NoSuchWorkspaceException;
import javax.jcr.PathNotFoundException;
import javax.jcr.Session;
@@ -75,8 +76,25 @@
return;
}
- curSession.move(clientSession().getPrevParamsEx(), repoPath);
- curSession.save();
+ // now check does move executed on same workspace
+ ArrayList<String> prevParamPath =
clientSession().getFullPath(clientSession().getPrevParamsEx());
+ String prevRepoPath = clientSession().getRepoPath(prevParamPath);
+ if (prevParamPath.get(0).equals(newPath.get(0)))
+ {
+ //its the same workspace
+ curSession.move(prevRepoPath, repoPath);
+ curSession.save();
+ }
+ else
+ {
+ // there is different workspaces operation
+ curSession.getWorkspace().copy(prevParamPath.get(0), prevRepoPath,
repoPath);
+ // now remove source node
+ Session srcSession = clientSession().getSession(prevParamPath.get(0));
+ Item item = srcSession.getItem(prevRepoPath);
+ item.remove();
+ srcSession.save();
+ }
reply(String.format(FtpConst.Replyes.REPLY_250, FtpConst.Commands.CMD_RNTO));
return;
Added:
jcr/branches/1.12.x/exo.jcr.component.ftp/src/test/java/org/exoplatform/services/ftp/usecases/TestCopyBetweenWorkspaces.java
===================================================================
---
jcr/branches/1.12.x/exo.jcr.component.ftp/src/test/java/org/exoplatform/services/ftp/usecases/TestCopyBetweenWorkspaces.java
(rev 0)
+++
jcr/branches/1.12.x/exo.jcr.component.ftp/src/test/java/org/exoplatform/services/ftp/usecases/TestCopyBetweenWorkspaces.java 2010-08-30
07:29:51 UTC (rev 3009)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2003-2010 eXo Platform SAS.
+ *
+ * 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. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not,
see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.ftp.usecases;
+
+import org.exoplatform.services.ftp.BaseFtpTest;
+import org.exoplatform.services.ftp.FtpConst;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date:
+ *
+ * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
+ * @version $Id: TestCopyBetweenWorkspaces.java 111 2008-11-11 11:11:11Z serg $
+ */
+public class TestCopyBetweenWorkspaces extends BaseFtpTest
+{
+
+ public void testCopyBetweenWorkspaces() throws Exception
+ {
+ String filename = "testCopy.txt";
+ String fileContent = "exo ftp test copy server test\n";
+ try
+ {
+ connect();
+ pwd();
+ cwd("ws");
+ pwd();
+ stor(fileContent.getBytes(), filename);
+ String retrieved = new String(retr(filename));
+ assertEquals(fileContent, retrieved);
+
+ // make move
+ sendCommand(FtpConst.Commands.CMD_RNFR + ' ' + filename);
+ String response = readResponse();
+ assertTrue("Must start with 350, but was [" + response +
"]", response.startsWith("350 "));
+ sendCommand(FtpConst.Commands.CMD_RNTO + ' ' + "/ws2/" +
filename);
+ response = readResponse();
+ assertTrue("Must start with 250, but was [" + response +
"]", response.startsWith("250 "));
+
+ }
+ finally
+ {
+ disconnect();
+ }
+ }
+}
Modified:
jcr/branches/1.12.x/exo.jcr.component.ftp/src/test/resources/conf/standalone/test-jcr-config.xml
===================================================================
---
jcr/branches/1.12.x/exo.jcr.component.ftp/src/test/resources/conf/standalone/test-jcr-config.xml 2010-08-30
07:26:10 UTC (rev 3008)
+++
jcr/branches/1.12.x/exo.jcr.component.ftp/src/test/resources/conf/standalone/test-jcr-config.xml 2010-08-30
07:29:51 UTC (rev 3009)
@@ -32,10 +32,7 @@
<property name="sourceName" value="jdbcjcr"
/>
<property name="dialect" value="generic"
/>
<!-- example of direct jdbc connection usage (without JNDI), see
docs for details -->
- <!-- property name="driverClassName"
value="org.hsqldb.jdbcDriver" />
- <property name="url"
value="jdbc:hsqldb:file:target/temp/data/portal" />
- <property name="username" value="sa" />
- <property name="password" value="" / -->
+
<property name="multi-db" value="false"
/>
<property name="update-storage" value="true"
/>
<property name="max-buffer-size"
value="204800" />
@@ -50,18 +47,51 @@
</cache>
<query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
<properties>
- <property name="indexDir"
value="target/temp/index" />
+ <property name="indexDir"
value="target/temp/index/ws" />
</properties>
</query-handler>
<lock-manager>
<time-out>900000</time-out><!-- 15min -->
<persister
class="org.exoplatform.services.jcr.impl.core.lock.FileSystemLockPersister">
<properties>
- <property name="path"
value="target/temp/lock" />
+ <property name="path"
value="target/temp/lock/ws" />
</properties>
</persister>
</lock-manager>
</workspace>
+ <workspace name="ws2"
auto-init-root-nodetype="nt:unstructured">
+ <!-- for system storage -->
+ <container
class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
+ <properties>
+ <property name="sourceName" value="jdbcjcr"
/>
+ <property name="dialect" value="generic"
/>
+ <!-- example of direct jdbc connection usage (without JNDI), see
docs for details -->
+ <property name="multi-db" value="false"
/>
+ <property name="update-storage" value="true"
/>
+ <property name="max-buffer-size"
value="204800" />
+ <property name="swap-directory"
value="target/temp/swap/ws2" />
+ </properties>
+ </container>
+ <cache enabled="true">
+ <properties>
+ <property name="maxSize" value="3000" />
+ <property name="liveTime" value="300"
/><!-- 30 sec -->
+ </properties>
+ </cache>
+ <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
+ <properties>
+ <property name="indexDir"
value="target/temp/index/ws2" />
+ </properties>
+ </query-handler>
+ <lock-manager>
+ <time-out>900000</time-out><!-- 15min -->
+ <persister
class="org.exoplatform.services.jcr.impl.core.lock.FileSystemLockPersister">
+ <properties>
+ <property name="path"
value="target/temp/lock/ws2" />
+ </properties>
+ </persister>
+ </lock-manager>
+ </workspace>
</workspaces>
</repository>
</repositories>