Author: trang_vu
Date: 2011-11-02 06:49:50 -0400 (Wed, 02 Nov 2011)
New Revision: 5146
Added:
jcr/branches/1.12.x/patch/1.12.11-GA/JCR-1680/readme.txt
Modified:
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/resource/CollectionResource.java
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/resources/xslt/get-method.xsl
jcr/branches/1.12.x/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestGet.java
Log:
JCR-1680: webdav bug when clicking go back link in a folder whose name contains a space
Fix description
* Changed the way we determine the parent href for current collection.
Now we pass special attribute for it to the streaming output for the xslt insted of
using the address of the current collection with the last element being cut off.
Modified:
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/resource/CollectionResource.java
===================================================================
---
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/resource/CollectionResource.java 2011-11-02
10:19:20 UTC (rev 5145)
+++
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/resource/CollectionResource.java 2011-11-02
10:49:50 UTC (rev 5146)
@@ -86,6 +86,11 @@
final String XML_HREF = "xlink:href";
/**
+ * XML parent href constant.
+ */
+ final static String XML_PARENT_HREF = "xlink:parent-href";
+
+ /**
* XML namespace prefix.
*/
final String PREFIX_XMLNS = "xmlns:sv";
@@ -418,6 +423,20 @@
writer.writeAttribute(XLINK_XMLNS, XLINK_LINK);
writer.writeAttribute(XML_NAME, node.getName());
writer.writeAttribute(XML_HREF, rootHref + TextUtil.escape(node.getPath(),
'%', true));
+
+
+ if (!node.getPath().equals("/"))
+ {
+ // this is added to fix EXOJCR-1379
+ // XSLT string operations with actual node href, (which are used during
XSLT transformation
+ // to receive parent href) produce wrong parent-href if node path
containes non-latin symbols,
+ // so instead we simply add one more attribute which already contains
parent-href
+ // as result: no XLST processor string manipulation is needed
+ String nodeParentHref = rootHref +
TextUtil.escape(node.getParent().getPath(), '%', true);
+ writer.writeAttribute(XML_PARENT_HREF, nodeParentHref);
+ }
+
+
// add properties
for (PropertyIterator pi = node.getProperties(); pi.hasNext();)
{
Modified:
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/resources/xslt/get-method.xsl
===================================================================
---
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/resources/xslt/get-method.xsl 2011-11-02
10:19:20 UTC (rev 5145)
+++
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/resources/xslt/get-method.xsl 2011-11-02
10:49:50 UTC (rev 5146)
@@ -26,7 +26,7 @@
<!-- Parent node link -->
<a>
<xsl:attribute name="href">
- <xsl:value-of select="substring(./@xlink:href, 1,
string-length(./@xlink:href) - string-length(./@sv:name))" />
+ <xsl:value-of select="./@xlink:parent-href" />
</xsl:attribute>
<xsl:if test="$folder-icon-path!=''">
<img src="{$folder-icon-path}" alt="" />
Modified:
jcr/branches/1.12.x/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestGet.java
===================================================================
---
jcr/branches/1.12.x/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestGet.java 2011-11-02
10:19:20 UTC (rev 5145)
+++
jcr/branches/1.12.x/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestGet.java 2011-11-02
10:49:50 UTC (rev 5146)
@@ -39,6 +39,7 @@
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringWriter;
+import java.net.URLDecoder;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;
@@ -194,6 +195,64 @@
}
+ /**
+ * We test for parent href to be contained in response.
+ * We GET a collection and receive an html. Html should contain
+ * a href to parent collection of requested collection.
+ * @throws Exception
+ */
+ public void testParentHrefForGetColRequest() throws Exception
+ {
+ String folderOne = TestUtils.getFolderName();
+ String folderTwo = folderOne + TestUtils.getFolderName();
+
+ // add collections
+ TestUtils.addFolder(session, folderOne, defaultFolderNodeType, "");
+ TestUtils.addFolder(session, folderTwo, defaultFolderNodeType, "");
+
+ // get a sub-collection
+ ContainerResponse response = service(WebDAVMethods.GET, getPathWS() + folderTwo,
"", null, null);
+ assertEquals(HTTPStatus.OK, response.getStatus());
+
+ // serialize response entity to string
+ XSLTStreamingOutput XSLTout = (XSLTStreamingOutput)response.getEntity();
+ ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
+ XSLTout.write(byteOut);
+
+ assertTrue("Response should contain parent collection href",
byteOut.toString().contains(folderOne));
+ }
+
+ /**
+ * We test for parent href to be contained in response. We GET a collection,
+ * which has non latin letters in its name, and receive an html like response.
+ * Response should contain href to parent collection of requested collection.
+ * Details can be found here:
https://issues.jboss.org/browse/EXOJCR-1379
+ * @throws Exception
+ */
+ public void testParentHrefForGetColWithNonLatinNameRequest() throws Exception
+ {
+ // "%40" corresponds to '@' symbol
+ String folderOne = TestUtils.getFolderName() + "%40";
+ String folderTwo = folderOne + TestUtils.getFolderName() + "%40";
+
+ ContainerResponse response;
+
+ //add collections
+ TestUtils.addFolder(session, URLDecoder.decode(folderOne, "UTF-8"),
defaultFolderNodeType, "");
+ TestUtils.addFolder(session, URLDecoder.decode(folderTwo, "UTF-8"),
defaultFolderNodeType, "");
+
+ //get a sub-collection
+ response = service(WebDAVMethods.GET, getPathWS() + folderTwo, "", null,
null);
+ assertEquals(HTTPStatus.OK, response.getStatus());
+
+ // serialize response entity to string
+ XSLTStreamingOutput XSLTout = (XSLTStreamingOutput)response.getEntity();
+ ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
+ XSLTout.write(byteOut);
+
+ assertTrue("Response should contain parent collection href",
byteOut.toString().contains(folderOne));
+ }
+
@Override
protected String getRepositoryName()
{
Added: jcr/branches/1.12.x/patch/1.12.11-GA/JCR-1680/readme.txt
===================================================================
--- jcr/branches/1.12.x/patch/1.12.11-GA/JCR-1680/readme.txt (rev
0)
+++ jcr/branches/1.12.x/patch/1.12.11-GA/JCR-1680/readme.txt 2011-11-02 10:49:50 UTC (rev
5146)
@@ -0,0 +1,78 @@
+Summary
+
+ * Status: webdav bug when clicking go back link in a folder whose name contains a
space
+ * CCP Issue: CCP-1123, Product Jira Issue: JCR-1680.
+ * Complexity: Low
+
+The Proposal
+Problem description
+
+What is the problem to fix?
+How to reproduce on PLF 3.0.5:
+
+1)Login
+2)Type this URL in your browser
http://localhost:8080/portal/rest/jcr/repository/collaboration/sites content/live/acme/web
contents
+3)Click on the ".." link
+You'll be redirected to an erroneous link
http://localhost:8080/portal/rest/jcr/repository/collaboration/sites content/live/acme/we
+rather than being redirected to the parent folder.You'll get also an error message
"Can't find path: /sites content/live/acme/we"
+This happens with all folders whose name contains space character such as "web
contents".
+
+Fix description
+
+How is the problem fixed?
+
+ * Changed the way we determine the parent href for current collection.
+ Now we pass special attribute for it to the streaming output for the xslt insted of
using the address of the current collection with the last element being cut off.
+
+Patch file: JCR-1680.patch
+
+Tests to perform
+
+Reproduction test
+
+ * Reproduced on PLF 3.0.5 while browsing collections which has 'space'
character in the name
+
+Tests performed at DevLevel
+
+ * Reproduced on JCR WebDAV component. Added unit tests which covers this issue.
+
+Tests performed at QA/Support Level
+
+ *
+
+Documentation changes
+
+Documentation changes:
+
+ * None
+
+Configuration changes
+
+Configuration changes:
+
+ * None
+
+Will previous configuration continue to work?
+
+ * Yes
+
+Risks and impacts
+
+Can this bug fix have any side effects on current client projects?
+
+ * No
+
+Is there a performance risk/cost?
+
+ * No
+
+Validation (PM/Support/QA)
+
+PM Comment
+* Patch validated
+
+Support Comment
+* Patch validated
+
+QA Feedbacks
+*