Bug 401784 - Support jetty 9
 - updates to help to support servlet 3.1

Change-Id: I6a2f395c43a2e47eaf785e4f198835fd2c78706a
Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/ValidatorServlet.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/ValidatorServlet.java
index 30be71f..90699e3 100644
--- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/ValidatorServlet.java
+++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/ValidatorServlet.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
+ * Copyright (c) 2011, 2014 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -11,7 +11,6 @@
 package org.eclipse.help.internal.webapp.servlet;
 
 import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -145,7 +144,6 @@
 	
 	public boolean isSecure(HttpServletRequest req,HttpServletResponseAdv resp) 
 			throws SecurityException {
-		
 		Enumeration names = req.getParameterNames();
 		List values = new ArrayList();
 		List scripts = new ArrayList();
@@ -160,7 +158,6 @@
 		}
 		
 		if (resp.getWriter() != null) {
-			
 			String data = resp.getString();
 			for (int s=0; s < scripts.size(); s++)
 				if (data.indexOf((String)scripts.get(s)) > -1)
@@ -193,13 +190,11 @@
 	private class HttpServletResponseAdv extends HttpServletResponseWrapper {
 		
 		private HttpServletResponse response;
-		private ByteArrayOutputStream out;
 		private ServletPrintWriter writer;
-		private SecureServletOutputStream stream;
+		private ServletOutputStream stream;
 		
 		public HttpServletResponseAdv(HttpServletResponse response) {
 			super(response);
-			out = new ByteArrayOutputStream();
 			this.response = response;
 		}
 
@@ -210,10 +205,10 @@
 			return writer;
 		}
 		
-		public ServletOutputStream getOutputStream() {
+		public ServletOutputStream getOutputStream() throws IOException {
 			
 			if (stream == null && writer == null)
-				stream = new SecureServletOutputStream(out);
+				stream = response.getOutputStream();
 			return stream;
 		}
 		
@@ -221,23 +216,13 @@
 			
 			OutputStream os = response.getOutputStream();
 			InputStream is = getInputStream();
-			
-			Utils.transferContent(is, os);
-			
+			if (is != null) {
+				Utils.transferContent(is, os);
+			}
 			os.flush();
 		}
 		
 		public InputStream getInputStream() {
-			
-			if (stream != null) {
-			
-				try {
-					out.flush();
-				} catch (IOException e) {
-					e.printStackTrace();
-				}
-				return new ByteArrayInputStream(out.toByteArray());
-			}
 			if (writer != null) {
 				
 				try {
@@ -257,18 +242,4 @@
 			return null;
 		}
 	}
-	
-	
-	private class SecureServletOutputStream extends ServletOutputStream {
-
-		private OutputStream out;
-
-		public SecureServletOutputStream(OutputStream out) {
-			this.out = out;
-		}
-		
-		public void write(int b) throws IOException {
-			out.write(b);
-		}
-	}
 }
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/MockServletRequest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/MockServletRequest.java
index 1aea35a..1d8aa67 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/MockServletRequest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/MockServletRequest.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2008, 2014 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -33,6 +33,7 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpUpgradeHandler;
 import javax.servlet.http.Part;
 
 /**
@@ -390,4 +391,19 @@
 		return null;
 	}
 
+	public long getContentLengthLong() {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	public String changeSessionId() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public <T extends HttpUpgradeHandler> T upgrade(Class<T> handlerClass) throws IOException, ServletException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
 }
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/MockServletResponse.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/MockServletResponse.java
index a31274c..9bddaf8 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/MockServletResponse.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/MockServletResponse.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2008, 2014 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -222,6 +222,11 @@
 		// TODO Auto-generated method stub
 		return null;
 	}
+
+	public void setContentLengthLong(long len) {
+		// TODO Auto-generated method stub
+		
+	}
 	
 	
 }