[MOBY-guts] biomoby commit

Gary Schlitz gss at pub.open-bio.org
Sat Mar 20 00:29:15 UTC 2004


gss
Fri Mar 19 19:29:15 EST 2004
Update of /home/repository/moby/moby-live/S-MOBY/ref-impl/core/org/smoby/tools/common/http
In directory pub.open-bio.org:/tmp/cvs-serv14175/org/smoby/tools/common/http

Modified Files:
	ParameterValue.java HTTPResponse.java HTTPRequest.java 
	HTTPException.java 
Log Message:
Misc

moby-live/S-MOBY/ref-impl/core/org/smoby/tools/common/http ParameterValue.java,1.1,1.2 HTTPResponse.java,1.1,1.2 HTTPRequest.java,1.1,1.2 HTTPException.java,1.1,1.2
===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/org/smoby/tools/common/http/ParameterValue.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/S-MOBY/ref-impl/core/org/smoby/tools/common/http/ParameterValue.java	2004/03/12 17:48:34	1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/org/smoby/tools/common/http/ParameterValue.java	2004/03/20 00:29:15	1.2
@@ -1,63 +1,63 @@
-package org.smoby.tools.common.http;
-
-/**
- * This class represents a named parameter and associated value to be sent
- * to an HTTP server.
- */
-public class ParameterValue
-{
-	/**
-	 * The name of the parameter.
-	 */
-	private String name;
-	
-	/**
-	 * The associated value of the parameter.
-	 */
-	private String value;
-	
-	/**
-	 * Create an instance with the given name and value.
-	 * @param name the name of the parameter.
-	 * @param the value of the parameter.
-	 */
-	public ParameterValue(String name, String value)
-	{
-		this.name = name;
-		this.value = value;
-	}
-	
-	/**
-	 * Return the name of the parameter.
-	 */
-	public String getName()
-	{
-		return name;
-	}
-	
-	/**
-	 * Set the name of the parameter.
-	 * @param name the new name.
-	 */
-	public void setName(String name)
-	{
-		this.name = name;
-	}
-
-	/**
-	 * Return the value of the parameter.
-	 */
-	public String getValue()
-	{
-		return value;
-	}
-	
-	/**
-	 * Set the value of the parameter.
-	 * @param value the new value.
-	 */
-	public void setValue(String value)
-	{
-		this.value = value;
-	}
-}
+package org.smoby.tools.common.http;
+
+/**
+ * This class represents a named parameter and associated value to be sent
+ * to an HTTP server.
+ */
+public class ParameterValue
+{
+	/**
+	 * The name of the parameter.
+	 */
+	private String name;
+	
+	/**
+	 * The associated value of the parameter.
+	 */
+	private String value;
+	
+	/**
+	 * Create an instance with the given name and value.
+	 * @param name the name of the parameter.
+	 * @param the value of the parameter.
+	 */
+	public ParameterValue(String name, String value)
+	{
+		this.name = name;
+		this.value = value;
+	}
+	
+	/**
+	 * Return the name of the parameter.
+	 */
+	public String getName()
+	{
+		return name;
+	}
+	
+	/**
+	 * Set the name of the parameter.
+	 * @param name the new name.
+	 */
+	public void setName(String name)
+	{
+		this.name = name;
+	}
+
+	/**
+	 * Return the value of the parameter.
+	 */
+	public String getValue()
+	{
+		return value;
+	}
+	
+	/**
+	 * Set the value of the parameter.
+	 * @param value the new value.
+	 */
+	public void setValue(String value)
+	{
+		this.value = value;
+	}
+}

===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/org/smoby/tools/common/http/HTTPResponse.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/S-MOBY/ref-impl/core/org/smoby/tools/common/http/HTTPResponse.java	2004/03/12 17:48:34	1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/org/smoby/tools/common/http/HTTPResponse.java	2004/03/20 00:29:15	1.2
@@ -1,80 +1,80 @@
-package org.smoby.tools.common.http;
-
-import java.io.*;
-import java.net.*;
-import java.util.*;
-
-import org.apache.commons.httpclient.*;
-import org.apache.commons.httpclient.methods.*;
-import org.smoby.tools.common.*;
-
-/**
- * This class abstracts the details of the response to executing
- * an HTTP command.
- */
-public class HTTPResponse
-{
-	/**
-	 * The object from the Jakarta HttpClient library that was
-	 * used to execute a command. It contains the status code
-	 * and server response, among other things.
-	 */
-	protected HttpMethod method;
-	
-	/**
-	 * Create an instance using the given HttpMethod object
-	 * @param method the method that was used to execute a command.
-	 */
-	public HTTPResponse(HttpMethod method)
-	{
-		this.method = method;
-	}
-    
-    /**
-     * Return whether or not this response represents a successful
-     * outcome to the command that was executed.
-     */
-    public boolean isSuccessful()
-    {
-        return method.getStatusCode() == HttpStatus.SC_OK;
-    }
-	
-	/**
-	 * Return the HTTP Status code returned by the server.
-	 */
-	public int getStatus()
-	{
-		return method.getStatusCode();
-	}
-	
-	/**
-	 * Return the HTTP Status text that was returned by the server.
-	 */
-	public String getStatusText()
-	{
-		return HttpStatus.getStatusText(method.getStatusCode());
-	}
-	
-	/**
-	 * Return the response body returned by the server.
-	 */
-	public String getBody()
-	{
-        try {
-            return method.getResponseBodyAsString();
-        } catch (IOException e) {
-            return "";
-        }
-	}
-    
-    /**
-     * Return the value associated with a given header field in the response
-     * returned by the server.
-     * @param headerName the name of the header field to be returned
-     * @return the value of the named header field
-     */
-    public String getHeaderValue(String headerName)
-    {
-    	return method.getResponseHeader(headerName).getValue();
-    }
+package org.smoby.tools.common.http;
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+
+import org.apache.commons.httpclient.*;
+import org.apache.commons.httpclient.methods.*;
+import org.smoby.tools.common.*;
+
+/**
+ * This class abstracts the details of the response to executing
+ * an HTTP command.
+ */
+public class HTTPResponse
+{
+	/**
+	 * The object from the Jakarta HttpClient library that was
+	 * used to execute a command. It contains the status code
+	 * and server response, among other things.
+	 */
+	protected HttpMethod method;
+	
+	/**
+	 * Create an instance using the given HttpMethod object
+	 * @param method the method that was used to execute a command.
+	 */
+	public HTTPResponse(HttpMethod method)
+	{
+		this.method = method;
+	}
+    
+    /**
+     * Return whether or not this response represents a successful
+     * outcome to the command that was executed.
+     */
+    public boolean isSuccessful()
+    {
+        return method.getStatusCode() == HttpStatus.SC_OK;
+    }
+	
+	/**
+	 * Return the HTTP Status code returned by the server.
+	 */
+	public int getStatus()
+	{
+		return method.getStatusCode();
+	}
+	
+	/**
+	 * Return the HTTP Status text that was returned by the server.
+	 */
+	public String getStatusText()
+	{
+		return HttpStatus.getStatusText(method.getStatusCode());
+	}
+	
+	/**
+	 * Return the response body returned by the server.
+	 */
+	public String getBody()
+	{
+        try {
+            return method.getResponseBodyAsString();
+        } catch (IOException e) {
+            return "";
+        }
+	}
+    
+    /**
+     * Return the value associated with a given header field in the response
+     * returned by the server.
+     * @param headerName the name of the header field to be returned
+     * @return the value of the named header field
+     */
+    public String getHeaderValue(String headerName)
+    {
+    	return method.getResponseHeader(headerName).getValue();
+    }
 }
\ No newline at end of file

===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/org/smoby/tools/common/http/HTTPRequest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/S-MOBY/ref-impl/core/org/smoby/tools/common/http/HTTPRequest.java	2004/03/12 17:48:34	1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/org/smoby/tools/common/http/HTTPRequest.java	2004/03/20 00:29:15	1.2
@@ -1,164 +1,164 @@
-package org.smoby.tools.common.http;
-
-import java.io.*;
-import java.net.*;
-import java.util.*;
-
-import org.apache.commons.httpclient.*;
-import org.apache.commons.httpclient.methods.*;
-import org.smoby.tools.common.*;
-
-/**
- * This is a helper class for executing HTTP commands. It makes use of the
- * Jakarta HttpClient library to avoid the need for using lower level classes
- * from the java.io and java.net packages where possible.
- */
-public class HTTPRequest
-{
-	/**
-	 * Constant meaning to use HTTP GET as the method for communicating
-	 * with the registration server.
-	 */
-	public final static int HTTP_GET = 0;
-	
-	/**
-	 * Constant meaning to use HTTP POST as the method for communicating
-	 * with the registration server.
-	 */
-	public final static int HTTP_POST = 1;
-	
-	/**
-	 * The URL of the server to be contacted
-	 */
-	private String serverURL = null;
-    
-    /**
-     * The method object (GetMethod or PostMethod)
-     */
-    private int method = HTTP_GET;
-	
-	/**
-	 * A list of ParameterValue objects.
-	 */
-	private List params = new ArrayList();
-    
-    /**
-     * A list of headers
-     */
-    private List headers = new ArrayList();
-	
-	/**
-	 * A helper object for abstracting the details of the HTTP
-	 * methods.
-	 */
-	private HttpClient client = new HttpClient();
-    
-    public static HTTPRequest newGetRequest(String serverURL)
-    {
-    	return new HTTPRequest(serverURL, HTTP_GET);
-    }
-    
-    public static HTTPRequest newPostRequest(String serverURL)
-    {
-        return new HTTPRequest(serverURL, HTTP_POST);
-    }
-    
-    public void addParameter(String paramName, String paramValue)
-    {
-    	params.add(new ParameterValue(paramName, paramValue));
-    }
-    
-    public void addHeader(String headerName, String headerValue)
-    {
-        headers.add(new ParameterValue(headerName, headerValue));
-    }
-	
-	/**
-	 * Create an instance for executing a command at the given URL string
-	 * with associated parameters and corresponding values.
-	 * @param serverURL a string representation of the URL of the server.
-     * @param method HTTP_GET or HTTP_POST
-	 */
-	private HTTPRequest(String serverURL, int method)
-	{
-		this.serverURL = serverURL;
-        this.method = method;
-    }
-	
-	/**
-	 * Execute the command using the associated method (HTT_GET or HTTP_POST).
-	 * @param method the HTTP method (HTTP_GET or HTTP_POST) to use.
-	 * @return an HTTPResponse object representing the response from the
-	 * server on which the URL was retrieved.
-	 * @throws HTTPException if the 
-	 */
-	public HTTPResponse send()
-		throws HTTPException
-	{
-        HttpMethod methodObject = null;
-        
-		if (method == HTTP_GET) {
-            methodObject = new GetMethod(getURLString());
-        }
-        else if (method == HTTP_POST) {
-            methodObject = new PostMethod(getURLString());
-        }
-        
-        // Add request headers to the method
-        //
-        for (Iterator it = headers.iterator(); it.hasNext();)
-        {
-        	ParameterValue pv = (ParameterValue) it.next();
-            methodObject.addRequestHeader(pv.getName(), pv.getValue());
-        }
-        
-        // Try to execute the method up to three times (some errors are recoverable)
-        //
-        int statusCode = -1;
-        for (int attempt = 0; statusCode == -1 && attempt < 3; attempt++)
-        {
-            try {
-                statusCode = client.executeMethod(methodObject);
-            } catch (HttpRecoverableException e) {
-            } catch (IOException e) {
-                // No use trying again
-                break;
-            }
-        }
-        
-        try {
-            methodObject.getResponseBodyAsString();
-        } catch (IOException e) {
-            throw new HTTPException("Couldn't get response body", e);
-        }
-        methodObject.releaseConnection();
-        
-        return new HTTPResponse(methodObject);
-	}
-	
-	/**
-	 * Build and return a string for executing this command.
-	 * @return the URL string.
-	 */
-	private String getURLString()
-	{
-		StringBuffer sb = new StringBuffer();
-		
-		sb.append(serverURL);
-        
-        Iterator it = params.iterator();
-		for (int i = 0; it.hasNext(); i++)
-		{
-			if (i == 0) {
-				sb.append("?");
-			} else {
-				sb.append("&");
-			}
-            ParameterValue pv = (ParameterValue) it.next();
-			sb.append(pv.getName());
-			sb.append("=");
-			sb.append(pv.getValue());
-		}
-		return sb.toString();
-	}
+package org.smoby.tools.common.http;
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+
+import org.apache.commons.httpclient.*;
+import org.apache.commons.httpclient.methods.*;
+import org.smoby.tools.common.*;
+
+/**
+ * This is a helper class for executing HTTP commands. It makes use of the
+ * Jakarta HttpClient library to avoid the need for using lower level classes
+ * from the java.io and java.net packages where possible.
+ */
+public class HTTPRequest
+{
+	/**
+	 * Constant meaning to use HTTP GET as the method for communicating
+	 * with the registration server.
+	 */
+	public final static int HTTP_GET = 0;
+	
+	/**
+	 * Constant meaning to use HTTP POST as the method for communicating
+	 * with the registration server.
+	 */
+	public final static int HTTP_POST = 1;
+	
+	/**
+	 * The URL of the server to be contacted
+	 */
+	private String serverURL = null;
+    
+    /**
+     * The method object (GetMethod or PostMethod)
+     */
+    private int method = HTTP_GET;
+	
+	/**
+	 * A list of ParameterValue objects.
+	 */
+	private List params = new ArrayList();
+    
+    /**
+     * A list of headers
+     */
+    private List headers = new ArrayList();
+	
+	/**
+	 * A helper object for abstracting the details of the HTTP
+	 * methods.
+	 */
+	private HttpClient client = new HttpClient();
+    
+    public static HTTPRequest newGetRequest(String serverURL)
+    {
+    	return new HTTPRequest(serverURL, HTTP_GET);
+    }
+    
+    public static HTTPRequest newPostRequest(String serverURL)
+    {
+        return new HTTPRequest(serverURL, HTTP_POST);
+    }
+    
+    public void addParameter(String paramName, String paramValue)
+    {
+    	params.add(new ParameterValue(paramName, paramValue));
+    }
+    
+    public void addHeader(String headerName, String headerValue)
+    {
+        headers.add(new ParameterValue(headerName, headerValue));
+    }
+	
+	/**
+	 * Create an instance for executing a command at the given URL string
+	 * with associated parameters and corresponding values.
+	 * @param serverURL a string representation of the URL of the server.
+     * @param method HTTP_GET or HTTP_POST
+	 */
+	private HTTPRequest(String serverURL, int method)
+	{
+		this.serverURL = serverURL;
+        this.method = method;
+    }
+	
+	/**
+	 * Execute the command using the associated method (HTT_GET or HTTP_POST).
+	 * @param method the HTTP method (HTTP_GET or HTTP_POST) to use.
+	 * @return an HTTPResponse object representing the response from the
+	 * server on which the URL was retrieved.
+	 * @throws HTTPException if the 
+	 */
+	public HTTPResponse send()
+		throws HTTPException
+	{
+        HttpMethod methodObject = null;
+        
+		if (method == HTTP_GET) {
+            methodObject = new GetMethod(getURLString());
+        }
+        else if (method == HTTP_POST) {
+            methodObject = new PostMethod(getURLString());
+        }
+        
+        // Add request headers to the method
+        //
+        for (Iterator it = headers.iterator(); it.hasNext();)
+        {
+        	ParameterValue pv = (ParameterValue) it.next();
+            methodObject.addRequestHeader(pv.getName(), pv.getValue());
+        }
+        
+        // Try to execute the method up to three times (some errors are recoverable)
+        //
+        int statusCode = -1;
+        for (int attempt = 0; statusCode == -1 && attempt < 3; attempt++)
+        {
+            try {
+                statusCode = client.executeMethod(methodObject);
+            } catch (HttpRecoverableException e) {
+            } catch (IOException e) {
+                // No use trying again
+                break;
+            }
+        }
+        
+        try {
+            methodObject.getResponseBodyAsString();
+        } catch (IOException e) {
+            throw new HTTPException("Couldn't get response body", e);
+        }
+        methodObject.releaseConnection();
+        
+        return new HTTPResponse(methodObject);
+	}
+	
+	/**
+	 * Build and return a string for executing this command.
+	 * @return the URL string.
+	 */
+	private String getURLString()
+	{
+		StringBuffer sb = new StringBuffer();
+		
+		sb.append(serverURL);
+        
+        Iterator it = params.iterator();
+		for (int i = 0; it.hasNext(); i++)
+		{
+			if (i == 0) {
+				sb.append("?");
+			} else {
+				sb.append("&");
+			}
+            ParameterValue pv = (ParameterValue) it.next();
+			sb.append(pv.getName());
+			sb.append("=");
+			sb.append(pv.getValue());
+		}
+		return sb.toString();
+	}
 }
\ No newline at end of file

===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/org/smoby/tools/common/http/HTTPException.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/S-MOBY/ref-impl/core/org/smoby/tools/common/http/HTTPException.java	2004/03/12 17:48:34	1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/org/smoby/tools/common/http/HTTPException.java	2004/03/20 00:29:15	1.2
@@ -1,22 +1,22 @@
-package org.smoby.tools.common.http;
-
-/**
- * This class wraps a String message and underlying Throwable
- * cause that occurred at some time during the processing of
- * trying to execute an HTTP commnand (normally using the
- * HTTPCommand class).
- */
-public class HTTPException extends Exception
-{
-	/**
-	 * Create an instance for the given message and underlying cause.
-	 * @param message a string indicating what was being done when the
-	 * throwable occurred; retrieved using the getMessage() method.
-	 * @param cause the underlying cause of the exception; retrieved
-	 * using the getCause() method.
-	 */
-	public HTTPException(String message, Throwable cause)
-	{
-		super(message, cause);
-	}
+package org.smoby.tools.common.http;
+
+/**
+ * This class wraps a String message and underlying Throwable
+ * cause that occurred at some time during the processing of
+ * trying to execute an HTTP commnand (normally using the
+ * HTTPCommand class).
+ */
+public class HTTPException extends Exception
+{
+	/**
+	 * Create an instance for the given message and underlying cause.
+	 * @param message a string indicating what was being done when the
+	 * throwable occurred; retrieved using the getMessage() method.
+	 * @param cause the underlying cause of the exception; retrieved
+	 * using the getCause() method.
+	 */
+	public HTTPException(String message, Throwable cause)
+	{
+		super(message, cause);
+	}
 }
\ No newline at end of file




More information about the MOBY-guts mailing list