com.noelios.restlet.ext.javamail
Class TriggerResource

java.lang.Object
  extended by org.restlet.Handler
      extended by org.restlet.resource.Resource
          extended by com.noelios.restlet.ext.javamail.TriggerResource

public class TriggerResource
extends Resource

Resource that handles requests to target resources according to parameters located in mails.

Author:
Jerome Louvel

Field Summary
static java.lang.String ATTRIBUTE_MAILBOX_CHALLENGE_SCHEME
           
static java.lang.String ATTRIBUTE_MAILBOX_LOGIN
           
static java.lang.String ATTRIBUTE_MAILBOX_PASSWORD
           
static java.lang.String ATTRIBUTE_MAILBOX_URI
           
 
Constructor Summary
TriggerResource(Context context, Request request, Response response)
          Constructor.
 
Method Summary
 void acceptRepresentation(Representation entity)
          Handles POST requests.
protected  void callTarget(Resolver<java.lang.String> resolver)
          Requests the target resource.
protected  void deleteMail(java.lang.String mailIdentifier)
          Deletes a mail after it has been processed.
protected  Representation getMail(java.lang.String identifier)
          Get the mail representation according to its identifier.
 ChallengeScheme getMailboxChallengeScheme()
          Returns the scheme of the mailbox challenge.
 java.lang.String getMailboxLogin()
          Returns the login for the mailbox.
 java.lang.String getMailboxPassword()
          Returns the password for the mailbox.
 java.lang.String getMailboxUri()
          Returns the URI of the mailbox.
protected  java.util.List<java.lang.String> getMailIdentifiers()
          Returns the list of identifiers for the mails in the inbox
protected  Reference getMailRef(java.lang.String identifier)
          Returns the reference of a mail according to its identifier.
 java.lang.String getMailUriTemplate()
          Returns the template of the mail's URI.
 MailResolver getResolver()
          Returns the resolver based on a mail.
protected  MailResolver getResolver(java.lang.String mailIdentifier, Representation email)
          Returns a new resolver based on a mail.
protected  Representation getResponseRepresentation(java.util.List<java.lang.String> mailsSuccessful, java.util.Map<java.lang.String,java.lang.String> mailsUnsuccessful)
          Returns the response's representation according to the list of successfull and unsuccessfull mails.
protected  Status getResponseStatus(java.util.List<java.lang.String> mailsSuccessful, java.util.Map<java.lang.String,java.lang.String> mailsUnsuccessful)
          Returns the response's status according to the list of successfull and unsuccessfull mails.
protected  ChallengeResponse getTargetChallengeResponse(Resolver<java.lang.String> resolver)
          Returns the authentication data sent by client to the target according to the a list of properties.
protected  Representation getTargetEntity(Resolver<java.lang.String> resolver)
          Returns the entity sent to the target.
 Method getTargetMethod()
          Returns the default target method.
protected  Method getTargetMethod(Resolver<java.lang.String> resolver)
          Returns the target method according to a list of properties.
protected  Reference getTargetRef(Resolver<java.lang.String> resolver)
          Returns the reference of the target according to the a list of properties.
 java.lang.String getTargetUri()
          Returns the target URI template.
 boolean isTargetEntityEnabled()
          Indicate whether or not the target supports entity in the request.
 void setMailboxChallengeScheme(ChallengeScheme mailboxChallengeScheme)
          Sets the scheme of the mailbox challenge.
 void setMailboxLogin(java.lang.String mailboxLogin)
          Sets the login for the mailbox access.
 void setMailboxPassword(java.lang.String mailboxPassword)
          Sets the password for the mailbox access.
 void setMailboxUri(java.lang.String mailboxUri)
          Sets the URI of the mailbox.
 void setMailUriTemplate(java.lang.String mailUriTemplate)
          Sets the URI template for the target.
 void setTargetEntityEnabled(boolean targetEntityEnabled)
          Indicate whether or not the target supports entity in the request.
 void setTargetMethod(Method targetMethod)
          Sets the default target method.
 void setTargetUri(java.lang.String targetUri)
          Sets the target URI template.
 
Methods inherited from class org.restlet.resource.Resource
allowDelete, allowGet, allowPost, allowPut, delete, getPreferredRepresentation, getPreferredVariant, getRepresentation, getVariants, handleDelete, handleGet, handlePost, handlePut, init, isAvailable, isModifiable, isNegotiateContent, isReadable, post, put, removeRepresentations, represent, 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

ATTRIBUTE_MAILBOX_CHALLENGE_SCHEME

public static final java.lang.String ATTRIBUTE_MAILBOX_CHALLENGE_SCHEME
See Also:
Constant Field Values

ATTRIBUTE_MAILBOX_LOGIN

public static final java.lang.String ATTRIBUTE_MAILBOX_LOGIN
See Also:
Constant Field Values

ATTRIBUTE_MAILBOX_PASSWORD

public static final java.lang.String ATTRIBUTE_MAILBOX_PASSWORD
See Also:
Constant Field Values

ATTRIBUTE_MAILBOX_URI

public static final java.lang.String ATTRIBUTE_MAILBOX_URI
See Also:
Constant Field Values
Constructor Detail

TriggerResource

public TriggerResource(Context context,
                       Request request,
                       Response response)
Constructor.

Parameters:
context - The parent context.
request - The request to handle.
response - The response to return.
Method Detail

acceptRepresentation

public void acceptRepresentation(Representation entity)
                          throws ResourceException
Handles POST requests. It retrieves a list of mails and generate requests to target resources.

Overrides:
acceptRepresentation in class Resource
Throws:
ResourceException

callTarget

protected void callTarget(Resolver<java.lang.String> resolver)
                   throws ResourceException
Requests the target resource.

Parameters:
resolver - The data model that provides parameters value.
Throws:
ResourceException

deleteMail

protected void deleteMail(java.lang.String mailIdentifier)
                   throws ResourceException
Deletes a mail after it has been processed.

Parameters:
mailIdentifier - The identifier of the mail
Throws:
ResourceException

getMail

protected Representation getMail(java.lang.String identifier)
                          throws ResourceException
Get the mail representation according to its identifier.

Parameters:
identifier - the mail identifier.
Throws:
ResourceException

getMailboxChallengeScheme

public ChallengeScheme getMailboxChallengeScheme()
Returns the scheme of the mailbox challenge.

Returns:
The scheme of the mailbox challenge.

getMailboxLogin

public java.lang.String getMailboxLogin()
Returns the login for the mailbox.

Returns:
The login for the mailbox.

getMailboxPassword

public java.lang.String getMailboxPassword()
Returns the password for the mailbox.

Returns:
The password for the mailbox.

getMailboxUri

public java.lang.String getMailboxUri()
Returns the URI of the mailbox.

Returns:
The URI of the mailbox.

getMailIdentifiers

protected java.util.List<java.lang.String> getMailIdentifiers()
                                                       throws ResourceException
Returns the list of identifiers for the mails in the inbox

Returns:
The list of identifiers.
Throws:
ResourceException

getMailRef

protected Reference getMailRef(java.lang.String identifier)
                        throws ResourceException
Returns the reference of a mail according to its identifier.

Parameters:
identifier - The identifier of a mail.
Returns:
The URI of the mail.
Throws:
ResourceException

getMailUriTemplate

public java.lang.String getMailUriTemplate()
Returns the template of the mail's URI.

Returns:
the template of the mail's URI.

getResolver

public MailResolver getResolver()
Returns the resolver based on a mail.

Returns:
The resolver.

getResolver

protected MailResolver getResolver(java.lang.String mailIdentifier,
                                   Representation email)
Returns a new resolver based on a mail.

Parameters:
mailIdentifier - Identifier of the mail.
email - The mail.
Returns:
A resolver.

getResponseRepresentation

protected Representation getResponseRepresentation(java.util.List<java.lang.String> mailsSuccessful,
                                                   java.util.Map<java.lang.String,java.lang.String> mailsUnsuccessful)
Returns the response's representation according to the list of successfull and unsuccessfull mails.

Parameters:
mailsSuccessful - The list of successfull mails.
mailsUnsuccessful - The list of successfull mails and related error message.
Returns:
The response's representation.

getResponseStatus

protected Status getResponseStatus(java.util.List<java.lang.String> mailsSuccessful,
                                   java.util.Map<java.lang.String,java.lang.String> mailsUnsuccessful)
Returns the response's status according to the list of successfull and unsuccessfull mails.

Parameters:
mailsSuccessful - The list of successfull mails.
mailsUnsuccessful - The list of successfull mails and related error message.
Returns:
The response's status.

getTargetChallengeResponse

protected ChallengeResponse getTargetChallengeResponse(Resolver<java.lang.String> resolver)
                                                throws ResourceException
Returns the authentication data sent by client to the target according to the a list of properties. By default, this method returns checks the variable "challengeScheme", "login", "password" in order to build the ChallengeResponse object. It can be overriden.

Parameters:
resolver - The resolver.
Returns:
The target challengeResponse object.
Throws:
ResourceException

getTargetEntity

protected Representation getTargetEntity(Resolver<java.lang.String> resolver)
Returns the entity sent to the target. By default, it sends the mail message.

Parameters:
resolver - the resolver.
Returns:
The entity to be sent to the target.

getTargetMethod

public Method getTargetMethod()
Returns the default target method.

Returns:
The default target method.

getTargetMethod

protected Method getTargetMethod(Resolver<java.lang.String> resolver)
Returns the target method according to a list of properties.

Parameters:
resolver - The resolver.
Returns:
The target method.

getTargetRef

protected Reference getTargetRef(Resolver<java.lang.String> resolver)
                          throws ResourceException
Returns the reference of the target according to the a list of properties.

Parameters:
resolver - The resolver.
Returns:
The target reference.
Throws:
ResourceException

getTargetUri

public java.lang.String getTargetUri()
Returns the target URI template.

Returns:
The template that represents a target URI.

isTargetEntityEnabled

public boolean isTargetEntityEnabled()
Indicate whether or not the target supports entity in the request.

Returns:
True if the target supports entity in the request, false, otherwise.

setMailboxChallengeScheme

public void setMailboxChallengeScheme(ChallengeScheme mailboxChallengeScheme)
Sets the scheme of the mailbox challenge.

Parameters:
mailboxChallengeScheme - The scheme of the mailbox challenge.

setMailboxLogin

public void setMailboxLogin(java.lang.String mailboxLogin)
Sets the login for the mailbox access.

Parameters:
mailboxLogin - The login for the mailbox access.

setMailboxPassword

public void setMailboxPassword(java.lang.String mailboxPassword)
Sets the password for the mailbox access.

Parameters:
mailboxPassword - The password for the mailbox access.

setMailboxUri

public void setMailboxUri(java.lang.String mailboxUri)
Sets the URI of the mailbox.

Parameters:
mailboxUri - the URI of the mailbox.

setMailUriTemplate

public void setMailUriTemplate(java.lang.String mailUriTemplate)
Sets the URI template for the target.

Parameters:
mailUriTemplate - the URI template for the target.

setTargetEntityEnabled

public void setTargetEntityEnabled(boolean targetEntityEnabled)
Indicate whether or not the target supports entity in the request.

Parameters:
targetEntityEnabled - True if the target supports entity in the request, false, otherwise.

setTargetMethod

public void setTargetMethod(Method targetMethod)
Sets the default target method.

Parameters:
targetMethod - The default target method.

setTargetUri

public void setTargetUri(java.lang.String targetUri)
Sets the target URI template.

Parameters:
targetUri - The target URI template.


Copyright © 2005-2008 Noelios Technologies.