org.hackystat.sensorbase.resource.sensorbase
Class ResponseMessage

java.lang.Object
  extended by org.hackystat.sensorbase.resource.sensorbase.ResponseMessage

public class ResponseMessage
extends java.lang.Object

Provides standardized strings and formatting for response codes. This class is intended to make error reporting more uniform and informative. A good error message will always include an explanation for why the operation failed, and what the requested operation was.

Author:
Philip Johnson

Constructor Summary
ResponseMessage()
           
 
Method Summary
(package private) static java.lang.String adminOnly(SensorBaseResource resource)
          The error message for requests that only the admin can handle.
(package private) static java.lang.String adminOrAuthUserOnly(SensorBaseResource resource, java.lang.String authUser, java.lang.String uriUser)
          The error message for requests where the authorized user must be the same as the user in the URI string, or the authorized use is the admin (and then the user in the URI string can be anyone).
(package private) static java.lang.String badTimestamp(SensorBaseResource resource, java.lang.String timestamp)
          The error message for requests where a timestamp is not supplied or is not parsable.
(package private) static java.lang.String cannotViewProject(SensorBaseResource resource, java.lang.String user, java.lang.String project)
          The error message for requests involving projects not owned by the specified user.
(package private) static java.lang.String internalError(SensorBaseResource resource, java.util.logging.Logger logger, java.lang.Exception e)
          The error message for requests that generate an unspecified internal error.
(package private) static java.lang.String miscError(SensorBaseResource resource, java.lang.String message)
          The error message for miscellaneous "one off" error messages.
(package private) static java.lang.String notProjectOwner(SensorBaseResource resource, java.lang.String user, java.lang.String project)
          The error message for requests where the requesting user is not the owner.
(package private) static java.lang.String undefinedProject(SensorBaseResource resource, User user, java.lang.String project)
          The error message for requests involving projects not owned by the specified user.
(package private) static java.lang.String undefinedUser(SensorBaseResource resource, java.lang.String user)
          The error message for unknown users.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResponseMessage

public ResponseMessage()
Method Detail

adminOnly

static java.lang.String adminOnly(SensorBaseResource resource)
The error message for requests that only the admin can handle.

Parameters:
resource - The resource associated with this request.
Returns:
A string describing the problem.

adminOrAuthUserOnly

static java.lang.String adminOrAuthUserOnly(SensorBaseResource resource,
                                            java.lang.String authUser,
                                            java.lang.String uriUser)
The error message for requests where the authorized user must be the same as the user in the URI string, or the authorized use is the admin (and then the user in the URI string can be anyone).

Parameters:
resource - The resource associated with this request.
authUser - The authorized user.
uriUser - The user in the URI string.
Returns:
A string describing the problem.

internalError

static java.lang.String internalError(SensorBaseResource resource,
                                      java.util.logging.Logger logger,
                                      java.lang.Exception e)
The error message for requests that generate an unspecified internal error.

Parameters:
resource - The resource associated with this request.
logger - The logger.
e - The exception.
Returns:
A string describing the problem.

miscError

static java.lang.String miscError(SensorBaseResource resource,
                                  java.lang.String message)
The error message for miscellaneous "one off" error messages.

Parameters:
resource - The resource associated with this request.
message - A short string describing the problem.
Returns:
A string describing the problem.

undefinedUser

static java.lang.String undefinedUser(SensorBaseResource resource,
                                      java.lang.String user)
The error message for unknown users.

Parameters:
resource - The resource associated with this request.
user - A short string describing the problem.
Returns:
A string describing the problem.

undefinedProject

static java.lang.String undefinedProject(SensorBaseResource resource,
                                         User user,
                                         java.lang.String project)
The error message for requests involving projects not owned by the specified user.

Parameters:
resource - The resource associated with this request.
user - The user.
project - The project.
Returns:
A string describing the problem.

cannotViewProject

static java.lang.String cannotViewProject(SensorBaseResource resource,
                                          java.lang.String user,
                                          java.lang.String project)
The error message for requests involving projects not owned by the specified user.

Parameters:
resource - The resource associated with this request.
user - The user.
project - The project.
Returns:
A string describing the problem.

notProjectOwner

static java.lang.String notProjectOwner(SensorBaseResource resource,
                                        java.lang.String user,
                                        java.lang.String project)
The error message for requests where the requesting user is not the owner.

Parameters:
resource - The resource associated with this request.
user - The user.
project - The project
Returns:
A string describing the problem.

badTimestamp

static java.lang.String badTimestamp(SensorBaseResource resource,
                                     java.lang.String timestamp)
The error message for requests where a timestamp is not supplied or is not parsable.

Parameters:
resource - The resource associated with this request.
timestamp - The bogus timestamp.
Returns:
A string describing the problem.