org.apache.lenya.cms.usecase
Interface Usecase

All Known Implementing Classes:
AbstractUsecase, DocumentUsecase, DummyUsecase, ManageJobs

public interface Usecase

Usecase interface.

Version:
$Id: Usecase.java 568271 2007-08-21 20:49:18Z andreas $

Field Summary
static java.lang.String ROLE
          The Usecase role.
 
Method Summary
 void advance()
          Advances the usecase to the next step.
 void cancel()
          Cancels the usecase.
 void checkExecutionConditions()
          Checks the conditions right before the operation is executed.
 void checkPostconditions()
          Checks the conditions after the usecase was executed.
 void checkPreconditions()
          Checks the conditions before a form is displayed.
 void execute()
          Executes the usecase.
 java.util.List getErrorMessages()
          Returns the error messages from the previous operation.
 java.util.List getInfoMessages()
          Returns the info messages from the previous operation.
 java.lang.String getName()
           
 java.lang.Object getParameter(java.lang.String name)
          Returns the current value of a parameter.
 java.lang.Object getParameter(java.lang.String name, java.lang.Object defaultValue)
          Returns the current value of a parameter.
 java.lang.String getParameterAsString(java.lang.String name)
          Returns the current value of a parameter as a string.
 java.lang.String[] getParameterNames()
           
 org.apache.cocoon.servlet.multipart.Part getPart(java.lang.String name)
          Returns the current value of a part parameter as a string.
 org.apache.lenya.cms.repository.Session getSession()
           
 java.lang.String getSourceURL()
           
 java.lang.String getTargetURL(boolean success)
          Returns the webapp URL which should be redirected to after the usecase is completed.
 UsecaseView getView()
           
 boolean hasErrors()
          Determine if the usecase has error messages.
 boolean hasInfoMessages()
          Determine if the usecase has info messages.
 boolean isOptimistic()
           
 void lockInvolvedObjects()
          Locks all objects that are involved in the transaction.
 void setName(java.lang.String name)
           
 void setParameter(java.lang.String name, java.lang.Object value)
          Sets a parameter from the form.
 void setPart(java.lang.String name, org.apache.cocoon.servlet.multipart.Part value)
          Sets a parameter from the form.
 void setSourceURL(java.lang.String url)
           
 void setTestSession(org.apache.lenya.cms.repository.Session session)
          If you invoke this method, the usecase won't use its own isolated session, but the passed test session.
 void setView(UsecaseView view)
           
 

Field Detail

ROLE

static final java.lang.String ROLE
The Usecase role.

Method Detail

setSourceURL

void setSourceURL(java.lang.String url)
Parameters:
url - The URL the usecase is invoked on.

setParameter

void setParameter(java.lang.String name,
                  java.lang.Object value)
Sets a parameter from the form.

Parameters:
name - The parameter name.
value - The parameter value.

getParameter

java.lang.Object getParameter(java.lang.String name)
Returns the current value of a parameter.

Parameters:
name - The parameter name.
Returns:
An object.

getParameter

java.lang.Object getParameter(java.lang.String name,
                              java.lang.Object defaultValue)
Returns the current value of a parameter.

Parameters:
name - The parameter name.
defaultValue - The default value to return if the parameter is not set.
Returns:
An object.

getParameterAsString

java.lang.String getParameterAsString(java.lang.String name)
Returns the current value of a parameter as a string.

Parameters:
name - The parameter name.
Returns:
A string or null if the parameter was not set.

getParameterNames

java.lang.String[] getParameterNames()
Returns:
The parameter names.

setPart

void setPart(java.lang.String name,
             org.apache.cocoon.servlet.multipart.Part value)
Sets a parameter from the form. This method is called for parts in multipart requests.

Parameters:
name - The parameter name.
value - The parameter value.

getPart

org.apache.cocoon.servlet.multipart.Part getPart(java.lang.String name)
Returns the current value of a part parameter as a string.

Parameters:
name - The part parameter name.
Returns:
A part or null if the part was not set.

advance

void advance()
             throws UsecaseException
Advances the usecase to the next step. This method is called when all parameters are set.

Throws:
UsecaseException - if an error occurs.

checkPreconditions

void checkPreconditions()
                        throws UsecaseException
Checks the conditions before a form is displayed.

Throws:
UsecaseException - if an error occurs that causes an unstable system.

checkPostconditions

void checkPostconditions()
                         throws UsecaseException
Checks the conditions after the usecase was executed.

Throws:
UsecaseException - if an error occurs that causes an unstable system.

checkExecutionConditions

void checkExecutionConditions()
                              throws UsecaseException
Checks the conditions right before the operation is executed.

Throws:
UsecaseException - if an error occurs that causes an unstable system.

lockInvolvedObjects

void lockInvolvedObjects()
                         throws UsecaseException
Locks all objects that are involved in the transaction.

Throws:
UsecaseException - if an error occurs.

getErrorMessages

java.util.List getErrorMessages()
Returns the error messages from the previous operation. Error messages prevent the operation from being executed.

Returns:
A list of UsecaseMessage objects.

getInfoMessages

java.util.List getInfoMessages()
Returns the info messages from the previous operation. Info messages do not prevent the operation from being executed.

Returns:
A list of UsecaseMessage objects.

hasErrors

boolean hasErrors()
Determine if the usecase has error messages. Provides a way of checking for errors without actually retrieving them.

Returns:
true if the usecase resulted in error messages.

hasInfoMessages

boolean hasInfoMessages()
Determine if the usecase has info messages. Provides a way of checking for info messages without actually retrieving them.

Returns:
true if the usecase resulted in info messages being generated.

execute

void execute()
             throws UsecaseException
Executes the usecase. During this method error and info messages are filled in. If getErrorMessages() returns an empty array, the operation succeeded. Otherwise, the operation failed.

Throws:
UsecaseException - if an error occured that causes an unstable system.

cancel

void cancel()
            throws UsecaseException
Cancels the usecase.

Throws:
UsecaseException - if an error occurs.

getSourceURL

java.lang.String getSourceURL()
Returns:
The web application URL the usecase was invoked on.

getTargetURL

java.lang.String getTargetURL(boolean success)
Returns the webapp URL which should be redirected to after the usecase is completed.

Parameters:
success - If the usecase was completed successfully.
Returns:
A web application URL.

setName

void setName(java.lang.String name)
Parameters:
name - The name of this usecase.

getName

java.lang.String getName()
Returns:
The name of this usecase.

getView

UsecaseView getView()
Returns:
The view of the usecase.

setView

void setView(UsecaseView view)
Parameters:
view - The view of the usecase.

getSession

org.apache.lenya.cms.repository.Session getSession()
Returns:
The repository session.

setTestSession

void setTestSession(org.apache.lenya.cms.repository.Session session)
If you invoke this method, the usecase won't use its own isolated session, but the passed test session. The session will not be committed when the usecase is invoked, so you can check it for modifications without modifying the repository.

Parameters:
session - The test session.

isOptimistic

boolean isOptimistic()
Returns:
if the usecase uses optimistic offline lock.


Copyright © $ Apache Software Foundation. All Rights Reserved.