[exo-jcr-commits] exo-jcr SVN: r3472 - ws/branches/2.1.x/exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/provider.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Nov 17 09:18:55 EST 2010


Author: dkuleshov
Date: 2010-11-17 09:18:55 -0500 (Wed, 17 Nov 2010)
New Revision: 3472

Modified:
   ws/branches/2.1.x/exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/provider/XSLTStreamingOutput.java
Log:
JCR-151: added XSLTStreamingOutput constructor to pass an XSLT parameters Map

Modified: ws/branches/2.1.x/exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/provider/XSLTStreamingOutput.java
===================================================================
--- ws/branches/2.1.x/exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/provider/XSLTStreamingOutput.java	2010-11-17 13:40:14 UTC (rev 3471)
+++ ws/branches/2.1.x/exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/provider/XSLTStreamingOutput.java	2010-11-17 14:18:55 UTC (rev 3472)
@@ -28,6 +28,7 @@
 
 import java.io.IOException;
 import java.io.OutputStream;
+import java.util.Map;
 
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.StreamingOutput;
@@ -51,6 +52,8 @@
 
    private Source source;
 
+   private Map<String, String> xsltParams;
+
    /**
     * XSLTStreamingOutput constructor.
     * 
@@ -68,6 +71,21 @@
    }
 
    /**
+    * XSLTStreamingOutput constructor.
+    * 
+    * @param schemeName XLST scheme name. Must be registered in
+    *          {@link org.exoplatform.services.xml.transform.impl.trax.TRAXTemplatesLoaderPlugin
+    *          TRAXTemplatesLoaderPlugin }
+    * @param source entity to write into output stream.
+    * @param xsltParams XSLT parameters
+    */
+   public XSLTStreamingOutput(String schemeName, Source source, Map<String, String> xsltParams)
+   {
+      this(schemeName, source);
+      this.xsltParams = xsltParams;
+   }
+
+   /**
     * {@inheritDoc} .
     */
    public void write(OutputStream outStream) throws IOException, WebApplicationException
@@ -97,6 +115,13 @@
             throw new NullPointerException(msg);
          }
          transformer.initResult(new StreamResult(outStream));
+         if (xsltParams != null)
+         {
+            for (Map.Entry<String, String> e : xsltParams.entrySet())
+            {
+               transformer.setParameter(e.getKey(), e.getValue());
+            }
+         }
          transformer.transform(source);
       }
       catch (TransformerConfigurationException tce)



More information about the exo-jcr-commits mailing list