com.versionone.apiclient
Class V1APIConnector

java.lang.Object
  extended by com.versionone.apiclient.V1APIConnector
All Implemented Interfaces:
IAPIConnector

public class V1APIConnector
extends java.lang.Object
implements IAPIConnector

This class represents a connection to the VersionOne server.


Field Summary
 java.util.Map<java.lang.String,java.lang.String> customHttpHeaders
          Additional headers for request to the VersionOne server
 
Constructor Summary
V1APIConnector(java.lang.String url)
          Create a connection with only the URL.
V1APIConnector(java.lang.String url, ProxyProvider proxy)
          Create a connection with only the URL and proxy.
V1APIConnector(java.lang.String url, java.lang.String userName, java.lang.String password)
          Create Connection.
V1APIConnector(java.lang.String url, java.lang.String userName, java.lang.String password, ProxyProvider proxy)
          Create Connection.
 
Method Summary
 java.io.OutputStream beginRequest(java.lang.String path, java.lang.String contentType)
          Beginning HTTP request to server.
 java.io.InputStream endRequest(java.lang.String path)
          Completing HTTP request and getting response.
 ICookiesManager getCookiesJar()
          Returns cookies jar
 java.io.Reader getData()
          Read data from the root of the connection Note: Caller is responsible for closing the returned stream
 java.io.Reader getData(java.lang.String path)
          Read data from the path provided Note: Caller is responsible for closing the returned stream
 java.io.Reader sendData(java.lang.String path, java.lang.String data)
          Send data to the path Note: Caller is responsible for closing the returned stream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

customHttpHeaders

public final java.util.Map<java.lang.String,java.lang.String> customHttpHeaders
Additional headers for request to the VersionOne server

Constructor Detail

V1APIConnector

public V1APIConnector(java.lang.String url,
                      java.lang.String userName,
                      java.lang.String password)
Create Connection.

Parameters:
url - - URL to VersionOne system.
userName - - Name of the user wishing to connect.
password - - password of the user wishing to connect.

V1APIConnector

public V1APIConnector(java.lang.String url,
                      java.lang.String userName,
                      java.lang.String password,
                      ProxyProvider proxy)
Create Connection.

Parameters:
url - - URL to VersionOne system.
userName - - Name of the user wishing to connect.
password - - password of the user wishing to connect.
proxy - - proxy for connection.

V1APIConnector

public V1APIConnector(java.lang.String url)
Create a connection with only the URL. Use this constructor to access MetaData, which does not require or if you want to use have Windows Integrated Authentication or MetaData does not require the use of credentials

Parameters:
url - - Complete URL to VersionOne system

V1APIConnector

public V1APIConnector(java.lang.String url,
                      ProxyProvider proxy)
Create a connection with only the URL and proxy. Use this constructor to access MetaData, which does not require or if you want to use have Windows Integrated Authentication or MetaData does not require the use of credentials

Parameters:
url - - Complete URL to VersionOne system
proxy - - Proxy for connection.
Method Detail

getCookiesJar

public ICookiesManager getCookiesJar()
Returns cookies jar


getData

public java.io.Reader getData()
                       throws ConnectionException
Read data from the root of the connection Note: Caller is responsible for closing the returned stream

Specified by:
getData in interface IAPIConnector
Returns:
the stream for reading data
Throws:
java.io.IOException
ConnectionException - if any connection problems occur

getData

public java.io.Reader getData(java.lang.String path)
                       throws ConnectionException
Read data from the path provided Note: Caller is responsible for closing the returned stream

Specified by:
getData in interface IAPIConnector
Parameters:
path -
Returns:
the stream for reading data
Throws:
java.io.IOException
ConnectionException - if any connection problems occur

sendData

public java.io.Reader sendData(java.lang.String path,
                               java.lang.String data)
                        throws ConnectionException
Send data to the path Note: Caller is responsible for closing the returned stream

Specified by:
sendData in interface IAPIConnector
Parameters:
path -
data -
Returns:
the response in a stream
Throws:
java.io.IOException
ConnectionException - if any connection problems occur

beginRequest

public java.io.OutputStream beginRequest(java.lang.String path,
                                         java.lang.String contentType)
                                  throws ConnectionException
Beginning HTTP request to server.

To begin POST request contentType parameter must be defined. If contentType parameter is null, GET request used. It's obligatory to complete request and get response by endRequest(String) method with the same path parameter.

Specified by:
beginRequest in interface IAPIConnector
Parameters:
path - path to the data on server.
contentType - Content-type of output content. If null - GET request used.
Returns:
the stream for writing POST data.
Throws:
ConnectionException - if any connection problems occur
See Also:
endRequest(String)

endRequest

public java.io.InputStream endRequest(java.lang.String path)
                               throws ConnectionException
Completing HTTP request and getting response.

Specified by:
endRequest in interface IAPIConnector
Parameters:
path - path to the data on server.
Returns:
the response stream for reading data.
Throws:
ConnectionException - if any connection problems occur
See Also:
beginRequest(String, String)