de.twenty11.skysail.server.restlet
Class ListServerResource<T>

java.lang.Object
  extended by org.restlet.resource.Resource
      extended by org.restlet.resource.UniformResource
          extended by org.restlet.resource.ServerResource
              extended by de.twenty11.skysail.server.restlet.SkysailServerResource2<T>
                  extended by de.twenty11.skysail.server.restlet.ListServerResource<T>

public class ListServerResource<T>
extends SkysailServerResource2<T>

An class dealing with common functionality for a skysail server resource.. The class is not abstract in order to let jackson deserialize json requests more easily.
Concurrency note from parent: contrary to the Uniform class and its main Restlet subclass where a single instance can handle several calls concurrently, one instance of ServerResource is created for each call handled and accessed by only one thread at a time.

Author:
carsten

Constructor Summary
ListServerResource()
           
 
Method Summary
protected  de.twenty11.skysail.common.responses.Response<de.twenty11.skysail.common.forms.ConstraintViolations<T>> addEntity(javax.persistence.EntityManager em, T entity, de.twenty11.skysail.common.forms.ConstraintViolations<T> constraintViolations)
           
 void buildGrid()
           
protected  de.twenty11.skysail.common.responses.Response<String> deleteEntity(javax.persistence.EntityManager em, T entity)
           
protected  int doHandlePagination(String configIdentifier, int defaultSize)
           
protected  Integer getCurrentPage()
           
protected  de.twenty11.skysail.common.responses.Response<List<T>> getEntities(List<T> data, String defaultMsg)
           
protected  de.twenty11.skysail.common.responses.Response<T> getEntity(T data)
           
 T getFilteredData()
          Implementors of this class have to provide skysailData which will be used to create a restlet representation.
protected  Integer getPageSize()
           
protected  Map<String,String> getParamsFromRequest()
           
 int getTotalResults()
           
protected  javax.validation.Validator getValidator()
           
 int handlePagination()
           
 void setCurrentPage(Integer currentPage)
           
 void setPageSize(Integer pageSize)
           
protected  void setTotalResults(int length)
           
 
Methods inherited from class de.twenty11.skysail.server.restlet.SkysailServerResource2
describe, describe, describe, describe, describe, describe, describeDelete, describeGet, describeMethod, describeOptions, describeParameters, describePost, describePut, determineValue, getDescription, getMessage, getName, getParent, getResourcePath, getSkysailData, options, setAutoDescribing, setDescription, setLocationRef, setLocationRef, setMessage, setName, setSkysailData
 
Methods inherited from class org.restlet.resource.ServerResource
abort, commit, delete, delete, describeVariants, doCatch, doConditionalHandle, doError, doHandle, doHandle, doNegotiatedHandle, get, get, getAttribute, getInfo, getInfo, getOnSent, getPreferredVariant, getVariants, getVariants, handle, hasAnnotations, head, head, isAnnotated, isAutoCommitting, isCommitted, isConditional, isExisting, isInRole, isNegotiated, options, post, post, put, put, redirectPermanent, redirectPermanent, redirectSeeOther, redirectSeeOther, redirectTemporary, redirectTemporary, setAllowedMethods, setAnnotated, setAttribute, setAutoCommitting, setChallengeRequests, setCommitted, setConditional, setCookieSettings, setDimensions, setExisting, 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, toObject, toRepresentation, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ListServerResource

public ListServerResource()
Method Detail

buildGrid

public void buildGrid()

handlePagination

public int handlePagination()

getEntities

protected de.twenty11.skysail.common.responses.Response<List<T>> getEntities(List<T> data,
                                                                             String defaultMsg)

getEntity

protected de.twenty11.skysail.common.responses.Response<T> getEntity(T data)

deleteEntity

protected de.twenty11.skysail.common.responses.Response<String> deleteEntity(javax.persistence.EntityManager em,
                                                                             T entity)

addEntity

protected de.twenty11.skysail.common.responses.Response<de.twenty11.skysail.common.forms.ConstraintViolations<T>> addEntity(javax.persistence.EntityManager em,
                                                                                                                            T entity,
                                                                                                                            de.twenty11.skysail.common.forms.ConstraintViolations<T> constraintViolations)

getValidator

protected javax.validation.Validator getValidator()

getFilteredData

public final T getFilteredData()
Implementors of this class have to provide skysailData which will be used to create a restlet representation. Which type of representation (json, xml, ...) will be returned depends on the request details.

Returns:
Type extending SkysailData

doHandlePagination

protected int doHandlePagination(String configIdentifier,
                                 int defaultSize)

getParamsFromRequest

protected Map<String,String> getParamsFromRequest()

getPageSize

protected Integer getPageSize()

setPageSize

public void setPageSize(Integer pageSize)

getCurrentPage

protected Integer getCurrentPage()

setCurrentPage

public void setCurrentPage(Integer currentPage)

setTotalResults

protected void setTotalResults(int length)

getTotalResults

public int getTotalResults()


Copyright © 2011-2013. All Rights Reserved.