org.weborganic.bastille.util
Class Errors

java.lang.Object
  extended by org.weborganic.bastille.util.Errors

public final class Errors
extends Object

A utility class for handling error situations in generators.


Method Summary
static void error(ContentRequest req, XMLWriter xml, String type, String message, ContentStatus status)
          Write the XML for when an error occurs
static void invalidParameter(ContentRequest req, XMLWriter xml, String name)
          Write the XML for when a required parameter is missing.
static void noParameter(ContentRequest req, XMLWriter xml, String name)
          Write the XML for when a required parameter is missing.
static void noUser(ContentRequest req, XMLWriter xml)
          Write the XML for when the user has not logged in, but is required.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

noParameter

public static void noParameter(ContentRequest req,
                               XMLWriter xml,
                               String name)
                        throws IOException
Write the XML for when a required parameter is missing.

Also sets the status of the response to 'bad request'.

Generator should generally terminate after invoking this method.

Parameters:
req - The content request
xml - The XML writer
name - The name of the missing parameter
Throws:
IOException - Should any error occur while writing the XML.
NullPointerException - If Any argument is null.

invalidParameter

public static void invalidParameter(ContentRequest req,
                                    XMLWriter xml,
                                    String name)
                             throws IOException
Write the XML for when a required parameter is missing.

Also sets the status of the response to 'bad request'.

Generator should generally terminate after invoking this method.

Parameters:
req - The content request
xml - The XML writer
name - The name of the invalid parameter
Throws:
IOException - Should any error occur while writing the XML.
NullPointerException - If Any argument is null.

noUser

public static void noUser(ContentRequest req,
                          XMLWriter xml)
                   throws IOException
Write the XML for when the user has not logged in, but is required.

Also sets the status of the response to 'forbidden'.

Generator should generally terminate after invoking this method.

Parameters:
req - The content request.
xml - The XML writer.
Throws:
IOException - Should any error occur while writing the XML.
NullPointerException - If Any argument is null.

error

public static void error(ContentRequest req,
                         XMLWriter xml,
                         String type,
                         String message,
                         ContentStatus status)
                  throws IOException
Write the XML for when an error occurs

Also sets the status of the response.

Generator should generally terminate after invoking this method.

Parameters:
req - The content request.
xml - The XML writer.
type - The type of error.
message - The message to explain the error.
status - The new status of the request.
Throws:
IOException - Should any error occur while writing the XML.
NullPointerException - If Any argument is null.