Author: ieb
Date: Fri Aug 12 11:57:45 2016
New Revision: 1756167
URL: http://svn.apache.org/viewvc?rev=1756167&view=rev
Log:
SLING-5948 Support Streaming - Implementation of StreamingUploadOperation to
work with proposal 2 implemented in previous commit (Interator<Part>)
Added:
sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/StreamedUploadOperation.java
(with props)
sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/helper/MockSlingHttpServlet3Request.java
(with props)
sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/helper/MockSlingHttpServlet3Response.java
(with props)
Modified:
sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/parameters/RequestPartsIterator.java
sling/trunk/bundles/servlets/post/pom.xml
sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/SlingPostServlet.java
sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/SlingPostServletTest.java
sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/helper/MediaRangeListTest.java
Modified:
sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/parameters/RequestPartsIterator.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/parameters/RequestPartsIterator.java?rev=1756167&r1=1756166&r2=1756167&view=diff
==============================================================================
---
sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/parameters/RequestPartsIterator.java
(original)
+++
sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/parameters/RequestPartsIterator.java
Fri Aug 12 11:57:45 2016
@@ -30,7 +30,11 @@ import javax.servlet.http.HttpServletReq
import javax.servlet.http.Part;
import java.io.IOException;
import java.io.InputStream;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
public class RequestPartsIterator implements Iterator<Part> {
private static final Logger LOG =
LoggerFactory.getLogger(RequestPartsIterator.class);
Modified: sling/trunk/bundles/servlets/post/pom.xml
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/pom.xml?rev=1756167&r1=1756166&r2=1756167&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/pom.xml (original)
+++ sling/trunk/bundles/servlets/post/pom.xml Fri Aug 12 11:57:45 2016
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.sling</groupId>
<artifactId>sling</artifactId>
- <version>26</version>
+ <version>27</version>
<relativePath />
</parent>
@@ -103,15 +103,15 @@
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
+ <artifactId>osgi.core</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
+ <artifactId>osgi.cmpn</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
+ <artifactId>javax.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>javax.jcr</groupId>
Modified:
sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/SlingPostServlet.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/SlingPostServlet.java?rev=1756167&r1=1756166&r2=1756167&view=diff
==============================================================================
---
sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/SlingPostServlet.java
(original)
+++
sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/SlingPostServlet.java
Fri Aug 12 11:57:45 2016
@@ -19,12 +19,7 @@ package org.apache.sling.servlets.post.i
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
+import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -62,15 +57,7 @@ import org.apache.sling.servlets.post.Ve
import org.apache.sling.servlets.post.impl.helper.DateParser;
import org.apache.sling.servlets.post.impl.helper.DefaultNodeNameGenerator;
import org.apache.sling.servlets.post.impl.helper.MediaRangeList;
-import org.apache.sling.servlets.post.impl.operations.CheckinOperation;
-import org.apache.sling.servlets.post.impl.operations.CheckoutOperation;
-import org.apache.sling.servlets.post.impl.operations.CopyOperation;
-import org.apache.sling.servlets.post.impl.operations.DeleteOperation;
-import org.apache.sling.servlets.post.impl.operations.ImportOperation;
-import org.apache.sling.servlets.post.impl.operations.ModifyOperation;
-import org.apache.sling.servlets.post.impl.operations.MoveOperation;
-import org.apache.sling.servlets.post.impl.operations.NopOperation;
-import org.apache.sling.servlets.post.impl.operations.RestoreOperation;
+import org.apache.sling.servlets.post.impl.operations.*;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceRegistration;
@@ -144,6 +131,8 @@ public class SlingPostServlet extends Sl
private final ModifyOperation modifyOperation = new ModifyOperation();
+ private final StreamedUploadOperation streamedUploadOperation = new
StreamedUploadOperation();
+
private ServiceRegistration[] internalOperations;
/** Map of post operations. */
@@ -227,7 +216,6 @@ public class SlingPostServlet extends Sl
* Redirects the HttpServletResponse, if redirectURL is not empty
* @param htmlResponse
* @param request
- * @param redirectURL The computed redirect URL
* @param response The HttpServletResponse to use for redirection
* @return Whether a redirect was requested
* @throws IOException
@@ -286,6 +274,9 @@ public class SlingPostServlet extends Sl
private PostOperation getSlingPostOperation(
final SlingHttpServletRequest request) {
+ if (streamedUploadOperation.isRequestStreamed(request)) {
+ return streamedUploadOperation;
+ }
final String operation =
request.getParameter(SlingPostConstants.RP_OPERATION);
if (operation == null || operation.length() == 0) {
// standard create/modify operation;
@@ -425,19 +416,20 @@ public class SlingPostServlet extends Sl
private ServiceRegistration registerOperation(final BundleContext context,
final String opCode, final PostOperation operation) {
- final Properties properties = new Properties();
+ final Hashtable<String, Object> properties = new Hashtable<String,
Object>();
properties.put(PostOperation.PROP_OPERATION_NAME, opCode);
properties.put(Constants.SERVICE_DESCRIPTION,
"Apache Sling POST Servlet Operation " + opCode);
properties.put(Constants.SERVICE_VENDOR,
context.getBundle().getHeaders().get(Constants.BUNDLE_VENDOR));
return context.registerService(PostOperation.SERVICE_NAME, operation,
- properties);
+ properties);
}
@Override
public void init() throws ServletException {
modifyOperation.setServletContext(getServletContext());
+ streamedUploadOperation.setServletContext(getServletContext());
}
@Modified
@@ -472,11 +464,13 @@ public class SlingPostServlet extends Sl
this.importOperation.setDefaultNodeNameGenerator(nodeNameGenerator);
this.modifyOperation.setIgnoredParameterNamePattern(paramMatchPattern);
this.importOperation.setIgnoredParameterNamePattern(paramMatchPattern);
+
}
@Override
public void destroy() {
modifyOperation.setServletContext(null);
+ streamedUploadOperation.setServletContext(null);
}
@Deactivate
Added:
sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/StreamedUploadOperation.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/StreamedUploadOperation.java?rev=1756167&view=auto
==============================================================================
---
sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/StreamedUploadOperation.java
(added)
+++
sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/StreamedUploadOperation.java
Fri Aug 12 11:57:45 2016
@@ -0,0 +1,204 @@
+/*
+ * 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.sling.servlets.post.impl.operations;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.jackrabbit.util.Text;
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.resource.ModifiableValueMap;
+import org.apache.sling.api.resource.PersistenceException;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceUtil;
+import org.apache.sling.servlets.post.AbstractPostOperation;
+import org.apache.sling.servlets.post.Modification;
+import org.apache.sling.servlets.post.PostResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jcr.RepositoryException; // required due to AbstractPostOperation
signature.
+import javax.servlet.ServletContext;
+import javax.servlet.http.Part;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Performs a streamed modification of the content.
+ * Each File body encountered will result in a session save operation, to
cause the underlying Resource implementation
+ * to stream content from the request to the target.
+ *
+ * This implements PostOperation but does not touch the normal Sling Request
processing which is not streamed.
+ *
+ * The map of available fields is built up as the request is streamed. It is
advisable to submit the request with all the form
+ * fields at the start of the request (normally based on DOM order) to ensure
they are available before the streamed bodies are processed.
+ *
+ * The implementation does not implement the full Sling protocol aiming to
keep it simple, and just deal with a streaming upload operation.
+ * The implementation binds to the Sling Resource API rather than JCR to keep
it independent of the type of persistence.
+ */
+public class StreamedUploadOperation extends AbstractPostOperation {
+ private static final Logger LOG =
LoggerFactory.getLogger(StreamedUploadOperation.class);
+ public static final String NT_FILE = "nt:file";
+ public static final String JCR_LASTMODIFIED = "jcr:lastModified";
+ public static final String JCR_MIMETYPE = "jcr:mimeType";
+ public static final String JCR_DATA = "jcr:data";
+ private static final String MT_APP_OCTET = "application/octet-stream";
+ private ServletContext servletContext;
+
+ public void setServletContext(final ServletContext servletContext) {
+ this.setServletContext(servletContext);
+ }
+
+
+ public boolean isRequestStreamed(SlingHttpServletRequest request) {
+ return request.getAttribute("request-parts-iterator") != null;
+ }
+
+ @Override
+ protected void doRun(SlingHttpServletRequest request, PostResponse
response, List<Modification> changes) throws RepositoryException {
+ try {
+ Iterator<Part> partsIterator = (Iterator<Part>)
request.getAttribute("request-parts-iterator");
+ Map<String, List<String>> formFields = new HashMap<String,
List<String>>();
+ boolean streamingBodies = false;
+ while (partsIterator.hasNext()) {
+ Part part = partsIterator.next();
+ String name = part.getName();
+
+ if (isFormField(part)) {
+ addField(formFields, name, part);
+ if (streamingBodies) {
+ LOG.warn("Form field {} was sent after the bodies
started to be streamed. " +
+ "Will not have been available to all streamed
bodies. " +
+ "It is recommended to send all form fields
before streamed bodies in the POST ", name);
+ }
+ } else {
+ streamingBodies = true;
+ // process the file body and commit.
+ writeContent(request.getResourceResolver(), part,
formFields, response, changes);
+
+ }
+ }
+ } catch ( final PersistenceException pe) {
+ if ( pe.getCause() instanceof RepositoryException ) {
+ throw (RepositoryException)pe.getCause();
+ }
+ throw new RepositoryException(pe);
+ }
+
+ }
+
+ private void addField(Map<String, List<String>> formFields, String name,
Part part) {
+ List<String> values = formFields.get(name);
+ if ( values == null ) {
+ values = new ArrayList<String>();
+ formFields.put(name, values);
+ }
+ try {
+ values.add(IOUtils.toString(part.getInputStream(),"UTF-8"));
+ } catch (IOException e) {
+ LOG.error("Failed to read form field "+name,e);
+ }
+ }
+
+
+ private void writeContent(final ResourceResolver resolver,
+ final Part part,
+ final Map<String, List<String>> formFields,
+ final PostResponse response,
+ final List<Modification> changes)
+ throws PersistenceException {
+
+ final String path = response.getPath();
+ final Resource parentResource = resolver.getResource(path);
+ if ( !resourceExists(parentResource)) {
+ throw new IllegalArgumentException("Parent resource must already
exist to be able to stream upload content. Please create first ");
+ }
+ final Map<String, Object> props = new HashMap<String, Object>();
+ props.put("sling:resourceType", NT_FILE);
+ // TODO: Should all the formFields be added to the prop map ?
+ props.put(JCR_LASTMODIFIED, Calendar.getInstance());
+ props.put(JCR_MIMETYPE, getContentType(part));
+ try {
+ props.put(JCR_DATA, part.getInputStream());
+ } catch (final IOException e) {
+ throw new PersistenceException("Error while retrieving inputstream
from request part.", e);
+ }
+
+ String name = getUploadName(part);
+ // get or create resource
+ Resource result = parentResource.getChild(name);
+ if ( result != null ) {
+ final ModifiableValueMap vm =
result.adaptTo(ModifiableValueMap.class);
+ if ( vm == null ) {
+ throw new PersistenceException("Resource at " +
parentResource.getPath() + '/' + name + " is not modifiable.");
+ }
+ vm.putAll(props);
+ } else {
+ result =
parentResource.getResourceResolver().create(parentResource, name, props);
+ }
+ for(final String key : props.keySet()) {
+ changes.add(Modification.onModified(result.getPath() + '/' + key));
+ }
+ }
+
+ private boolean isFormField(Part part) {
+ return (part.getSubmittedFileName() == null);
+ }
+
+ private String getUploadName(Part part) {
+ String name = part.getSubmittedFileName();
+ // strip of possible path (some browsers include the entire path)
+ name = name.substring(name.lastIndexOf('/') + 1);
+ name = name.substring(name.lastIndexOf('\\') + 1);
+ return Text.escapeIllegalJcrChars(name);
+ }
+
+ private boolean resourceExists(final Resource resource) {
+ return (resource != null &&
!ResourceUtil.isSyntheticResource(resource));
+ }
+
+
+
+ private String getContentType(final Part part) {
+ String contentType = part.getContentType();
+ if (contentType != null) {
+ int idx = contentType.indexOf(';');
+ if (idx > 0) {
+ contentType = contentType.substring(0, idx);
+ }
+ }
+ if (contentType == null || contentType.equals(MT_APP_OCTET)) {
+ // try to find a better content type
+ ServletContext ctx = this.servletContext;
+ if (ctx != null) {
+ contentType = ctx.getMimeType(part.getSubmittedFileName());
+ }
+ if (contentType == null || contentType.equals(MT_APP_OCTET)) {
+ contentType = MT_APP_OCTET;
+ }
+ }
+ return contentType;
+ }
+
+
+
+}
Propchange:
sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/StreamedUploadOperation.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/SlingPostServletTest.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/SlingPostServletTest.java?rev=1756167&r1=1756166&r2=1756167&view=diff
==============================================================================
---
sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/SlingPostServletTest.java
(original)
+++
sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/SlingPostServletTest.java
Fri Aug 12 11:57:45 2016
@@ -27,12 +27,13 @@ import junit.framework.TestCase;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.commons.testing.sling.MockSlingHttpServletRequest;
-import org.apache.sling.commons.testing.sling.MockSlingHttpServletResponse;
import org.apache.sling.servlets.post.HtmlResponse;
import org.apache.sling.servlets.post.JSONResponse;
import org.apache.sling.servlets.post.PostResponse;
import org.apache.sling.servlets.post.SlingPostConstants;
import org.apache.sling.servlets.post.impl.helper.MediaRangeList;
+import org.apache.sling.servlets.post.impl.helper.MockSlingHttpServlet3Request;
+import
org.apache.sling.servlets.post.impl.helper.MockSlingHttpServlet3Response;
public class SlingPostServletTest extends TestCase {
@@ -72,7 +73,7 @@ public class SlingPostServletTest extend
}
public void testGetJsonResponse() {
- MockSlingHttpServletRequest req = new
MockSlingHttpServletRequest(null, null, null, null, null) {
+ MockSlingHttpServletRequest req = new
MockSlingHttpServlet3Request(null, null, null, null, null) {
@Override
public String getHeader(String name) {
return name.equals(MediaRangeList.HEADER_ACCEPT) ?
"application/json" : super.getHeader(name);
@@ -114,7 +115,7 @@ public class SlingPostServletTest extend
/**
*
*/
- private final class RedirectServletRequest extends
MockSlingHttpServletRequest {
+ private final class RedirectServletRequest extends
MockSlingHttpServlet3Request {
private String requestPath;
private String redirect;
@@ -135,7 +136,7 @@ public class SlingPostServletTest extend
}
}
- private final class RedirectServletResponse extends
MockSlingHttpServletResponse {
+ private final class RedirectServletResponse extends
MockSlingHttpServlet3Response {
private String redirectLocation;
@@ -166,7 +167,7 @@ public class SlingPostServletTest extend
}
private static class StatusParamSlingHttpServletRequest extends
- MockSlingHttpServletRequest {
+ MockSlingHttpServlet3Request {
private String statusParam;
Modified:
sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/helper/MediaRangeListTest.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/helper/MediaRangeListTest.java?rev=1756167&r1=1756166&r2=1756167&view=diff
==============================================================================
---
sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/helper/MediaRangeListTest.java
(original)
+++
sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/helper/MediaRangeListTest.java
Fri Aug 12 11:57:45 2016
@@ -19,6 +19,8 @@ package org.apache.sling.servlets.post.i
import junit.framework.TestCase;
import org.apache.sling.commons.testing.sling.MockSlingHttpServletRequest;
+import java.util.Enumeration;
+
public class MediaRangeListTest extends TestCase {
protected MediaRangeList rangeList;
@@ -44,7 +46,7 @@ public class MediaRangeListTest extends
}
public void testHttpEquivParam() {
- MockSlingHttpServletRequest req = new
MockSlingHttpServletRequest(null, null, null, null, null) {
+ MockSlingHttpServletRequest req = new
MockSlingHttpServlet3Request(null, null, null, null, null) {
@Override
public String getHeader(String name) {
return name.equals(MediaRangeList.HEADER_ACCEPT) ?
"text/plain" : super.getHeader(name);
@@ -55,6 +57,11 @@ public class MediaRangeListTest extends
return name.equals(MediaRangeList.PARAM_ACCEPT) ? "text/html"
: super.getParameter(name);
}
+ @Override
+ public Enumeration<String> getHeaderNames() {
+ return null;
+ }
+
public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
return null;
}
@@ -69,7 +76,7 @@ public class MediaRangeListTest extends
//See acceptHeader at
http://hg.openjdk.java.net/jdk6/jdk6-gate/jdk/file/tip/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java
//To support such case the MediaRange parser has to be made bit linient
final String invalidHeader = "text/html, image/gif, image/jpeg, *;
q=.2, */*; q=.2";
- MockSlingHttpServletRequest req = new
MockSlingHttpServletRequest(null, null, null, null, null) {
+ MockSlingHttpServletRequest req = new
MockSlingHttpServlet3Request(null, null, null, null, null) {
@Override
public String getHeader(String name) {
return name.equals(MediaRangeList.HEADER_ACCEPT) ?
invalidHeader : super.getHeader(name);
Added:
sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/helper/MockSlingHttpServlet3Request.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/helper/MockSlingHttpServlet3Request.java?rev=1756167&view=auto
==============================================================================
---
sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/helper/MockSlingHttpServlet3Request.java
(added)
+++
sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/helper/MockSlingHttpServlet3Request.java
Fri Aug 12 11:57:45 2016
@@ -0,0 +1,148 @@
+/*
+ * 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.sling.servlets.post.impl.helper;
+
+import org.apache.sling.commons.testing.sling.MockSlingHttpServletRequest;
+
+import javax.servlet.*;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpUpgradeHandler;
+import javax.servlet.http.Part;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * When MockSlingHttpServletRequest supports Servlet 3 correctly, delete this
class.
+ */
+public class MockSlingHttpServlet3Request extends MockSlingHttpServletRequest {
+ public MockSlingHttpServlet3Request(String o, String o1, String o2, String
o3, String o4) {
+ super(o,o1,o2,o3,o4);
+ }
+
+ @Override
+ public Enumeration<Locale> getLocales() {
+ return (Enumeration<Locale>) super.getLocales();
+ }
+
+ @Override
+ public Enumeration<String> getHeaders(String name) {
+ return (Enumeration<String>) super.getHeaders(name);
+ }
+
+ @Override
+ public Enumeration<String> getHeaderNames() {
+ return (Enumeration<String>) super.getHeaderNames();
+ }
+
+ @Override
+ public Enumeration<String> getAttributeNames() {
+ return (Enumeration<String>) super.getAttributeNames();
+ }
+
+ @Override
+ public Map<String, String[]> getParameterMap() {
+ return ( Map<String, String[]> ) super.getParameterMap();
+ }
+
+ @Override
+ public Enumeration<String> getParameterNames() {
+ return (Enumeration<String>) super.getParameterNames();
+ }
+
+ @Override
+ public Enumeration<String> getResponseContentTypes() {
+ return (Enumeration<String>) super.getResponseContentTypes();
+ }
+
+ @Override
+ public String changeSessionId() {
+ return null;
+ }
+
+ @Override
+ public boolean authenticate(HttpServletResponse httpServletResponse)
throws IOException, ServletException {
+ return false;
+ }
+
+ @Override
+ public void login(String s, String s1) throws ServletException {
+
+ }
+
+ @Override
+ public void logout() throws ServletException {
+
+ }
+
+ @Override
+ public Collection<Part> getParts() throws IOException, ServletException {
+ return null;
+ }
+
+ @Override
+ public Part getPart(String s) throws IOException, ServletException {
+ return null;
+ }
+
+ @Override
+ public <T extends HttpUpgradeHandler> T upgrade(Class<T> aClass) throws
IOException, ServletException {
+ return null;
+ }
+
+ @Override
+ public long getContentLengthLong() {
+ return 0;
+ }
+
+ @Override
+ public ServletContext getServletContext() {
+ return null;
+ }
+
+ @Override
+ public AsyncContext startAsync() throws IllegalStateException {
+ return null;
+ }
+
+ @Override
+ public AsyncContext startAsync(ServletRequest servletRequest,
ServletResponse servletResponse) throws IllegalStateException {
+ return null;
+ }
+
+ @Override
+ public boolean isAsyncStarted() {
+ return false;
+ }
+
+ @Override
+ public boolean isAsyncSupported() {
+ return false;
+ }
+
+ @Override
+ public AsyncContext getAsyncContext() {
+ return null;
+ }
+
+ @Override
+ public DispatcherType getDispatcherType() {
+ return null;
+ }
+}
Propchange:
sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/helper/MockSlingHttpServlet3Request.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/helper/MockSlingHttpServlet3Response.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/helper/MockSlingHttpServlet3Response.java?rev=1756167&view=auto
==============================================================================
---
sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/helper/MockSlingHttpServlet3Response.java
(added)
+++
sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/helper/MockSlingHttpServlet3Response.java
Fri Aug 12 11:57:45 2016
@@ -0,0 +1,51 @@
+/*
+ * 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.sling.servlets.post.impl.helper;
+
+import org.apache.sling.commons.testing.sling.MockSlingHttpServletResponse;
+
+import java.util.Collection;
+
+/**
+ * When MockSlingHttpServletResponse supports Servlet 3 correctly, delete this
class.
+ */
+public class MockSlingHttpServlet3Response extends
MockSlingHttpServletResponse {
+ @Override
+ public int getStatus() {
+ return 0;
+ }
+
+ @Override
+ public String getHeader(String s) {
+ return null;
+ }
+
+ @Override
+ public Collection<String> getHeaders(String s) {
+ return null;
+ }
+
+ @Override
+ public Collection<String> getHeaderNames() {
+ return null;
+ }
+
+ @Override
+ public void setContentLengthLong(long l) {
+
+ }
+}
Propchange:
sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/helper/MockSlingHttpServlet3Response.java
------------------------------------------------------------------------------
svn:eol-style = native