com.esri.aims.mtier.io
Class ConnectionProxy

java.lang.Object
  extended by com.esri.aims.mtier.io.ConnectionProxy
All Implemented Interfaces:
Serializable

public class ConnectionProxy
extends Object
implements Serializable

Used by client applications to establish communication with the ArcIMS Application Server.

See Also:
Serialized Form

Field Summary
static int HTTP
          Defines a HTTP connection type.
static int HTTP_ADMIN
          Defines a HTTP connection for administrative requests.
static int PING_FAIL
          Describes a failed ping.
static int PING_FIRST_LOGIN
          Indicates that the username and password have not been set.
static int PING_OK
          Desribes a successful ping.
static int TCP
          Defines a TCP connection type.
static int TCP_ADMIN
          Defines a TCP connection for administrative requests.
 
Constructor Summary
ConnectionProxy()
          Constructs a new ConnectionProxy object.
 
Method Summary
 int getConnectionType()
          Returns the current connection type setting.
 boolean getDisplayMessages()
          Returns True, if requests and responses are to be written to System.out, False otherwise.
 String getHost()
          Returns the current hostname for the connection proxy.
 String getPassword()
          Returns the password used for authentication.
 int getPort()
          Returns the current port of the host machine that is used to send requests.
 String getService()
          Returns the name of the service which is currently being used to access the defined host machine.
 URL getUrl()
          Returns the defined URL.
 String getUsername()
          Returns the username used for authentication.
 com.esri.aims.mtier.model.axl.admin.Warnings getWarnings()
           
 int ping()
          Sends a ping to the Application Server to test the connection.
 int ping(boolean validate)
          Sends a ping to the Application Server to test the connection.
 String send(String request)
          Sends a request to the service configured by the connector bean.
static String send(String host, String service, int port, int connectionType, String request)
          An utility method that can be used to send a single request without having to maintain a ConnectionProxy object reference.
static String send(String host, String service, int port, int connectionType, String username, String password, String request)
          An utility method that can be used to send a single authenticatable request without having to maintain a ConnectionProxy object reference.
 InputStream sendGetStream(String request)
          Sends a request to the service configured by the connector bean.
 void setConnectionType(int newConnectionType)
          Sets the connection type with given integer.
 void setConnectionType(String newConnectionType)
          Sets the connection type with given string.
 void setDisplayMessages(boolean display)
          Used to write requests and responses to System.out.
 void setFileLength(long fileLength)
          Sets the size of the mxd InputStream.
 void setHost(String newHost)
          Defines the name of the host machine, on which the ArcIMS Application Server is running.
 void setMxdStream(InputStream mxdStream)
          Sets the InputStream for mxd stream.
 void setPassword(String newPassword)
          Sets the password used for authentication.
 void setPort(int newPort)
          Sets the port on the host machine to which the request is being sent, this port is the port that ArcIMS Application Server listens to.
 void setService(String newService)
          Defines the service this connection object will be accessing.
 void setUrl(URL newUrl)
          Sets the URL to connect with.
 void setUsername(String newUsername)
          Sets the username to be used for authentication.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TCP

public static final int TCP
Defines a TCP connection type.

See Also:
Constant Field Values

HTTP

public static final int HTTP
Defines a HTTP connection type.

See Also:
Constant Field Values

TCP_ADMIN

public static final int TCP_ADMIN
Defines a TCP connection for administrative requests.

See Also:
Constant Field Values

HTTP_ADMIN

public static final int HTTP_ADMIN
Defines a HTTP connection for administrative requests.

See Also:
Constant Field Values

PING_OK

public static final int PING_OK
Desribes a successful ping.

See Also:
Constant Field Values

PING_FAIL

public static final int PING_FAIL
Describes a failed ping.

See Also:
Constant Field Values

PING_FIRST_LOGIN

public static final int PING_FIRST_LOGIN
Indicates that the username and password have not been set.

See Also:
Constant Field Values
Constructor Detail

ConnectionProxy

public ConnectionProxy()
Constructs a new ConnectionProxy object.

Method Detail

ping

public int ping()
         throws ConnectionParameterException
Sends a ping to the Application Server to test the connection. For administrative requests, the username and password are validated as well. If the response is PING_FIRST_LOGIN, the username and password of the ConnectionProxy are reset. The old username and password will only work with a request to Site.setSiteUser() to set the site user profile. Same as calling ping(true);

Throws:
ConnectionParameterException

ping

public int ping(boolean validate)
         throws ConnectionParameterException
Sends a ping to the Application Server to test the connection. If validate is true then for administrative requests, the username and password are validated as well. Else, the Application Server is only pinged for existence. If the response is PING_FIRST_LOGIN, the username and password of the ConnectionProxy are reset. The old username and password will only work with a request to Site.setSiteUser() to set the site user profile.

Throws:
ConnectionParameterException

send

public static String send(String host,
                          String service,
                          int port,
                          int connectionType,
                          String request)
                   throws ConnectionParameterException,
                          com.esri.aims.mtier.io.http.UnableToPingEsrimapException,
                          AuthenticationException,
                          IOException
An utility method that can be used to send a single request without having to maintain a ConnectionProxy object reference.

Parameters:
host - the server
service - see parameter newService in function setService
port - the port the server is running on
connectionType - the type of connection being used
request - the request being sent
Returns:
the response returned
Throws:
ConnectionParameterException, - if a parameter is set incorrectly or if there is an error trying to load a given parameter.
UnableToPingEsrimapException, - if the server defined cannot be found on a given network (internet or intranet).
ConnectionParameterException
com.esri.aims.mtier.io.http.UnableToPingEsrimapException
AuthenticationException
IOException

send

public static String send(String host,
                          String service,
                          int port,
                          int connectionType,
                          String username,
                          String password,
                          String request)
                   throws ConnectionParameterException,
                          com.esri.aims.mtier.io.http.UnableToPingEsrimapException,
                          AuthenticationException,
                          IOException
An utility method that can be used to send a single authenticatable request without having to maintain a ConnectionProxy object reference.

Parameters:
host - the server
service - see parameter newService in function setService
port - the port the server is running on
connectionType - the type of connection being used
username - the username used to authenticate the request
password - the password used to authenticate the request
request - the request being sent
Returns:
the response
Throws:
ConnectionParameterException, - if a parameter is set incorrectly or if there is an error in trying to load a given parameter.
UnableToPingEsrimapException, - if the server defined cannot be found on a given network (internet or intranet).
AuthenticationException, - if the user profile defined by the username and password cannot be authenticated on the service defined by this connection.
ConnectionParameterException
com.esri.aims.mtier.io.http.UnableToPingEsrimapException
AuthenticationException
IOException

send

public String send(String request)
            throws ConnectionParameterException,
                   com.esri.aims.mtier.io.http.UnableToPingEsrimapException,
                   AuthenticationException,
                   IOException
Sends a request to the service configured by the connector bean. The request is sent to the service as a String and the response is returned as a string.

Parameters:
request - the request sent to the defined location
Returns:
the response string from the defined server
Throws:
ConnectionParameterException, - if a parameter is set incorrectly or if there is an error in trying to load a given parameter.
UnableToPingEsrimapException, - if the server cannot be found on a given network (internet or intranet).
AuthenticationException, - if the user profile defined by the username and password cannot be authenticated on the service defined by this connection.
ConnectionParameterException
com.esri.aims.mtier.io.http.UnableToPingEsrimapException
AuthenticationException
IOException

sendGetStream

public InputStream sendGetStream(String request)
                          throws ConnectionParameterException,
                                 com.esri.aims.mtier.io.http.UnableToPingEsrimapException,
                                 AuthenticationException,
                                 IOException
Sends a request to the service configured by the connector bean. The request is sent to the service as a String and the response is returned as an InputStream.

Parameters:
request - the request to be sent the defined location
Returns:
the response a stream - java.io.StreamInput
Throws:
ConnectionParameterException, - if a parameter is set incorrectly or if there is an error in trying to load a given parameter.
UnableToPingEsrimapException, - if the server defined cannot be found on a given network (internet or intranet).
AuthenticationException, - if the user profile defined by the username and password cannot be authenticated on the service defined by this connection.
ConnectionParameterException
com.esri.aims.mtier.io.http.UnableToPingEsrimapException
AuthenticationException
IOException

setHost

public void setHost(String newHost)
Defines the name of the host machine, on which the ArcIMS Application Server is running.

Parameters:
newHost - the name of the host machine.

getHost

public String getHost()
Returns the current hostname for the connection proxy.

Returns:
the hostname used by the instance of this object.

setPort

public void setPort(int newPort)
Sets the port on the host machine to which the request is being sent, this port is the port that ArcIMS Application Server listens to.

Parameters:
newPort - the port on the remote machine.

getPort

public int getPort()
Returns the current port of the host machine that is used to send requests.

Returns:
the current port assignment

setService

public void setService(String newService)
Defines the service this connection object will be accessing.
 connectionProxy.setService("SantaClara&CustomService=Query");
 

Parameters:
newService - specfies the map service name and the custom service, in the format of "map_service_name&CustomService=custom_service_name", the custom_service_name can be of three values: "Query" for <GET_FEATURES> request, "Geocode" for <GET_GEOCODE> request, and "Image", the default, is for all other requests.

getService

public String getService()
Returns the name of the service which is currently being used to access the defined host machine.

Returns:
String The current name of the service.

setConnectionType

public void setConnectionType(int newConnectionType)
Sets the connection type with given integer. The connection type is defined by the protocol static integers defined in this class, such as, TCP, HTTP, and HTTPS.

Parameters:
newConnectionType - the connection type used for communication - TCP/HTTP/HTTPS

setConnectionType

public void setConnectionType(String newConnectionType)
                       throws ConnectionParameterException
Sets the connection type with given string. The connection type is defined by passing a case-sensitive protocol string such as "TCP", "HTTP", or "HTTPS".

Parameters:
newConnectionType - the connection type used for communication - TCP/HTTP/HTTPS
Throws:
ConnectionParameterException, - if the protocol defined is not found.
ConnectionParameterException

getConnectionType

public int getConnectionType()
Returns the current connection type setting. This method defines the protocol of the connection being made.

Returns:
int the connection type as defined within this class.

setUsername

public void setUsername(String newUsername)
Sets the username to be used for authentication.

Parameters:
newUsername - the new username

getUsername

public String getUsername()
Returns the username used for authentication.

Returns:
the username if set

setPassword

public void setPassword(String newPassword)
Sets the password used for authentication.

Parameters:
newPassword - the password string

setMxdStream

public void setMxdStream(InputStream mxdStream)
Sets the InputStream for mxd stream.

Parameters:
mxdStream - is the mxd InputStream.

setFileLength

public void setFileLength(long fileLength)
Sets the size of the mxd InputStream.

Parameters:
fileLength - the size of the mxd InputStream.

getPassword

public String getPassword()
Returns the password used for authentication.

Returns:
the password string if set.

setUrl

public void setUrl(URL newUrl)
Sets the URL to connect with.

Parameters:
newUrl - the URL to connect with.

getUrl

public URL getUrl()
Returns the defined URL.

Returns:
a java.net.URL, if defined for this object.

setDisplayMessages

public void setDisplayMessages(boolean display)
Used to write requests and responses to System.out. Note, that you may have performance issues if set to True.

Parameters:
display - a boolean attribute - True, to display requests and responses, False otherwise.

getDisplayMessages

public boolean getDisplayMessages()
Returns True, if requests and responses are to be written to System.out, False otherwise.

Returns:
a boolean variable.

getWarnings

public com.esri.aims.mtier.model.axl.admin.Warnings getWarnings()