org.hackystat.telemetry.service.resource.telemetry
Class TelemetryResource

java.lang.Object
  extended by org.restlet.Handler
      extended by org.restlet.resource.Resource
          extended by org.hackystat.telemetry.service.resource.telemetry.TelemetryResource
Direct Known Subclasses:
CacheResource, ChartDataResource, ChartDefinitionResource, ChartsResource, PingResource

public abstract class TelemetryResource
extends org.restlet.resource.Resource

An abstract superclass for all Telemetry resources that supplies common initialization processing. This includes:

Author:
Philip Johnson

Field Summary
protected  java.lang.String authUser
          The authenticated user, retrieved from the ChallengeResponse, or null.
protected  java.lang.String badAuth
          The standard error message returned from invalid authentication.
protected  java.lang.String chart
          To be retrieved from the URL as the 'chart' template parameter, or null.
protected  java.lang.String dpdHost
          The dailyprojectdata host (for analysis).
protected  java.lang.String end
          To be retrieved from the URL as the 'end' template parameter, or null.
protected  java.lang.String granularity
          To be retrieved from the URL as the 'granularity' template parameter, or null.
protected  java.lang.String params
          To be retrieved from the URL as the 'params' template parameter, or null.
protected  java.lang.String projectName
          To be retrieved from the URL as the 'project' template parameter, or null.
protected  long requestStartTime
          Records the time at which each HTTP request was initiated.
protected  java.lang.String sensorBaseHost
          The sensorbase host (for authentication).
protected  java.lang.String start
          To be retrieved from the URL as the 'start' template parameter, or null.
protected  Server telemetryServer
          This server (telemetry).
protected  java.lang.String uriUser
          To be retrieved from the URL as the 'email' template parameter, or null.
 
Constructor Summary
TelemetryResource(org.restlet.Context context, org.restlet.data.Request request, org.restlet.data.Response response)
          Provides the following representational variants: TEXT_XML.
 
Method Summary
 org.hackystat.dailyprojectdata.client.DailyProjectDataClient getDailyProjectDataClient()
          Returns a DailyProjectDataClient instance associated with the User in this request.
 org.hackystat.sensorbase.client.SensorBaseClient getSensorBaseClient()
          Returns a SensorBaseClient instance associated with the User in this request.
 org.restlet.resource.StringRepresentation getStringRepresentation(java.lang.String xmlData)
          Creates and returns a new Restlet StringRepresentation built from xmlData.
 java.util.List<TelemetryDefinition> getTelemetryDefinitions()
          Returns a list of TelemetryDefinition instances corresponding to all definitions in telemetry.definitions.xml.
protected  void logRequest()
          Generates a log message indicating the type of request, the elapsed time required, the user who requested the data, and the day.
protected  void logRequest(java.lang.String command)
          Generates a log message indicating the command.
abstract  org.restlet.resource.Representation represent(org.restlet.resource.Variant variant)
          The Restlet getRepresentation method which must be overridden by all concrete Resources.
protected  void setStatusError(java.lang.String msg)
          Called when an error occurs during processing.
protected  void setStatusError(java.lang.String msg, java.lang.Exception e)
          Called when an error resulting from an exception is caught during processing.
protected  void setStatusInternalError(java.lang.String msg)
          Called when an internal error occurs during processing.
 
Methods inherited from class org.restlet.resource.Resource
acceptRepresentation, allowDelete, allowGet, allowPost, allowPut, delete, getPreferredRepresentation, getPreferredVariant, getRepresentation, getVariants, handleDelete, handleGet, handlePost, handlePut, init, isAvailable, isModifiable, isNegotiateContent, isReadable, post, put, removeRepresentations, represent, setAvailable, setModifiable, setNegotiateContent, setReadable, setVariants, storeRepresentation
 
Methods inherited from class org.restlet.Handler
allowHead, allowOptions, generateRef, getAllowedMethods, getApplication, getContext, getLogger, getMatrix, getQuery, getRequest, getResponse, handleHead, handleOptions, setContext, setRequest, setResponse, updateAllowedMethods
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

uriUser

protected java.lang.String uriUser
To be retrieved from the URL as the 'email' template parameter, or null.


projectName

protected java.lang.String projectName
To be retrieved from the URL as the 'project' template parameter, or null.


chart

protected java.lang.String chart
To be retrieved from the URL as the 'chart' template parameter, or null.


granularity

protected java.lang.String granularity
To be retrieved from the URL as the 'granularity' template parameter, or null.


start

protected java.lang.String start
To be retrieved from the URL as the 'start' template parameter, or null.


end

protected java.lang.String end
To be retrieved from the URL as the 'end' template parameter, or null.


params

protected java.lang.String params
To be retrieved from the URL as the 'params' template parameter, or null.


authUser

protected java.lang.String authUser
The authenticated user, retrieved from the ChallengeResponse, or null.


telemetryServer

protected Server telemetryServer
This server (telemetry).


sensorBaseHost

protected java.lang.String sensorBaseHost
The sensorbase host (for authentication).


dpdHost

protected java.lang.String dpdHost
The dailyprojectdata host (for analysis).


badAuth

protected java.lang.String badAuth
The standard error message returned from invalid authentication.


requestStartTime

protected long requestStartTime
Records the time at which each HTTP request was initiated.

Constructor Detail

TelemetryResource

public TelemetryResource(org.restlet.Context context,
                         org.restlet.data.Request request,
                         org.restlet.data.Response response)
Provides the following representational variants: TEXT_XML.

Parameters:
context - The context.
request - The request object.
response - The response object.
Method Detail

represent

public abstract org.restlet.resource.Representation represent(org.restlet.resource.Variant variant)
The Restlet getRepresentation method which must be overridden by all concrete Resources.

Overrides:
represent in class org.restlet.resource.Resource
Parameters:
variant - The variant requested.
Returns:
The Representation.

getStringRepresentation

public org.restlet.resource.StringRepresentation getStringRepresentation(java.lang.String xmlData)
Creates and returns a new Restlet StringRepresentation built from xmlData. The xmlData will be prefixed with a processing instruction indicating UTF-8 and version 1.0.

Parameters:
xmlData - The xml data as a string.
Returns:
A StringRepresentation of that xmldata.

getDailyProjectDataClient

public org.hackystat.dailyprojectdata.client.DailyProjectDataClient getDailyProjectDataClient()
Returns a DailyProjectDataClient instance associated with the User in this request.

Returns:
The DailyProjectDataClient instance.

getSensorBaseClient

public org.hackystat.sensorbase.client.SensorBaseClient getSensorBaseClient()
Returns a SensorBaseClient instance associated with the User in this request.

Returns:
The SensorBaseClient instance.

getTelemetryDefinitions

public java.util.List<TelemetryDefinition> getTelemetryDefinitions()
Returns a list of TelemetryDefinition instances corresponding to all definitions in telemetry.definitions.xml.

Returns:
A List of TelemetryDefinition instances.

logRequest

protected void logRequest()
Generates a log message indicating the type of request, the elapsed time required, the user who requested the data, and the day.


logRequest

protected void logRequest(java.lang.String command)
Generates a log message indicating the command.

Parameters:
command - The command (typically cache).

setStatusError

protected void setStatusError(java.lang.String msg,
                              java.lang.Exception e)
Called when an error resulting from an exception is caught during processing.

Parameters:
msg - A description of the error.
e - A chained exception.

setStatusError

protected void setStatusError(java.lang.String msg)
Called when an error occurs during processing.

Parameters:
msg - A description of the error.

setStatusInternalError

protected void setStatusInternalError(java.lang.String msg)
Called when an internal error occurs during processing.

Parameters:
msg - A description of the error.