Author: andreas
Date: Sun Aug 12 05:06:16 2007
New Revision: 565039
URL: http://svn.apache.org/viewvc?view=rev&rev=565039
Log:
Advance state machine in AbstractUsecase after corresponding method succeeded
Modified:
lenya/trunk/src/modules-core/usecase/java/src/org/apache/lenya/cms/usecase/AbstractUsecase.java
Modified: lenya/trunk/src/modules-core/usecase/java/src/org/apache/lenya/cms/usecase/AbstractUsecase.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/usecase/java/src/org/apache/lenya/cms/usecase/AbstractUsecase.java?view=diff&rev=565039&r1=565038&r2=565039
==============================================================================
--- lenya/trunk/src/modules-core/usecase/java/src/org/apache/lenya/cms/usecase/AbstractUsecase.java (original)
+++ lenya/trunk/src/modules-core/usecase/java/src/org/apache/lenya/cms/usecase/AbstractUsecase.java Sun Aug 12 05:06:16 2007
@@ -81,6 +81,12 @@
protected void initParameters() {
}
+ /**
+ * Advance the usecase state machine to the next state. This method has to be
+ * called at the end of the corresponding method to ensure that the subsequent
+ * methods can only be invoked if nothing went wrong.
+ * @param event The vent to invoke.
+ */
protected void advanceState(String event) {
StateMachine machine = (StateMachine) getParameter(PARAMETER_STATE_MACHINE);
machine.invoke(event);
@@ -283,7 +289,6 @@
* @see org.apache.lenya.cms.usecase.Usecase#execute()
*/
public final void execute() throws UsecaseException {
- advanceState("execute");
Exception exception = null;
try {
clearErrorMessages();
@@ -315,6 +320,7 @@
+ " (see logfiles for details)");
}
}
+ advanceState("execute");
}
/**
@@ -331,7 +337,6 @@
* @see org.apache.lenya.cms.usecase.Usecase#checkPostconditions()
*/
public void checkPostconditions() throws UsecaseException {
- advanceState("checkPostconditions");
try {
clearErrorMessages();
clearInfoMessages();
@@ -344,6 +349,7 @@
throw new UsecaseException(e);
}
}
+ advanceState("checkPostconditions");
}
/**
@@ -545,8 +551,9 @@
protected DocumentFactory getDocumentFactory() {
DocumentFactory factory = (DocumentFactory) getParameter(PARAMETER_FACTORY);
- if (factory == null || factory.getSession() != getSession()) {
- factory = DocumentUtil.createDocumentFactory(this.manager, getSession());
+ Session session = getSession();
+ if (factory == null || factory.getSession() != session) {
+ factory = DocumentUtil.createDocumentFactory(this.manager, session);
setParameter(PARAMETER_FACTORY, factory);
}
return factory;
@@ -737,7 +744,6 @@
* @see org.apache.lenya.cms.usecase.Usecase#lockInvolvedObjects()
*/
public final void lockInvolvedObjects() throws UsecaseException {
- advanceState("lockInvolvedObjects");
try {
startTransaction();
} catch (RepositoryException e) {
@@ -746,6 +752,7 @@
synchronized (TransactionLock.LOCK) {
lockInvolvedObjects(getNodesToLock());
}
+ advanceState("lockInvolvedObjects");
}
protected void startTransaction() throws RepositoryException {
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.