com.hyper9.vangaea.server.rest
Class BaseResource<T extends com.hyper9.common.beans.Bean>

java.lang.Object
  extended by org.restlet.resource.UniformResource
      extended by org.restlet.resource.ServerResource
          extended by com.hyper9.vangaea.server.rest.BaseResource<T>
Type Parameters:
T - The type of bean to this resource returns to the client.
Direct Known Subclasses:
AuthdResource, LoginResource

public abstract class BaseResource<T extends com.hyper9.common.beans.Bean>
extends org.restlet.resource.ServerResource

The base resource for all server resources in the Vangaea project.

Author:
akutz

Field Summary
protected  java.sql.Connection conn
          The database connection.
protected  java.util.List<com.hyper9.common.Function> initCallbacks
          A list of registered initialization functions to execute on behalf of sub-classes.
protected  java.util.List<com.hyper9.common.beans.BeanSerializationCallback<com.hyper9.common.beans.Bean>> preProcessBeanCallbacks
          A list of registered functions that are executed on a bean prior to it being serialized.
protected  java.lang.String rootPathPath
           
 
Constructor Summary
BaseResource()
           
 
Method Summary
protected  void doCatch(java.lang.Throwable throwable)
           
 void doInit()
          Initializes the resource.
 void doRelease()
          Clean up the resource.
protected  org.restlet.representation.Representation get()
           
protected  java.lang.String getAuthCookieName()
          Gets the configured name of the authentication cookie.
protected  java.lang.String getAuthCookieValue()
          Gets the authentication cookie value.
protected  java.lang.String getBaseUrl()
          Gets the base URL for the current request.
abstract  java.util.List<T> getBeans()
          Get the beans list.
protected  java.lang.String getRedirectUri()
          Gets and decodes the specified URL/UTF-8 encoded redirect URI.
protected static java.lang.String getSystemProperty(java.lang.String key, java.lang.String defaultValue)
          Gets a system property value.
 boolean isAnnotated()
          Do not allow this class or sub-classes to use the HTTP VERB annotations as they may break the polymorphic rules in place.
protected  boolean isDefaultHttpPort()
          Returns a value indicating whether or not the current request is using the default HTTP port.
protected  boolean isDefaultHttpsPort()
          Returns a value indicating whether or not the current request is using the default HTTPS port.
protected  boolean isDefaultHttpsPort(int port)
          Returns a value indicating whether the given port is the default HTTPS port.
 
Methods inherited from class org.restlet.resource.ServerResource
delete, delete, describeVariants, doConditionalHandle, doHandle, doHandle, doNegotiatedHandle, get, getInfo, getInfo, getPreferredVariant, getVariants, getVariants, handle, head, head, isConditional, isExisting, isInRole, isNegotiated, options, options, post, post, put, put, redirectPermanent, redirectPermanent, redirectSeeOther, redirectSeeOther, redirectTemporary, redirectTemporary, setAllowedMethods, setAnnotated, setChallengeRequests, setConditional, setCookieSettings, setDimensions, setExisting, setLocationRef, setLocationRef, setNegotiated, setServerInfo, setStatus, setStatus, setStatus, setStatus, setVariants, updateAllowedMethods, updateDimensions
 
Methods inherited from class org.restlet.resource.UniformResource
getAllowedMethods, getApplication, getChallengeRequests, getChallengeResponse, getClientInfo, getConditions, getContext, getCookies, getCookieSettings, getDimensions, getHostRef, getLocationRef, getLogger, getMatrix, getMethod, getOriginalRef, getProtocol, getQuery, getRanges, getReference, getReferrerRef, getRequest, getRequestAttributes, getRequestEntity, getResponse, getResponseAttributes, getResponseEntity, getRootRef, getServerInfo, getStatus, init, isConfidential, release
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rootPathPath

protected final java.lang.String rootPathPath

conn

protected java.sql.Connection conn
The database connection.


initCallbacks

protected java.util.List<com.hyper9.common.Function> initCallbacks
A list of registered initialization functions to execute on behalf of sub-classes.


preProcessBeanCallbacks

protected java.util.List<com.hyper9.common.beans.BeanSerializationCallback<com.hyper9.common.beans.Bean>> preProcessBeanCallbacks
A list of registered functions that are executed on a bean prior to it being serialized.

Constructor Detail

BaseResource

public BaseResource()
Method Detail

isAnnotated

public final boolean isAnnotated()
Do not allow this class or sub-classes to use the HTTP VERB annotations as they may break the polymorphic rules in place.

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

doInit

public final void doInit()
                  throws org.restlet.resource.ResourceException
Initializes the resource.

Overrides:
doInit in class org.restlet.resource.UniformResource
Throws:
org.restlet.resource.ResourceException

get

protected org.restlet.representation.Representation get()
                                                 throws org.restlet.resource.ResourceException
Overrides:
get in class org.restlet.resource.ServerResource
Throws:
org.restlet.resource.ResourceException

getBeans

public abstract java.util.List<T> getBeans()
                                                                         throws java.lang.Exception
Get the beans list.

Returns:
The beans list.
Throws:
java.lang.Exception - When an error occurs.

doCatch

protected void doCatch(java.lang.Throwable throwable)
Overrides:
doCatch in class org.restlet.resource.UniformResource

doRelease

public void doRelease()
               throws org.restlet.resource.ResourceException
Clean up the resource.

Overrides:
doRelease in class org.restlet.resource.UniformResource
Throws:
org.restlet.resource.ResourceException

getSystemProperty

protected static java.lang.String getSystemProperty(java.lang.String key,
                                                    java.lang.String defaultValue)
Gets a system property value.

Parameters:
key - The property's key.
defaultValue - The default value to assign if the property's value is not present in the backing store.
Returns:
A system property value.

getBaseUrl

protected java.lang.String getBaseUrl()
Gets the base URL for the current request.

Returns:
The base URL with or without the root paths.

isDefaultHttpPort

protected boolean isDefaultHttpPort()
Returns a value indicating whether or not the current request is using the default HTTP port.

Returns:
A value indicating whether or not the current request is using the default HTTP port.

isDefaultHttpsPort

protected boolean isDefaultHttpsPort(int port)
Returns a value indicating whether the given port is the default HTTPS port.

Parameters:
port - The port to check.
Returns:
A value indicating whether the given port is the default HTTPS port.

isDefaultHttpsPort

protected boolean isDefaultHttpsPort()
Returns a value indicating whether or not the current request is using the default HTTPS port.

Returns:
A value indicating whether or not the current request is using the default HTTPS port.

getAuthCookieValue

protected java.lang.String getAuthCookieValue()
Gets the authentication cookie value.

Returns:
The authentication cookie value.

getAuthCookieName

protected java.lang.String getAuthCookieName()
Gets the configured name of the authentication cookie.

Returns:
The configured name of the authentication cookie.

getRedirectUri

protected java.lang.String getRedirectUri()
                                   throws java.io.UnsupportedEncodingException
Gets and decodes the specified URL/UTF-8 encoded redirect URI.

Returns:
The decoded redirect URI.
Throws:
java.io.UnsupportedEncodingException - When an error occurs URL decoding the redirect URI.


Copyright © 2009 Hyper9. All Rights Reserved.