Author: fmui
Date: Sat Oct 31 12:25:55 2015
New Revision: 1711618

URL: http://svn.apache.org/viewvc?rev=1711618&view=rev
Log:
added RequestAwareTempStoreOutputStream

Added:
    
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/RequestAwareTempStoreOutputStream.java
Modified:
    
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/server/CmisServiceFactory.java
    
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java
    
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java
    
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java
    
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/TempStoreOutputStreamFactory.java

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/server/CmisServiceFactory.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/server/CmisServiceFactory.java?rev=1711618&r1=1711617&r2=1711618&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/server/CmisServiceFactory.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/server/CmisServiceFactory.java
 Sat Oct 31 12:25:55 2015
@@ -90,8 +90,8 @@ public interface CmisServiceFactory {
     long getMaxContentSize();
 
     /**
-     * Returns a {@link TempStoreOutputStream} object for the given
-     * {@link CallContext}.
+     * Returns a {@link TempStoreOutputStream} object for the given repository
+     * ID.
      * 
      * This method is only called for the AtomPub and the Browser binding
      * requests. The Web Services binding always used temporary files (see

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java?rev=1711618&r1=1711617&r2=1711618&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java
 Sat Oct 31 12:25:55 2015
@@ -180,7 +180,7 @@ public class CmisAtomPubServlet extends
 
             // create stream factory
             TempStoreOutputStreamFactory streamFactoy = 
TempStoreOutputStreamFactory.newInstance(getServiceFactory(),
-                    pathFragments.length > 0 ? pathFragments[0] : null);
+                    pathFragments.length > 0 ? pathFragments[0] : null, 
request);
 
             // treat HEAD requests
             if (METHOD_HEAD.equals(request.getMethod())) {

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java?rev=1711618&r1=1711617&r2=1711618&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java
 Sat Oct 31 12:25:55 2015
@@ -230,7 +230,7 @@ public class CmisBrowserBindingServlet e
 
             // create stream factory
             TempStoreOutputStreamFactory streamFactoy = 
TempStoreOutputStreamFactory.newInstance(getServiceFactory(),
-                    pathFragments.length > 0 ? pathFragments[0] : null);
+                    pathFragments.length > 0 ? pathFragments[0] : null, 
request);
 
             // check HTTP method
             if (METHOD_GET.equals(method)) {

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java?rev=1711618&r1=1711617&r2=1711618&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java
 Sat Oct 31 12:25:55 2015
@@ -109,7 +109,8 @@ public abstract class AbstractService {
             throw new CmisRuntimeException("Server configuration issue. CMIS 
version not set!");
         }
 
-        TempStoreOutputStreamFactory streamFactoy = 
TempStoreOutputStreamFactory.newInstance(factory, repositoryId);
+        TempStoreOutputStreamFactory streamFactoy = 
TempStoreOutputStreamFactory.newInstance(factory, repositoryId,
+                request);
         CallContextImpl context = new 
CallContextImpl(CallContext.BINDING_WEBSERVICES, cmisVersion, repositoryId,
                 servletContext, request, response, factory, streamFactoy);
 

Added: 
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/RequestAwareTempStoreOutputStream.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/RequestAwareTempStoreOutputStream.java?rev=1711618&view=auto
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/RequestAwareTempStoreOutputStream.java
 (added)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/RequestAwareTempStoreOutputStream.java
 Sat Oct 31 12:25:55 2015
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.chemistry.opencmis.server.shared;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.chemistry.opencmis.commons.server.TempStoreOutputStream;
+
+/**
+ * A {@link TempStoreOutputStream} that knows about the HTTP request
+ */
+public abstract class RequestAwareTempStoreOutputStream extends 
TempStoreOutputStream {
+
+    /**
+     * Sets the HTTP request object.
+     * 
+     * This method is usually be called right after creation of this object. It
+     * might never be called if the HTTP request object is unknown or this
+     * object is not used in the context of a HTTP request.
+     * 
+     * @param request
+     *            the HTTP request object or {@code null} if the HTTP request
+     *            object is unknown or this object is not used in the context 
of
+     *            a HTTP request
+     */
+    public abstract void setHttpServletRequest(HttpServletRequest request);
+}

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/TempStoreOutputStreamFactory.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/TempStoreOutputStreamFactory.java?rev=1711618&r1=1711617&r2=1711618&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/TempStoreOutputStreamFactory.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/TempStoreOutputStreamFactory.java
 Sat Oct 31 12:25:55 2015
@@ -20,6 +20,8 @@ package org.apache.chemistry.opencmis.se
 
 import java.io.File;
 
+import javax.servlet.http.HttpServletRequest;
+
 import org.apache.chemistry.opencmis.commons.server.CmisServiceFactory;
 import org.apache.chemistry.opencmis.commons.server.TempStoreOutputStream;
 
@@ -30,19 +32,21 @@ public class TempStoreOutputStreamFactor
 
     private CmisServiceFactory factory;
     private String repositoryId;
+    private HttpServletRequest request;
 
     private File tempDir;
     private int memoryThreshold;
     private long maxContentSize;
     private boolean encrypt;
 
-    protected TempStoreOutputStreamFactory(CmisServiceFactory factory, String 
repositoryId) {
+    protected TempStoreOutputStreamFactory(CmisServiceFactory factory, String 
repositoryId, HttpServletRequest request) {
         this.factory = factory;
         this.repositoryId = repositoryId;
         this.tempDir = factory.getTempDirectory();
         this.memoryThreshold = factory.getMemoryThreshold();
         this.maxContentSize = factory.getMaxContentSize();
         this.encrypt = factory.encryptTempFiles();
+        this.request = request;
     }
 
     protected TempStoreOutputStreamFactory(File tempDir, int memoryThreshold, 
long maxContentSize, boolean encrypt) {
@@ -62,9 +66,13 @@ public class TempStoreOutputStreamFactor
      *            the CmisService object factory
      * @param repositoryId
      *            the repository ID
+     * @param request
+     *            the HTTP request object or {@code null} if such an object is
+     *            not available
      */
-    public static TempStoreOutputStreamFactory newInstance(CmisServiceFactory 
factory, String repositoryId) {
-        return new TempStoreOutputStreamFactory(factory, repositoryId);
+    public static TempStoreOutputStreamFactory newInstance(CmisServiceFactory 
factory, String repositoryId,
+            HttpServletRequest request) {
+        return new TempStoreOutputStreamFactory(factory, repositoryId, 
request);
     }
 
     /**
@@ -97,6 +105,8 @@ public class TempStoreOutputStreamFactor
 
         if (stream == null) {
             stream = new ThresholdOutputStream(tempDir, memoryThreshold, 
maxContentSize, encrypt);
+        } else if (stream instanceof RequestAwareTempStoreOutputStream) {
+            ((RequestAwareTempStoreOutputStream) 
stream).setHttpServletRequest(request);
         }
 
         return stream;


Reply via email to