Author: dkuleshov
Date: 2010-11-17 09:24:34 -0500 (Wed, 17 Nov 2010)
New Revision: 3473
Modified:
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.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
jcr/branches/1.12.x/exo.jcr.component.webdav/src/test/resources/conf/standalone/test-configuration.xml
jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/protocols/webdav.xml
Log:
JCR-1511: modified WebDavServiceImpl to receive folde-icon-path init param, and to pass it
to GetCommand
Modified:
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java
===================================================================
---
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java 2010-11-17
14:18:55 UTC (rev 3472)
+++
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java 2010-11-17
14:24:34 UTC (rev 3473)
@@ -75,6 +75,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import javax.jcr.NoSuchWorkspaceException;
import javax.jcr.PathNotFoundException;
@@ -136,6 +137,8 @@
private HashMap<MediaType, String> cacheControlMap = new HashMap<MediaType,
String>();
+ public static final String FOLDER_ICON_PATH = "folder-icon-path";
+
/**
* Logger.
*/
@@ -182,6 +185,11 @@
private String autoVersionType = "checkout-checkin";
/**
+ * XSLT parameters.
+ */
+ private Map<String, String> xsltParams = new HashMap<String, String>();
+
+ /**
* The list of allowed methods.
*/
private static final String ALLOW;
@@ -222,6 +230,13 @@
this.repositoryService = repositoryService;
this.nullResourceLocks = new NullResourceLocksHolder();
+ ValueParam pXSLTParam = params.getValueParam(FOLDER_ICON_PATH);
+ if (pXSLTParam != null)
+ {
+ xsltParams.put(FOLDER_ICON_PATH, pXSLTParam.getValue());
+ log.info(FOLDER_ICON_PATH + " = " + pXSLTParam.getValue());
+ }
+
ValueParam pDefFolderNodeType =
params.getValueParam(INIT_PARAM_DEF_FOLDER_NODE_TYPE);
if (pDefFolderNodeType != null)
{
@@ -545,7 +560,8 @@
String uri =
uriInfo.getBaseUriBuilder().path(getClass()).path(repoName).path(workspaceName(repoPath)).build()
.toString();
- return new GetCommand().get(session, path(repoPath), version, uri, ranges,
ifModifiedSince, cacheControlMap);
+ return new GetCommand(xsltParams).get(session, path(repoPath), version, uri,
ranges, ifModifiedSince,
+ cacheControlMap);
}
catch (PathNotFoundException exc)
Modified:
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java
===================================================================
---
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java 2010-11-17
14:18:55 UTC (rev 3472)
+++
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java 2010-11-17
14:24:34 UTC (rev 3473)
@@ -18,26 +18,6 @@
*/
package org.exoplatform.services.jcr.webdav.command;
-import java.io.InputStream;
-import java.net.URI;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-
-import javax.jcr.Node;
-import javax.jcr.PathNotFoundException;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.xml.transform.stream.StreamSource;
-
import org.exoplatform.common.http.HTTPStatus;
import org.exoplatform.common.util.HierarchicalProperty;
import org.exoplatform.services.jcr.webdav.Range;
@@ -59,6 +39,27 @@
import org.exoplatform.services.rest.ext.provider.XSLTStreamingOutput;
import org.exoplatform.services.rest.impl.header.MediaTypeHelper;
+import java.io.InputStream;
+import java.net.URI;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.xml.transform.stream.StreamSource;
+
/**
* Created by The eXo Platform SAS Author : <a
* href="gavrikvetal(a)gmail.com">Vitaly Guly</a>.
@@ -74,6 +75,17 @@
*/
private static Log log =
ExoLogger.getLogger("exo.jcr.component.webdav.GetCommand");
+ private Map<String, String> xsltParams;
+
+ public GetCommand()
+ {
+ }
+
+ public GetCommand(Map<String, String> xsltParams)
+ {
+ this.xsltParams = xsltParams;
+ }
+
/**
* GET content of the resource. Can be return content of the file. The content
* returns in the XML type. If version parameter is present, returns the
@@ -206,8 +218,8 @@
resource = new CollectionResource(uri, node, nsContext);
istream = ((CollectionResource)resource).getContentAsStream(baseURI);
- XSLTStreamingOutput entity = new
XSLTStreamingOutput("get.method.template", new StreamSource(istream));
-
+ XSLTStreamingOutput entity =
+ new XSLTStreamingOutput("get.method.template", new
StreamSource(istream), xsltParams);
return Response.ok(entity, MediaType.TEXT_HTML).build();
}
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 2010-11-17
14:18:55 UTC (rev 3472)
+++
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/resources/xslt/get-method.xsl 2010-11-17
14:24:34 UTC (rev 3473)
@@ -2,6 +2,7 @@
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sv="http://www.jcp.org/jcr/sv/1.0"
xmlns:xlink="http://www.w3.org/1999/xlink"
exclude-result-prefixes="xlink">
<xsl:output method="html" encoding="UTF-8" />
+ <xsl:param name="folder-icon-path"></xsl:param>
<xsl:template match="/sv:node">
<html>
<head>
@@ -27,7 +28,9 @@
<xsl:attribute name="href">
<xsl:value-of select="substring(./@xlink:href, 1,
string-length(./@xlink:href) - string-length(./@sv:name))" />
</xsl:attribute>
- <img
src="/ecm/skin/icons/16x16/NodeTypes/DefaultSkin/nt-folder.gif" alt=""
/>
+ <xsl:if test="$folder-icon-path!=''">
+ <img src="{$folder-icon-path}" alt="" />
+ </xsl:if>
<xsl:text> ..</xsl:text>
</a>
<br />
@@ -50,9 +53,11 @@
<xsl:template match="sv:node">
<a>
<xsl:attribute name="href">
- <xsl:value-of select="./@xlink:href" />
- </xsl:attribute>
- <img src="/ecm/skin/icons/16x16/NodeTypes/DefaultSkin/nt-folder.gif"
alt="" />
+ <xsl:value-of select="./@xlink:href" />
+ </xsl:attribute>
+ <xsl:if test="$folder-icon-path!=''">
+ <img src="{$folder-icon-path}" alt="" />
+ </xsl:if>
<xsl:text> </xsl:text>
<xsl:value-of select="./@sv:name" />
</a>
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 2010-11-17
14:18:55 UTC (rev 3472)
+++
jcr/branches/1.12.x/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestGet.java 2010-11-17
14:24:34 UTC (rev 3473)
@@ -18,7 +18,21 @@
*/
package org.exoplatform.services.jcr.webdav.command;
+import org.exoplatform.common.http.HTTPStatus;
+import org.exoplatform.services.jcr.core.nodetype.ExtendedNodeTypeManager;
+import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
+import org.exoplatform.services.jcr.impl.core.version.VersionImpl;
+import org.exoplatform.services.jcr.webdav.BaseStandaloneTest;
+import org.exoplatform.services.jcr.webdav.WebDavConst;
+import org.exoplatform.services.jcr.webdav.WebDavConstants.WebDAVMethods;
+import org.exoplatform.services.jcr.webdav.utils.TestUtils;
+import org.exoplatform.services.rest.ExtHttpHeaders;
+import org.exoplatform.services.rest.ext.provider.XSLTStreamingOutput;
+import org.exoplatform.services.rest.impl.ContainerResponse;
+import org.exoplatform.services.rest.impl.MultivaluedMapImpl;
+
import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
@@ -32,18 +46,6 @@
import javax.jcr.Node;
import javax.ws.rs.core.MultivaluedMap;
-import org.exoplatform.common.http.HTTPStatus;
-import org.exoplatform.services.jcr.core.nodetype.ExtendedNodeTypeManager;
-import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
-import org.exoplatform.services.jcr.impl.core.version.VersionImpl;
-import org.exoplatform.services.jcr.webdav.BaseStandaloneTest;
-import org.exoplatform.services.jcr.webdav.WebDavConst;
-import org.exoplatform.services.jcr.webdav.WebDavConstants.WebDAVMethods;
-import org.exoplatform.services.jcr.webdav.utils.TestUtils;
-import org.exoplatform.services.rest.ExtHttpHeaders;
-import org.exoplatform.services.rest.impl.ContainerResponse;
-import org.exoplatform.services.rest.impl.MultivaluedMapImpl;
-
/**
* Created by The eXo Platform SAS Author : Dmytro Katayev
* work.visor.ck(a)gmail.com Aug 13, 2008
@@ -173,6 +175,25 @@
assertEquals(HTTPStatus.NOT_MODIFIED, response.getStatus());
}
+ public void testXSLTParamsPassing() throws Exception
+ {
+ String strToTest = "/absolute/path/to/file";
+ String folderName = TestUtils.getFolderName();
+ TestUtils.addFolder(session, folderName, defaultFolderNodeType, "");
+ ContainerResponse response = service(WebDAVMethods.GET, getPathWS() + folderName,
"", null, null);
+
+ assertEquals(HTTPStatus.OK, response.getStatus());
+
+ XSLTStreamingOutput XSLTout = (XSLTStreamingOutput)response.getEntity();
+ ByteArrayOutputStream BAOS = new ByteArrayOutputStream();
+ XSLTout.write(BAOS);
+
+ System.out.println("\n" + BAOS.toString() + "\n");
+
+ assertTrue(BAOS.toString().contains(strToTest));
+
+ }
+
@Override
protected String getRepositoryName()
{
Modified:
jcr/branches/1.12.x/exo.jcr.component.webdav/src/test/resources/conf/standalone/test-configuration.xml
===================================================================
---
jcr/branches/1.12.x/exo.jcr.component.webdav/src/test/resources/conf/standalone/test-configuration.xml 2010-11-17
14:18:55 UTC (rev 3472)
+++
jcr/branches/1.12.x/exo.jcr.component.webdav/src/test/resources/conf/standalone/test-configuration.xml 2010-11-17
14:24:34 UTC (rev 3473)
@@ -1,13 +1,24 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
- <!--
+<!--
+ Copyright (C) 2009 eXo Platform SAS.
- Copyright (C) 2009 eXo Platform SAS. This is free software; you can redistribute it
and/or modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version. This software 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 Lesser General Public License for more details. You should
have received a copy of the GNU Lesser General Public License along with
- this software; if not, write to the Free Software Foundation, Inc., 51 Franklin St,
Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF site:
-
http://www.fsf.org.
- -->
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+
+-->
+
<configuration
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd
http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
<component>
@@ -193,6 +204,11 @@
<value>text/xml,text/html:max-age=1800;text/*:max-age=777;image/png,image/jpg:max-age=3600;*/*:no-cache;image/*:max-age=555</value>
</value-param>
+ <value-param>
+ <name>folder-icon-path</name>
+ <value>/absolute/path/to/file</value>
+ </value-param>
+
</init-params>
</component>
Modified:
jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/protocols/webdav.xml
===================================================================
---
jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/protocols/webdav.xml 2010-11-17
14:18:55 UTC (rev 3472)
+++
jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/protocols/webdav.xml 2010-11-17
14:24:34 UTC (rev 3473)
@@ -142,6 +142,15 @@
<name>cache-control</name>
<value>text/xml,text/html:max-age=3600;image/png,image/jpg:max-age=1800;*/*:no-cache;</value>
</value-param>
+
+ <!--
+ This parameter determines the absolute path to the folder icon file, which is
shown
+ during WebDAV view of the contents
+ -->
+ <value-param>
+ <name>folder-icon-path</name>
+ <value>/absolute/path/to/file</value>
+ </value-param>
</init-params
</component></programlisting>