exo-jcr SVN: r4046 - in jcr/branches/1.12.x/patch/1.12.8-GA: JCR-1594 and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2011-03-02 09:58:15 -0500 (Wed, 02 Mar 2011)
New Revision: 4046
Added:
jcr/branches/1.12.x/patch/1.12.8-GA/JCR-1594/
jcr/branches/1.12.x/patch/1.12.8-GA/JCR-1594/JCR-1594.patch
Log:
JCR-1594: patch proposed
Added: jcr/branches/1.12.x/patch/1.12.8-GA/JCR-1594/JCR-1594.patch
===================================================================
--- jcr/branches/1.12.x/patch/1.12.8-GA/JCR-1594/JCR-1594.patch (rev 0)
+++ jcr/branches/1.12.x/patch/1.12.8-GA/JCR-1594/JCR-1594.patch 2011-03-02 14:58:15 UTC (rev 4046)
@@ -0,0 +1,305 @@
+Index: exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/query/TestUpdateProperty.java
+===================================================================
+--- exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/query/TestUpdateProperty.java (revision 0)
++++ exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/query/TestUpdateProperty.java (revision 0)
+@@ -0,0 +1,211 @@
++/*
++ * Copyright (C) 2003-2007 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.jcr.usecases.query;
++
++import org.exoplatform.services.jcr.usecases.BaseUsecasesTest;
++
++import javax.jcr.Node;
++import javax.jcr.query.Query;
++import javax.jcr.query.QueryManager;
++
++/**
++ * @author <a href="mailto:anatoliy.bazko@gmail.com">Anatoliy Bazko</a>
++ * @version $Id: TestUpdateProperty.java 34360 2009-07-22 23:58:59Z tolusha $
++ */
++public class TestUpdateProperty extends BaseUsecasesTest
++{
++
++ public void testAddUpdateRemoveProperty() throws Exception
++ {
++
++ Node node = root.addNode("testNode");
++ node.setProperty("prop1", "value1");
++ node.setProperty("prop2", "value2");
++ root.save();
++
++ QueryManager manager = session.getWorkspace().getQueryManager();
++ Query query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value1')", Query.SQL);
++ assertEquals(1, query.execute().getNodes().getSize());
++
++ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value2')", Query.SQL);
++ assertEquals(1, query.execute().getNodes().getSize());
++
++ // the main issue that the last state is property deleting
++ node.setProperty("prop1", "value1-2");
++ node.setProperty("prop3", "value3");
++ node.getProperty("prop2").remove();
++ root.save();
++
++ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value1-2')", Query.SQL);
++ assertEquals(1, query.execute().getNodes().getSize());
++
++ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value1')", Query.SQL);
++ assertEquals(0, query.execute().getNodes().getSize());
++
++ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value2')", Query.SQL);
++ assertEquals(0, query.execute().getNodes().getSize());
++
++ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value3')", Query.SQL);
++ assertEquals(1, query.execute().getNodes().getSize());
++
++ // remove node
++ node.remove();
++ root.save();
++
++ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value1-2')", Query.SQL);
++ assertEquals(0, query.execute().getNodes().getSize());
++
++ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value3')", Query.SQL);
++ assertEquals(0, query.execute().getNodes().getSize());
++ }
++
++ public void testMoveNode() throws Exception
++ {
++
++ Node node = root.addNode("testNode");
++ node.setProperty("prop1", "value1");
++ node.setProperty("prop2", "value2");
++
++ node = node.addNode("subNode");
++ node.setProperty("prop21", "value21");
++ node.setProperty("prop22", "value22");
++ root.save();
++
++ QueryManager manager = session.getWorkspace().getQueryManager();
++ Query query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value1')", Query.SQL);
++ assertEquals(1, query.execute().getNodes().getSize());
++
++ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value2')", Query.SQL);
++ assertEquals(1, query.execute().getNodes().getSize());
++
++ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value21')", Query.SQL);
++ assertEquals(1, query.execute().getNodes().getSize());
++
++ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value22')", Query.SQL);
++ assertEquals(1, query.execute().getNodes().getSize());
++
++ session.move("/testNode", "/testNode2");
++ root.save();
++
++ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value1')", Query.SQL);
++ assertEquals(1, query.execute().getNodes().getSize());
++
++ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value2')", Query.SQL);
++ assertEquals(1, query.execute().getNodes().getSize());
++
++ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value21')", Query.SQL);
++ assertEquals(1, query.execute().getNodes().getSize());
++
++ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value22')", Query.SQL);
++ assertEquals(1, query.execute().getNodes().getSize());
++ }
++
++ public void testSetRemovePropertyImmediatly() throws Exception
++ {
++
++ Node node = root.addNode("testNode");
++ node.setProperty("prop1", "value1");
++ node.getProperty("prop1").remove();
++ root.save();
++
++ QueryManager manager = session.getWorkspace().getQueryManager();
++ Query query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value1')", Query.SQL);
++ assertEquals(0, query.execute().getNodes().getSize());
++ }
++
++ public void testSetRemoveProperty() throws Exception
++ {
++
++ Node node = root.addNode("testNode");
++ node.setProperty("prop1", "value1");
++ root.save();
++
++ QueryManager manager = session.getWorkspace().getQueryManager();
++ Query query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value1')", Query.SQL);
++ assertEquals(1, query.execute().getNodes().getSize());
++
++ node.getProperty("prop1").remove();
++ root.save();
++
++ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value1')", Query.SQL);
++ assertEquals(0, query.execute().getNodes().getSize());
++ }
++
++ public void testRemoveNodeUpdateProperty() throws Exception
++ {
++
++ Node node = root.addNode("testNode");
++ node.setProperty("prop1", "value1");
++ root.save();
++
++ QueryManager manager = session.getWorkspace().getQueryManager();
++ Query query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value1')", Query.SQL);
++ assertEquals(1, query.execute().getNodes().getSize());
++
++ node.setProperty("prop1", "value2");
++ node.remove();
++ root.save();
++
++ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value1')", Query.SQL);
++ assertEquals(0, query.execute().getNodes().getSize());
++
++ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value2')", Query.SQL);
++ assertEquals(0, query.execute().getNodes().getSize());
++ }
++
++ public void testRemoveNodeSetProperty() throws Exception
++ {
++
++ Node node = root.addNode("testNode");
++ node.setProperty("prop1", "value1");
++ root.save();
++
++ QueryManager manager = session.getWorkspace().getQueryManager();
++ Query query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value1')", Query.SQL);
++ assertEquals(1, query.execute().getNodes().getSize());
++
++ node.setProperty("prop2", "valu2");
++ node.remove();
++ root.save();
++
++ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value1')", Query.SQL);
++ assertEquals(0, query.execute().getNodes().getSize());
++
++ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value2')", Query.SQL);
++ assertEquals(0, query.execute().getNodes().getSize());
++ }
++
++ public void testRemoveNodeRemoveProperty() throws Exception
++ {
++
++ Node node = root.addNode("testNode");
++ node.setProperty("prop1", "value1");
++ root.save();
++
++ QueryManager manager = session.getWorkspace().getQueryManager();
++ Query query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value1')", Query.SQL);
++ assertEquals(1, query.execute().getNodes().getSize());
++
++ node.getProperty("prop1").remove();
++ node.remove();
++ root.save();
++
++ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value1')", Query.SQL);
++ assertEquals(0, query.execute().getNodes().getSize());
++ }
++
++}
+Index: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerChangesFilter.java
+===================================================================
+--- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerChangesFilter.java (revision 4025)
++++ exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerChangesFilter.java (working copy)
+@@ -163,66 +163,36 @@
+ private void acceptChanges(final Set<String> removedNodes, final Set<String> addedNodes,
+ final Map<String, List<ItemState>> updatedNodes, ItemState itemState)
+ {
+- {
+- String uuid =
+- itemState.isNode() ? itemState.getData().getIdentifier() : itemState.getData().getParentIdentifier();
++ String uuid =
++ itemState.isNode() ? itemState.getData().getIdentifier() : itemState.getData().getParentIdentifier();
+
++ if (itemState.isNode())
++ {
+ if (itemState.isAdded())
+ {
+- if (itemState.isNode())
+- {
+- addedNodes.add(uuid);
+- }
+- else
+- {
+- if (!addedNodes.contains(uuid))
+- {
+- createNewOrAdd(uuid, itemState, updatedNodes);
+- }
+- }
++ addedNodes.add(uuid);
+ }
+- else if (itemState.isRenamed())
++ else if (itemState.isRenamed() || itemState.isUpdated() || itemState.isMixinChanged())
+ {
+- if (itemState.isNode())
+- {
+- addedNodes.add(uuid);
+- }
+- else
+- {
+- createNewOrAdd(uuid, itemState, updatedNodes);
+- }
+- }
+- else if (itemState.isUpdated())
+- {
+ createNewOrAdd(uuid, itemState, updatedNodes);
+ }
+- else if (itemState.isMixinChanged())
++ else if (itemState.isDeleted())
+ {
+- createNewOrAdd(uuid, itemState, updatedNodes);
++ addedNodes.remove(uuid);
++ removedNodes.add(uuid);
++
++ // remove all changes after node remove
++ updatedNodes.remove(uuid);
+ }
+- else if (itemState.isDeleted())
++ }
++ else
++ {
++ if (itemState.isAdded() || itemState.isUpdated() || itemState.isDeleted())
+ {
+- if (itemState.isNode())
++ if (!addedNodes.contains(uuid) && !removedNodes.contains(uuid) && !updatedNodes.containsKey(uuid))
+ {
+- if (addedNodes.contains(uuid))
+- {
+- addedNodes.remove(uuid);
+- removedNodes.remove(uuid);
+- }
+- else
+- {
+- removedNodes.add(uuid);
+- }
+- // remove all changes after node remove
+- updatedNodes.remove(uuid);
++ createNewOrAdd(uuid, itemState, updatedNodes);
+ }
+- else
+- {
+- if (!removedNodes.contains(uuid) && !addedNodes.contains(uuid))
+- {
+- createNewOrAdd(uuid, itemState, updatedNodes);
+- }
+- }
+ }
+ }
+ }
15 years, 2 months
exo-jcr SVN: r4045 - in jcr/trunk/exo.jcr.component.core/src: test/java/org/exoplatform/services/jcr/usecases/query and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2011-03-02 09:42:35 -0500 (Wed, 02 Mar 2011)
New Revision: 4045
Added:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/query/TestUpdateProperty.java
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerChangesFilter.java
Log:
EXOJCR-1218: Problem of renaming folders in WebDav
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerChangesFilter.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerChangesFilter.java 2011-03-02 11:14:04 UTC (rev 4044)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerChangesFilter.java 2011-03-02 14:42:35 UTC (rev 4045)
@@ -126,14 +126,17 @@
{
ItemState itemState = iter.next();
- if (!indexingTree.isExcluded(itemState))
+ if (itemState.isPersisted())
{
- acceptChanges(removedNodes, addedNodes, updatedNodes, itemState);
+ if (!indexingTree.isExcluded(itemState))
+ {
+ acceptChanges(removedNodes, addedNodes, updatedNodes, itemState);
+ }
+ else if (parentIndexingTree != null && !parentIndexingTree.isExcluded(itemState))
+ {
+ acceptChanges(parentRemovedNodes, parentAddedNodes, parentUpdatedNodes, itemState);
+ }
}
- else if (parentIndexingTree != null && !parentIndexingTree.isExcluded(itemState))
- {
- acceptChanges(parentRemovedNodes, parentAddedNodes, parentUpdatedNodes, itemState);
- }
}
for (String uuid : updatedNodes.keySet())
@@ -160,66 +163,36 @@
private void acceptChanges(final Set<String> removedNodes, final Set<String> addedNodes,
final Map<String, List<ItemState>> updatedNodes, ItemState itemState)
{
- {
- String uuid =
- itemState.isNode() ? itemState.getData().getIdentifier() : itemState.getData().getParentIdentifier();
+ String uuid =
+ itemState.isNode() ? itemState.getData().getIdentifier() : itemState.getData().getParentIdentifier();
+ if (itemState.isNode())
+ {
if (itemState.isAdded())
{
- if (itemState.isNode())
- {
- addedNodes.add(uuid);
- }
- else
- {
- if (!addedNodes.contains(uuid))
- {
- createNewOrAdd(uuid, itemState, updatedNodes);
- }
- }
+ addedNodes.add(uuid);
}
- else if (itemState.isRenamed())
+ else if (itemState.isRenamed() || itemState.isUpdated() || itemState.isMixinChanged())
{
- if (itemState.isNode())
- {
- addedNodes.add(uuid);
- }
- else
- {
- createNewOrAdd(uuid, itemState, updatedNodes);
- }
- }
- else if (itemState.isUpdated())
- {
createNewOrAdd(uuid, itemState, updatedNodes);
}
- else if (itemState.isMixinChanged())
+ else if (itemState.isDeleted())
{
- createNewOrAdd(uuid, itemState, updatedNodes);
+ addedNodes.remove(uuid);
+ removedNodes.add(uuid);
+
+ // remove all changes after node remove
+ updatedNodes.remove(uuid);
}
- else if (itemState.isDeleted())
+ }
+ else
+ {
+ if (itemState.isAdded() || itemState.isUpdated() || itemState.isDeleted())
{
- if (itemState.isNode())
+ if (!addedNodes.contains(uuid) && !removedNodes.contains(uuid) && !updatedNodes.containsKey(uuid))
{
- if (addedNodes.contains(uuid))
- {
- addedNodes.remove(uuid);
- removedNodes.remove(uuid);
- }
- else
- {
- removedNodes.add(uuid);
- }
- // remove all changes after node remove
- updatedNodes.remove(uuid);
+ createNewOrAdd(uuid, itemState, updatedNodes);
}
- else
- {
- if (!removedNodes.contains(uuid) && !addedNodes.contains(uuid))
- {
- createNewOrAdd(uuid, itemState, updatedNodes);
- }
- }
}
}
}
Added: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/query/TestUpdateProperty.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/query/TestUpdateProperty.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/query/TestUpdateProperty.java 2011-03-02 14:42:35 UTC (rev 4045)
@@ -0,0 +1,211 @@
+/*
+ * Copyright (C) 2003-2007 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.jcr.usecases.query;
+
+import org.exoplatform.services.jcr.usecases.BaseUsecasesTest;
+
+import javax.jcr.Node;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryManager;
+
+/**
+ * @author <a href="mailto:anatoliy.bazko@gmail.com">Anatoliy Bazko</a>
+ * @version $Id: TestUpdateProperty.java 34360 2009-07-22 23:58:59Z tolusha $
+ */
+public class TestUpdateProperty extends BaseUsecasesTest
+{
+
+ public void testAddUpdateRemoveProperty() throws Exception
+ {
+
+ Node node = root.addNode("testNode");
+ node.setProperty("prop1", "value1");
+ node.setProperty("prop2", "value2");
+ root.save();
+
+ QueryManager manager = session.getWorkspace().getQueryManager();
+ Query query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value1')", Query.SQL);
+ assertEquals(1, query.execute().getNodes().getSize());
+
+ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value2')", Query.SQL);
+ assertEquals(1, query.execute().getNodes().getSize());
+
+ // the main issue that the last state is property deleting
+ node.setProperty("prop1", "value1-2");
+ node.setProperty("prop3", "value3");
+ node.getProperty("prop2").remove();
+ root.save();
+
+ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value1-2')", Query.SQL);
+ assertEquals(1, query.execute().getNodes().getSize());
+
+ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value1')", Query.SQL);
+ assertEquals(0, query.execute().getNodes().getSize());
+
+ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value2')", Query.SQL);
+ assertEquals(0, query.execute().getNodes().getSize());
+
+ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value3')", Query.SQL);
+ assertEquals(1, query.execute().getNodes().getSize());
+
+ // remove node
+ node.remove();
+ root.save();
+
+ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value1-2')", Query.SQL);
+ assertEquals(0, query.execute().getNodes().getSize());
+
+ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value3')", Query.SQL);
+ assertEquals(0, query.execute().getNodes().getSize());
+ }
+
+ public void testMoveNode() throws Exception
+ {
+
+ Node node = root.addNode("testNode");
+ node.setProperty("prop1", "value1");
+ node.setProperty("prop2", "value2");
+
+ node = node.addNode("subNode");
+ node.setProperty("prop21", "value21");
+ node.setProperty("prop22", "value22");
+ root.save();
+
+ QueryManager manager = session.getWorkspace().getQueryManager();
+ Query query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value1')", Query.SQL);
+ assertEquals(1, query.execute().getNodes().getSize());
+
+ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value2')", Query.SQL);
+ assertEquals(1, query.execute().getNodes().getSize());
+
+ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value21')", Query.SQL);
+ assertEquals(1, query.execute().getNodes().getSize());
+
+ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value22')", Query.SQL);
+ assertEquals(1, query.execute().getNodes().getSize());
+
+ session.move("/testNode", "/testNode2");
+ root.save();
+
+ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value1')", Query.SQL);
+ assertEquals(1, query.execute().getNodes().getSize());
+
+ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value2')", Query.SQL);
+ assertEquals(1, query.execute().getNodes().getSize());
+
+ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value21')", Query.SQL);
+ assertEquals(1, query.execute().getNodes().getSize());
+
+ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value22')", Query.SQL);
+ assertEquals(1, query.execute().getNodes().getSize());
+ }
+
+ public void testSetRemovePropertyImmediatly() throws Exception
+ {
+
+ Node node = root.addNode("testNode");
+ node.setProperty("prop1", "value1");
+ node.getProperty("prop1").remove();
+ root.save();
+
+ QueryManager manager = session.getWorkspace().getQueryManager();
+ Query query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value1')", Query.SQL);
+ assertEquals(0, query.execute().getNodes().getSize());
+ }
+
+ public void testSetRemoveProperty() throws Exception
+ {
+
+ Node node = root.addNode("testNode");
+ node.setProperty("prop1", "value1");
+ root.save();
+
+ QueryManager manager = session.getWorkspace().getQueryManager();
+ Query query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value1')", Query.SQL);
+ assertEquals(1, query.execute().getNodes().getSize());
+
+ node.getProperty("prop1").remove();
+ root.save();
+
+ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value1')", Query.SQL);
+ assertEquals(0, query.execute().getNodes().getSize());
+ }
+
+ public void testRemoveNodeUpdateProperty() throws Exception
+ {
+
+ Node node = root.addNode("testNode");
+ node.setProperty("prop1", "value1");
+ root.save();
+
+ QueryManager manager = session.getWorkspace().getQueryManager();
+ Query query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value1')", Query.SQL);
+ assertEquals(1, query.execute().getNodes().getSize());
+
+ node.setProperty("prop1", "value2");
+ node.remove();
+ root.save();
+
+ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value1')", Query.SQL);
+ assertEquals(0, query.execute().getNodes().getSize());
+
+ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value2')", Query.SQL);
+ assertEquals(0, query.execute().getNodes().getSize());
+ }
+
+ public void testRemoveNodeSetProperty() throws Exception
+ {
+
+ Node node = root.addNode("testNode");
+ node.setProperty("prop1", "value1");
+ root.save();
+
+ QueryManager manager = session.getWorkspace().getQueryManager();
+ Query query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value1')", Query.SQL);
+ assertEquals(1, query.execute().getNodes().getSize());
+
+ node.setProperty("prop2", "valu2");
+ node.remove();
+ root.save();
+
+ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value1')", Query.SQL);
+ assertEquals(0, query.execute().getNodes().getSize());
+
+ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value2')", Query.SQL);
+ assertEquals(0, query.execute().getNodes().getSize());
+ }
+
+ public void testRemoveNodeRemoveProperty() throws Exception
+ {
+
+ Node node = root.addNode("testNode");
+ node.setProperty("prop1", "value1");
+ root.save();
+
+ QueryManager manager = session.getWorkspace().getQueryManager();
+ Query query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value1')", Query.SQL);
+ assertEquals(1, query.execute().getNodes().getSize());
+
+ node.getProperty("prop1").remove();
+ node.remove();
+ root.save();
+
+ query = manager.createQuery("SELECT * FROM nt:base " + " WHERE CONTAINS(., 'value1')", Query.SQL);
+ assertEquals(0, query.execute().getNodes().getSize());
+ }
+
+}
15 years, 2 months
exo-jcr SVN: r4044 - in jcr/trunk: exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation and 1 other directory.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2011-03-02 06:14:04 -0500 (Wed, 02 Mar 2011)
New Revision: 4044
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryCreationSynchronizer.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java
Log:
EXOJCR-1116: Make RepositoryCreationSynchronizer self disabling at container start.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryCreationSynchronizer.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryCreationSynchronizer.java 2011-03-02 10:27:39 UTC (rev 4043)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryCreationSynchronizer.java 2011-03-02 11:14:04 UTC (rev 4044)
@@ -154,22 +154,19 @@
@Override
public void startContainer(ExoContainer container) throws Exception
{
- if (needToInitWorkspace)
+ needToInitWorkspace = false;
+ try
{
- needToInitWorkspace = false;
- try
+ if (LOG.isDebugEnabled())
{
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Release the other cluster nodes if needed.");
- }
- rpcService.executeCommandOnAllNodes(releaseCommand, false);
+ LOG.debug("Release the other cluster nodes.");
}
- catch (Exception e)
- {
- LOG.error("Could not release all the nodes", e);
- }
+ rpcService.executeCommandOnAllNodes(releaseCommand, false);
}
+ catch (Exception e)
+ {
+ LOG.error("Could not release all the nodes", e);
+ }
}
});
// Used to release the coordinator
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java 2011-03-02 10:27:39 UTC (rev 4043)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java 2011-03-02 11:14:04 UTC (rev 4044)
@@ -77,7 +77,7 @@
/**
* The logger.
*/
- private static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.RepositoryCreationSynchronizer");
+ private static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.RepositoryCreationService");
private final RepositoryService repositoryService;
15 years, 2 months
exo-jcr SVN: r4043 - jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command.
by do-not-reply@jboss.org
Author: dkuleshov
Date: 2011-03-02 05:27:39 -0500 (Wed, 02 Mar 2011)
New Revision: 4043
Modified:
jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestMove.java
Log:
EXOJCR-1217: yet another fix
Modified: jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestMove.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestMove.java 2011-03-02 10:24:00 UTC (rev 4042)
+++ jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestMove.java 2011-03-02 10:27:39 UTC (rev 4043)
@@ -75,7 +75,7 @@
MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
headers.add(ExtHttpHeaders.DESTINATION, host + getPathDestWS() + destFilename);
ContainerResponse response = service(WebDAVMethods.MOVE, getPathWS() + filename, host, headers, null);
- assertEquals(HTTPStatus.NO_CONTENT, response.getStatus());
+ assertEquals(HTTPStatus.CREATED, response.getStatus());
assertTrue(destSession.getRootNode().hasNode(TextUtil.relativizePath(destFilename)));
Node nodeDest = destSession.getRootNode().getNode(TextUtil.relativizePath(destFilename));
assertTrue(nodeDest.hasNode("jcr:content"));
15 years, 2 months
exo-jcr SVN: r4042 - jcr/branches/1.12.x/patch/1.12.8-GA/JCR-1593.
by do-not-reply@jboss.org
Author: dkuleshov
Date: 2011-03-02 05:24:00 -0500 (Wed, 02 Mar 2011)
New Revision: 4042
Modified:
jcr/branches/1.12.x/patch/1.12.8-GA/JCR-1593/JCR-1593.patch
Log:
JCR-1593: patched test fixed
Modified: jcr/branches/1.12.x/patch/1.12.8-GA/JCR-1593/JCR-1593.patch
===================================================================
--- jcr/branches/1.12.x/patch/1.12.8-GA/JCR-1593/JCR-1593.patch 2011-03-02 10:18:05 UTC (rev 4041)
+++ jcr/branches/1.12.x/patch/1.12.8-GA/JCR-1593/JCR-1593.patch 2011-03-02 10:24:00 UTC (rev 4042)
@@ -22,17 +22,19 @@
assertEquals(HTTPStatus.CREATED, response.getStatus());
assertTrue(session.getRootNode().hasNode(TextUtil.relativizePath(destFilename)));
Node nodeDest = session.getRootNode().getNode(TextUtil.relativizePath(destFilename));
-@@ -71,8 +73,8 @@
+@@ -71,9 +73,9 @@
TestUtils.addContent(session, filename, inputStream, defaultFileNodeType, "");
String destFilename = TestUtils.getFileName();
MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
- headers.add(ExtHttpHeaders.DESTINATION, getPathDestWS() + destFilename);
- ContainerResponse response = service(WebDAVMethods.MOVE, getPathWS() + filename, "", headers, null);
+- assertEquals(HTTPStatus.NO_CONTENT, response.getStatus());
+ headers.add(ExtHttpHeaders.DESTINATION, host + getPathDestWS() + destFilename);
+ ContainerResponse response = service(WebDAVMethods.MOVE, getPathWS() + filename, host, headers, null);
- assertEquals(HTTPStatus.NO_CONTENT, response.getStatus());
++ assertEquals(HTTPStatus.CREATED, response.getStatus());
assertTrue(destSession.getRootNode().hasNode(TextUtil.relativizePath(destFilename)));
Node nodeDest = destSession.getRootNode().getNode(TextUtil.relativizePath(destFilename));
+ assertTrue(nodeDest.hasNode("jcr:content"));
@@ -85,6 +87,101 @@
assertFalse(session.getRootNode().hasNode(TextUtil.relativizePath(filename)));
}
15 years, 2 months
exo-jcr SVN: r4041 - in jcr/branches/1.12.x/patch/1.12.8-GA: JCR-1593 and 1 other directory.
by do-not-reply@jboss.org
Author: dkuleshov
Date: 2011-03-02 05:18:05 -0500 (Wed, 02 Mar 2011)
New Revision: 4041
Added:
jcr/branches/1.12.x/patch/1.12.8-GA/JCR-1593/
jcr/branches/1.12.x/patch/1.12.8-GA/JCR-1593/JCR-1593.patch
Log:
JCR-1593: patch added
Added: jcr/branches/1.12.x/patch/1.12.8-GA/JCR-1593/JCR-1593.patch
===================================================================
--- jcr/branches/1.12.x/patch/1.12.8-GA/JCR-1593/JCR-1593.patch (rev 0)
+++ jcr/branches/1.12.x/patch/1.12.8-GA/JCR-1593/JCR-1593.patch 2011-03-02 10:18:05 UTC (rev 4041)
@@ -0,0 +1,600 @@
+Index: exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestMove.java
+===================================================================
+--- exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestMove.java (revision 4038)
++++ exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestMove.java (working copy)
+@@ -40,6 +40,8 @@
+ public class TestMove extends BaseStandaloneTest
+ {
+
++ final static private String host = "http://localhost:8080";
++
+ public void testMoveForNonCollectionSingleWorkspace() throws Exception
+ {
+ String content = TestUtils.getFileContent();
+@@ -48,8 +50,8 @@
+ TestUtils.addContent(session, filename, inputStream, defaultFileNodeType, "");
+ String destFilename = TestUtils.getFileName();
+ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+- headers.add(ExtHttpHeaders.DESTINATION, getPathWS() + destFilename);
+- ContainerResponse response = service(WebDAVMethods.MOVE, getPathWS() + filename, "", headers, null);
++ headers.add(ExtHttpHeaders.DESTINATION, host + getPathWS() + destFilename);
++ ContainerResponse response = service(WebDAVMethods.MOVE, getPathWS() + filename, host, headers, null);
+ assertEquals(HTTPStatus.CREATED, response.getStatus());
+ assertTrue(session.getRootNode().hasNode(TextUtil.relativizePath(destFilename)));
+ Node nodeDest = session.getRootNode().getNode(TextUtil.relativizePath(destFilename));
+@@ -71,8 +73,8 @@
+ TestUtils.addContent(session, filename, inputStream, defaultFileNodeType, "");
+ String destFilename = TestUtils.getFileName();
+ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+- headers.add(ExtHttpHeaders.DESTINATION, getPathDestWS() + destFilename);
+- ContainerResponse response = service(WebDAVMethods.MOVE, getPathWS() + filename, "", headers, null);
++ headers.add(ExtHttpHeaders.DESTINATION, host + getPathDestWS() + destFilename);
++ ContainerResponse response = service(WebDAVMethods.MOVE, getPathWS() + filename, host, headers, null);
+ assertEquals(HTTPStatus.NO_CONTENT, response.getStatus());
+ assertTrue(destSession.getRootNode().hasNode(TextUtil.relativizePath(destFilename)));
+ Node nodeDest = destSession.getRootNode().getNode(TextUtil.relativizePath(destFilename));
+@@ -85,6 +87,101 @@
+ assertFalse(session.getRootNode().hasNode(TextUtil.relativizePath(filename)));
+ }
+
++ /**
++ * Testing for correct destination header parsing in MOVE method.
++ * We pass a path which contains escaped space - "%20"
++ * and escaped space with quote symbol "%20'"
++ * @throws Exception
++ */
++ public void testDestinationHeaderParsing() throws Exception
++ {
++ String content = TestUtils.getFileContent();
++ String filename = TestUtils.getFileName();
++ InputStream inputStream = new ByteArrayInputStream(content.getBytes());
++ TestUtils.addContent(session, filename, inputStream, defaultFileNodeType, "");
++
++ String destFilename = TestUtils.getFileName() + "%20test";
++
++ // prepare headers
++ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
++ headers.add(ExtHttpHeaders.DESTINATION, host + getPathWS() + destFilename);
++
++ // execute the query
++ ContainerResponse response = service(WebDAVMethods.MOVE, getPathWS() + filename, host, headers, null);
++ // check if operation completed successfully, we expect a new resource to be created
++ assertEquals(HTTPStatus.CREATED, response.getStatus());
++
++ filename = destFilename;
++
++ destFilename = TestUtils.getFileName() + "%20'test";
++
++ // prepare headers
++ headers = new MultivaluedMapImpl();
++ headers.add(ExtHttpHeaders.DESTINATION, host + getPathWS() + destFilename);
++
++ // execute the query
++ response = service(WebDAVMethods.MOVE, getPathWS() + filename, host, headers, null);
++ // check if operation completed successfully, we expect a new resource to be created
++ assertEquals(HTTPStatus.CREATED, response.getStatus());
++
++ }
++
++ /**
++ * Testing for correct response after MOVE a resource to the destination,
++ * where another resource already existed
++ * For more info see <a href=http://www.webdav.org/specs/rfc2518.html#METHOD_MOVE>this</a>.
++ * @throws Exception
++ */
++ public void testNoContentResponses() throws Exception
++ {
++ String content = TestUtils.getFileContent();
++ String filename = TestUtils.getFileName();
++ InputStream inputStream = new ByteArrayInputStream(content.getBytes());
++ TestUtils.addContent(session, filename, inputStream, defaultFileNodeType, "");
++
++ String destFilename = TestUtils.getFileName();
++ inputStream = new ByteArrayInputStream(content.getBytes());
++ TestUtils.addContent(session, destFilename, inputStream, defaultFileNodeType, "");
++
++ // prepare headers
++ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
++ headers.add(ExtHttpHeaders.DESTINATION, host + getPathWS() + destFilename);
++ headers.add(ExtHttpHeaders.OVERWRITE, "T");
++
++ // execute the query
++ ContainerResponse response = service(WebDAVMethods.MOVE, getPathWS() + filename, host, headers, null);
++ // check if operation completed successfully, we expect a new resource to be created
++ assertEquals(HTTPStatus.NO_CONTENT, response.getStatus());
++
++ }
++
++ /**
++ * Testing for correct destination header parsing using "https"
++ * instead of usual "http" scheme.
++ * @throws Exception
++ */
++ public void testHttpsSchemeInDestinationHeaderParsing() throws Exception
++ {
++ String httpsHost = "https://localhost:8080";
++
++ String content = TestUtils.getFileContent();
++ String filename = TestUtils.getFileName();
++ InputStream inputStream = new ByteArrayInputStream(content.getBytes());
++ TestUtils.addContent(session, filename, inputStream, defaultFileNodeType, "");
++
++ String destFilename = TestUtils.getFileName();
++
++ // prepare headers
++ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
++ headers.add(ExtHttpHeaders.DESTINATION, httpsHost + getPathWS() + destFilename);
++
++ // execute the query
++ ContainerResponse response = service(WebDAVMethods.MOVE, getPathWS() + filename, host, headers, null);
++ // check if operation completed successfully, we expect a new resource to be created
++ assertEquals(HTTPStatus.CREATED, response.getStatus());
++
++ }
++
+ @Override
+ protected String getRepositoryName()
+ {
+Index: exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestCopy.java
+===================================================================
+--- exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestCopy.java (revision 4038)
++++ exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestCopy.java (working copy)
+@@ -39,6 +39,7 @@
+ */
+ public class TestCopy extends BaseStandaloneTest
+ {
++ static final private String host = "http://localhost:8080";
+
+ public void testeCopyForNonCollectionSingleWorkSpace() throws Exception
+ {
+@@ -48,8 +49,8 @@
+ TestUtils.addContent(session, filename, inputStream, defaultFileNodeType, "");
+ String destFilename = TestUtils.getFileName();
+ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+- headers.add(ExtHttpHeaders.DESTINATION, getPathWS() + destFilename);
+- ContainerResponse response = service(WebDAVMethods.COPY, getPathWS() + filename, "", headers, null);
++ headers.add(ExtHttpHeaders.DESTINATION, host + getPathWS() + destFilename);
++ ContainerResponse response = service(WebDAVMethods.COPY, getPathWS() + filename, host, headers, null);
+ assertEquals(HTTPStatus.CREATED, response.getStatus());
+ assertTrue(session.getRootNode().hasNode(TextUtil.relativizePath(destFilename)));
+ Node nodeDest = session.getRootNode().getNode(TextUtil.relativizePath(destFilename));
+@@ -78,8 +79,8 @@
+ TestUtils.addContent(session, filename, inputStream, defaultFileNodeType, "");
+ String destFilename = TestUtils.getFileName();
+ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+- headers.add(ExtHttpHeaders.DESTINATION, getPathDestWS() + destFilename);
+- ContainerResponse response = service(WebDAVMethods.COPY, getPathWS() + filename, "", headers, null);
++ headers.add(ExtHttpHeaders.DESTINATION, host + getPathDestWS() + destFilename);
++ ContainerResponse response = service(WebDAVMethods.COPY, getPathWS() + filename, host, headers, null);
+ assertEquals(HTTPStatus.CREATED, response.getStatus());
+
+ assertTrue(destSession.getRootNode().hasNode(TextUtil.relativizePath(destFilename)));
+@@ -101,6 +102,101 @@
+
+ }
+
++ /**
++ * Testing for correct destination header parsing in COPY method.
++ * We pass a path which contains escaped space - "%20"
++ * and escaped space with quote symbol "%20'"
++ * @throws Exception
++ */
++ public void testDestinationHeaderParsing() throws Exception
++ {
++ String content = TestUtils.getFileContent();
++ String filename = TestUtils.getFileName();
++ InputStream inputStream = new ByteArrayInputStream(content.getBytes());
++ TestUtils.addContent(session, filename, inputStream, defaultFileNodeType, "");
++
++ String destFilename = TestUtils.getFileName() + "%20test";
++
++ // prepare headers
++ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
++ headers.add(ExtHttpHeaders.DESTINATION, host + getPathWS() + destFilename);
++
++ // execute the query
++ ContainerResponse response = service(WebDAVMethods.COPY, getPathWS() + filename, host, headers, null);
++ // check if operation completed successfully, we expect a new resource to be created
++ assertEquals(HTTPStatus.CREATED, response.getStatus());
++
++ filename = destFilename;
++
++ destFilename = TestUtils.getFileName() + "%20'test";
++
++ // prepare headers
++ headers = new MultivaluedMapImpl();
++ headers.add(ExtHttpHeaders.DESTINATION, host + getPathWS() + destFilename);
++
++ // execute the query
++ response = service(WebDAVMethods.COPY, getPathWS() + filename, host, headers, null);
++ // check if operation completed successfully, we expect a new resource to be created
++ assertEquals(HTTPStatus.CREATED, response.getStatus());
++
++ }
++
++ /**
++ * Testing for correct response after COPY a resource to the destination,
++ * where another resource already existed
++ * For more info see <a href=http://www.webdav.org/specs/rfc2518.html#METHOD_MOVE>this</a>.
++ * @throws Exception
++ */
++ public void testNoContentResponses() throws Exception
++ {
++ String content = TestUtils.getFileContent();
++ String filename = TestUtils.getFileName();
++ InputStream inputStream = new ByteArrayInputStream(content.getBytes());
++ TestUtils.addContent(session, filename, inputStream, defaultFileNodeType, "");
++
++ String destFilename = TestUtils.getFileName();
++ inputStream = new ByteArrayInputStream(content.getBytes());
++ TestUtils.addContent(session, destFilename, inputStream, defaultFileNodeType, "");
++
++ // prepare headers
++ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
++ headers.add(ExtHttpHeaders.DESTINATION, host + getPathWS() + destFilename);
++ headers.add(ExtHttpHeaders.OVERWRITE, "T");
++
++ // execute the query
++ ContainerResponse response = service(WebDAVMethods.COPY, getPathWS() + filename, host, headers, null);
++ // check if operation completed successfully, we expect a new resource to be created
++ assertEquals(HTTPStatus.NO_CONTENT, response.getStatus());
++
++ }
++
++ /**
++ * Testing for correct destination header parsing using "https"
++ * instead of usual "http" scheme.
++ * @throws Exception
++ */
++ public void testHttpsSchemeInDestinationHeaderParsing() throws Exception
++ {
++ String httpsHost = "https://localhost:8080";
++
++ String content = TestUtils.getFileContent();
++ String filename = TestUtils.getFileName();
++ InputStream inputStream = new ByteArrayInputStream(content.getBytes());
++ TestUtils.addContent(session, filename, inputStream, defaultFileNodeType, "");
++
++ String destFilename = TestUtils.getFileName();
++
++ // prepare headers
++ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
++ headers.add(ExtHttpHeaders.DESTINATION, httpsHost + getPathWS() + destFilename);
++
++ // execute the query
++ ContainerResponse response = service(WebDAVMethods.COPY, getPathWS() + filename, host, headers, null);
++ // check if operation completed successfully, we expect a new resource to be created
++ assertEquals(HTTPStatus.CREATED, response.getStatus());
++
++ }
++
+ @Override
+ protected String getRepositoryName()
+ {
+Index: exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java
+===================================================================
+--- exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java (revision 4038)
++++ exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java (working copy)
+@@ -71,6 +71,7 @@
+ import java.io.InputStream;
+ import java.lang.annotation.Annotation;
+ import java.lang.reflect.Method;
++import java.net.URI;
+ import java.net.URLEncoder;
+ import java.util.ArrayList;
+ import java.util.HashMap;
+@@ -370,6 +371,9 @@
+ @HeaderParam(ExtHttpHeaders.OVERWRITE) String overwriteHeader, @Context UriInfo uriInfo, HierarchicalProperty body)
+ {
+
++ // to trace if an item on destination path exists
++ boolean itemExisted = false;
++
+ if (log.isDebugEnabled())
+ {
+ log.debug("COPY " + repoName + "/" + repoPath);
+@@ -380,18 +384,27 @@
+ try
+ {
+ String serverURI = uriInfo.getBaseUriBuilder().path(getClass()).path(repoName).build().toString();
++ URI dest = new URI(destinationHeader);
++ URI base = new URI(serverURI);
+
+- destinationHeader = TextUtil.unescape(destinationHeader, '%');
++ String destPath = dest.getPath();
++ int repoIndex = destPath.indexOf(repoName);
+
+- if (!destinationHeader.startsWith(serverURI))
++ // check if destination corresponds to base uri
++ // if the destination is on another server
++ // or destination header is malformed
++ // we return BAD_GATEWAY(502) HTTP status
++ // more info here http://www.webdav.org/specs/rfc2518.html#METHOD_COPY
++ if (!base.getHost().equals(dest.getHost()) || repoIndex == -1)
+ {
+ return Response.status(HTTPStatus.BAD_GATEWAY).entity("Bad Gateway").build();
+ }
+
++ destPath = normalizePath(dest.getPath().substring(repoIndex + repoName.length() + 1));
++
+ String srcWorkspace = workspaceName(repoPath);
+ String srcNodePath = path(repoPath);
+
+- String destPath = destinationHeader.substring(serverURI.length() + 1);
+ String destWorkspace = workspaceName(destPath);
+ String destNodePath = path(destPath);
+
+@@ -403,7 +416,8 @@
+
+ if (overwrite)
+ {
+- delete(repoName, destPath, lockTokenHeader, ifHeader);
++ Response delResponse = delete(repoName, destPath, lockTokenHeader, ifHeader);
++ itemExisted = (delResponse.getStatus() == HTTPStatus.NO_CONTENT);
+ }
+ else
+ {
+@@ -411,7 +425,8 @@
+
+ if (session.getRootNode().hasNode(TextUtil.relativizePath(repoPath)))
+ {
+- return Response.status(HTTPStatus.PRECON_FAILED).entity("Not Found").build();
++ return Response.status(HTTPStatus.PRECON_FAILED)
++ .entity("Item exists on destination path, while overwriting is forbidden").build();
+ }
+
+ }
+@@ -422,11 +437,11 @@
+ if (srcWorkspace.equals(destWorkspace))
+ {
+ Session session = session(repoName, destWorkspace, lockTokens);
+- return new CopyCommand().copy(session, srcNodePath, destNodePath);
++ return new CopyCommand(itemExisted).copy(session, srcNodePath, destNodePath);
+ }
+
+ Session destSession = session(repoName, destWorkspace, lockTokens);
+- return new CopyCommand().copy(destSession, srcWorkspace, srcNodePath, destNodePath);
++ return new CopyCommand(itemExisted).copy(destSession, srcWorkspace, srcNodePath, destNodePath);
+
+ }
+ else if (depth.getIntValue() == 0)
+@@ -748,6 +763,9 @@
+ @HeaderParam(ExtHttpHeaders.OVERWRITE) String overwriteHeader, @Context UriInfo uriInfo, HierarchicalProperty body)
+ {
+
++ // to trace if an item on destination path exists
++ boolean itemExisted = false;
++
+ if (log.isDebugEnabled())
+ {
+ log.debug("MOVE " + repoName + "/" + repoPath);
+@@ -759,14 +777,26 @@
+ {
+ String serverURI = uriInfo.getBaseUriBuilder().path(getClass()).path(repoName).build().toString();
+
+- destinationHeader = TextUtil.unescape(destinationHeader, '%');
++ URI dest = new URI(destinationHeader);
++ URI base = new URI(serverURI);
+
++ String destPath = dest.getPath();
++ int repoIndex = destPath.indexOf(repoName);
++
++ // check if destination corresponds to base uri
++ // if the destination is on another server
++ // or destination header is malformed
++ // we return BAD_GATEWAY(502) HTTP status
++ // more info here http://www.webdav.org/specs/rfc2518.html#METHOD_MOVE
++ if (!base.getHost().equals(dest.getHost()) || repoIndex == -1)
++
+ if (!destinationHeader.startsWith(serverURI))
+ {
+ return Response.status(HTTPStatus.BAD_GATEWAY).entity("Bad Gateway").build();
+ }
+
+- String destPath = destinationHeader.substring(serverURI.length() + 1);
++ destPath = normalizePath(dest.getPath().substring(repoIndex + repoName.length() + 1));
++
+ String destWorkspace = workspaceName(destPath);
+ String destNodePath = path(destPath);
+
+@@ -781,7 +811,8 @@
+
+ if (overwrite)
+ {
+- delete(repoName, destPath, lockTokenHeader, ifHeader);
++ Response delResponse = delete(repoName, destPath, lockTokenHeader, ifHeader);
++ itemExisted = (delResponse.getStatus() == HTTPStatus.NO_CONTENT);
+ }
+ else
+ {
+@@ -792,7 +823,8 @@
+ Response prpfind = new PropFindCommand().propfind(session, destNodePath, body, depth.getIntValue(), uri);
+ if (prpfind.getStatus() != HTTPStatus.NOT_FOUND)
+ {
+- return Response.status(HTTPStatus.PRECON_FAILED).entity("Preconditions Failed").build();
++ return Response.status(HTTPStatus.PRECON_FAILED)
++ .entity("Item exists on destination path, while overwriting is forbidden").build();
+ }
+ }
+
+@@ -801,12 +833,12 @@
+ if (srcWorkspace.equals(destWorkspace))
+ {
+ Session session = session(repoName, srcWorkspace, lockTokens);
+- return new MoveCommand().move(session, srcNodePath, destNodePath);
++ return new MoveCommand(itemExisted).move(session, srcNodePath, destNodePath);
+ }
+
+ Session srcSession = session(repoName, srcWorkspace, lockTokens);
+ Session destSession = session(repoName, destWorkspace, lockTokens);
+- return new MoveCommand().move(srcSession, destSession, srcNodePath, destNodePath);
++ return new MoveCommand(itemExisted).move(srcSession, destSession, srcNodePath, destNodePath);
+ }
+ else
+ {
+Index: exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/MoveCommand.java
+===================================================================
+--- exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/MoveCommand.java (revision 4038)
++++ exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/MoveCommand.java (working copy)
+@@ -44,6 +44,12 @@
+ private static CacheControl cacheControl = new CacheControl();
+
+ /**
++ * To trace if an item on destination path existed.
++ */
++
++ final private boolean itemExisted;
++
++ /**
+ * Logger.
+ */
+ private static Log log = ExoLogger.getLogger("exo.jcr.component.webdav.MoveCommand");
+@@ -54,7 +60,27 @@
+ cacheControl.setNoCache(true);
+ }
+
++ public MoveCommand()
++ {
++ this.itemExisted = false;
++ }
++
+ /**
++ * Here we pass info about pre-existence of item on the move
++ * destination path If an item existed, we must respond with NO_CONTENT (204)
++ * HTTP status.
++ * If an item did not exist, we must respond with CREATED (201) HTTP status
++ * More info can be found <a
++ * href=http://www.webdav.org/specs/rfc2518.html#METHOD_MOVE>here</a>.
++ * @param uriBuilder - provide data used in 'location' header
++ * @param itemExisted - indicates if an item existed on copy destination
++ */
++ public MoveCommand(boolean itemExisted)
++ {
++ this.itemExisted = itemExisted;
++ }
++
++ /**
+ * Webdav Move method implementation.
+ *
+ * @param session current session.
+@@ -66,20 +92,17 @@
+ {
+ try
+ {
+-
+- boolean itemExisted = session.itemExists(destPath);
+- if (itemExisted)
+- {
+- session.getItem(destPath).remove();
+- }
+-
+ session.move(srcPath, destPath);
+ session.save();
+
++ // If the source resource was successfully moved
++ // to a pre-existing destination resource.
+ if (itemExisted)
+ {
+ return Response.status(HTTPStatus.NO_CONTENT).cacheControl(cacheControl).build();
+ }
++ // If the source resource was successfully moved,
++ // and a new resource was created at the destination.
+ else
+ {
+ return Response.status(HTTPStatus.CREATED).cacheControl(cacheControl).build();
+@@ -122,7 +145,18 @@
+ sourceSession.getItem(srcPath).remove();
+ sourceSession.save();
+
+- return Response.status(HTTPStatus.NO_CONTENT).cacheControl(cacheControl).build();
++ // If the source resource was successfully moved
++ // to a pre-existing destination resource.
++ if (itemExisted)
++ {
++ return Response.status(HTTPStatus.NO_CONTENT).cacheControl(cacheControl).build();
++ }
++ // If the source resource was successfully moved,
++ // and a new resource was created at the destination.
++ else
++ {
++ return Response.status(HTTPStatus.CREATED).cacheControl(cacheControl).build();
++ }
+
+ }
+ catch (LockException exc)
+Index: exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/CopyCommand.java
+===================================================================
+--- exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/CopyCommand.java (revision 4038)
++++ exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/CopyCommand.java (working copy)
+@@ -46,6 +46,31 @@
+ private static Log log = ExoLogger.getLogger("exo.jcr.component.webdav.CopyCommand");
+
+ /**
++ * To trace if an item on destination path existed.
++ */
++
++ final private boolean itemExisted;
++
++ public CopyCommand()
++ {
++ this.itemExisted = false;
++ }
++
++ /**
++ * Here we pass info about pre-existence of item on the move
++ * destination path If an item existed, we must respond with NO_CONTENT (204)
++ * HTTP status.
++ * If an item did not exist, we must respond with CREATED (201) HTTP status
++ * More info can be found <a
++ * href=http://www.webdav.org/specs/rfc2518.html#METHOD_COPY>here</a>.
++ *
++ */
++ public CopyCommand(boolean itemExisted)
++ {
++ this.itemExisted = itemExisted;
++ }
++
++ /**
+ * Webdav COPY method implementation for the same workspace.
+ *
+ * @param destSession destination session
+@@ -58,7 +83,18 @@
+ try
+ {
+ destSession.getWorkspace().copy(sourcePath, destPath);
+- return Response.status(HTTPStatus.CREATED).build();
++ // If the source resource was successfully moved
++ // to a pre-existing destination resource.
++ if (itemExisted)
++ {
++ return Response.status(HTTPStatus.NO_CONTENT).build();
++ }
++ // If the source resource was successfully moved,
++ // and a new resource was created at the destination.
++ else
++ {
++ return Response.status(HTTPStatus.CREATED).build();
++ }
+ }
+ catch (ItemExistsException e)
+ {
+@@ -97,7 +133,18 @@
+ try
+ {
+ destSession.getWorkspace().copy(sourceWorkspace, sourcePath, destPath);
+- return Response.status(HTTPStatus.CREATED).build();
++ // If the source resource was successfully moved
++ // to a pre-existing destination resource.
++ if (itemExisted)
++ {
++ return Response.status(HTTPStatus.NO_CONTENT).build();
++ }
++ // If the source resource was successfully moved,
++ // and a new resource was created at the destination.
++ else
++ {
++ return Response.status(HTTPStatus.CREATED).build();
++ }
+ }
+ catch (ItemExistsException e)
+ {
15 years, 2 months
exo-jcr SVN: r4040 - in jcr/trunk/exo.jcr.component.webdav/src: main/java/org/exoplatform/services/jcr/webdav/command and 1 other directories.
by do-not-reply@jboss.org
Author: dkuleshov
Date: 2011-03-02 05:08:09 -0500 (Wed, 02 Mar 2011)
New Revision: 4040
Modified:
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/MoveCommand.java
jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestCopy.java
jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestMove.java
Log:
EXOJCR-1217: small fixes
Modified: jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java 2011-03-02 08:47:58 UTC (rev 4039)
+++ jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java 2011-03-02 10:08:09 UTC (rev 4040)
@@ -522,7 +522,8 @@
if (session.getRootNode().hasNode(TextUtil.relativizePath(repoPath)))
{
- return Response.status(HTTPStatus.PRECON_FAILED).entity("Not Found").build();
+ return Response.status(HTTPStatus.PRECON_FAILED)
+ .entity("Item exists on destination path, while overwriting is forbidden").build();
}
}
@@ -932,7 +933,8 @@
Response prpfind = new PropFindCommand().propfind(session, destNodePath, body, depth.getIntValue(), uri);
if (prpfind.getStatus() != HTTPStatus.NOT_FOUND)
{
- return Response.status(HTTPStatus.PRECON_FAILED).entity("Preconditions Failed").build();
+ return Response.status(HTTPStatus.PRECON_FAILED)
+ .entity("Item exists on destination path, while overwriting is forbidden").build();
}
}
Modified: jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/MoveCommand.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/MoveCommand.java 2011-03-02 08:47:58 UTC (rev 4039)
+++ jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/MoveCommand.java 2011-03-02 10:08:09 UTC (rev 4040)
@@ -162,8 +162,26 @@
sourceSession.getItem(srcPath).remove();
sourceSession.save();
- return Response.status(HTTPStatus.NO_CONTENT).cacheControl(cacheControl).build();
+ // If the source resource was successfully moved
+ // to a pre-existing destination resource.
+ if (itemExisted)
+ {
+ return Response.status(HTTPStatus.NO_CONTENT).cacheControl(cacheControl).build();
+ }
+ // If the source resource was successfully moved,
+ // and a new resource was created at the destination.
+ else
+ {
+ if (uriBuilder != null)
+ {
+ return Response.created(uriBuilder.path(destSession.getWorkspace().getName()).path(destPath).build())
+ .cacheControl(cacheControl).build();
+ }
+ // to save compatibility if uriBuilder is not provided
+ return Response.status(HTTPStatus.CREATED).cacheControl(cacheControl).build();
+ }
+
}
catch (LockException exc)
{
Modified: jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestCopy.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestCopy.java 2011-03-02 08:47:58 UTC (rev 4039)
+++ jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestCopy.java 2011-03-02 10:08:09 UTC (rev 4040)
@@ -41,7 +41,7 @@
public class TestCopy extends BaseStandaloneTest
{
- static final String host = "http://localhost:8080";
+ final static private String host = "http://localhost:8080";
public void testeCopyForNonCollectionSingleWorkSpace() throws Exception
{
Modified: jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestMove.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestMove.java 2011-03-02 08:47:58 UTC (rev 4039)
+++ jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestMove.java 2011-03-02 10:08:09 UTC (rev 4040)
@@ -40,7 +40,7 @@
*/
public class TestMove extends BaseStandaloneTest
{
- final static String host = "http://localhost:8080";
+ final static private String host = "http://localhost:8080";
public void testMoveForNonCollectionSingleWorkspace() throws Exception
{
15 years, 2 months
exo-jcr SVN: r4039 - in jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr: impl/core/query/ispn and 2 other directories.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2011-03-02 03:47:58 -0500 (Wed, 02 Mar 2011)
New Revision: 4039
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/infinispan/ISPNCacheableLockManagerImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexChangesFilter.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexInfosKey.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexUpdateKey.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexerCacheStore.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/LocalIndexChangesFilter.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/ISPNCacheWorkspaceStorageCache.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/ISPNCacheFactory.java
Log:
EXOJCR-832 : fixing CacheStore listener, adding static string to IndexInfosKey and IndexUpdateKey.
EXOJCR-833 : fixing cache names (avoid dashes).
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/infinispan/ISPNCacheableLockManagerImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/infinispan/ISPNCacheableLockManagerImpl.java 2011-03-02 08:08:02 UTC (rev 4038)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/infinispan/ISPNCacheableLockManagerImpl.java 2011-03-02 08:47:58 UTC (rev 4039)
@@ -87,22 +87,22 @@
private Cache<Serializable, Object> cache;
public ISPNCacheableLockManagerImpl(WorkspacePersistentDataManager dataManager, WorkspaceEntry config,
- InitialContextInitializer context, TransactionService transactionService, ConfigurationManager cfm, LockRemoverHolder lockRemoverHolder)
- throws RepositoryConfigurationException, RepositoryException
+ InitialContextInitializer context, TransactionService transactionService, ConfigurationManager cfm,
+ LockRemoverHolder lockRemoverHolder) throws RepositoryConfigurationException, RepositoryException
{
this(dataManager, config, context, transactionService.getTransactionManager(), cfm, lockRemoverHolder);
}
public ISPNCacheableLockManagerImpl(WorkspacePersistentDataManager dataManager, WorkspaceEntry config,
- InitialContextInitializer context, ConfigurationManager cfm, LockRemoverHolder lockRemoverHolder) throws RepositoryConfigurationException,
- RepositoryException
+ InitialContextInitializer context, ConfigurationManager cfm, LockRemoverHolder lockRemoverHolder)
+ throws RepositoryConfigurationException, RepositoryException
{
this(dataManager, config, context, (TransactionManager)null, cfm, lockRemoverHolder);
}
public ISPNCacheableLockManagerImpl(WorkspacePersistentDataManager dataManager, WorkspaceEntry config,
- InitialContextInitializer context, TransactionManager transactionManager, ConfigurationManager cfm, LockRemoverHolder lockRemoverHolder)
- throws RepositoryConfigurationException, RepositoryException
+ InitialContextInitializer context, TransactionManager transactionManager, ConfigurationManager cfm,
+ LockRemoverHolder lockRemoverHolder) throws RepositoryConfigurationException, RepositoryException
{
super(dataManager, config, transactionManager, lockRemoverHolder);
@@ -115,7 +115,7 @@
// configure cache loader parameters with correct DB data-types
configureJDBCCacheLoader(config.getLockManager());
- cache = factory.createCache("Lock-" + config.getUniqueName(), config.getLockManager());
+ cache = factory.createCache("Lock_" + config.getUniqueName(), config.getLockManager());
// Context recall is a workaround of JDBCCacheLoader starting.
context.recall();
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexChangesFilter.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexChangesFilter.java 2011-03-02 08:08:02 UTC (rev 4038)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexChangesFilter.java 2011-03-02 08:47:58 UTC (rev 4039)
@@ -85,7 +85,7 @@
ISPNCacheFactory<Serializable, Object> factory = new ISPNCacheFactory<Serializable, Object>(cfm);
config.putParameterValue(PARAM_INFINISPAN_CACHESTORE_CLASS, IndexerCacheStore.class.getName());
- this.cache = factory.createCache("Indexer-" + searchManager.getWsId(), config);
+ this.cache = factory.createCache("Indexer_" + searchManager.getWsId(), config);
CacheLoaderManager cacheLoaderManager =
cache.getAdvancedCache().getComponentRegistry().getComponent(CacheLoaderManager.class);
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexInfosKey.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexInfosKey.java 2011-03-02 08:08:02 UTC (rev 4038)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexInfosKey.java 2011-03-02 08:47:58 UTC (rev 4039)
@@ -33,7 +33,7 @@
IndexInfosKey(String id)
{
- super(id);
+ super("IndexInfos" + id);
}
/**
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexUpdateKey.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexUpdateKey.java 2011-03-02 08:08:02 UTC (rev 4038)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexUpdateKey.java 2011-03-02 08:47:58 UTC (rev 4039)
@@ -33,7 +33,7 @@
IndexUpdateKey(String id)
{
- super(id);
+ super("UpdateMonitor" + id);
}
/**
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexerCacheStore.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexerCacheStore.java 2011-03-02 08:08:02 UTC (rev 4038)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexerCacheStore.java 2011-03-02 08:47:58 UTC (rev 4039)
@@ -79,7 +79,7 @@
super.init(config, cache, m);
this.cacheManager = cache == null ? null : (EmbeddedCacheManager)cache.getCacheManager();
listener = new CacheListener();
- cache.addListener(listener);
+ cacheManager.addListener(listener);
}
/**
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/LocalIndexChangesFilter.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/LocalIndexChangesFilter.java 2011-03-02 08:08:02 UTC (rev 4038)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/LocalIndexChangesFilter.java 2011-03-02 08:47:58 UTC (rev 4039)
@@ -81,7 +81,7 @@
this.wsId = searchManager.getWsId().hashCode();
ISPNCacheFactory<Serializable, Object> factory = new ISPNCacheFactory<Serializable, Object>(cfm);
config.putParameterValue(PARAM_INFINISPAN_CACHESTORE_CLASS, LocalIndexCacheStore.class.getName());
- this.cache = factory.createCache("Indexer-" + searchManager.getWsId(), config);
+ this.cache = factory.createCache("Indexer_" + searchManager.getWsId(), config);
CacheLoaderManager cacheLoaderManager =
cache.getAdvancedCache().getComponentRegistry().getComponent(CacheLoaderManager.class);
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/ISPNCacheWorkspaceStorageCache.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/ISPNCacheWorkspaceStorageCache.java 2011-03-02 08:08:02 UTC (rev 4038)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/ISPNCacheWorkspaceStorageCache.java 2011-03-02 08:47:58 UTC (rev 4039)
@@ -223,7 +223,7 @@
// create parent Infinispan instance
CacheEntry cacheEntry = wsConfig.getCache();
- Cache<Serializable, Object> parentCache = factory.createCache("Data-" + wsConfig.getUniqueName(), cacheEntry);
+ Cache<Serializable, Object> parentCache = factory.createCache("Data_" + wsConfig.getUniqueName(), cacheEntry);
Boolean allowLocalChanges = null;
try
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/ISPNCacheFactory.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/ISPNCacheFactory.java 2011-03-02 08:08:02 UTC (rev 4038)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/ISPNCacheFactory.java 2011-03-02 08:47:58 UTC (rev 4039)
@@ -95,7 +95,8 @@
// get Infinispan configuration file path
final String configurationPath = parameterEntry.getParameterValue(INFINISPAN_CONFIG);
log.info("Infinispan Cache configuration used: " + configurationPath);
-
+ // avoid dashes in cache name. Some SQL servers doesn't allow dashes in table names
+ final String regionIdEscaped = regionId.replace("-", "_");
// prepare configuration
final InputStream configStream;
try
@@ -118,7 +119,7 @@
{
public EmbeddedCacheManager run() throws IOException
{
- return getUniqueInstance(regionId, new DefaultCacheManager(configStream));
+ return getUniqueInstance(regionIdEscaped, new DefaultCacheManager(configStream));
}
});
@@ -132,7 +133,7 @@
{
public Cache<K, V> run()
{
- return manager.getCache(regionId);
+ return manager.getCache(regionIdEscaped);
}
};
Cache<K, V> cache = AccessController.doPrivileged(action);
@@ -155,7 +156,7 @@
GlobalConfiguration gc = manager.getGlobalConfiguration();
ExoContainer container = ExoContainerContext.getCurrentContainer();
// Ensure that the cluster name won't be used between 2 ExoContainers
- gc.setClusterName(gc.getClusterName() + "-" + container.getContext().getName());
+ gc.setClusterName(gc.getClusterName() + "_" + container.getContext().getName());
Configuration conf = manager.getDefaultConfiguration();
if (CACHE_MANAGERS.containsKey(gc))
{
15 years, 2 months
exo-jcr SVN: r4038 - in jcr/trunk/exo.jcr.component.webdav/src: main/java/org/exoplatform/services/jcr/webdav/command and 1 other directories.
by do-not-reply@jboss.org
Author: dkuleshov
Date: 2011-03-02 03:08:02 -0500 (Wed, 02 Mar 2011)
New Revision: 4038
Modified:
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/CopyCommand.java
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/MoveCommand.java
jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestCopy.java
jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestMove.java
Log:
EXOJCR-1217: fixed COPY, MOVE methods parsing 'destination' header
Modified: jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java 2011-03-01 21:30:45 UTC (rev 4037)
+++ jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java 2011-03-02 08:08:02 UTC (rev 4038)
@@ -73,6 +73,7 @@
import java.io.InputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
+import java.net.URI;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
@@ -466,6 +467,8 @@
@HeaderParam(ExtHttpHeaders.DEPTH) String depthHeader,
@HeaderParam(ExtHttpHeaders.OVERWRITE) String overwriteHeader, @Context UriInfo uriInfo, HierarchicalProperty body)
{
+ // to trace if an item on destination path exists
+ boolean itemExisted = false;
if (log.isDebugEnabled())
{
@@ -478,17 +481,27 @@
{
String serverURI = uriInfo.getBaseUriBuilder().path(getClass()).path(repoName).build().toString();
- destinationHeader = TextUtil.unescape(destinationHeader, '%');
+ URI dest = new URI(destinationHeader);
+ URI base = new URI(serverURI);
- if (!destinationHeader.startsWith(serverURI))
+ String destPath = dest.getPath();
+ int repoIndex = destPath.indexOf(repoName);
+
+ // check if destination corresponds to base uri
+ // if the destination is on another server
+ // or destination header is malformed
+ // we return BAD_GATEWAY(502) HTTP status
+ // more info here http://www.webdav.org/specs/rfc2518.html#METHOD_COPY
+ if (!base.getHost().equals(dest.getHost()) || repoIndex == -1)
{
return Response.status(HTTPStatus.BAD_GATEWAY).entity("Bad Gateway").build();
}
+ destPath = normalizePath(dest.getPath().substring(repoIndex + repoName.length() + 1));
+
String srcWorkspace = workspaceName(repoPath);
String srcNodePath = path(repoPath);
- String destPath = destinationHeader.substring(serverURI.length() + 1);
String destWorkspace = workspaceName(destPath);
String destNodePath = path(destPath);
@@ -500,7 +513,8 @@
if (overwrite)
{
- delete(repoName, destPath, lockTokenHeader, ifHeader);
+ Response delResponse = delete(repoName, destPath, lockTokenHeader, ifHeader);
+ itemExisted = (delResponse.getStatus() == HTTPStatus.NO_CONTENT);
}
else
{
@@ -519,12 +533,14 @@
if (srcWorkspace.equals(destWorkspace))
{
Session session = session(repoName, destWorkspace, lockTokens);
- return new CopyCommand(uriInfo.getBaseUriBuilder().path(getClass()).path(repoName)).copy(session,
+ return new CopyCommand(uriInfo.getBaseUriBuilder().path(getClass()).path(repoName), itemExisted).copy(
+ session,
srcNodePath, destNodePath);
}
Session destSession = session(repoName, destWorkspace, lockTokens);
- return new CopyCommand(uriInfo.getBaseUriBuilder().path(getClass()).path(repoName)).copy(destSession,
+ return new CopyCommand(uriInfo.getBaseUriBuilder().path(getClass()).path(repoName), itemExisted).copy(
+ destSession,
srcWorkspace, srcNodePath, destNodePath);
}
@@ -857,7 +873,9 @@
@HeaderParam(ExtHttpHeaders.DEPTH) String depthHeader,
@HeaderParam(ExtHttpHeaders.OVERWRITE) String overwriteHeader, @Context UriInfo uriInfo, HierarchicalProperty body)
{
-
+ // to trace if an item on destination path exists
+ boolean itemExisted = false;
+
if (log.isDebugEnabled())
{
log.debug("MOVE " + repoName + "/" + repoPath);
@@ -869,14 +887,25 @@
{
String serverURI = uriInfo.getBaseUriBuilder().path(getClass()).path(repoName).build().toString();
- destinationHeader = TextUtil.unescape(destinationHeader, '%');
+ URI dest = new URI(destinationHeader);
+ URI base = new URI(serverURI);
+
- if (!destinationHeader.startsWith(serverURI))
+ String destPath = dest.getPath();
+ int repoIndex = destPath.indexOf(repoName);
+
+ // check if destination corresponds to base uri
+ // if the destination is on another server
+ // or destination header is malformed
+ // we return BAD_GATEWAY(502) HTTP status
+ // more info here http://www.webdav.org/specs/rfc2518.html#METHOD_MOVE
+ if (!base.getHost().equals(dest.getHost()) || repoIndex == -1)
{
return Response.status(HTTPStatus.BAD_GATEWAY).entity("Bad Gateway").build();
}
+
+ destPath = normalizePath(dest.getPath().substring(repoIndex + repoName.length() + 1));
- String destPath = destinationHeader.substring(serverURI.length() + 1);
String destWorkspace = workspaceName(destPath);
String destNodePath = path(destPath);
@@ -891,7 +920,8 @@
if (overwrite)
{
- delete(repoName, destPath, lockTokenHeader, ifHeader);
+ Response delResponse = delete(repoName, destPath, lockTokenHeader, ifHeader);
+ itemExisted = (delResponse.getStatus() == HTTPStatus.NO_CONTENT);
}
else
{
@@ -911,13 +941,13 @@
if (srcWorkspace.equals(destWorkspace))
{
Session session = session(repoName, srcWorkspace, lockTokens);
- return new MoveCommand(uriInfo.getBaseUriBuilder().path(getClass()).path(repoName)).move(session,
+ return new MoveCommand(uriInfo.getBaseUriBuilder().path(getClass()).path(repoName), itemExisted).move(session,
srcNodePath, destNodePath);
}
Session srcSession = session(repoName, srcWorkspace, lockTokens);
Session destSession = session(repoName, destWorkspace, lockTokens);
- return new MoveCommand(uriInfo.getBaseUriBuilder().path(getClass()).path(repoName)).move(srcSession,
+ return new MoveCommand(uriInfo.getBaseUriBuilder().path(getClass()).path(repoName), itemExisted).move(srcSession,
destSession, srcNodePath, destNodePath);
}
else
Modified: jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/CopyCommand.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/CopyCommand.java 2011-03-01 21:30:45 UTC (rev 4037)
+++ jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/CopyCommand.java 2011-03-02 08:08:02 UTC (rev 4038)
@@ -54,21 +54,34 @@
private final UriBuilder uriBuilder;
/**
+ * To trace if an item on destination path existed.
+ */
+ private final boolean itemExisted;
+
+ /**
* Empty constructor
*/
public CopyCommand()
{
this.uriBuilder = null;
+ this.itemExisted = false;
}
/**
- * Constructor
+ * Here we pass URI builder and info about pre-existence of item on the move
+ * destination path If an item existed, we must respond with NO_CONTENT (204)
+ * HTTP status.
+ * If an item did not exist, we must respond with CREATED (201) HTTP status
+ * More info can be found <a
+ * href=http://www.webdav.org/specs/rfc2518.html#METHOD_MOVE>here</a>.
*
* @param uriBuilder - provide data used in 'location' header
+ * @param itemExisted - indicates if an item existed on copy destination
*/
- public CopyCommand(UriBuilder uriBuilder)
+ public CopyCommand(UriBuilder uriBuilder, boolean itemExisted)
{
this.uriBuilder = uriBuilder;
+ this.itemExisted = itemExisted;
}
/**
@@ -85,13 +98,26 @@
{
Workspace workspace = destSession.getWorkspace();
workspace.copy(sourcePath, destPath);
- if (uriBuilder != null)
+
+ // If the source resource was successfully moved
+ // to a pre-existing destination resource.
+ if (itemExisted)
{
- return Response.created(uriBuilder.path(workspace.getName()).path(destPath).build()).build();
+ return Response.noContent().build();
}
+ // If the source resource was successfully moved,
+ // and a new resource was created at the destination.
+ else
+ {
+ if (uriBuilder != null)
+ {
+ return Response.created(uriBuilder.path(workspace.getName()).path(destPath).build()).build();
+ }
- // to save compatibility if uribuilder is not provided
- return Response.status(HTTPStatus.CREATED).build();
+ // to save compatibility if uribuilder is not provided
+ return Response.status(HTTPStatus.CREATED).build();
+ }
+
}
catch (ItemExistsException e)
{
@@ -131,13 +157,26 @@
{
Workspace destWorkspace = destSession.getWorkspace();
destWorkspace.copy(sourceWorkspace, sourcePath, destPath);
- if (uriBuilder != null)
+
+ // If the source resource was successfully moved
+ // to a pre-existing destination resource.
+ if (itemExisted)
{
- return Response.created(uriBuilder.path(destWorkspace.getName()).path(destPath).build()).build();
+ return Response.noContent().build();
}
+ // If the source resource was successfully moved,
+ // and a new resource was created at the destination.
+ else
+ {
+ if (uriBuilder != null)
+ {
+ return Response.created(uriBuilder.path(destWorkspace.getName()).path(destPath).build()).build();
+ }
- // to save compatibility if uriBuilder is not provided
- return Response.status(HTTPStatus.CREATED).build();
+ // to save compatibility if uriBuilder is not provided
+ return Response.status(HTTPStatus.CREATED).build();
+ }
+
}
catch (ItemExistsException e)
{
Modified: jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/MoveCommand.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/MoveCommand.java 2011-03-01 21:30:45 UTC (rev 4037)
+++ jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/MoveCommand.java 2011-03-02 08:08:02 UTC (rev 4038)
@@ -53,6 +53,11 @@
* Provides URI information needed for 'location' header in 'CREATED' response
*/
private final UriBuilder uriBuilder;
+
+ /**
+ * To trace if an item on destination path existed.
+ */
+ private final boolean itemExisted;
// Fix problem with moving under Windows Explorer.
static
@@ -66,16 +71,23 @@
public MoveCommand()
{
this.uriBuilder = null;
+ this.itemExisted = false;
}
/**
- * Constructor to receive URI Info
- *
+ * Here we pass URI builder and info about pre-existence of item on the move
+ * destination path If an item existed, we must respond with NO_CONTENT (204)
+ * HTTP status.
+ * If an item did not exist, we must respond with CREATED (201) HTTP status
+ * More info can be found <a
+ * href=http://www.webdav.org/specs/rfc2518.html#METHOD_MOVE>here</a>.
* @param uriBuilder - provide data used in 'location' header
+ * @param itemExisted - indicates if an item existed on copy destination
*/
- public MoveCommand(UriBuilder uriBuilder)
+ public MoveCommand(UriBuilder uriBuilder, boolean itemExisted)
{
this.uriBuilder = uriBuilder;
+ this.itemExisted = itemExisted;
}
/**
@@ -90,20 +102,17 @@
{
try
{
-
- boolean itemExisted = session.itemExists(destPath);
- if (itemExisted)
- {
- session.getItem(destPath).remove();
- }
-
session.move(srcPath, destPath);
session.save();
+ // If the source resource was successfully moved
+ // to a pre-existing destination resource.
if (itemExisted)
{
return Response.status(HTTPStatus.NO_CONTENT).cacheControl(cacheControl).build();
}
+ // If the source resource was successfully moved,
+ // and a new resource was created at the destination.
else
{
if (uriBuilder != null)
Modified: jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestCopy.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestCopy.java 2011-03-01 21:30:45 UTC (rev 4037)
+++ jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestCopy.java 2011-03-02 08:08:02 UTC (rev 4038)
@@ -41,6 +41,8 @@
public class TestCopy extends BaseStandaloneTest
{
+ static final String host = "http://localhost:8080";
+
public void testeCopyForNonCollectionSingleWorkSpace() throws Exception
{
String content = TestUtils.getFileContent();
@@ -49,8 +51,8 @@
TestUtils.addContent(session, filename, inputStream, defaultFileNodeType, "");
String destFilename = TestUtils.getFileName();
MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
- headers.add(ExtHttpHeaders.DESTINATION, getPathWS() + destFilename);
- ContainerResponse response = service(WebDAVMethods.COPY, getPathWS() + filename, "", headers, null);
+ headers.add(ExtHttpHeaders.DESTINATION, host + getPathWS() + destFilename);
+ ContainerResponse response = service(WebDAVMethods.COPY, getPathWS() + filename, host, headers, null);
assertEquals(HTTPStatus.CREATED, response.getStatus());
assertTrue(session.getRootNode().hasNode(TextUtil.relativizePath(destFilename)));
Node nodeDest = session.getRootNode().getNode(TextUtil.relativizePath(destFilename));
@@ -79,8 +81,8 @@
TestUtils.addContent(session, filename, inputStream, defaultFileNodeType, "");
String destFilename = TestUtils.getFileName();
MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
- headers.add(ExtHttpHeaders.DESTINATION, getPathDestWS() + destFilename);
- ContainerResponse response = service(WebDAVMethods.COPY, getPathWS() + filename, "", headers, null);
+ headers.add(ExtHttpHeaders.DESTINATION, host + getPathDestWS() + destFilename);
+ ContainerResponse response = service(WebDAVMethods.COPY, getPathWS() + filename, host, headers, null);
assertEquals(HTTPStatus.CREATED, response.getStatus());
assertTrue(destSession.getRootNode().hasNode(TextUtil.relativizePath(destFilename)));
@@ -118,18 +120,114 @@
// prepare headers
MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
- headers.add(ExtHttpHeaders.DESTINATION, getPathWS() + destFilename);
+ headers.add(ExtHttpHeaders.DESTINATION, host + getPathWS() + destFilename);
// execute query
- ContainerResponse response = service(WebDAVMethods.COPY, getPathWS() + filename, "", headers, null);
+ ContainerResponse response = service(WebDAVMethods.COPY, getPathWS() + filename, host, headers, null);
// check if operation completed successfully, we expect a new resource to be created
assertEquals(HTTPStatus.CREATED, response.getStatus());
// check if response 'CREATED' contains 'LOCATION' header
assertTrue(response.getHttpHeaders().containsKey(ExtHttpHeaders.LOCATION));
// check if 'CREATED' response 'LOCATION' header contains correct location path
- assertEquals(getPathWS() + destFilename, response.getHttpHeaders().getFirst(ExtHttpHeaders.LOCATION).toString());
+ assertEquals(host + getPathWS() + destFilename, response.getHttpHeaders().getFirst(ExtHttpHeaders.LOCATION)
+ .toString());
}
+ /**
+ * Testing for correct destination header parsing in COPY method.
+ * We pass a path which contains escaped space - "%20"
+ * and escaped space with quote symbol "%20'"
+ * @throws Exception
+ */
+ public void testDestinationHeaderParsing() throws Exception
+ {
+ String content = TestUtils.getFileContent();
+ String filename = TestUtils.getFileName();
+ InputStream inputStream = new ByteArrayInputStream(content.getBytes());
+ TestUtils.addContent(session, filename, inputStream, defaultFileNodeType, "");
+
+ String destFilename = TestUtils.getFileName() + "%20test";
+
+ // prepare headers
+ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+ headers.add(ExtHttpHeaders.DESTINATION, host + getPathWS() + destFilename);
+
+ // execute the query
+ ContainerResponse response = service(WebDAVMethods.COPY, getPathWS() + filename, host, headers, null);
+ // check if operation completed successfully, we expect a new resource to be created
+ assertEquals(HTTPStatus.CREATED, response.getStatus());
+
+ filename = destFilename;
+
+ destFilename = TestUtils.getFileName() + "%20'test";
+
+ // prepare headers
+ headers = new MultivaluedMapImpl();
+ headers.add(ExtHttpHeaders.DESTINATION, host + getPathWS() + destFilename);
+
+ // execute the query
+ response = service(WebDAVMethods.COPY, getPathWS() + filename, host, headers, null);
+ // check if operation completed successfully, we expect a new resource to be created
+ assertEquals(HTTPStatus.CREATED, response.getStatus());
+
+ }
+
+ /**
+ * Testing for correct response after COPY a resource to the destination,
+ * where another resource already existed
+ * For more info see <a href=http://www.webdav.org/specs/rfc2518.html#METHOD_MOVE>this</a>.
+ * @throws Exception
+ */
+ public void testNoContentResponses() throws Exception
+ {
+ String content = TestUtils.getFileContent();
+ String filename = TestUtils.getFileName();
+ InputStream inputStream = new ByteArrayInputStream(content.getBytes());
+ TestUtils.addContent(session, filename, inputStream, defaultFileNodeType, "");
+
+ String destFilename = TestUtils.getFileName();
+ inputStream = new ByteArrayInputStream(content.getBytes());
+ TestUtils.addContent(session, destFilename, inputStream, defaultFileNodeType, "");
+
+ // prepare headers
+ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+ headers.add(ExtHttpHeaders.DESTINATION, host + getPathWS() + destFilename);
+ headers.add(ExtHttpHeaders.OVERWRITE, "T");
+
+ // execute the query
+ ContainerResponse response = service(WebDAVMethods.COPY, getPathWS() + filename, host, headers, null);
+ // check if operation completed successfully, we expect a new resource to be created
+ assertEquals(HTTPStatus.NO_CONTENT, response.getStatus());
+
+ }
+
+ /**
+ * Testing for correct destination header parsing using "https"
+ * instead of usual "http" scheme.
+ * @throws Exception
+ */
+ public void testHttpsSchemeInDestinationHeaderParsing() throws Exception
+ {
+ String httpsHost = "https://localhost:8080";
+
+ String content = TestUtils.getFileContent();
+ String filename = TestUtils.getFileName();
+ InputStream inputStream = new ByteArrayInputStream(content.getBytes());
+ TestUtils.addContent(session, filename, inputStream, defaultFileNodeType, "");
+
+ String destFilename = TestUtils.getFileName();
+
+ // prepare headers
+ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+ headers.add(ExtHttpHeaders.DESTINATION, httpsHost + getPathWS() + destFilename);
+
+ // execute the query
+ ContainerResponse response = service(WebDAVMethods.COPY, getPathWS() + filename, host, headers, null);
+ // check if operation completed successfully, we expect a new resource to be created
+ assertEquals(HTTPStatus.CREATED, response.getStatus());
+
+ }
+
@Override
protected String getRepositoryName()
{
Modified: jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestMove.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestMove.java 2011-03-01 21:30:45 UTC (rev 4037)
+++ jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestMove.java 2011-03-02 08:08:02 UTC (rev 4038)
@@ -40,6 +40,7 @@
*/
public class TestMove extends BaseStandaloneTest
{
+ final static String host = "http://localhost:8080";
public void testMoveForNonCollectionSingleWorkspace() throws Exception
{
@@ -49,8 +50,8 @@
TestUtils.addContent(session, filename, inputStream, defaultFileNodeType, "");
String destFilename = TestUtils.getFileName();
MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
- headers.add(ExtHttpHeaders.DESTINATION, getPathWS() + destFilename);
- ContainerResponse response = service(WebDAVMethods.MOVE, getPathWS() + filename, "", headers, null);
+ headers.add(ExtHttpHeaders.DESTINATION, host + getPathWS() + destFilename);
+ ContainerResponse response = service(WebDAVMethods.MOVE, getPathWS() + filename, host, headers, null);
assertEquals(HTTPStatus.CREATED, response.getStatus());
assertTrue(session.getRootNode().hasNode(TextUtil.relativizePath(destFilename)));
Node nodeDest = session.getRootNode().getNode(TextUtil.relativizePath(destFilename));
@@ -72,8 +73,8 @@
TestUtils.addContent(session, filename, inputStream, defaultFileNodeType, "");
String destFilename = TestUtils.getFileName();
MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
- headers.add(ExtHttpHeaders.DESTINATION, getPathDestWS() + destFilename);
- ContainerResponse response = service(WebDAVMethods.MOVE, getPathWS() + filename, "", headers, null);
+ headers.add(ExtHttpHeaders.DESTINATION, host + getPathDestWS() + destFilename);
+ ContainerResponse response = service(WebDAVMethods.MOVE, getPathWS() + filename, host, headers, null);
assertEquals(HTTPStatus.NO_CONTENT, response.getStatus());
assertTrue(destSession.getRootNode().hasNode(TextUtil.relativizePath(destFilename)));
Node nodeDest = destSession.getRootNode().getNode(TextUtil.relativizePath(destFilename));
@@ -102,19 +103,115 @@
// prepare headers
MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
- headers.add(ExtHttpHeaders.DESTINATION, getPathWS() + destFilename);
+ headers.add(ExtHttpHeaders.DESTINATION, host + getPathWS() + destFilename);
// execute the query
- ContainerResponse response = service(WebDAVMethods.MOVE, getPathWS() + filename, "", headers, null);
+ ContainerResponse response = service(WebDAVMethods.MOVE, getPathWS() + filename, host, headers, null);
// check if operation completed successfully, we expect a new resource to be created
assertEquals(HTTPStatus.CREATED, response.getStatus());
// check if 'CREATED' response contains 'LOCATION' header
assertTrue(response.getHttpHeaders().containsKey(ExtHttpHeaders.LOCATION));
// check if 'CREATED' response 'LOCATION' header contains correct location path
- assertEquals(getPathWS() + destFilename, response.getHttpHeaders().getFirst(ExtHttpHeaders.LOCATION).toString());
+ assertEquals(host + getPathWS() + destFilename,
+ response.getHttpHeaders().getFirst(ExtHttpHeaders.LOCATION).toString());
}
+ /**
+ * Testing for correct destination header parsing in MOVE method.
+ * We pass a path which contains escaped space - "%20"
+ * and escaped space with quote symbol "%20'"
+ * @throws Exception
+ */
+ public void testDestinationHeaderParsing() throws Exception
+ {
+ String content = TestUtils.getFileContent();
+ String filename = TestUtils.getFileName();
+ InputStream inputStream = new ByteArrayInputStream(content.getBytes());
+ TestUtils.addContent(session, filename, inputStream, defaultFileNodeType, "");
+
+ String destFilename = TestUtils.getFileName() + "%20test";
+
+ // prepare headers
+ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+ headers.add(ExtHttpHeaders.DESTINATION, host + getPathWS() + destFilename);
+
+ // execute the query
+ ContainerResponse response = service(WebDAVMethods.MOVE, getPathWS() + filename, host, headers, null);
+ // check if operation completed successfully, we expect a new resource to be created
+ assertEquals(HTTPStatus.CREATED, response.getStatus());
+
+ filename = destFilename;
+
+ destFilename = TestUtils.getFileName() + "%20'test";
+
+ // prepare headers
+ headers = new MultivaluedMapImpl();
+ headers.add(ExtHttpHeaders.DESTINATION, host + getPathWS() + destFilename);
+
+ // execute the query
+ response = service(WebDAVMethods.MOVE, getPathWS() + filename, host, headers, null);
+ // check if operation completed successfully, we expect a new resource to be created
+ assertEquals(HTTPStatus.CREATED, response.getStatus());
+
+ }
+
+ /**
+ * Testing for correct response after MOVE a resource to the destination,
+ * where another resource already existed
+ * For more info see <a href=http://www.webdav.org/specs/rfc2518.html#METHOD_MOVE>this</a>.
+ * @throws Exception
+ */
+ public void testNoContentResponses() throws Exception
+ {
+ String content = TestUtils.getFileContent();
+ String filename = TestUtils.getFileName();
+ InputStream inputStream = new ByteArrayInputStream(content.getBytes());
+ TestUtils.addContent(session, filename, inputStream, defaultFileNodeType, "");
+
+ String destFilename = TestUtils.getFileName();
+ inputStream = new ByteArrayInputStream(content.getBytes());
+ TestUtils.addContent(session, destFilename, inputStream, defaultFileNodeType, "");
+
+ // prepare headers
+ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+ headers.add(ExtHttpHeaders.DESTINATION, host + getPathWS() + destFilename);
+ headers.add(ExtHttpHeaders.OVERWRITE, "T");
+
+ // execute the query
+ ContainerResponse response = service(WebDAVMethods.MOVE, getPathWS() + filename, host, headers, null);
+ // check if operation completed successfully, we expect a new resource to be created
+ assertEquals(HTTPStatus.NO_CONTENT, response.getStatus());
+
+ }
+
+ /**
+ * Testing for correct destination header parsing using "https"
+ * instead of usual "http" scheme.
+ * @throws Exception
+ */
+ public void testHttpsSchemeInDestinationHeaderParsing() throws Exception
+ {
+ String httpsHost = "https://localhost:8080";
+
+ String content = TestUtils.getFileContent();
+ String filename = TestUtils.getFileName();
+ InputStream inputStream = new ByteArrayInputStream(content.getBytes());
+ TestUtils.addContent(session, filename, inputStream, defaultFileNodeType, "");
+
+ String destFilename = TestUtils.getFileName();
+
+ // prepare headers
+ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+ headers.add(ExtHttpHeaders.DESTINATION, httpsHost + getPathWS() + destFilename);
+
+ // execute the query
+ ContainerResponse response = service(WebDAVMethods.MOVE, getPathWS() + filename, host, headers, null);
+ // check if operation completed successfully, we expect a new resource to be created
+ assertEquals(HTTPStatus.CREATED, response.getStatus());
+
+ }
+
@Override
protected String getRepositoryName()
{
15 years, 2 months
exo-jcr SVN: r4037 - jcr/trunk/packaging/module/src/main/javascript.
by do-not-reply@jboss.org
Author: tolusha
Date: 2011-03-01 16:30:45 -0500 (Tue, 01 Mar 2011)
New Revision: 4037
Modified:
jcr/trunk/packaging/module/src/main/javascript/jcr.packaging.module.js
Log:
EXOJCR-1159: update module.js
Modified: jcr/trunk/packaging/module/src/main/javascript/jcr.packaging.module.js
===================================================================
--- jcr/trunk/packaging/module/src/main/javascript/jcr.packaging.module.js 2011-03-01 21:26:13 UTC (rev 4036)
+++ jcr/trunk/packaging/module/src/main/javascript/jcr.packaging.module.js 2011-03-01 21:30:45 UTC (rev 4037)
@@ -21,22 +21,22 @@
addDependency(core.component.documents) .
addDependency(new Project("jcr", "jcr", "jar", "1.0")).
addDependency(new Project("concurrent", "concurrent", "jar", "1.3.4")).
- addDependency(new Project("jgroups", "jgroups", "jar", "2.6.13.GA")).
+ addDependency(new Project("jgroups", "jgroups", "jar", "2.11.1.Final")).
// addDependency(new Project("stax", "stax-api", "jar", "1.0")).
// addDependency(new Project("stax", "stax", "jar", "1.2.0")).
addDependency(new Project("org.jboss.cache","jbosscache-core","jar","3.2.6.GA")).
addDependency(new Project("jboss.jbossts","jbossjts","jar","4.6.1.GA")).
addDependency(new Project("jboss.jbossts","jbossts-common","jar","4.6.1.GA")).
addDependency(new Project("org.apache.ws.commons","ws-commons-util","jar","1.0.1")).
- addDependency(new Project("org.apache.lucene", "lucene-core", "jar", "2.4.1")).
- addDependency(new Project("org.apache.lucene", "lucene-spellchecker", "jar", "2.4.1")).
- addDependency(new Project("org.apache.lucene", "lucene-memory", "jar", "2.4.1"));
+ addDependency(new Project("org.apache.lucene", "lucene-core", "jar", "2.9.4")).
+ addDependency(new Project("org.apache.lucene", "lucene-spellchecker", "jar", "2.9.4")).
+ addDependency(new Project("org.apache.lucene", "lucene-memory", "jar", "2.9.4"));
module.frameworks = {}
module.frameworks.web =
new Project("org.exoplatform.jcr", "exo.jcr.framework.web", "jar", module.version).
addDependency(ws.rest).
- addDependency(new Project("commons-chain", "commons-chain", "jar", "1.0"));
+ addDependency(new Project("commons-chain", "commons-chain", "jar", "1.2"));
module.frameworks.command = new Project("org.exoplatform.jcr", "exo.jcr.framework.command", "jar", module.version).
addDependency(new Project("commons-fileupload", "commons-fileupload", "jar", "1.2.1"));
15 years, 2 months