com.sibvisions.rad.server.http.rest.service
Class StorageService

java.lang.Object
  extended by org.restlet.resource.Resource
      extended by org.restlet.resource.ServerResource
          extended by com.sibvisions.rad.server.http.rest.service.StorageService

public class StorageService
extends org.restlet.resource.ServerResource

The StorageService lists all available records of an AbstractStorage.


Field Summary
protected static String JCODE_END
          the java code suffix.
protected static String JCODE_START
          the java code prefix.
 
Constructor Summary
StorageService()
           
 
Method Summary
protected  Object[] convertParameter(Object... pParams)
          Converts a string parameter to a Java object, if possible.
protected  org.restlet.representation.Representation createExceptionResponse(RestServiceException pException, Throwable pCause)
          Creates a general representation for a given service exception.
 void debug(Object... pInfo)
          Logs debug information.
 void error(Object... pInfo)
          Logs error information.
 org.restlet.representation.Representation executeDelete()
          Deletes records from the storage.
 org.restlet.representation.Representation executeFetch()
          Fetches records from the storage.
 org.restlet.representation.Representation executeGetMetaData()
          Gets the metadata for the storage.
 org.restlet.representation.Representation executeInsert(org.restlet.representation.Representation pRepresentation)
          Inserts a new record.
 org.restlet.representation.Representation executeUpdate(org.restlet.representation.Representation pRepresentation)
          Updates a record.
protected  DirectServerSession getSession()
          Gets the session for the current user.
 org.restlet.representation.Representation handle()
          
protected  org.restlet.representation.Representation handleException(Throwable pException)
          Handles an exception.
 void info(Object... pInfo)
          Logs information.
protected  boolean isDryRun()
          Gets whether the request is a dry-run test.
protected  org.restlet.representation.Representation toHtmlErrorRepresentation(IBean pBean)
          Converts an error bean to a html response.
protected  org.restlet.representation.Representation toInternalRepresentation(Object pObject)
          Configures a Jackson representation.
 
Methods inherited from class org.restlet.resource.ServerResource
abort, commit, delete, delete, describeVariants, doCatch, doConditionalHandle, doError, doHandle, doHandle, doNegotiatedHandle, get, get, getAttribute, getDescription, getInfo, getInfo, getName, getOnSent, getPreferredVariant, getRole, getVariants, getVariants, hasAnnotations, head, head, isAnnotated, isAutoCommitting, isCommitted, isConditional, isExisting, isInRole, isNegotiated, options, options, patch, patch, post, post, put, put, redirectPermanent, redirectPermanent, redirectSeeOther, redirectSeeOther, redirectTemporary, redirectTemporary, setAllowedMethods, setAnnotated, setAttribute, setAutoCommitting, setChallengeRequests, setCommitted, setConditional, setCookieSettings, setDescription, setDimensions, setExisting, setLocationRef, setLocationRef, setName, setNegotiated, setOnSent, setProxyChallengeRequests, setServerInfo, setStatus, setStatus, setStatus, setStatus, updateAllowedMethods, updateDimensions
 
Methods inherited from class org.restlet.resource.Resource
doError, doInit, doRelease, getAllowedMethods, getApplication, getChallengeRequests, getChallengeResponse, getClientInfo, getConditions, getConnegService, getContext, getConverterService, getCookies, getCookieSettings, getDimensions, getHostRef, getLocationRef, getLogger, getMatrix, getMatrixValue, getMaxForwards, getMetadataService, getMethod, getOriginalRef, getProtocol, getProxyChallengeRequests, getProxyChallengeResponse, getQuery, getQueryValue, getRanges, getReference, getReferrerRef, getRequest, getRequestAttributes, getRequestCacheDirectives, getRequestEntity, getResponse, getResponseAttributes, getResponseCacheDirectives, getResponseEntity, getRootRef, getServerInfo, getStatus, getStatusService, init, isConfidential, isLoggable, release, setApplication, setQueryValue, setRequest, setResponse, toBoolean, toByte, toDouble, toFloat, toInteger, toLong, toObject, toRepresentation, toRepresentation, toRepresentation, toShort, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

JCODE_START

protected static final String JCODE_START
the java code prefix.

See Also:
Constant Field Values

JCODE_END

protected static final String JCODE_END
the java code suffix.

See Also:
Constant Field Values
Constructor Detail

StorageService

public StorageService()
Method Detail

executeFetch

@Get
public org.restlet.representation.Representation executeFetch()
Fetches records from the storage. It is possible to filter the result if query parameters are used.

Returns:
the records as JSON representation

executeInsert

@Post
public org.restlet.representation.Representation executeInsert(org.restlet.representation.Representation pRepresentation)
Inserts a new record.

Parameters:
pRepresentation - the new record
Returns:
the inserted record

executeUpdate

@Put
public org.restlet.representation.Representation executeUpdate(org.restlet.representation.Representation pRepresentation)
Updates a record. It is not possible to change columns that are primary key columns.

Parameters:
pRepresentation - the new record
Returns:
the updated record

executeDelete

@Delete
public org.restlet.representation.Representation executeDelete()
Deletes records from the storage. It is possible to delete more than one row if query parameters are used. If no record is found, the NOT_FOUND status is set. If PK is used and more than one records were found, the CONFLICT status is set.

Returns:
the number of deleted records

executeGetMetaData

@Options
public org.restlet.representation.Representation executeGetMetaData()
Gets the metadata for the storage.

Returns:
the metadata

handle

public org.restlet.representation.Representation handle()

Overrides:
handle in class org.restlet.resource.ServerResource

handleException

protected org.restlet.representation.Representation handleException(Throwable pException)
Handles an exception. This method logs the excception as debug message and sets the status dependent of the exception.

Parameters:
pException - the exception
Returns:
null

createExceptionResponse

protected org.restlet.representation.Representation createExceptionResponse(RestServiceException pException,
                                                                            Throwable pCause)
Creates a general representation for a given service exception.

Parameters:
pException - the service exception
pCause - the exception cause
Returns:
the representation or null if no general representation could be created

isDryRun

protected boolean isDryRun()
Gets whether the request is a dry-run test. That means, no data manipulation should be done.

Returns:
true if the request is a dry-run request (Request-Header: X-DRYRUN is set to "true"), false otherwise

toInternalRepresentation

protected org.restlet.representation.Representation toInternalRepresentation(Object pObject)
Configures a Jackson representation.

Parameters:
pObject - the object to transfer
Returns:
the configured representation

toHtmlErrorRepresentation

protected org.restlet.representation.Representation toHtmlErrorRepresentation(IBean pBean)
Converts an error bean to a html response.

Parameters:
pBean - the error bean
Returns:
the response/representation

debug

public void debug(Object... pInfo)
Logs debug information.

Parameters:
pInfo - the debug information

info

public void info(Object... pInfo)
Logs information.

Parameters:
pInfo - the information

error

public void error(Object... pInfo)
Logs error information.

Parameters:
pInfo - the error information

convertParameter

protected Object[] convertParameter(Object... pParams)
Converts a string parameter to a Java object, if possible.

Parameters:
pParams - the input parameter
Returns:
a new object array which contains the converted parameter

getSession

protected DirectServerSession getSession()
Gets the session for the current user.

Returns:
the session


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.