com.novell.sentinel.client.bean.java
Class BeanTransporterSyncBase<B extends SentinelBean,P>

java.lang.Object
  extended by com.novell.sentinel.client.bean.BeanTransporterBase<B,P>
      extended by com.novell.sentinel.client.bean.java.BeanTransporterSyncBase<B,P>
Type Parameters:
B - Bean type (e.g., IdentityBean)
P - HTTP content parser type (e.g., JSONParser or org.xml.sax.Parser)
All Implemented Interfaces:
BeanTransporter<B>, BeanTransporterSync<B>
Direct Known Subclasses:
BeanTransporterJSONSync

public abstract class BeanTransporterSyncBase<B extends SentinelBean,P>
extends BeanTransporterBase<B,P>
implements BeanTransporterSync<B>

A base class for synchronous Java BeanTransporterSync implementations.

This classes uses the callback methods in its implementation, but hides the messy callback details in order to provide a clean, synchronous implementation whose methods return results directly and throw exceptions rather than reporting results and exceptions through callbacks.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.novell.sentinel.client.bean.BeanTransporterBase
BeanTransporterBase.ParseException
 
Field Summary
 
Fields inherited from interface com.novell.sentinel.client.bean.BeanTransporter
NO_FIELDS, UNLIMITED_PAGE_SIZE
 
Constructor Summary
protected BeanTransporterSyncBase(BeanMetaData<? extends B> _beanMD, HttpRequestor<P> _requestor, UriConstructorFactory _urlFactory)
          Constructor for derived classes.
 
Method Summary
 void cleanup(String url)
          Issues a cleanup request to the server for the passed URL.
 long count()
          Get a count of the data instances available.
 long count(String query)
          Get a count of the data instances available, optionally filtered by the passed query.
 void delete(B bean)
          Delete the data instance represented by the passed bean.
 void delete(String url)
          Delete the data instance at the specified URL.
 B get(String url, Iterable<String> fields)
          Get the data at the passed URL in a bean.
 byte[] getOctetData(String url)
          Get the octet stream value of an object attribute referenced by the passed URL.
 PagedBeanCollection<B> list()
          Get a collection of the beans available.
 PagedBeanCollection<B> list(String query, int pageSize, Iterable<String> fields)
          Get a collection of the data instances available, optionally filtered by the passed query.
 PagedBeanCollection<B> list(String query, int pageSize, Iterable<String> fields, boolean getChangeCounts)
          Get a collection of the data instances available, optionally filtered by the passed query.
 PagedBeanCollection<B> listFromURL(String url)
          Get a collection of the beans available at the passed URL.
 PagedBeanCollection<B> listFromURL(String url, int pageSize, Iterable<String> fields)
          Get a collection of the data instances available at the passed URL.
 PagedBeanCollection<B> listFromURL(String url, int pageSize, Iterable<String> fields, boolean getChangeCounts)
          Get a collection of the data instances available at the passed URL.
 String post(B bean)
          Create a new data instance.
 void put(B bean)
          Update the underlying Sentinel data from the passed bean.
 void put(String url, byte[] data)
          Put the octet stream value of an object attribute referenced by the passed URL.
 
Methods inherited from class com.novell.sentinel.client.bean.BeanTransporterBase
cleanup, count, count, createBean, createPage, createParser, delete, delete, get, get, getBeanMD, getLocaleName, getRequestor, getSortFields, getUrlFactory, list, list, list, listFromURL, listFromURL, listFromURL, parseCount, parseURL, post, put, put, setLocaleName, setSortFields
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeanTransporterSyncBase

protected BeanTransporterSyncBase(BeanMetaData<? extends B> _beanMD,
                                  HttpRequestor<P> _requestor,
                                  UriConstructorFactory _urlFactory)
Constructor for derived classes.

The passed HttpRequestor implementation must be a synchronous implementation.

Parameters:
_beanMD - The metadata for the SentinelBean type.
_requestor - The HttpRequestor implementation that will be used to make requests. This must be a synchronous implementation.
_urlFactory - The factory that will be used to construct URI instances.
Method Detail

count

public long count()
           throws HttpException
Description copied from interface: BeanTransporterSync
Get a count of the data instances available.

Specified by:
count in interface BeanTransporterSync<B extends SentinelBean>
Returns:
The result of the HTTP request.
Throws:
HttpException - If an error occurs executing the HTTP request.

count

public long count(String query)
           throws HttpException
Description copied from interface: BeanTransporterSync
Get a count of the data instances available, optionally filtered by the passed query.

Specified by:
count in interface BeanTransporterSync<B extends SentinelBean>
Parameters:
query - Optional filter for the results (may be null).
Returns:
The result of the HTTP request.
Throws:
HttpException - If an error occurs executing the HTTP request.

listFromURL

public PagedBeanCollection<B> listFromURL(String url)
                                                        throws HttpException
Description copied from interface: BeanTransporterSync
Get a collection of the beans available at the passed URL. The URL supplied must be appropriate for the bean type <B>.

Specified by:
listFromURL in interface BeanTransporterSync<B extends SentinelBean>
Parameters:
url - The URL specifying the beans.
Returns:
The result of the HTTP request.
Throws:
HttpException - If an error occurs executing the HTTP request.

listFromURL

public PagedBeanCollection<B> listFromURL(String url,
                                          int pageSize,
                                          Iterable<String> fields)
                                                        throws HttpException
Description copied from interface: BeanTransporterSync
Get a collection of the data instances available at the passed URL. The URL supplied must be appropriate for the bean type <B>.

Specified by:
listFromURL in interface BeanTransporterSync<B extends SentinelBean>
Parameters:
url - The URL specifying the beans.
pageSize - The maximum number of beans to return as a result of this call.
fields - Optional collection of the names of fields to return in each bean (may be null, if a single value of "none" is specified then no fields are retrieved).
Returns:
The result of the HTTP request.
Throws:
HttpException - If an error occurs executing the HTTP request.

listFromURL

public PagedBeanCollection<B> listFromURL(String url,
                                          int pageSize,
                                          Iterable<String> fields,
                                          boolean getChangeCounts)
                                                        throws HttpException
Description copied from interface: BeanTransporterSync
Get a collection of the data instances available at the passed URL. The URL supplied must be appropriate for the bean type <B>.

Specified by:
listFromURL in interface BeanTransporterSync<B extends SentinelBean>
Parameters:
url - The URL specifying the beans.
pageSize - The maximum number of beans to return as a result of this call.
fields - Optional collection of the names of fields to return in each bean (may be null, if a single value of "none" is specified then no fields are retrieved).
getChangeCounts - if true, get the "delta counts" of the object.
Returns:
The result of the HTTP request.
Throws:
HttpException - If an error occurs executing the HTTP request.

list

public PagedBeanCollection<B> list(String query,
                                   int pageSize,
                                   Iterable<String> fields)
                                                 throws HttpException
Description copied from interface: BeanTransporterSync
Get a collection of the data instances available, optionally filtered by the passed query.

Specified by:
list in interface BeanTransporterSync<B extends SentinelBean>
Parameters:
query - Optional filter for the results (may be null).
pageSize - The maximum number of beans to return as a result of this call.
fields - Optional collection of the names of fields to return in each bean (may be null, if a single value of "none" is specified then no fields are retrieved).
Returns:
The result of the HTTP request.
Throws:
HttpException - If an error occurs executing the HTTP request.

list

public PagedBeanCollection<B> list(String query,
                                   int pageSize,
                                   Iterable<String> fields,
                                   boolean getChangeCounts)
                                                 throws HttpException
Description copied from interface: BeanTransporterSync
Get a collection of the data instances available, optionally filtered by the passed query.

Specified by:
list in interface BeanTransporterSync<B extends SentinelBean>
Parameters:
query - Optional filter for the results (may be null).
pageSize - The maximum number of beans to return as a result of this call.
fields - Optional collection of the names of fields to return in each bean (may be null, if a single value of "none" is specified then no fields are retrieved).
getChangeCounts - if true, get the "delta counts" of the object.
Returns:
The result of the HTTP request.
Throws:
HttpException - If an error occurs executing the HTTP request.

list

public PagedBeanCollection<B> list()
                                                 throws HttpException
Description copied from interface: BeanTransporterSync
Get a collection of the beans available.

Specified by:
list in interface BeanTransporterSync<B extends SentinelBean>
Returns:
The result of the HTTP request.
Throws:
HttpException - If an error occurs executing the HTTP request.

get

public B get(String url,
             Iterable<String> fields)
                           throws HttpException
Description copied from interface: BeanTransporterSync
Get the data at the passed URL in a bean.

Specified by:
get in interface BeanTransporterSync<B extends SentinelBean>
Parameters:
url - The URL specifying the data to retrieve.
fields - Optional collection of the names of fields to return in each bean (may be null, if a single value of "none" is specified then no fields are retrieved).
Returns:
The result of the HTTP request.
Throws:
HttpException - If an error occurs executing the HTTP request.

getOctetData

public byte[] getOctetData(String url)
                    throws HttpException
Description copied from interface: BeanTransporterSync
Get the octet stream value of an object attribute referenced by the passed URL.

Specified by:
getOctetData in interface BeanTransporterSync<B extends SentinelBean>
Parameters:
url - The reference to the attribute value.
Returns:
The result of the HTTP request.
Throws:
HttpException - If an error occurs executing the HTTP request.

put

public void put(B bean)
         throws BeanSerializationException,
                HttpException
Description copied from interface: BeanTransporterSync
Update the underlying Sentinel data from the passed bean.

Specified by:
put in interface BeanTransporterSync<B extends SentinelBean>
Parameters:
bean - The bean containing the updated data (must have been obtained from a list or get call.
Throws:
BeanSerializationException
HttpException - If an error occurs executing the HTTP request.

put

public void put(String url,
                byte[] data)
         throws HttpException
Description copied from interface: BeanTransporterSync
Put the octet stream value of an object attribute referenced by the passed URL.

Specified by:
put in interface BeanTransporterSync<B extends SentinelBean>
Parameters:
url - The reference to the attribute value.
data - The octet stream data for the attribute value.
Throws:
HttpException - If an error occurs executing the HTTP request.

post

public String post(B bean)
            throws BeanSerializationException,
                   HttpException
Description copied from interface: BeanTransporterSync
Create a new data instance.

Specified by:
post in interface BeanTransporterSync<B extends SentinelBean>
Parameters:
bean - The bean containing the data for the new instance.
Returns:
The result of the HTTP request (the URL to the newly-created entity).
Throws:
BeanSerializationException - If an error occurs transforming the bean data into HTTP request data.
HttpException - If an error occurs executing the HTTP request.

delete

public void delete(String url)
            throws HttpException
Description copied from interface: BeanTransporterSync
Delete the data instance at the specified URL.

Specified by:
delete in interface BeanTransporterSync<B extends SentinelBean>
Parameters:
url - The URL specifying the data instance to be deleted.
Throws:
HttpException - If an error occurs executing the HTTP request.

delete

public void delete(B bean)
            throws HttpException
Description copied from interface: BeanTransporterSync
Delete the data instance represented by the passed bean.

Specified by:
delete in interface BeanTransporterSync<B extends SentinelBean>
Parameters:
bean - The representation of the data instance to be deleted (must have been obtained from a list or get call.
Throws:
HttpException - If an error occurs executing the HTTP request.

cleanup

public void cleanup(String url)
             throws HttpException
Description copied from interface: BeanTransporterSync
Issues a cleanup request to the server for the passed URL. Cleanup requests are used for certain types of resources that implicitly create server-side resources that can be freed once the client is finished with them. An example is a search job created implicitly when events are searched for using the EventBean list operation, rather than the EventSearch post operation.

Specified by:
cleanup in interface BeanTransporterSync<B extends SentinelBean>
Parameters:
url - The URL representing the resource to clean up.
Throws:
HttpException - If an error occurs executing the HTTP request.