org.restlet.service
Class StatusService

java.lang.Object
  extended by org.restlet.service.StatusService

public class StatusService
extends Object

Service providing common representations for exception status.

Author:
Jerome Louvel (contact@noelios.com)

Constructor Summary
StatusService(boolean enabled)
          Constructor.
 
Method Summary
 String getContactEmail()
          Returns the email address to contact in case of error.
 Reference getHomeRef()
          Returns the home URI to propose in case of error.
 Representation getRepresentation(Status status, Request request, Response response)
          Returns a representation for the given status.
In order to customize the default representation, this method can be overriden.
 Status getStatus(Throwable throwable, Request request, Response response)
          Returns a status for a given exception or error.
 boolean isEnabled()
          Indicates if the service should be enabled.
 boolean isOverwrite()
          Indicates if an existing entity should be overwritten.
 void setContactEmail(String contactEmail)
          Sets the email address to contact in case of error.
 void setEnabled(boolean enabled)
          Indicates if the service should be enabled.
 void setHomeRef(Reference homeRef)
          Sets the home URI to propose in case of error.
 void setOverwrite(boolean overwrite)
          Indicates if an existing entity should be overwritten.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StatusService

public StatusService(boolean enabled)
Constructor.

Parameters:
enabled - True if the service has been enabled.
Method Detail

getContactEmail

public String getContactEmail()
Returns the email address to contact in case of error. This is typically used when creating the status representations.

Returns:
The email address to contact in case of error.

getHomeRef

public Reference getHomeRef()
Returns the home URI to propose in case of error.

Returns:
The home URI to propose in case of error.

getRepresentation

public Representation getRepresentation(Status status,
                                        Request request,
                                        Response response)
Returns a representation for the given status.
In order to customize the default representation, this method can be overriden. It returns null by default.

Parameters:
status - The status to represent.
request - The request handled.
response - The response updated.
Returns:
The representation of the given status.

getStatus

public Status getStatus(Throwable throwable,
                        Request request,
                        Response response)
Returns a status for a given exception or error. By default it returns an Status.SERVER_ERROR_INTERNAL status and logs a severe message.
In order to customize the default behavior, this method can be overriden.

Parameters:
throwable - The exception or error caught.
request - The request handled.
response - The response updated.
Returns:
The representation of the given status.

isEnabled

public boolean isEnabled()
Indicates if the service should be enabled.

Returns:
True if the service should be enabled.

isOverwrite

public boolean isOverwrite()
Indicates if an existing entity should be overwritten. False by default.

Returns:
True if an existing entity should be overwritten.

setContactEmail

public void setContactEmail(String contactEmail)
Sets the email address to contact in case of error. This is typically used when creating the status representations.

Parameters:
contactEmail - The email address to contact in case of error.

setEnabled

public void setEnabled(boolean enabled)
Indicates if the service should be enabled.

Parameters:
enabled - True if the service should be enabled.

setHomeRef

public void setHomeRef(Reference homeRef)
Sets the home URI to propose in case of error.

Parameters:
homeRef - The home URI to propose in case of error.

setOverwrite

public void setOverwrite(boolean overwrite)
Indicates if an existing entity should be overwritten.

Parameters:
overwrite - True if an existing entity should be overwritten.


Copyright © 2005-2007 Noelios Consulting.