lenya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andr...@apache.org
Subject cvs commit: cocoon-lenya/src/java/org/apache/lenya/workflow/impl History.java
Date Tue, 05 Aug 2003 12:01:15 GMT
andreas     2003/08/05 05:01:15

  Modified:    src/java/org/apache/lenya/workflow/impl History.java
  Log:
  added getWorkflowId() methods
  
  Revision  Changes    Path
  1.8       +54 -15    cocoon-lenya/src/java/org/apache/lenya/workflow/impl/History.java
  
  Index: History.java
  ===================================================================
  RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/workflow/impl/History.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- History.java	23 Jul 2003 13:21:08 -0000	1.7
  +++ History.java	5 Aug 2003 12:01:15 -0000	1.8
  @@ -96,8 +96,8 @@
   
       /**
        * Creates a new history object. A new history file is created and initialized.
  -     * @param file The history file.
  -     * @param workflowFileName The workflow reference.
  +     * @param workflowId The workflow ID.
  +     * @throws WorkflowException when something went wrong.
        */
       public void initialize(String workflowId) throws WorkflowException {
           try {
  @@ -128,10 +128,49 @@
       }
   
       private WorkflowInstanceImpl instance = null;
  +    private String workflowId = null;
  +    
  +    /**
  +     * Returns the namespace helper for the history file.
  +     * @return A namespace helper.
  +     * @throws WorkflowException It the helper could not be obtained.
  +     */
  +    protected NamespaceHelper getNamespaceHelper() throws WorkflowException {
  +        NamespaceHelper helper;
  +        try {
  +            Document document = DocumentHelper.readDocument(getHistoryFile());
  +            helper = new NamespaceHelper(Workflow.NAMESPACE, Workflow.DEFAULT_PREFIX, document);
  +        } catch (Exception e) {
  +            throw new WorkflowException(e);
  +        }
  +        return helper;
  +    }
  +    
  +    /**
  +     * Returns the workflow ID for this history.
  +     * @return A string.
  +     * @throws WorkflowException when something went wrong.
  +     */
  +    protected String getWorkflowId() throws WorkflowException {
  +        return getWorkflowId(getNamespaceHelper());
  +    }
  +
  +    /**
  +     * Returns the workflow ID for this history.
  +     * @param helper The namespace helper for the history document.
  +     * @return A string.
  +     * @throws WorkflowException when something went wrong.
  +     */
  +    protected String getWorkflowId(NamespaceHelper helper) throws WorkflowException {
  +        if (workflowId == null) {
  +            workflowId = helper.getDocument().getDocumentElement().getAttribute(WORKFLOW_ATTRIBUTE);
  +        }
  +        return workflowId;
  +    }
   
       /**
        * Restores the workflow, state and variables of a workflow instance from this history.
  -     * @param instance The workflow instance to restore.
  +     * @return The workflow instance to restore.
        * @throws WorkflowException if something goes wrong.
        */
       public WorkflowInstanceImpl getInstance() throws WorkflowException {
  @@ -141,18 +180,9 @@
               }
   
               WorkflowInstanceImpl instance = createInstance();
  -            NamespaceHelper helper;
  -            String workflowId;
  -
  -            try {
  -                Document document = DocumentHelper.readDocument(getHistoryFile());
  -                helper = new NamespaceHelper(Workflow.NAMESPACE, Workflow.DEFAULT_PREFIX,
document);
  -            } catch (Exception e) {
  -                throw new WorkflowException(e);
  -            }
  -
  -            workflowId = helper.getDocument().getDocumentElement().getAttribute(WORKFLOW_ATTRIBUTE);
  +            NamespaceHelper helper = getNamespaceHelper();
   
  +            String workflowId = getWorkflowId(helper);
               if (null == workflowId) {
                   throw new WorkflowException("No workflow attribute set in history document!");
               }
  @@ -186,10 +216,19 @@
       /**
        * Factory method to create a workflow instance object.
        * @return A workflow instance object.
  +     * @throws WorkflowException if something goes wrong.
        */
       protected abstract WorkflowInstanceImpl createInstance()
           throws WorkflowException;
   
  +    /**
  +     * Creates a new version element. This method is called after a tansition invocation.
  +     * @param helper The namespace helper of the history document.
  +     * @param state The state of the new version.
  +     * @param situation The current situation.
  +     * @param event The event that was invoked.
  +     * @return An XML element.
  +     */
       protected Element createVersionElement(NamespaceHelper helper, StateImpl state,
           Situation situation, Event event) {
           Element versionElement = helper.createElement(VERSION_ELEMENT);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-cvs-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-cvs-help@cocoon.apache.org


Mime
View raw message