anchor.diff:  </textarea><br>
   Or upload a file in format of graphml or gzipped graphml<br>
   <input type="file" name="graphml"/><br>
  +<select name="format">
  +  <option value="graphml">GraphML</option>
  +  <option value="graphml.gz.base64">GraphML.GZ.Base64</option>
  +  <option value="graphml.gz">GraphML.GZ (only for uploaded file)</option>
  +</select>
   <input type="submit" name="submit" value="Submit" />
   </form>
   </div>
  
positive.code: <%@ page import="java.io.BufferedReader" %>
  <%@ page import="java.io.InputStreamReader" %>
  <%@ page import="java.util.zip.GZIPInputStream" %>
  <%@ page import="org.mskcc.portal.util.SkinUtil" %>
  <%@ page import="org.mskcc.portal.util.FileUploadRequestWrapper" %>
  <%@ page import="org.apache.commons.lang.StringEscapeUtils" %>
  <%@ page import="org.apache.commons.fileupload.FileItem" %>
  <html>
  <body>
  
  
negative.code: 		</td>
  	</tr>
  </table>
  <script type="text/javascript">
      //alert('< %=org.mskcc.portal.util.ResponseUtil.getResponseString(request.getInputStream())%>');
  </script>
                          
  <%
  String format = request.getParameter("format");
  String graphml = null;
  
  if (format!=null) {
      graphml = request.getParameter("graphml");
      if (graphml!=null&&!graphml.isEmpty()) {
          if (!format.equalsIgnoreCase("graphml")) {
              try {
                  byte[] bytes = null;
                  if (format.equalsIgnoreCase("graphml.gz")) {
                      bytes = graphml.getBytes();
                  } else if (format.equalsIgnoreCase("graphml.gz.base64")) {
                      bytes = Base64.decodeBase64(graphml.getBytes());
                  }
  
                  if (bytes!=null) {
                      BufferedReader bufferedReader = new BufferedReader(
                              new InputStreamReader(new GZIPInputStream(
                                  new ByteArrayInputStream(bytes))));
                      StringBuilder builder = new StringBuilder();
                      for (String line=bufferedReader.readLine(); line!=null;
                              line=bufferedReader.readLine()) {
                          builder.append(line);
                      }
                      graphml = builder.toString();
                  }
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
      } else if (request instanceof FileUploadRequestWrapper) {
          // if graphml is not posted, look for uploaded file
          FileUploadRequestWrapper fileUploadRequestWrapper = (FileUploadRequestWrapper)request;
          FileItem fileItem = fileUploadRequestWrapper.getFileItem("graphml");
          if (fileItem!=null) {
              if (format.equalsIgnoreCase("graphml")) {
                  graphml = fileItem.getString();
              } else {
                  try {
                      InputStream is = null;
                      if (format.equalsIgnoreCase("graphml.gz")) {
                          is = fileItem.getInputStream();
                      } else if (format.equalsIgnoreCase("graphml.gz.base64")) {
                          is = new ByteArrayInputStream(Base64.decodeBase64(fileItem.getString().getBytes()));
                      }
  
                      if (is!=null) {
                          BufferedReader bufferedReader = new BufferedReader(
                                  new InputStreamReader(new GZIPInputStream(is)));
                          StringBuilder builder = new StringBuilder();
                          for (String line=bufferedReader.readLine(); line!=null;
                                  line=bufferedReader.readLine()) {
                              builder.append(line);
                          }
                          graphml = builder.toString();
                      }
                  } catch (Exception e) {
                      e.printStackTrace();
                  }
              }
          }
      }
  }
  