[MOBY-guts] biomoby commit

Eddie Kawas kawas at dev.open-bio.org
Tue Oct 17 14:11:42 UTC 2006


kawas
Tue Oct 17 10:11:42 EDT 2006
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms
In directory dev.open-bio.org:/tmp/cvs-serv20120/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms

Modified Files:
	Lsid_resolver.java LSID_ResolverClient.java 
Log Message:
embedded the stylesheet in the html, instead of using a link
moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms Lsid_resolver.java,1.4,1.5 LSID_ResolverClient.java,1.2,1.3
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/Lsid_resolver.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/Lsid_resolver.java	2006/10/11 01:54:50	1.4
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/Lsid_resolver.java	2006/10/17 14:11:42	1.5
@@ -31,8 +31,8 @@
  *         <p>
  *         Created for the BioMoby Project.
  *         <p>
- *         This class was created to replace the perl LSID client resolver.
- *         This servlet will resolve LSIDs to metadata. In the future, I plan on
+ *         This class was created to replace the perl LSID client resolver. This
+ *         servlet will resolve LSIDs to metadata. In the future, I plan on
  *         adding the ability to resolve LSIDs to Data.
  *         <p>
  *         For questions, comments, or bugs
@@ -41,7 +41,8 @@
  */
 public class Lsid_resolver extends HttpServlet {
 
-	 private Log log = LogFactory.getLog(this.getClass());
+	private Log log = LogFactory.getLog(this.getClass());
+
 	/**
 	 * 
 	 */
@@ -56,8 +57,8 @@
 	 * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest,
 	 *      javax.servlet.http.HttpServletResponse)
 	 */
-	protected void doGet(HttpServletRequest request,
-			HttpServletResponse response) throws ServletException, IOException {
+	protected void doGet(HttpServletRequest request, HttpServletResponse response)
+			throws ServletException, IOException {
 		// set the content type
 		response.setContentType("text/html");
 		PrintWriter out = response.getWriter();
@@ -67,17 +68,167 @@
 			return;
 		}
 		lsid = lsid.trim();
-		String pre = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" + 
-				"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" + 
-				"<head>\n" + 
-				"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />\n" + 
-				"<title>BioMOBY LSID Metadata Resolver</title>\n" + 
-				"</head>\n" + 
-				"\n" + 
-				"<body>\n <strong>"+ lsid + "</strong><p><pre>";
+		String pre = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"
+				+ "<html xmlns=\"http://www.w3.org/1999/xhtml\">"
+				+ "<head>"
+				+ "<style type=\"text/css\">"
+				+ "body { background: #ffffcd;"
+				+ "       color: #000000;"
+				+ "       font-family: Arial, Helvetica, sans-serif;"
+				+ "       font-size: 12pt;"
+				+ "       font-weight: normal;"
+				+ "       margin-top: 10px;"
+				+ "       margin-right: 1em;"
+				+ "       margin-bottom: 1em;"
+				+ "       margin-left: 1em;"
+				+ "       background-position: left top;"
+				+ "       background-repeat: no-repeat;"
+				+ "       scrollbar-track-color: #ffffff;  scrollbar-arrow-color: #336666;  scrollbar-darkshadow-color: #ffffff;"
+				+ "     }"
+				+ ""
+				+ ".indent {"
+				+ "     margin-left: 5em;"
+				+ "   }"
+				+ ""
+				+ "td.text { background: #ffffcd;"
+				+ "       color: #000000;"
+				+ "       font-family: Arial, Helvetica, sans-serif;"
+				+ "       font-size: 12pt;"
+				+ "       font-weight: normal;"
+				+ "       margin-top: 110px;"
+				+ "       margin-right: 1em;"
+				+ "       margin-bottom: 1em;"
+				+ "       margin-left: 1em;"
+				+ "     }"
+				+ ""
+				+ "h1 { border: solid; "
+				+ "     text-align:center;"
+				+ "     background-color:yellow;"
+				+ "     color: navy;"
+				+ "   }"
+				+ "h2 { border: ridge;"
+				+ "     padding: 5px;"
+				+ "     background-color:yellow;"
+				+ "     color: navy;"
+				+ "   }"
+				+ "h3 { border: none;"
+				+ "     padding: 5px;"
+				+ "     background-color:yellow;"
+				+ "     color: navy;"
+				+ "   }"
+				+ ""
+				+ ".subtitle { border: none;"
+				+ "     padding: 5px;"
+				+ "     background-color:yellow;"
+				+ "     color: navy;"
+				+ "   }"
+				+ ""
+				+ "a:link    { color: #0000ff; font-family: Arial, Helvetica, sans-serif; font-weight: normal; text-decoration: underline}"
+				+ "a:visited { color: #0099ff; font-family: Arial, Helvetica, sans-serif; font-weight: normal; text-decoration: underline}"
+				+ "a:active  { color: #0000ff; font-family: Arial, Helvetica, sans-serif; font-weight: normal; text-decoration: underline}"
+				+ "a:hover   { color: #336666; font-family: Arial, Helvetica, sans-serif; font-weight: normal; text-decoration: underline}"
+				+ ""
+				+ "li { list-style-type: square;"
+				+ "     margin: 1em;"
+				+ "   }"
+				+ "li.tiny { list-style-type: square;"
+				+ "          margin: 0;"
+				+ "          list-style-image: none;"
+				+ "        }"
+				+ "li.count { list-style-type: upper-roman;"
+				+ "           list-style-image: none;"
+				+ "           margin: 0;"
+				+ "         }"
+				+ "li.dcount { list-style-type: decimal;"
+				+ "           list-style-image: none;"
+				+ "           margin: 0;"
+				+ "         }"
+				+ ""
+				+ "dd { margin-bottom: 0.5em }"
+				+ ""
+				+ ".address { font-size: 5pt; margin-right:1em }"
+				+ ".smaller { font-size: 8pt }"
+				+ ""
+				+ ".note { font-style: italic;"
+				+ "	padding-left: 5em;"
+				+ "        margin: 1em;"
+				+ "      }"
+				+ ""
+				+ ".update {"
+				+ "        background-color:#ccffcd;"
+				+ "      }"
+				+ ""
+				+ "pre.code { border: ridge;"
+				+ "     padding: 5px;"
+				+ "     background-color:#FFFF99;"
+				+ "     color: navy;"
+				+ "   }"
+				+ ""
+				+ "pre.script {"
+				+ "     padding: 5px;"
+				+ "     background-color: white;"
+				+ "     color: navy;"
+				+ "   }"
+				+ ""
+				+ "pre.script2 {"
+				+ "     padding: 5px;"
+				+ "     background-color: white;"
+				+ "     color: navy;"
+				+ "     margin-left: 5em;"
+				+ "   }"
+				+ ""
+				+ ""
+				+ "pre.sscript {"
+				+ "     padding: 5px;"
+				+ "     background-color: white;"
+				+ "     color: navy;"
+				+ "     font-size: 8pt;"
+				+ "   }"
+				+ "pre.ssscript {"
+				+ "     padding: 5px;"
+				+ "     background-color: white;"
+				+ "     color: navy;"
+				+ "     font-size: 6pt;"
+				+ "   }"
+				+ ""
+				+ "tr.options {"
+				+ "     background-color: #FFFF99;"
+				+ "     color: navy;"
+				+ "   }"
+				+ ""
+				+ "b.step {"
+				+ "     background-color: white;"
+				+ "     color: navy;     "
+				+ "     font-size: 8pt;"
+				+ "   }"
+				+ ".motto {"
+				+ "     text-align: right;"
+				+ "     font-style: italic;"
+				+ "     font-size: 10pt;"
+				+ "   }"
+				+ ".motto-signature {"
+				+ "     text-align: right;"
+				+ "     font-style: normal;"
+				+ "     font-size: 8pt;"
+				+ "   }"
+				+ ""
+				+ ".sb {"
+				+ "     font-weight: bold;"
+				+ "     font-size: 8pt;"
+				+ "}"
+				+ ".sbred {"
+				+ "     font-weight: bold;"
+				+ "     font-size: 8pt;"
+				+ "     color: red;"
+				+ "}"
+				+ " </style>"
+				+ "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />"
+				+ "<title>BioMOBY LSID Metadata Resolver</title>"
+				+ "</head>"
+				+ ""
+				+ "<body><p> <strong>" + lsid + "</strong><pre>";
 
-				String post = "</pre></body>\n" + 
-				"</html>";
+		String post = "</pre></div></body>" + "</html>";
 		String page = filter(getMetaData(lsid));
 		out.println(pre + page + post);
 		return;
@@ -88,7 +239,7 @@
 	 * lsid.
 	 */
 	public String getMetaData(String lsid_to_use) {
-        
+
 		try {
 			String str = resolveLSID(lsid_to_use, "soap");
 			return str;
@@ -114,67 +265,72 @@
 	 * @param lsid_to_use
 	 * @return
 	 */
-	private String resolveLSID(String lsid_to_use, String proto) throws MobyException{
+	private String resolveLSID(String lsid_to_use, String proto) throws MobyException {
 		try {
 
-    		LSID lsid = new LSID(lsid_to_use);
-    		// TODO strip out the revision for now
-    		log.info(lsid_to_use);
-            LSIDResolver resolver = new LSIDResolver(lsid);
-            resolver.setUseLocalCache(false);
-            String output = "";
-            LSIDWSDLWrapper wrapper = resolver.getWSDLWrapper();
-            // get metadata
-            LSIDMetadataPort port = wrapper
-                    .getMetadataPortForProtocol(proto);
-            
-            MetadataResponse resp = resolver.getMetadata(port);
-            InputStream in = resp.getMetadata();
-            byte[] bytes = new byte[1024];
-            int numbytes = in.read(bytes);
-            int totalmeta = 0;
-            while (numbytes != -1) {
-                output += new String(bytes,0,numbytes);
-                totalmeta += numbytes;
-                numbytes = in.read(bytes);
-            }
-            output += "\n";
-            output += "metadata bytes read: " + totalmeta + "\n";
-            output += "metadata expires: " + resp.getExpires() + "\n";
-            output += "metadata format: " + resp.getFormat() + "\n";
-            in.close();
-            return output;
-        }  catch (LSIDServerException e) {
-            return ("No metadata associated with your LSID.\n" + e.getLocalizedMessage());
-        } catch (IOException e) {
-        	throw new MobyException("Problem retrieving Metadata. Please try again later.\n" + e.getLocalizedMessage());
+			LSID lsid = new LSID(lsid_to_use);
+			// TODO strip out the revision for now
+			log.info(lsid_to_use);
+			LSIDResolver resolver = new LSIDResolver(lsid);
+			resolver.setUseLocalCache(false);
+			String output = "";
+			LSIDWSDLWrapper wrapper = resolver.getWSDLWrapper();
+			// get metadata
+			LSIDMetadataPort port = wrapper.getMetadataPortForProtocol(proto);
+
+			MetadataResponse resp = resolver.getMetadata(port);
+			InputStream in = resp.getMetadata();
+			byte[] bytes = new byte[1024];
+			int numbytes = in.read(bytes);
+			int totalmeta = 0;
+			while (numbytes != -1) {
+				output += new String(bytes, 0, numbytes);
+				totalmeta += numbytes;
+				numbytes = in.read(bytes);
+			}
+			output += newline;
+			output += "metadata bytes read: " + totalmeta + newline;
+			output += "metadata expires: " + resp.getExpires() + newline;
+			output += "metadata format: " + resp.getFormat() + newline;
+			in.close();
+			return output;
+		} catch (LSIDServerException e) {
+			return ("No metadata associated with your LSID." + newline + e.getLocalizedMessage());
+		} catch (IOException e) {
+			throw new MobyException("Problem retrieving Metadata. Please try again later."
+					+ newline + e.getLocalizedMessage());
 		} catch (MalformedLSIDException e) {
-			return ("Malformed LSID. Please enter a valid LSID.\n" + e.getLocalizedMessage());
+			return ("Malformed LSID. Please enter a valid LSID." + newline + e
+					.getLocalizedMessage());
 		} catch (LSIDException e) {
-			throw new MobyException ("Couldn't create a resolver for the given LSID. Please try again later.\n" + e.getLocalizedMessage());
+			throw new MobyException(
+					"Couldn't create a resolver for the given LSID. Please try again later."
+							+ newline + e.getLocalizedMessage());
 		}
 	}
-    private static String filter(String input) {
-        if (input == null)
-            return null;
-        StringBuffer filtered = new StringBuffer(input.length());
-        char c;
-        for (int i = 0; i < input.length(); i++) {
-            c = input.charAt(i);
-            if (c == '<') {
-                filtered.append("&lt;");
-            } else if (c == '>') {
-                filtered.append("&gt;");
-            } else if (c == '"') {
-                filtered.append("&quot;");
-            } else if (c == '&') {
-                filtered.append("&amp;");
-            } else {
-                filtered.append(c);
-            }
-        }
-        return (filtered.toString());
-    }
+
+	private static String filter(String input) {
+		if (input == null)
+			return null;
+		StringBuffer filtered = new StringBuffer(input.length());
+		char c;
+		for (int i = 0; i < input.length(); i++) {
+			c = input.charAt(i);
+			if (c == '<') {
+				filtered.append("&lt;");
+			} else if (c == '>') {
+				filtered.append("&gt;");
+			} else if (c == '"') {
+				filtered.append("&quot;");
+			} else if (c == '&') {
+				filtered.append("&amp;");
+			} else {
+				filtered.append(c);
+			}
+		}
+		return (filtered.toString());
+	}
+
 	/*
 	 * (non-Javadoc)
 	 * 
@@ -185,8 +341,9 @@
 			throws ServletException, IOException {
 		doGet(arg0, arg1);
 	}
-	
+
 	public static void main(String[] args) {
-		System.out.println(new Lsid_resolver().getMetaData("urn:lsid:biomoby.org:serviceinstance:bioinfo.icapture.ubc.ca,getSHound3DNeighboursFromGi"));
+		System.out.println(new Lsid_resolver()
+				.getMetaData("urn:lsid:biomoby.org:objectclass:DNASequence:2001-09-21T16-00-00Z"));
 	}
 }

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/LSID_ResolverClient.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/LSID_ResolverClient.java	2006/10/11 01:54:50	1.2
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/LSID_ResolverClient.java	2006/10/17 14:11:42	1.3
@@ -32,8 +32,8 @@
  *         <p>
  *         Created for the BioMoby Project.
  *         <p>
- *         This class was created to replace the perl LSID client resolver.
- *         This servlet will resolve LSIDs to metadata. In the future, I plan on
+ *         This class was created to replace the perl LSID client resolver. This
+ *         servlet will resolve LSIDs to metadata. In the future, I plan on
  *         adding the ability to resolve LSIDs to Data.
  *         <p>
  *         For questions, comments, or bugs
@@ -42,7 +42,8 @@
  */
 public class LSID_ResolverClient extends HttpServlet {
 
-	 private Log log = LogFactory.getLog(this.getClass());
+	private Log log = LogFactory.getLog(this.getClass());
+
 	/**
 	 * 
 	 */
@@ -57,8 +58,8 @@
 	 * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest,
 	 *      javax.servlet.http.HttpServletResponse)
 	 */
-	protected void doGet(HttpServletRequest request,
-			HttpServletResponse response) throws ServletException, IOException {
+	protected void doGet(HttpServletRequest request, HttpServletResponse response)
+			throws ServletException, IOException {
 		// set the content type
 		response.setContentType("text/html");
 		PrintWriter out = response.getWriter();
@@ -68,31 +69,181 @@
 			return;
 		}
 		boolean getData = false;
-		
+
 		try {
 			getData = Boolean.valueOf(filter(request.getParameter("data"))).booleanValue();
 		} catch (Exception e) {
-			
+
 		}
-		
+
 		lsid = lsid.trim();
-		String pre = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" + 
-				"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" + 
-				"<head>\n" + 
-				"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />\n" + 
-				"<title>BioMOBY LSID Client Resolver</title>\n" + 
-				"</head>\n" + 
-				"\n" + 
-				"<body>\n <strong>"+ lsid + "</strong><p><pre>";
-
-				String post = "</pre></body>\n" + 
-				"</html>";
-		String page = "" ;
-		
+		String pre = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"
+				+ "<html xmlns=\"http://www.w3.org/1999/xhtml\">"
+				+ "<head>"
+				+ "<style type=\"text/css\">"
+				+ "body { background: #ffffcd;"
+				+ "       color: #000000;"
+				+ "       font-family: Arial, Helvetica, sans-serif;"
+				+ "       font-size: 12pt;"
+				+ "       font-weight: normal;"
+				+ "       margin-top: 10px;"
+				+ "       margin-right: 1em;"
+				+ "       margin-bottom: 1em;"
+				+ "       margin-left: 1em;"
+				+ "       background-position: left top;"
+				+ "       background-repeat: no-repeat;"
+				+ "       scrollbar-track-color: #ffffff;  scrollbar-arrow-color: #336666;  scrollbar-darkshadow-color: #ffffff;"
+				+ "     }"
+				+ ""
+				+ ".indent {"
+				+ "     margin-left: 5em;"
+				+ "   }"
+				+ ""
+				+ "td.text { background: #ffffcd;"
+				+ "       color: #000000;"
+				+ "       font-family: Arial, Helvetica, sans-serif;"
+				+ "       font-size: 12pt;"
+				+ "       font-weight: normal;"
+				+ "       margin-top: 110px;"
+				+ "       margin-right: 1em;"
+				+ "       margin-bottom: 1em;"
+				+ "       margin-left: 1em;"
+				+ "     }"
+				+ ""
+				+ "h1 { border: solid; "
+				+ "     text-align:center;"
+				+ "     background-color:yellow;"
+				+ "     color: navy;"
+				+ "   }"
+				+ "h2 { border: ridge;"
+				+ "     padding: 5px;"
+				+ "     background-color:yellow;"
+				+ "     color: navy;"
+				+ "   }"
+				+ "h3 { border: none;"
+				+ "     padding: 5px;"
+				+ "     background-color:yellow;"
+				+ "     color: navy;"
+				+ "   }"
+				+ ""
+				+ ".subtitle { border: none;"
+				+ "     padding: 5px;"
+				+ "     background-color:yellow;"
+				+ "     color: navy;"
+				+ "   }"
+				+ ""
+				+ "a:link    { color: #0000ff; font-family: Arial, Helvetica, sans-serif; font-weight: normal; text-decoration: underline}"
+				+ "a:visited { color: #0099ff; font-family: Arial, Helvetica, sans-serif; font-weight: normal; text-decoration: underline}"
+				+ "a:active  { color: #0000ff; font-family: Arial, Helvetica, sans-serif; font-weight: normal; text-decoration: underline}"
+				+ "a:hover   { color: #336666; font-family: Arial, Helvetica, sans-serif; font-weight: normal; text-decoration: underline}"
+				+ ""
+				+ "li { list-style-type: square;"
+				+ "     margin: 1em;"
+				+ "   }"
+				+ "li.tiny { list-style-type: square;"
+				+ "          margin: 0;"
+				+ "          list-style-image: none;"
+				+ "        }"
+				+ "li.count { list-style-type: upper-roman;"
+				+ "           list-style-image: none;"
+				+ "           margin: 0;"
+				+ "         }"
+				+ "li.dcount { list-style-type: decimal;"
+				+ "           list-style-image: none;"
+				+ "           margin: 0;"
+				+ "         }"
+				+ ""
+				+ "dd { margin-bottom: 0.5em }"
+				+ ""
+				+ ".address { font-size: 5pt; margin-right:1em }"
+				+ ".smaller { font-size: 8pt }"
+				+ ""
+				+ ".note { font-style: italic;"
+				+ "	padding-left: 5em;"
+				+ "        margin: 1em;"
+				+ "      }"
+				+ ""
+				+ ".update {"
+				+ "        background-color:#ccffcd;"
+				+ "      }"
+				+ ""
+				+ "pre.code { border: ridge;"
+				+ "     padding: 5px;"
+				+ "     background-color:#FFFF99;"
+				+ "     color: navy;"
+				+ "   }"
+				+ ""
+				+ "pre.script {"
+				+ "     padding: 5px;"
+				+ "     background-color: white;"
+				+ "     color: navy;"
+				+ "   }"
+				+ ""
+				+ "pre.script2 {"
+				+ "     padding: 5px;"
+				+ "     background-color: white;"
+				+ "     color: navy;"
+				+ "     margin-left: 5em;"
+				+ "   }"
+				+ ""
+				+ ""
+				+ "pre.sscript {"
+				+ "     padding: 5px;"
+				+ "     background-color: white;"
+				+ "     color: navy;"
+				+ "     font-size: 8pt;"
+				+ "   }"
+				+ "pre.ssscript {"
+				+ "     padding: 5px;"
+				+ "     background-color: white;"
+				+ "     color: navy;"
+				+ "     font-size: 6pt;"
+				+ "   }"
+				+ ""
+				+ "tr.options {"
+				+ "     background-color: #FFFF99;"
+				+ "     color: navy;"
+				+ "   }"
+				+ ""
+				+ "b.step {"
+				+ "     background-color: white;"
+				+ "     color: navy;     "
+				+ "     font-size: 8pt;"
+				+ "   }"
+				+ ".motto {"
+				+ "     text-align: right;"
+				+ "     font-style: italic;"
+				+ "     font-size: 10pt;"
+				+ "   }"
+				+ ".motto-signature {"
+				+ "     text-align: right;"
+				+ "     font-style: normal;"
+				+ "     font-size: 8pt;"
+				+ "   }"
+				+ ""
+				+ ".sb {"
+				+ "     font-weight: bold;"
+				+ "     font-size: 8pt;"
+				+ "}"
+				+ ".sbred {"
+				+ "     font-weight: bold;"
+				+ "     font-size: 8pt;"
+				+ "     color: red;"
+				+ "}"
+				+ " </style>"
+				+ "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />"
+				+ "<title>BioMOBY LSID Client Resolver</title>"
+				+ "</head>"
+				+ ""
+				+ "<body> <p><strong>" + lsid + "</strong><br/><br/>";
+
+		String post = "</p></body>" + "</html>";
+		String page = "";
+
 		if (getData) {
 			page = filter(getData(lsid));
 		} else {
-			page = filter(getMetaData(lsid));
+			page = "<pre>" + filter(getMetaData(lsid)) + "</pre>";
 		}
 		out.println(pre + page + post);
 		return;
@@ -103,7 +254,7 @@
 	 * lsid.
 	 */
 	public String getMetaData(String lsid_to_use) {
-        
+
 		try {
 			String str = resolveLSID(lsid_to_use, "soap");
 			return str;
@@ -126,7 +277,7 @@
 	}
 
 	public String getData(String lsid_to_use) {
-        
+
 		try {
 			String str = resolveLSID2Data(lsid_to_use, "soap");
 			return str;
@@ -147,115 +298,124 @@
 		}
 		return "Couldn't resolve your lsid to Data.";
 	}
-	
+
 	/**
 	 * @param lsid_to_use
 	 * @return
 	 */
-	private String resolveLSID2Data(String lsid_to_use, String proto) throws MobyException{
+	private String resolveLSID2Data(String lsid_to_use, String proto) throws MobyException {
 		try {
 
-    		LSID lsid = new LSID(lsid_to_use);
-    		log.info(lsid_to_use);
-            LSIDResolver resolver = new LSIDResolver(lsid);
-            resolver.setUseLocalCache(false);
-            String output = "";
-            // get Data
-            LSIDWSDLWrapper wrapper = resolver.getWSDLWrapper();
-            LSIDDataPort port = wrapper.getDataPortForProtocol(proto);
-            if (port ==  null) {
-            	throw new MobyException ("Protocol " + proto + " not supported by the Authority");
-            }
-            
-            InputStream in = resolver.getData(port);
-            byte[] bytes = new byte[1024];
-            int numbytes = in.read(bytes);
-            int totalData = 0;
-            while (numbytes != -1) {
-                output += new String(bytes,0,numbytes);
-                totalData += numbytes;
-                numbytes = in.read(bytes);
-            }
-            output += "\n";
-            output += "Data bytes read: " + totalData + "\n";
-            in.close();
-            return output;
-        }  catch (LSIDServerException e) {
-            return ("No Data associated with your LSID.\n" + e.getLocalizedMessage());
-        } catch (IOException e) {
-        	throw new MobyException("Problem retrieving Data. Please try again later.\n" + e.getLocalizedMessage());
+			LSID lsid = new LSID(lsid_to_use);
+			log.info(lsid_to_use);
+			LSIDResolver resolver = new LSIDResolver(lsid);
+			resolver.setUseLocalCache(false);
+			String output = "";
+			// get Data
+			LSIDWSDLWrapper wrapper = resolver.getWSDLWrapper();
+			LSIDDataPort port = wrapper.getDataPortForProtocol(proto);
+			if (port == null) {
+				throw new MobyException("Protocol " + proto + " not supported by the Authority");
+			}
+
+			InputStream in = resolver.getData(port);
+			byte[] bytes = new byte[1024];
+			int numbytes = in.read(bytes);
+			int totalData = 0;
+			while (numbytes != -1) {
+				output += new String(bytes, 0, numbytes);
+				totalData += numbytes;
+				numbytes = in.read(bytes);
+			}
+			output += newline;
+			output += "Data bytes read: " + totalData + newline;
+			in.close();
+			return output;
+		} catch (LSIDServerException e) {
+			return ("No Data associated with your LSID." + newline + e.getLocalizedMessage());
+		} catch (IOException e) {
+			throw new MobyException("Problem retrieving Data. Please try again later." + newline
+					+ e.getLocalizedMessage());
 		} catch (MalformedLSIDException e) {
-			return ("Malformed LSID. Please enter a valid LSID.\n" + e.getLocalizedMessage());
+			return ("Malformed LSID. Please enter a valid LSID." + newline + e
+					.getLocalizedMessage());
 		} catch (LSIDException e) {
-			throw new MobyException ("Couldn't create a resolver for the given LSID. Please try again later.\n" + e.getLocalizedMessage());
+			throw new MobyException(
+					"Couldn't create a resolver for the given LSID. Please try again later."
+							+ newline + e.getLocalizedMessage());
 		}
 	}
-	
+
 	/**
 	 * @param lsid_to_use
 	 * @return
 	 */
-	private String resolveLSID(String lsid_to_use, String proto) throws MobyException{
+	private String resolveLSID(String lsid_to_use, String proto) throws MobyException {
 		try {
 
-    		LSID lsid = new LSID(lsid_to_use);
-    		// TODO strip out the revision for now
-    		log.info(lsid_to_use);
-            LSIDResolver resolver = new LSIDResolver(lsid);
-            resolver.setUseLocalCache(false);
-            String output = "";
-            LSIDWSDLWrapper wrapper = resolver.getWSDLWrapper();
-            // get metadata
-            LSIDMetadataPort port = wrapper
-                    .getMetadataPortForProtocol(proto);
-            
-            MetadataResponse resp = resolver.getMetadata(port);
-            InputStream in = resp.getMetadata();
-            byte[] bytes = new byte[1024];
-            int numbytes = in.read(bytes);
-            int totalmeta = 0;
-            while (numbytes != -1) {
-                output += new String(bytes,0,numbytes);
-                totalmeta += numbytes;
-                numbytes = in.read(bytes);
-            }
-            output += "\n";
-            output += "metadata bytes read: " + totalmeta + "\n";
-            output += "metadata expires: " + resp.getExpires() + "\n";
-            output += "metadata format: " + resp.getFormat() + "\n";
-            in.close();
-            return output;
-        }  catch (LSIDServerException e) {
-            return ("No metadata associated with your LSID.\n" + e.getLocalizedMessage());
-        } catch (IOException e) {
-        	throw new MobyException("Problem retrieving Metadata. Please try again later.\n" + e.getLocalizedMessage());
+			LSID lsid = new LSID(lsid_to_use);
+			// TODO strip out the revision for now
+			log.info(lsid_to_use);
+			LSIDResolver resolver = new LSIDResolver(lsid);
+			resolver.setUseLocalCache(false);
+			String output = "";
+			LSIDWSDLWrapper wrapper = resolver.getWSDLWrapper();
+			// get metadata
+			LSIDMetadataPort port = wrapper.getMetadataPortForProtocol(proto);
+
+			MetadataResponse resp = resolver.getMetadata(port);
+			InputStream in = resp.getMetadata();
+			byte[] bytes = new byte[1024];
+			int numbytes = in.read(bytes);
+			int totalmeta = 0;
+			while (numbytes != -1) {
+				output += new String(bytes, 0, numbytes);
+				totalmeta += numbytes;
+				numbytes = in.read(bytes);
+			}
+			output += newline;
+			output += "metadata bytes read: " + totalmeta + newline;
+			output += "metadata expires: " + resp.getExpires() + newline;
+			output += "metadata format: " + resp.getFormat() + newline;
+			in.close();
+			return output;
+		} catch (LSIDServerException e) {
+			return ("No metadata associated with your LSID." + newline + e.getLocalizedMessage());
+		} catch (IOException e) {
+			throw new MobyException("Problem retrieving Metadata. Please try again later."
+					+ newline + e.getLocalizedMessage());
 		} catch (MalformedLSIDException e) {
-			return ("Malformed LSID. Please enter a valid LSID.\n" + e.getLocalizedMessage());
+			return ("Malformed LSID. Please enter a valid LSID." + newline + e
+					.getLocalizedMessage());
 		} catch (LSIDException e) {
-			throw new MobyException ("Couldn't create a resolver for the given LSID. Please try again later.\n" + e.getLocalizedMessage());
+			throw new MobyException(
+					"Couldn't create a resolver for the given LSID. Please try again later."
+							+ newline + e.getLocalizedMessage());
 		}
 	}
-    private static String filter(String input) {
-        if (input == null)
-            return null;
-        StringBuffer filtered = new StringBuffer(input.length());
-        char c;
-        for (int i = 0; i < input.length(); i++) {
-            c = input.charAt(i);
-            if (c == '<') {
-                filtered.append("&lt;");
-            } else if (c == '>') {
-                filtered.append("&gt;");
-            } else if (c == '"') {
-                filtered.append("&quot;");
-            } else if (c == '&') {
-                filtered.append("&amp;");
-            } else {
-                filtered.append(c);
-            }
-        }
-        return (filtered.toString());
-    }
+
+	private static String filter(String input) {
+		if (input == null)
+			return null;
+		StringBuffer filtered = new StringBuffer(input.length());
+		char c;
+		for (int i = 0; i < input.length(); i++) {
+			c = input.charAt(i);
+			if (c == '<') {
+				filtered.append("&lt;");
+			} else if (c == '>') {
+				filtered.append("&gt;");
+			} else if (c == '"') {
+				filtered.append("&quot;");
+			} else if (c == '&') {
+				filtered.append("&amp;");
+			} else {
+				filtered.append(c);
+			}
+		}
+		return (filtered.toString());
+	}
+
 	/*
 	 * (non-Javadoc)
 	 * 
@@ -266,8 +426,9 @@
 			throws ServletException, IOException {
 		doGet(arg0, arg1);
 	}
-	
+
 	public static void main(String[] args) {
-		System.out.println(new LSID_ResolverClient().getData("urn:lsid:ncbi.nlm.nih.gov.lsid.biopathways.org:pubmed:12441807"));
+		System.out.println(new LSID_ResolverClient()
+				.getData("urn:lsid:ncbi.nlm.nih.gov.lsid.biopathways.org:pubmed:12441807"));
 	}
 }




More information about the MOBY-guts mailing list