Class EScidocBasicHandler

java.lang.Object
  extended by EScidocBasicHandler

public class EScidocBasicHandler
extends java.lang.Object

Handler to create a connection with an eScidoc server

Author:
dwinter

Field Summary
private  int eScidocPort
           
private  java.lang.String eScidocServer
           
private  java.lang.String eScidocUrl
           
private  org.apache.http.impl.client.DefaultHttpClient httpclient
           
private  java.lang.String password
           
private  java.lang.String user
           
 
Constructor Summary
EScidocBasicHandler(java.lang.String eScidocServer, int eScidocPort, java.lang.String user, java.lang.String password)
           
 
Method Summary
static java.lang.String convertStreamToString(java.io.InputStream is)
          To convert the InputStream to String we use the BufferedReader.readLine() method.
 org.apache.http.HttpResponse eScidocGet(java.lang.String command)
          Sends a GET request to the escidoc client. performs a login if not done before.
 org.apache.http.HttpResponse eScidocPost(java.lang.String command, java.io.InputStream body)
          Sends a POST request to the escidoc client. performs a login if not done before.
 org.apache.http.HttpResponse eScidocPut(java.lang.String command, java.io.InputStream body)
          Sends a PUT request to the escidoc client. performs a login if not done before.
private  org.apache.http.HttpResponse eScidocRequestBase(org.apache.http.client.methods.HttpRequestBase httpBase, java.lang.String command, java.io.InputStream body)
          Generates and sends a general request to escidoc, used by escidocPUT, POST and GET.
 org.apache.http.impl.client.DefaultHttpClient login()
          Logs you into escidoc and sets the httpclient field to the current client for this session
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

eScidocServer

private java.lang.String eScidocServer

eScidocPort

private int eScidocPort

user

private java.lang.String user

password

private java.lang.String password

eScidocUrl

private java.lang.String eScidocUrl

httpclient

private org.apache.http.impl.client.DefaultHttpClient httpclient
Constructor Detail

EScidocBasicHandler

public EScidocBasicHandler(java.lang.String eScidocServer,
                           int eScidocPort,
                           java.lang.String user,
                           java.lang.String password)
Parameters:
eScidocServer -
eScidocPort -
user -
password -
Method Detail

login

public org.apache.http.impl.client.DefaultHttpClient login()
                                                    throws org.apache.http.client.ClientProtocolException,
                                                           java.io.IOException
Logs you into escidoc and sets the httpclient field to the current client for this session

Returns:
gives you the httpclient for further usage.
Throws:
org.apache.http.client.ClientProtocolException
java.io.IOException

eScidocPut

public org.apache.http.HttpResponse eScidocPut(java.lang.String command,
                                               java.io.InputStream body)
                                        throws org.apache.http.client.ClientProtocolException,
                                               java.io.IOException
Sends a PUT request to the escidoc client. performs a login if not done before.

Parameters:
command -
body -
Returns:
Throws:
org.apache.http.client.ClientProtocolException
java.io.IOException

eScidocPost

public org.apache.http.HttpResponse eScidocPost(java.lang.String command,
                                                java.io.InputStream body)
                                         throws org.apache.http.client.ClientProtocolException,
                                                java.io.IOException
Sends a POST request to the escidoc client. performs a login if not done before.

Parameters:
command -
body -
Returns:
Throws:
org.apache.http.client.ClientProtocolException
java.io.IOException

eScidocGet

public org.apache.http.HttpResponse eScidocGet(java.lang.String command)
                                        throws org.apache.http.client.ClientProtocolException,
                                               java.io.IOException
Sends a GET request to the escidoc client. performs a login if not done before.

Parameters:
command -
Returns:
Throws:
org.apache.http.client.ClientProtocolException
java.io.IOException

eScidocRequestBase

private org.apache.http.HttpResponse eScidocRequestBase(org.apache.http.client.methods.HttpRequestBase httpBase,
                                                        java.lang.String command,
                                                        java.io.InputStream body)
                                                 throws org.apache.http.client.ClientProtocolException,
                                                        java.io.IOException
Generates and sends a general request to escidoc, used by escidocPUT, POST and GET.

Parameters:
httpBase -
command -
body -
Returns:
Throws:
org.apache.http.client.ClientProtocolException
java.io.IOException

convertStreamToString

public static java.lang.String convertStreamToString(java.io.InputStream is)
To convert the InputStream to String we use the BufferedReader.readLine() method. We iterate until the BufferedReader return null which means there's no more data to read. Each line will appended to a StringBuilder and returned as String.

Parameters:
is -
Returns: