SMILA (incubation) API documentation

org.eclipse.smila.objectstore.httphandler
Class StoreObjectHandler

java.lang.Object
  extended by org.eclipse.smila.http.server.util.ARequestHandler
      extended by org.eclipse.smila.http.server.json.JsonRequestHandler
          extended by org.eclipse.smila.objectstore.httphandler.AStoreHandler
              extended by org.eclipse.smila.objectstore.httphandler.StoreObjectHandler
All Implemented Interfaces:
HttpHandler, RequestHandler

public class StoreObjectHandler
extends AStoreHandler

Read BON object from a object store object and convert it to JSON. For bulk objects it returns only the first object.

Author:
jschumacher

Field Summary
 
Fields inherited from class org.eclipse.smila.http.server.json.JsonRequestHandler
FACTORY
 
Constructor Summary
StoreObjectHandler()
           
 
Method Summary
protected  int getSuccessStatus(java.lang.String requestMethod, java.lang.String requestUri, Record inputRecord, java.lang.Object resultObject)
          Returns the success code.
protected  boolean isValidMethod(java.lang.String method, java.lang.String requestUri)
          Checks if the handler allows the HTTP method.
protected  Any listObjects(java.lang.String storeName, java.lang.String objectIdPrefix)
          list all objects with the given prefix.
 java.lang.Object process(java.lang.String method, java.lang.String requestUri, Record inputRecord)
          process input record and return result object.
protected  void putBonObject(java.lang.String storeName, java.lang.String objectId, Record inputRecord)
          try to write one BON object to the object store.
protected  BinaryObjectStreamIterator readBonBulk(java.lang.String storeName, java.lang.String objectId)
          try to read object as a BON bulk.
protected  Any readJsonObject(java.lang.String storeName, java.lang.String objectId)
          try to read a single JSON object from the object store object.
protected  void removeObject(java.lang.String storeName, java.lang.String objectId, Record inputRecord)
          Remove object, input record is not needed here but in subclass.
protected  void writeResultObject(java.io.OutputStream responseStream, java.lang.Object resultObject)
          write result object.
 
Methods inherited from class org.eclipse.smila.objectstore.httphandler.AStoreHandler
getErrorStatus, getObjectId, getObjectStoreService, getStoreName, setObjectStoreService, unsetObjectStoreService
 
Methods inherited from class org.eclipse.smila.http.server.json.JsonRequestHandler
getRequestHost, getSuccessStatus, handle, writeErrorResult, writeSuccessResult
 
Methods inherited from class org.eclipse.smila.http.server.util.ARequestHandler
activate, getDynamicUriParts, getRootContextPath, getStaticUriParts, getUriPattern, matches, urlDecode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StoreObjectHandler

public StoreObjectHandler()
Method Detail

isValidMethod

protected boolean isValidMethod(java.lang.String method,
                                java.lang.String requestUri)
Checks if the handler allows the HTTP method.

Overrides:
isValidMethod in class JsonRequestHandler
Parameters:
method - HTTP method
requestUri - request URI
Returns:
true if the method can be used for the URI, else false.

process

public java.lang.Object process(java.lang.String method,
                                java.lang.String requestUri,
                                Record inputRecord)
                         throws java.lang.Exception
process input record and return result object.

Specified by:
process in class JsonRequestHandler
Parameters:
method - HTTP method
requestUri - request URI.
inputRecord - input record parsed either from request body, if it has content, or from request URI parameters.
Returns:
result object, may be null. If this is not a Record, you have to provide a JsonRequestHandler.writeResultObject(OutputStream, Object) method, too.
Throws:
java.lang.Exception - any failure during processing.

listObjects

protected Any listObjects(java.lang.String storeName,
                          java.lang.String objectIdPrefix)
                   throws ObjectStoreException
list all objects with the given prefix.

Throws:
ObjectStoreException

readBonBulk

protected BinaryObjectStreamIterator readBonBulk(java.lang.String storeName,
                                                 java.lang.String objectId)
                                          throws ObjectStoreException,
                                                 java.io.IOException
try to read object as a BON bulk.

Throws:
ObjectStoreException
java.io.IOException

readJsonObject

protected Any readJsonObject(java.lang.String storeName,
                             java.lang.String objectId)
                      throws ObjectStoreException,
                             java.io.IOException
try to read a single JSON object from the object store object.

Throws:
ObjectStoreException
java.io.IOException

putBonObject

protected void putBonObject(java.lang.String storeName,
                            java.lang.String objectId,
                            Record inputRecord)
                     throws ObjectStoreException
try to write one BON object to the object store.

Throws:
ObjectStoreException

removeObject

protected void removeObject(java.lang.String storeName,
                            java.lang.String objectId,
                            Record inputRecord)
                     throws ObjectStoreException
Remove object, input record is not needed here but in subclass.

Throws:
ObjectStoreException

getSuccessStatus

protected int getSuccessStatus(java.lang.String requestMethod,
                               java.lang.String requestUri,
                               Record inputRecord,
                               java.lang.Object resultObject)
Returns the success code.

Overrides:
getSuccessStatus in class JsonRequestHandler
Parameters:
requestMethod - HTTP method
requestUri - request URI
inputRecord - input record
resultObject - result object returned from process
Returns:
the status code to return for successful requests using the method and request URI.

writeResultObject

protected void writeResultObject(java.io.OutputStream responseStream,
                                 java.lang.Object resultObject)
                          throws java.io.IOException
write result object. The default implementation writes back single Record results. Subclasses that produce different result types must override this method.

Overrides:
writeResultObject in class JsonRequestHandler
Parameters:
responseStream - response stream
resultObject - result object.
Throws:
java.io.IOException - error writing result

SMILA (incubation) API documentation