|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectorg.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.lenya.cms.usecase.AbstractUsecase
public class AbstractUsecase
Abstract usecase implementation.
| Field Summary | |
|---|---|
protected static java.lang.String |
ATTRIBUTE_NAME
|
protected static java.lang.String |
ATTRIBUTE_POLICY
|
protected static java.lang.String |
ATTRIBUTE_USECASE
|
protected static java.lang.String |
ATTRIBUTE_VALUE
|
protected org.apache.avalon.framework.context.Context |
context
|
protected static java.lang.String |
ELEMENT_EXIT
|
protected static java.lang.String |
ELEMENT_PARAMETER
|
protected static java.lang.String |
ELEMENT_TRANSACTION
|
protected static java.lang.String |
ELEMENT_VIEW
|
protected static java.lang.String |
ERROR_OBJECTS_CHECKED_OUT
|
protected static java.lang.String |
EVENT_CHECK_EXECUTION_CONDITIONS
|
protected static java.lang.String |
EVENT_CHECK_POSTCONDITIONS
|
protected static java.lang.String |
EVENT_CHECK_PRECONDITIONS
|
protected static java.lang.String |
EVENT_EXECUTE
|
protected org.apache.avalon.framework.service.ServiceManager |
manager
|
protected static StateMachine.Model |
MODEL
|
protected static java.lang.String |
PARAMETER_CHECKOUT_RESTRICTED_TO_SESSION
|
protected static java.lang.String |
PARAMETER_FACTORY
|
protected static java.lang.String |
PARAMETER_SESSION
|
protected static java.lang.String |
PARAMETER_STATE_MACHINE
|
protected static java.lang.String |
PARAMETERS_INITIALIZED
|
protected java.lang.String |
SOURCE_URL
|
protected static StateMachine.Transition[] |
TRANSITIONS
|
protected static java.lang.String |
VALUE_OPTIMISTIC
|
protected static java.lang.String |
VALUE_PESSIMISTIC
|
| Fields inherited from interface org.apache.lenya.cms.usecase.Usecase |
|---|
ROLE |
| Constructor Summary | |
|---|---|
AbstractUsecase()
|
|
| Method Summary | |
|---|---|
void |
addErrorMessage(java.lang.String message)
Adds an error message. |
void |
addErrorMessage(java.lang.String message,
java.lang.String[] _params)
Adds an error message. |
void |
addErrorMessages(java.lang.String[] messages)
Adds an error message. |
void |
addInfoMessage(java.lang.String message)
Adds an info message. |
void |
addInfoMessage(java.lang.String message,
java.lang.String[] _params)
Adds an info message. |
void |
advance()
Advances the usecase to the next step. |
protected void |
advanceState(java.lang.String event)
Advance the usecase state machine to the next state. |
void |
cancel()
Cancels the usecase. |
protected boolean |
canCheckOut(org.apache.lenya.cms.repository.Node[] objects)
|
protected void |
checkEvent(java.lang.String event)
|
void |
checkExecutionConditions()
Checks the conditions right before the operation is executed. |
protected boolean |
checkoutRestrictedToSession()
|
void |
checkPostconditions()
Checks the conditions after the usecase was executed. |
void |
checkPreconditions()
Checks the conditions before a form is displayed. |
protected void |
clearErrorMessages()
Clears the error messages. |
protected void |
clearInfoMessages()
Clears the info messages. |
void |
configure(org.apache.avalon.framework.configuration.Configuration config)
|
void |
contextualize(org.apache.avalon.framework.context.Context context)
|
protected void |
deleteParameter(java.lang.String name)
Deletes a parameter. |
protected void |
doCheckExecutionConditions()
Checks the execution conditions. |
protected void |
doCheckPostconditions()
Checks the post conditions. |
protected void |
doCheckPreconditions()
Checks the preconditions. |
protected void |
doExecute()
Executes the operation. |
protected void |
doInitialize()
Does the actual initialization. |
protected void |
dumpErrorMessages()
Dumps the error messages to the log. |
void |
execute()
Executes the usecase. |
java.lang.String |
getBooleanCheckboxParameter(java.lang.String name)
Returns one of the strings "true" or "false" depending on whether the corresponding checkbox was checked. |
protected org.apache.avalon.framework.context.Context |
getContext()
Returns the context. |
protected org.apache.lenya.cms.publication.DocumentFactory |
getDocumentFactory()
|
java.util.List |
getErrorMessages()
Checks if the operation can be executed and returns the error messages. |
protected java.lang.String |
getExitQueryString()
Returns the query string to access the exit usecase of this usecase. |
java.util.List |
getInfoMessages()
Returns the information messages to show on the confirmation screen. |
java.lang.String |
getName()
|
protected org.apache.lenya.cms.repository.Node[] |
getNodesToLock()
|
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. |
boolean |
getParameterAsBoolean(java.lang.String name,
boolean defaultValue)
Returns a parameter as boolean. |
int |
getParameterAsInteger(java.lang.String name,
int defaultValue)
Returns a parameter as integer. |
java.lang.String |
getParameterAsString(java.lang.String name)
Returns the current value of a parameter as a string. |
java.lang.String |
getParameterAsString(java.lang.String name,
java.lang.String defaultValue)
Returns a parameter as string. |
java.lang.String[] |
getParameterNames()
|
java.util.Map |
getParameters()
Return a map of all parameters |
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()
|
protected StateMachine |
getStateMachine()
|
java.lang.String |
getTargetURL(boolean success)
If setDefaultTargetURL(String)was not called, the source document (
getSourceURL()) is returned. |
UsecaseView |
getView()
|
boolean |
hasErrors()
Determine if the usecase has error messages. |
boolean |
hasInfoMessages()
Determine if the usecase has info messages. |
void |
initialize()
|
protected void |
initializeParametersIfNotDone()
|
protected void |
initParameters()
Override to initialize parameters. |
boolean |
isOptimistic()
|
void |
lockInvolvedObjects()
This method starts the transaction and locks all involved objects immediately. |
void |
lockInvolvedObjects(org.apache.lenya.cms.repository.Node[] objects)
Lock the objects, for example when you need to change them (for example, delete). |
protected void |
prepareView()
Override this method to prepare the view (add information messages etc.). |
void |
service(org.apache.avalon.framework.service.ServiceManager manager)
|
protected void |
setDefaultTargetURL(java.lang.String url)
Sets the default target URL which should be used if no explicit target URL is set. |
protected void |
setExitParameter(java.lang.String name,
java.lang.String value)
Sets a parameter to pass to the exit usecase. |
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. |
protected void |
setSession(org.apache.lenya.cms.repository.Session session)
|
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)
|
protected void |
startTransaction()
Start a transaction by using a new, modifiable session. |
| Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled |
|---|
enableLogging, getLogger, setupLogger, setupLogger, setupLogger |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final java.lang.String EVENT_CHECK_POSTCONDITIONS
protected static final java.lang.String EVENT_EXECUTE
protected static final java.lang.String EVENT_CHECK_PRECONDITIONS
protected static final java.lang.String EVENT_CHECK_EXECUTION_CONDITIONS
protected static final java.lang.String ERROR_OBJECTS_CHECKED_OUT
protected static final StateMachine.Transition[] TRANSITIONS
protected static final StateMachine.Model MODEL
protected static final java.lang.String PARAMETER_STATE_MACHINE
protected static final java.lang.String PARAMETER_SESSION
protected static final java.lang.String PARAMETER_FACTORY
protected static final java.lang.String PARAMETER_CHECKOUT_RESTRICTED_TO_SESSION
protected static final java.lang.String PARAMETERS_INITIALIZED
protected java.lang.String SOURCE_URL
protected static final java.lang.String ELEMENT_PARAMETER
protected static final java.lang.String ATTRIBUTE_NAME
protected static final java.lang.String ATTRIBUTE_VALUE
protected static final java.lang.String ELEMENT_VIEW
protected static final java.lang.String ELEMENT_TRANSACTION
protected static final java.lang.String ATTRIBUTE_POLICY
protected static final java.lang.String VALUE_OPTIMISTIC
protected static final java.lang.String VALUE_PESSIMISTIC
protected static final java.lang.String ELEMENT_EXIT
protected static final java.lang.String ATTRIBUTE_USECASE
protected org.apache.avalon.framework.context.Context context
protected org.apache.avalon.framework.service.ServiceManager manager
| Constructor Detail |
|---|
public AbstractUsecase()
| Method Detail |
|---|
protected void initParameters()
protected void advanceState(java.lang.String event)
event - The vent to invoke.protected StateMachine getStateMachine()
protected void checkEvent(java.lang.String event)
public java.lang.String getSourceURL()
getSourceURL in interface UsecaseWe don't use getParameterAsString()
because this will typically cause stack overflows or NPEs in connection with
initParameters().protected org.apache.avalon.framework.context.Context getContext()
public boolean hasErrors()
hasErrors in interface Usecasepublic boolean hasInfoMessages()
hasInfoMessages in interface Usecasepublic java.util.List getErrorMessages()
getErrorMessages in interface Usecasepublic java.util.List getInfoMessages()
getInfoMessages in interface Usecasepublic void addErrorMessage(java.lang.String message)
message - The message.
public void addErrorMessage(java.lang.String message,
java.lang.String[] _params)
message - The message._params - parameterspublic void addErrorMessages(java.lang.String[] messages)
messages - The messages.
public void addInfoMessage(java.lang.String message,
java.lang.String[] _params)
message - The message._params - parameterspublic void addInfoMessage(java.lang.String message)
message - The message.
public final void checkExecutionConditions()
throws UsecaseException
Usecase
checkExecutionConditions in interface UsecaseUsecaseException - if an error occurs that causes an unstable
system.Usecase.checkExecutionConditions()
protected void doCheckExecutionConditions()
throws java.lang.Exception
java.lang.Exception - if an error occurs.
public final void checkPreconditions()
throws UsecaseException
Usecase
checkPreconditions in interface UsecaseUsecaseException - if an error occurs that causes an unstable
system.Usecase.checkPreconditions()
protected void doCheckPreconditions()
throws java.lang.Exception
java.lang.Exception - if an error occurs.protected void clearErrorMessages()
protected void clearInfoMessages()
public final void execute()
throws UsecaseException
Usecase
execute in interface UsecaseUsecaseException - if an error occured that causes an unstable
system.Usecase.execute()protected void dumpErrorMessages()
public void checkPostconditions()
throws UsecaseException
Usecase
checkPostconditions in interface UsecaseUsecaseException - if an error occurs that causes an unstable
system.Usecase.checkPostconditions()
protected void doCheckPostconditions()
throws java.lang.Exception
java.lang.Exception - if an error occured.
protected void doExecute()
throws java.lang.Exception
java.lang.Exception - when something went wrong.
public void setParameter(java.lang.String name,
java.lang.Object value)
Usecase
setParameter in interface Usecasename - The parameter name.value - The parameter value.Usecase.setParameter(java.lang.String, java.lang.Object)public java.lang.Object getParameter(java.lang.String name)
Usecase
getParameter in interface Usecasename - The parameter name.
Usecase.getParameter(java.lang.String)
public java.lang.Object getParameter(java.lang.String name,
java.lang.Object defaultValue)
Usecase
getParameter in interface Usecasename - The parameter name.defaultValue - The default value to return if the parameter is not set.
Usecase.getParameter(java.lang.String, java.lang.Object)public java.lang.String getParameterAsString(java.lang.String name)
Usecase
getParameterAsString in interface Usecasename - The parameter name.
null if the parameter was not set.Usecase.getParameterAsString(java.lang.String)
public java.lang.String getParameterAsString(java.lang.String name,
java.lang.String defaultValue)
name - The parameter name.defaultValue - The default value.
public int getParameterAsInteger(java.lang.String name,
int defaultValue)
name - The parameter name.defaultValue - The default value.
public boolean getParameterAsBoolean(java.lang.String name,
boolean defaultValue)
name - The parameter name.defaultValue - The default value.
public java.util.Map getParameters()
public java.lang.String getBooleanCheckboxParameter(java.lang.String name)
name - The parameter name.
protected void setDefaultTargetURL(java.lang.String url)
url - A URL string.public java.lang.String getTargetURL(boolean success)
setDefaultTargetURL(String)was not called, the source document (
getSourceURL()) is returned.
getTargetURL in interface Usecasesuccess - If the usecase was completed successfully.
Usecase.getTargetURL(boolean)
public void setPart(java.lang.String name,
org.apache.cocoon.servlet.multipart.Part value)
Usecase
setPart in interface Usecasename - The parameter name.value - The parameter value.Usecase.setPart(java.lang.String,
org.apache.cocoon.servlet.multipart.Part)public org.apache.cocoon.servlet.multipart.Part getPart(java.lang.String name)
Usecase
getPart in interface Usecasename - The part parameter name.
null if the part was not set.Usecase.getPart(java.lang.String)protected org.apache.lenya.cms.publication.DocumentFactory getDocumentFactory()
public final void initialize()
throws java.lang.Exception
initialize in interface org.apache.avalon.framework.activity.Initializablejava.lang.ExceptionInitializable.initialize()protected final void doInitialize()
public void advance()
throws UsecaseException
Usecase
advance in interface UsecaseUsecaseException - if an error occurs.Usecase.advance()protected void deleteParameter(java.lang.String name)
name - The parameter name.public void setName(java.lang.String name)
setName in interface Usecasename - The name of this usecase.Usecase.setName(java.lang.String)public java.lang.String getName()
getName in interface UsecaseUsecase.getName()public java.lang.String[] getParameterNames()
getParameterNames in interface UsecaseUsecase.getParameterNames()protected void initializeParametersIfNotDone()
public void setSourceURL(java.lang.String url)
setSourceURL in interface Usecaseurl - The URL the usecase is invoked on.Usecase.setSourceURL(java.lang.String)public UsecaseView getView()
getView in interface UsecaseUsecase.getView()
protected void prepareView()
throws java.lang.Exception
java.lang.Exception - If an error occurs.public boolean isOptimistic()
isOptimistic in interface Usecasetrue if the transaction policy is optimistic offline lock,
false if it is pessimistic offline lock.
public void configure(org.apache.avalon.framework.configuration.Configuration config)
throws org.apache.avalon.framework.configuration.ConfigurationException
configure in interface org.apache.avalon.framework.configuration.Configurableorg.apache.avalon.framework.configuration.ConfigurationExceptionConfigurable.configure(org.apache.avalon.framework.configuration.Configuration)public void setView(UsecaseView view)
setView in interface Usecaseview - The view of the usecase.Usecase.setView(org.apache.lenya.cms.usecase.UsecaseView)
protected org.apache.lenya.cms.repository.Node[] getNodesToLock()
throws UsecaseException
UsecaseException - if an error occurs.
public final void lockInvolvedObjects()
throws UsecaseException
This method starts the transaction and locks all involved objects immediately. This way, all changes to the objects in the session occur after the locking, avoiding overriding changes of other sessions.
This method is locked via the class lock to avoid inter-usecase synchronization issues.
lockInvolvedObjects in interface UsecaseUsecaseException - if an error occurs.Usecase.lockInvolvedObjects()
protected void startTransaction()
throws org.apache.lenya.cms.repository.RepositoryException
org.apache.lenya.cms.repository.RepositoryException - if an error occurs.
public final void lockInvolvedObjects(org.apache.lenya.cms.repository.Node[] objects)
throws UsecaseException
Lock the objects, for example when you need to change them (for example, delete). If you know when entering the usecase what these objects are, you do not need to call this, the framework will take of it if you implement getObjectsToLock(). If you do not know in advance what the objects are, you can call this method explicitly when appropriate.
objects - the transactionable objects to lock
UsecaseException - if an error occurs.lockInvolvedObjects(),
getNodesToLock()
protected boolean canCheckOut(org.apache.lenya.cms.repository.Node[] objects)
throws org.apache.lenya.cms.repository.RepositoryException
org.apache.lenya.cms.repository.RepositoryException
public void cancel()
throws UsecaseException
Usecase
cancel in interface UsecaseUsecaseException - if an error occurs.Usecase.cancel()
protected void setExitParameter(java.lang.String name,
java.lang.String value)
name - The parameter name.value - The parameter value.protected java.lang.String getExitQueryString()
?lenya.usecase=...¶m1=foo¶m2=bar.public org.apache.lenya.cms.repository.Session getSession()
getSession in interface Usecase
public void contextualize(org.apache.avalon.framework.context.Context context)
throws org.apache.avalon.framework.context.ContextException
contextualize in interface org.apache.avalon.framework.context.Contextualizableorg.apache.avalon.framework.context.ContextExceptionContextualizable.contextualize(org.apache.avalon.framework.context.Context)
public void service(org.apache.avalon.framework.service.ServiceManager manager)
throws org.apache.avalon.framework.service.ServiceException
service in interface org.apache.avalon.framework.service.Serviceableorg.apache.avalon.framework.service.ServiceExceptionprotected void setSession(org.apache.lenya.cms.repository.Session session)
public void setTestSession(org.apache.lenya.cms.repository.Session session)
Usecase
setTestSession in interface Usecasesession - The test session.protected boolean checkoutRestrictedToSession()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||