Author: ajaquith
Date: Thu May 22 21:08:55 2008
New Revision: 659409
URL: http://svn.apache.org/viewvc?rev=659409&view=rev
Log:
Miscellaneous and varied Java 5 enhancements (such as for-loops).
Modified:
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/AbstractStep.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/Decision.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/DecisionQueue.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/DecisionRequiredException.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/NoSuchOutcomeException.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/Outcome.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/SimpleDecision.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/SimpleNotification.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/Step.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/SystemPrincipal.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/Task.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/Workflow.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/WorkflowBuilder.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/WorkflowManager.java
Modified:
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/AbstractStep.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/AbstractStep.java?rev=659409&r1=659408&r2=659409&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/AbstractStep.java
(original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/AbstractStep.java
Thu May 22 21:08:55 2008
@@ -46,13 +46,13 @@
private boolean m_completed;
- private final Map m_successors;
+ private final Map<Outcome, Step> m_successors;
private Workflow m_workflow;
private Outcome m_outcome;
- private final List m_errors;
+ private final List<String> m_errors;
private boolean m_started;
@@ -74,10 +74,10 @@
m_start = Workflow.TIME_NOT_SET;
m_completed = false;
m_end = Workflow.TIME_NOT_SET;
- m_errors = new ArrayList();
+ m_errors = new ArrayList<String>();
m_outcome = Outcome.STEP_CONTINUE;
m_key = messageKey;
- m_successors = new LinkedHashMap();
+ m_successors = new LinkedHashMap<Outcome, Step>();
}
/**
@@ -112,7 +112,7 @@
*/
public final Collection getAvailableOutcomes()
{
- Set outcomes = m_successors.keySet();
+ Set<Outcome> outcomes = m_successors.keySet();
return Collections.unmodifiableCollection( outcomes );
}
Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/Decision.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/Decision.java?rev=659409&r1=659408&r2=659409&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/Decision.java
(original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/Decision.java Thu
May 22 21:08:55 2008
@@ -62,7 +62,7 @@
private final Outcome m_defaultOutcome;
- private final List m_facts;
+ private final List<Fact> m_facts;
/**
* Constructs a new Decision for a required "actor" Principal, having a
default Outcome.
@@ -78,7 +78,7 @@
super(workflow, messageKey);
m_actor = actor;
m_defaultOutcome = defaultOutcome;
- m_facts = new ArrayList();
+ m_facts = new ArrayList<Fact>();
addSuccessor(defaultOutcome, null);
}
Modified:
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/DecisionQueue.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/DecisionQueue.java?rev=659409&r1=659408&r2=659409&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/DecisionQueue.java
(original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/DecisionQueue.java
Thu May 22 21:08:55 2008
@@ -23,7 +23,6 @@
import java.security.Principal;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Iterator;
import java.util.LinkedList;
import com.ecyrd.jspwiki.WikiException;
@@ -39,7 +38,7 @@
public class DecisionQueue
{
- private LinkedList m_queue = new LinkedList();
+ private LinkedList<Decision> m_queue = new LinkedList<Decision>();
private volatile int m_next;
@@ -58,10 +57,10 @@
* @param decision
* the Decision to add
*/
- protected synchronized void add(Decision decision)
+ protected synchronized void add( Decision decision )
{
- m_queue.addLast(decision);
- decision.setId(nextId());
+ m_queue.addLast( decision );
+ decision.setId( nextId() );
}
/**
@@ -74,7 +73,7 @@
*/
protected Decision[] decisions()
{
- return (Decision[]) m_queue.toArray(new Decision[m_queue.size()]);
+ return m_queue.toArray( new Decision[m_queue.size()] );
}
/**
@@ -83,7 +82,7 @@
*/
protected synchronized void remove(Decision decision)
{
- m_queue.remove(decision);
+ m_queue.remove( decision );
}
/**
@@ -99,29 +98,27 @@
*/
public Collection getActorDecisions(WikiSession session)
{
- ArrayList decisions = new ArrayList();
- if (session.isAuthenticated())
+ ArrayList<Decision> decisions = new ArrayList<Decision>();
+ if ( session.isAuthenticated() )
{
Principal[] principals = session.getPrincipals();
Principal[] rolePrincipals = session.getRoles();
- for (Iterator it = m_queue.iterator(); it.hasNext();)
+ for ( Decision decision : m_queue )
{
- Decision decision = (Decision) it.next();
-
// Iterate through the Principal set
- for (int i = 0; i < principals.length; i++)
+ for ( Principal principal : principals )
{
- if (principals[i].equals(decision.getActor()))
+ if ( principal.equals( decision.getActor() ) )
{
- decisions.add(decision);
+ decisions.add( decision );
}
}
// Iterate through the Role set
- for (int i = 0; i < rolePrincipals.length; i++)
+ for ( Principal principal : rolePrincipals )
{
- if (rolePrincipals[i].equals(decision.getActor()))
+ if ( principal.equals( decision.getActor() ) )
{
- decisions.add(decision);
+ decisions.add( decision );
}
}
}
@@ -141,12 +138,12 @@
* @throws WikiException if the succeeding Step cannot start
* for any reason
*/
- public void decide(Decision decision, Outcome outcome) throws WikiException
+ public void decide( Decision decision, Outcome outcome ) throws
WikiException
{
- decision.decide(outcome);
- if (decision.isCompleted())
+ decision.decide( outcome );
+ if ( decision.isCompleted() )
{
- remove(decision);
+ remove( decision );
}
// TODO: We should fire an event indicating the Outcome, and whether
the
@@ -165,12 +162,12 @@
{
if (decision.isReassignable())
{
- decision.reassign(owner);
+ decision.reassign( owner );
// TODO: We should fire an event indicating the reassignment
return;
}
- throw new IllegalStateException("Reassignments not allowed for this
decision.");
+ throw new IllegalStateException( "Reassignments not allowed for this
decision." );
}
/**
Modified:
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/DecisionRequiredException.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/DecisionRequiredException.java?rev=659409&r1=659408&r2=659409&view=diff
==============================================================================
---
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/DecisionRequiredException.java
(original)
+++
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/DecisionRequiredException.java
Thu May 22 21:08:55 2008
@@ -40,8 +40,8 @@
* Constructs a new exception.
* @param message the message
*/
- public DecisionRequiredException(String message)
+ public DecisionRequiredException( String message )
{
- super(message);
+ super( message );
}
}
Modified:
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/NoSuchOutcomeException.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/NoSuchOutcomeException.java?rev=659409&r1=659408&r2=659409&view=diff
==============================================================================
---
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/NoSuchOutcomeException.java
(original)
+++
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/NoSuchOutcomeException.java
Thu May 22 21:08:55 2008
@@ -35,8 +35,8 @@
* Constructs a new exception.
* @param message the message
*/
- public NoSuchOutcomeException(String message)
+ public NoSuchOutcomeException( String message )
{
- super(message);
+ super( message );
}
}
Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/Outcome.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/Outcome.java?rev=659409&r1=659408&r2=659409&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/Outcome.java
(original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/Outcome.java Thu May
22 21:08:55 2008
@@ -31,28 +31,28 @@
{
/** Complete workflow step (without errors) */
- public static final Outcome STEP_COMPLETE = new
Outcome("outcome.step.complete", true);
+ public static final Outcome STEP_COMPLETE = new Outcome(
"outcome.step.complete", true );
/** Terminate workflow step (without errors) */
- public static final Outcome STEP_ABORT = new Outcome("outcome.step.abort",
true);
+ public static final Outcome STEP_ABORT = new Outcome(
"outcome.step.abort", true );
/** Continue workflow step (without errors) */
- public static final Outcome STEP_CONTINUE = new
Outcome("outcome.step.continue", false);
+ public static final Outcome STEP_CONTINUE = new Outcome(
"outcome.step.continue", false );
/** Acknowlege the Decision. */
- public static final Outcome DECISION_ACKNOWLEDGE = new
Outcome("outcome.decision.acknowledge", true);
+ public static final Outcome DECISION_ACKNOWLEDGE = new Outcome(
"outcome.decision.acknowledge", true );
/** Approve the Decision (and complete the step). */
- public static final Outcome DECISION_APPROVE = new
Outcome("outcome.decision.approve", true);
+ public static final Outcome DECISION_APPROVE = new Outcome(
"outcome.decision.approve", true );
/** Deny the Decision (and complete the step). */
- public static final Outcome DECISION_DENY = new
Outcome("outcome.decision.deny", true);
+ public static final Outcome DECISION_DENY = new Outcome(
"outcome.decision.deny", true );
/** Put the Decision on hold (and pause the step). */
- public static final Outcome DECISION_HOLD = new
Outcome("outcome.decision.hold", false);
+ public static final Outcome DECISION_HOLD = new Outcome(
"outcome.decision.hold", false );
/** Reassign the Decision to another actor (and pause the step). */
- public static final Outcome DECISION_REASSIGN = new
Outcome("outcome.decision.reassign", false);
+ public static final Outcome DECISION_REASSIGN = new Outcome(
"outcome.decision.reassign", false );
private static final Outcome[] OUTCOMES = new Outcome[] { STEP_COMPLETE,
STEP_ABORT, STEP_CONTINUE, DECISION_ACKNOWLEDGE,
DECISION_APPROVE, DECISION_DENY, DECISION_HOLD, DECISION_REASSIGN };
@@ -70,11 +70,11 @@
* whether this Outcome should be interpreted as the logical
* completion of a Step.
*/
- private Outcome(String key, boolean completion)
+ private Outcome( String key, boolean completion )
{
- if (key == null)
+ if ( key == null )
{
- throw new IllegalArgumentException("Key cannot be null.");
+ throw new IllegalArgumentException( "Key cannot be null." );
}
m_key = key;
m_completion = completion;
@@ -111,7 +111,7 @@
*/
public int hashCode()
{
- return m_key.hashCode() * (m_completion ? 1 : 2);
+ return m_key.hashCode() * ( m_completion ? 1 : 2 );
}
/**
@@ -119,13 +119,13 @@
* @param obj the object to test
* @return <code>true</code> if logically equal, <code>false</code> if not
*/
- public boolean equals(Object obj)
+ public boolean equals( Object obj )
{
if (!(obj instanceof Outcome))
{
return false;
}
- return m_key.equals(((Outcome) obj).getMessageKey());
+ return m_key.equals( ( (Outcome) obj ).getMessageKey() );
}
/**
@@ -138,19 +138,19 @@
* @throws NoSuchOutcomeException
* if an Outcome matching the key isn't found.
*/
- public static Outcome forName(String key) throws NoSuchOutcomeException
+ public static Outcome forName( String key ) throws NoSuchOutcomeException
{
- if (key != null)
+ if ( key != null )
{
for (int i = 0; i < OUTCOMES.length; i++)
{
- if (OUTCOMES[i].m_key.equals(key))
+ if ( OUTCOMES[i].m_key.equals( key ) )
{
return OUTCOMES[i];
}
}
}
- throw new NoSuchOutcomeException("Outcome " + key + " not found.");
+ throw new NoSuchOutcomeException( "Outcome " + key + " not found." );
}
/**
Modified:
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/SimpleDecision.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/SimpleDecision.java?rev=659409&r1=659408&r2=659409&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/SimpleDecision.java
(original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/SimpleDecision.java
Thu May 22 21:08:55 2008
@@ -41,12 +41,12 @@
* @param actor the Principal (<em>e.g.</em>, WikiPrincipal,
* GroupPrincipal, Role) who will decide
*/
- public SimpleDecision(Workflow workflow, String messageKey, Principal
actor)
+ public SimpleDecision( Workflow workflow, String messageKey, Principal
actor )
{
- super(workflow, messageKey, actor, Outcome.DECISION_APPROVE);
+ super( workflow, messageKey, actor, Outcome.DECISION_APPROVE );
// Add the other default outcomes
- super.addSuccessor(Outcome.DECISION_DENY, null);
+ super.addSuccessor( Outcome.DECISION_DENY, null );
}
}
Modified:
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/SimpleNotification.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/SimpleNotification.java?rev=659409&r1=659408&r2=659409&view=diff
==============================================================================
---
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/SimpleNotification.java
(original)
+++
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/SimpleNotification.java
Thu May 22 21:08:55 2008
@@ -50,9 +50,9 @@
* @param actor
* the Principal who will acknowledge the message
*/
- public SimpleNotification(Workflow workflow, String messageKey, Principal
actor)
+ public SimpleNotification( Workflow workflow, String messageKey, Principal
actor )
{
- super(workflow, messageKey, actor, Outcome.DECISION_ACKNOWLEDGE);
+ super( workflow, messageKey, actor, Outcome.DECISION_ACKNOWLEDGE );
}
/**
@@ -62,7 +62,7 @@
*/
public void acknowledge() throws WikiException
{
- this.decide( Outcome.DECISION_ACKNOWLEDGE );
+ this.decide( Outcome.DECISION_ACKNOWLEDGE );
}
/**
Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/Step.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/Step.java?rev=659409&r1=659408&r2=659409&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/Step.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/Step.java Thu May 22
21:08:55 2008
@@ -76,7 +76,7 @@
* the Step to associated with this Outcomes (<code>null</code>
* denotes no Steps)
*/
- public void addSuccessor(Outcome outcome, Step step);
+ public void addSuccessor( Outcome outcome, Step step );
/**
* Returns a Collection of available outcomes, such as "approve", "deny" or
@@ -224,7 +224,7 @@
*
* @param outcome whether the step should be considered completed
*/
- public void setOutcome(Outcome outcome);
+ public void setOutcome( Outcome outcome );
/**
* Convenience method that returns the owner of the Workflow by delegating
@@ -242,6 +242,6 @@
* the outcome
* @return the next step
*/
- public Step getSuccessor(Outcome outcome);
+ public Step getSuccessor( Outcome outcome );
}
Modified:
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/SystemPrincipal.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/SystemPrincipal.java?rev=659409&r1=659408&r2=659409&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/SystemPrincipal.java
(original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/SystemPrincipal.java
Thu May 22 21:08:55 2008
@@ -30,7 +30,7 @@
public final class SystemPrincipal implements Principal
{
/** The JSPWiki system user */
- public static final Principal SYSTEM_USER = new SystemPrincipal("System
User");
+ public static final Principal SYSTEM_USER = new SystemPrincipal( "System
User" );
private final String m_name;
@@ -38,7 +38,7 @@
* Private constructor to prevent direct instantiation.
* @param name the name of the Principal
*/
- private SystemPrincipal(String name)
+ private SystemPrincipal( String name )
{
m_name = name;
}
Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/Task.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/Task.java?rev=659409&r1=659408&r2=659409&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/Task.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/Task.java Thu May 22
21:08:55 2008
@@ -55,8 +55,8 @@
public Task( String messageKey )
{
super( messageKey );
- super.addSuccessor(Outcome.STEP_COMPLETE, null);
- super.addSuccessor(Outcome.STEP_ABORT, null);
+ super.addSuccessor( Outcome.STEP_COMPLETE, null );
+ super.addSuccessor( Outcome.STEP_ABORT, null );
}
/**
@@ -68,7 +68,7 @@
* @param messageKey
* the i18n message key
*/
- public Task(Workflow workflow, String messageKey)
+ public Task( Workflow workflow, String messageKey )
{
this( messageKey );
setWorkflow( workflow );
@@ -93,7 +93,7 @@
* @param step
* the successor
*/
- public final synchronized void setSuccessor(Step step)
+ public final synchronized void setSuccessor( Step step )
{
m_successor = step;
}
Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/Workflow.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/Workflow.java?rev=659409&r1=659408&r2=659409&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/Workflow.java
(original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/Workflow.java Thu
May 22 21:08:55 2008
@@ -201,7 +201,7 @@
public class Workflow
{
/** Time value: the start or end time has not been set. */
- public static final Date TIME_NOT_SET = new Date(0);
+ public static final Date TIME_NOT_SET = new Date( 0 );
/** ID value: the workflow ID has not been set. */
public static final int ID_NOT_SET = 0;
@@ -225,7 +225,7 @@
public static final int CREATED = -2;
/** Lazily-initialized attribute map. */
- private Map m_attributes;
+ private Map<String, Object> m_attributes;
/** The initial Step for this Workflow. */
private Step m_firstStep;
@@ -233,7 +233,7 @@
/** Flag indicating whether the Workflow has started yet. */
private boolean m_started;
- private final LinkedList m_history;
+ private final LinkedList<Step> m_history;
private int m_id;
@@ -241,7 +241,7 @@
private final Principal m_owner;
- private final List m_messageArgs;
+ private final List<Object> m_messageArgs;
private int m_state;
@@ -268,11 +268,11 @@
super();
m_attributes = null;
m_currentStep = null;
- m_history = new LinkedList();
+ m_history = new LinkedList<Step>();
m_id = ID_NOT_SET;
m_key = messageKey;
m_manager = null;
- m_messageArgs = new ArrayList();
+ m_messageArgs = new ArrayList<Object>();
m_owner = owner;
m_started = false;
m_state = CREATED;
@@ -292,27 +292,27 @@
public final synchronized void abort()
{
// Check corner cases: previous abort or completion
- if (m_state == ABORTED)
+ if ( m_state == ABORTED )
{
- throw new IllegalStateException("The workflow has already been
aborted.");
+ throw new IllegalStateException( "The workflow has already been
aborted." );
}
- if (m_state == COMPLETED)
+ if ( m_state == COMPLETED )
{
- throw new IllegalStateException("The workflow has already
completed.");
+ throw new IllegalStateException( "The workflow has already
completed." );
}
- if (m_currentStep != null)
+ if ( m_currentStep != null )
{
- if (m_manager != null && m_currentStep instanceof Decision)
+ if ( m_manager != null && m_currentStep instanceof Decision )
{
Decision d = (Decision)m_currentStep;
- m_manager.getDecisionQueue().remove(d);
+ m_manager.getDecisionQueue().remove( d );
}
- m_currentStep.setOutcome(Outcome.STEP_ABORT);
- m_history.addLast(m_currentStep);
+ m_currentStep.setOutcome( Outcome.STEP_ABORT );
+ m_history.addLast( m_currentStep );
}
m_state = ABORTED;
- fireEvent(WorkflowEvent.ABORTED);
+ fireEvent( WorkflowEvent.ABORTED );
cleanup();
}
@@ -325,14 +325,14 @@
* an IllegalArgumentException.
* @param obj the object to add
*/
- public final void addMessageArgument(Object obj)
+ public final void addMessageArgument( Object obj )
{
- if (obj instanceof String || obj instanceof Date || obj instanceof
Number)
+ if ( obj instanceof String || obj instanceof Date || obj instanceof
Number )
{
- m_messageArgs.add(obj);
+ m_messageArgs.add( obj );
return;
}
- throw new IllegalArgumentException("Message arguments must be of type
String, Date or Number.");
+ throw new IllegalArgumentException( "Message arguments must be of type
String, Date or Number." );
}
/**
@@ -343,7 +343,7 @@
*/
public final synchronized Principal getCurrentActor()
{
- if (m_currentStep == null)
+ if ( m_currentStep == null )
{
return null;
}
@@ -380,13 +380,13 @@
* the name of the attribute
* @return the value
*/
- public final synchronized Object getAttribute(String attr)
+ public final synchronized Object getAttribute( String attr )
{
- if (m_attributes == null)
+ if ( m_attributes == null )
{
return null;
}
- return m_attributes.get(attr);
+ return m_attributes.get( attr );
}
/**
@@ -399,10 +399,10 @@
*/
public final Date getEndTime()
{
- if (isCompleted())
+ if ( isCompleted() )
{
- Step last = (Step) m_history.getLast();
- if (last != null)
+ Step last = m_history.getLast();
+ if ( last != null )
{
return last.getEndTime();
}
@@ -442,12 +442,12 @@
*/
public final Object[] getMessageArguments()
{
- List args = new ArrayList();
- args.add(m_owner.getName());
+ List<Object> args = new ArrayList<Object>();
+ args.add( m_owner.getName() );
Principal actor = getCurrentActor();
- args.add(actor == null ? "-" : actor.getName());
- args.addAll(m_messageArgs);
- return args.toArray(new Object[args.size()]);
+ args.add( actor == null ? "-" : actor.getName() );
+ args.addAll( m_messageArgs );
+ return args.toArray( new Object[args.size()] );
}
/**
@@ -506,7 +506,7 @@
*/
public final List getHistory()
{
- return Collections.unmodifiableList(m_history);
+ return Collections.unmodifiableList( m_history );
}
/**
@@ -555,7 +555,7 @@
*/
public final Step getPreviousStep()
{
- return previousStep(m_currentStep);
+ return previousStep( m_currentStep );
}
/**
@@ -569,12 +569,12 @@
*/
public final synchronized void restart() throws WikiException
{
- if (m_state != WAITING)
+ if ( m_state != WAITING )
{
- throw new IllegalStateException("Workflow is not paused; cannot
restart.");
+ throw new IllegalStateException( "Workflow is not paused; cannot
restart." );
}
m_state = RUNNING;
- fireEvent(WorkflowEvent.RUNNING);
+ fireEvent( WorkflowEvent.RUNNING );
// Process current step
try
@@ -601,11 +601,11 @@
*/
public final synchronized void setAttribute(String attr, Object obj)
{
- if (m_attributes == null)
+ if ( m_attributes == null )
{
- m_attributes = new HashMap();
+ m_attributes = new HashMap<String, Object>();
}
- m_attributes.put(attr, obj);
+ m_attributes.put( attr, obj );
}
/**
@@ -628,7 +628,7 @@
* @param id
* the unique identifier
*/
- public final synchronized void setId(int id)
+ public final synchronized void setId( int id )
{
this.m_id = id;
}
@@ -639,10 +639,10 @@
* @param manager
* the workflow manager
*/
- public final synchronized void setWorkflowManager(WorkflowManager manager)
+ public final synchronized void setWorkflowManager( WorkflowManager manager
)
{
m_manager = manager;
- addWikiEventListener(manager);
+ addWikiEventListener( manager );
}
/**
@@ -656,21 +656,21 @@
*/
public final synchronized void start() throws WikiException
{
- if (m_state == ABORTED)
+ if ( m_state == ABORTED )
{
- throw new IllegalStateException("Workflow cannot be started; it
has already been aborted.");
+ throw new IllegalStateException( "Workflow cannot be started; it
has already been aborted." );
}
- if (m_started)
+ if ( m_started )
{
- throw new IllegalStateException("Workflow has already started.");
+ throw new IllegalStateException( "Workflow has already started." );
}
m_started = true;
m_state = RUNNING;
- fireEvent(WorkflowEvent.RUNNING);
+ fireEvent( WorkflowEvent.RUNNING );
// Mark the first step as the current one & add to history
m_currentStep = m_firstStep;
- m_history.add(m_currentStep);
+ m_history.add( m_currentStep );
// Process current step
try
@@ -692,12 +692,12 @@
*/
public final synchronized void waitstate()
{
- if (m_state != RUNNING)
+ if ( m_state != RUNNING )
{
- throw new IllegalStateException("Workflow is not running; cannot
pause.");
+ throw new IllegalStateException( "Workflow is not running; cannot
pause." );
}
m_state = WAITING;
- fireEvent(WorkflowEvent.WAITING);
+ fireEvent( WorkflowEvent.WAITING );
}
/**
@@ -721,7 +721,7 @@
if ( !isCompleted() )
{
m_state = COMPLETED;
- fireEvent(WorkflowEvent.COMPLETED);
+ fireEvent( WorkflowEvent.COMPLETED );
cleanup();
}
}
@@ -736,8 +736,8 @@
*/
protected final Step previousStep(Step step)
{
- int index = m_history.indexOf(step);
- return index < 1 ? null : (Step) m_history.get(index - 1);
+ int index = m_history.indexOf( step );
+ return index < 1 ? null : m_history.get( index - 1 );
}
/**
@@ -750,29 +750,29 @@
*/
protected final void processCurrentStep() throws WikiException
{
- while (m_currentStep != null)
+ while ( m_currentStep != null )
{
// Start and execute the current step
- if (!m_currentStep.isStarted())
+ if ( !m_currentStep.isStarted() )
{
m_currentStep.start();
}
try
{
Outcome result = m_currentStep.execute();
- if (Outcome.STEP_ABORT.equals(result))
+ if ( Outcome.STEP_ABORT.equals( result ) )
{
abort();
break;
}
- if (!m_currentStep.isCompleted())
+ if ( !m_currentStep.isCompleted() )
{
- m_currentStep.setOutcome(result);
+ m_currentStep.setOutcome( result );
}
}
- catch (WikiException e)
+ catch ( WikiException e )
{
throw e;
}
@@ -780,22 +780,22 @@
// Get the execution Outcome; if not complete, pause workflow and
// exit
Outcome outcome = m_currentStep.getOutcome();
- if (!outcome.isCompletion())
+ if ( !outcome.isCompletion() )
{
waitstate();
break;
}
// Get the next Step; if null, we're done
- Step nextStep = m_currentStep.getSuccessor(outcome);
- if (nextStep == null)
+ Step nextStep = m_currentStep.getSuccessor( outcome );
+ if ( nextStep == null )
{
complete();
break;
}
// Add the next step to Workflow history, and mark as current
- m_history.add(nextStep);
+ m_history.add( nextStep );
m_currentStep = nextStep;
}
@@ -810,9 +810,9 @@
* @param listener
* the event listener
*/
- public final synchronized void addWikiEventListener(WikiEventListener
listener)
+ public final synchronized void addWikiEventListener( WikiEventListener
listener )
{
- WikiEventManager.addWikiEventListener(this, listener);
+ WikiEventManager.addWikiEventListener( this, listener );
}
/**
@@ -822,9 +822,9 @@
* @param listener
* the event listener
*/
- public final synchronized void removeWikiEventListener(WikiEventListener
listener)
+ public final synchronized void removeWikiEventListener( WikiEventListener
listener )
{
- WikiEventManager.removeWikiEventListener(this, listener);
+ WikiEventManager.removeWikiEventListener( this, listener );
}
/**
@@ -834,11 +834,11 @@
* @param type
* the event type to be fired
*/
- protected final void fireEvent(int type)
+ protected final void fireEvent( int type )
{
- if (WikiEventManager.isListening(this))
+ if ( WikiEventManager.isListening( this ) )
{
- WikiEventManager.fireEvent(this, new WorkflowEvent(this, type));
+ WikiEventManager.fireEvent( this, new WorkflowEvent( this, type )
);
}
}
Modified:
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/WorkflowBuilder.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/WorkflowBuilder.java?rev=659409&r1=659408&r2=659409&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/WorkflowBuilder.java
(original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/WorkflowBuilder.java
Thu May 22 21:08:55 2008
@@ -33,7 +33,7 @@
*/
public final class WorkflowBuilder
{
- private static final Map BUILDERS = new HashMap();
+ private static final Map<WikiEngine, WorkflowBuilder> BUILDERS = new
HashMap<WikiEngine, WorkflowBuilder>();
private final WikiEngine m_engine;
/**
@@ -53,7 +53,7 @@
*/
public static WorkflowBuilder getBuilder( WikiEngine engine )
{
- WorkflowBuilder builder = (WorkflowBuilder)BUILDERS.get( engine );
+ WorkflowBuilder builder = BUILDERS.get( engine );
if ( builder == null )
{
builder = new WorkflowBuilder( engine );
@@ -130,9 +130,9 @@
// Add facts to the Decision, if any were supplied
if ( facts != null )
{
- for ( int i = 0; i < facts.length; i++ )
+ for ( Fact fact: facts )
{
- decision.addFact( facts[i] );
+ decision.addFact( fact );
}
// Add the first one as a message key
if ( facts.length > 0 )
Modified:
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/WorkflowManager.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/WorkflowManager.java?rev=659409&r1=659408&r2=659409&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/WorkflowManager.java
(original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/workflow/WorkflowManager.java
Thu May 22 21:08:55 2008
@@ -45,11 +45,11 @@
private final DecisionQueue m_queue = new DecisionQueue();
- private final Set m_workflows;
+ private final Set<Workflow> m_workflows;
- private final Map m_approvers;
+ private final Map<String, Principal> m_approvers;
- private final List m_completed;
+ private final List<Workflow> m_completed;
/** The prefix to use for looking up <code>jspwiki.properties</code>
approval roles. */
protected static final String PROPERTY_APPROVER_PREFIX =
"jspwiki.approver.";
@@ -61,9 +61,9 @@
public WorkflowManager()
{
m_next = 1;
- m_workflows = new HashSet();
- m_approvers = new HashMap();
- m_completed = new ArrayList();
+ m_workflows = new HashSet<Workflow>();
+ m_approvers = new HashMap<String, Principal>();
+ m_completed = new ArrayList<Workflow>();
}
/**
@@ -89,7 +89,7 @@
*/
public Collection getWorkflows()
{
- return new HashSet( m_workflows );
+ return new HashSet<Workflow>( m_workflows );
}
/**
@@ -98,7 +98,7 @@
*/
public List getCompletedWorkflows()
{
- return new ArrayList( m_completed );
+ return new ArrayList<Workflow>( m_completed );
}
private WikiEngine m_engine = null;
@@ -123,7 +123,7 @@
m_engine = engine;
// Identify the workflows requiring approvals
- for ( Iterator it = props.keySet().iterator(); it.hasNext(); )
+ for ( Iterator<?> it = props.keySet().iterator(); it.hasNext(); )
{
String prop = (String) it.next();
if ( prop.startsWith( PROPERTY_APPROVER_PREFIX ) )
@@ -172,7 +172,7 @@
*/
public Principal getApprover( String messageKey ) throws WikiException
{
- Principal approver = (Principal) m_approvers.get( messageKey );
+ Principal approver = m_approvers.get( messageKey );
if ( approver == null )
{
throw new WikiException( "Workflow '" + messageKey + "' does not
require approval." );
@@ -243,19 +243,18 @@
* @param session the wiki session
* @return the collection workflows the wiki session owns, which may be
empty
*/
- public Collection getOwnerWorkflows(WikiSession session)
+ public Collection getOwnerWorkflows( WikiSession session )
{
- List workflows = new ArrayList();
+ List<Workflow> workflows = new ArrayList<Workflow>();
if ( session.isAuthenticated() )
{
Principal[] sessionPrincipals = session.getPrincipals();
- for ( Iterator it = m_workflows.iterator(); it.hasNext(); )
+ for ( Workflow w : m_workflows )
{
- Workflow w = (Workflow)it.next();
Principal owner = w.getOwner();
- for ( int i = 0; i < sessionPrincipals.length; i++ )
+ for ( Principal sessionPrincipal : sessionPrincipals )
{
- if ( sessionPrincipals[i].equals(owner) )
+ if ( sessionPrincipal.equals( owner ) )
{
workflows.add( w );
break;