You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by ep...@apache.org on 2003/09/26 17:22:03 UTC

cvs commit: jakarta-turbine-fulcrum/osworkflow/example/src/java/org/apache/fulcrum/osworkflow/example/tools WorkflowTool.java

epugh       2003/09/26 08:22:03

  Added:       osworkflow/example/src/java/org/apache/fulcrum/osworkflow/example/modules/actions
                        Index.java WorkflowAction.java
               osworkflow/example/src/java/org/apache/fulcrum/osworkflow/example/tools
                        WorkflowTool.java
  Log:
  Add in renamed code.
  
  Revision  Changes    Path
  1.1                  jakarta-turbine-fulcrum/osworkflow/example/src/java/org/apache/fulcrum/osworkflow/example/modules/actions/Index.java
  
  Index: Index.java
  ===================================================================
  package org.apache.fulcrum.osworkflow.example.modules.actions;
  
  import org.apache.turbine.modules.actions.VelocityAction;
  import org.apache.turbine.util.RunData;
  import org.apache.velocity.context.Context;
  
  
  
  /**
   * @author     <a href="mailto:epugh@upstate.com">Eric Pugh</a>
   * @created    October 11, 2002
   */
  public class Index extends VelocityAction {
  
  	/**
  	 *  Default action is to load up the default template and list out the locations to go to:
  	 <ol><li>Inventory Add Request<li>Inventory Delete Request<li>General Admin of Request</ol>
  	 *
  	 * @param  data           Current RunData information
  	 * @param  context        Context to populate
  	 * @exception  Exception  Thrown on error
  	 */
  	public void doPerform(RunData data, Context context) throws Exception {
  
  		System.out.println("Doperform called");
  		data.setScreenTemplate("Index.vm");
  
  	}
  
  	
  	
  
  }
  
  
  
  1.1                  jakarta-turbine-fulcrum/osworkflow/example/src/java/org/apache/fulcrum/osworkflow/example/modules/actions/WorkflowAction.java
  
  Index: WorkflowAction.java
  ===================================================================
  package org.apache.fulcrum.osworkflow.example.modules.actions;
  import java.util.Collections;
  
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.apache.fulcrum.osworkflow.WorkflowInstance;
  import org.apache.fulcrum.osworkflow.WorkflowService;
  import org.apache.turbine.modules.actions.VelocityAction;
  import org.apache.turbine.services.InstantiationException;
  import org.apache.turbine.services.TurbineServices;
  import org.apache.turbine.services.avaloncomponent.AvalonComponentService;
  import org.apache.turbine.util.RunData;
  import org.apache.velocity.context.Context;
  import com.opensymphony.module.user.Group;
  import com.opensymphony.module.user.User;
  import com.opensymphony.module.user.UserManager;
  import com.opensymphony.workflow.Workflow;
  /**
   * @author     <a href="mailto:epugh@upstate.com">Eric Pugh</a>
   * @created    October 11, 2002
   */
  public class WorkflowAction extends VelocityAction
  {
      private static Log log = LogFactory.getLog(WorkflowAction.class);
      private WorkflowService workflowService;
      /**
       *  This guy deals with actions related to workflows.
       *
       * @param  data           Current RunData information
       * @param  context        Context to populate
       * @exception  Exception  Thrown on error
       */
      public void doPerform(RunData data, Context context) throws Exception
      {
          System.out.println("Doperform called");
          data.setScreenTemplate("Index.vm");
      }
      
  	/**
  		 *  This sets logs you in as user "test"
  		 *
  		 * @param  data           Current RunData information
  		 * @param  context        Context to populate
  		 * @exception  Exception  Thrown on error
  		 */
  		public void doLogin(RunData data, Context context) throws Exception
  		{
  			data.getUser().setName("test");
  	
          
  			data.getMessages().setMessage("", "INFO", "You are logged in as user test!");
  		}
      
      /**
       *  This sets up the user "test/test"
       *
       * @param  data           Current RunData information
       * @param  context        Context to populate
       * @exception  Exception  Thrown on error
       */
      public void doSetupuser(RunData data, Context context) throws Exception
      {
  	
          data.setScreenTemplate("Index.vm");
          UserManager um = UserManager.getInstance();
          User test = um.createUser("test");
          test.setPassword("test");
          Group foos = um.createGroup("foos");
          Group bars = um.createGroup("bars");
          Group bazs = um.createGroup("bazs");
          test.addToGroup(foos);
          test.addToGroup(bars);
          test.addToGroup(bazs);
          
          data.getMessages().setMessage("", "INFO", "User test/test is setup in system.  Don't forget to login!");
      }
      
      
      /**
       *  Create a new Workflow
       *
       * @param  data           Current RunData information
       * @param  context        Context to populate
       * @exception  Exception  Thrown on error
       */
      public void doNew(RunData data, Context context) throws Exception
      {
          System.out.println("doNew called");
          data.setScreenTemplate("Index.vm");
          try
          {
              Workflow wf = getWorkflowService().retrieveWorkflow(data.getUser().getName());
              long id = wf.initialize("example", 1, null);
              data.getMessages().setMessage("", "INFO", "New Workflow id " + id + " created and initialized!");
          }
          catch (Exception e)
          {
              log.error(e);
              data.getMessages().setMessage("", "ERROR", e.getMessage());
          }
      }
      /**
          *  Create a new Workflow
          *
          * @param  data           Current RunData information
          * @param  context        Context to populate
          * @exception  Exception  Thrown on error
          */
      public void doViewdetail(RunData data, Context context) throws Exception
      {
          System.out.println("doViewdetail called");
          data.setScreenTemplate("WorkflowDetail.vm");
          try
          {
              context.put("wf", getWorkflowInstance(data, context));
          }
          catch (Exception e)
          {
              log.error(e);
              data.getMessages().setMessage("", "ERROR", e.getMessage());
          }
      }
      /**
          * Lazy load the WorkflowService.
          * @return a fulcrum WorkflowService
          */
      public WorkflowService getWorkflowService()
      {
          if (workflowService == null)
          {
              AvalonComponentService acs =
                  (AvalonComponentService) TurbineServices.getInstance().getService(AvalonComponentService.SERVICE_NAME);
              try
              {
                  workflowService = (WorkflowService) acs.lookup(WorkflowService.ROLE);
              }
              catch (ComponentException ce)
              {
                  throw new InstantiationException("Problem looking up Workflow Service:" + ce.getMessage());
              }
          }
          return workflowService;
      }
      /**
          *  Perform an action
          *
          * @param  data           Current RunData information
          * @param  context        Context to populate
          * @exception  Exception  Thrown on error
          */
      public void doAction(RunData data, Context context) throws Exception
      {
          
          try
          {
              WorkflowInstance wf = getWorkflowInstance(data, context);
              int action = data.getParameters().getInt("actionId");
              wf.doAction(action, Collections.EMPTY_MAP);
          
          }
          catch (Exception e)
          {
              log.error(e);
              data.getMessages().setMessage("", "ERROR", e.getMessage());
          }
          doViewdetail(data,context);
      }
      protected WorkflowInstance getWorkflowInstance(RunData data, Context context)
      {
          long workflowId = data.getParameters().getLong("id");
          Workflow workflow = getWorkflowService().retrieveWorkflow(data.getUser().getName());
          WorkflowInstance wf = new WorkflowInstance(workflow, workflowId);
          return wf;
      }
  }
  
  
  
  1.1                  jakarta-turbine-fulcrum/osworkflow/example/src/java/org/apache/fulcrum/osworkflow/example/tools/WorkflowTool.java
  
  Index: WorkflowTool.java
  ===================================================================
  package org.apache.fulcrum.osworkflow.example.tools;
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Turbine" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Turbine", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  
  import java.util.ArrayList;
  import java.util.List;
  
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.apache.fulcrum.osworkflow.WorkflowInstance;
  import org.apache.fulcrum.osworkflow.WorkflowService;
  import org.apache.turbine.om.security.User;
  import org.apache.turbine.services.InstantiationException;
  import org.apache.turbine.services.TurbineServices;
  import org.apache.turbine.services.avaloncomponent.AvalonComponentService;
  import org.apache.turbine.services.pull.ApplicationTool;
  import org.apache.turbine.util.RunData;
  
  import com.opensymphony.workflow.Workflow;
  import com.opensymphony.workflow.WorkflowException;
  /**
   * A pull tool which provides lookups of workflows by delegating
   * to the configured Fulcrum <code>WorkflowService</code>.
   *
   * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
   */
  public class WorkflowTool implements ApplicationTool
  {
      /** Logging */
      private static Log log = LogFactory.getLog(WorkflowTool.class);
      /** Fulcrum Localization component */
      private WorkflowService workflowService;
      private User user;
  
  
      /**
       * Lazy load the WorkflowService.
       * @return a fulcrum WorkflowService
       */
      public WorkflowService getWorkflowService()
      {
          if (workflowService == null)
          {
              AvalonComponentService acs =
                  (AvalonComponentService) TurbineServices.getInstance().getService(AvalonComponentService.SERVICE_NAME);
                  try {
              workflowService = (WorkflowService)acs.lookup(WorkflowService.ROLE);
                  }
                  catch (ComponentException ce) {
                      throw new InstantiationException("Problem looking up Localization Service:"+ce.getMessage());
                  }
          }
          return workflowService;
      }
      /**
       * Creates a new instance.  Used by <code>PullService</code>.
       */
      public WorkflowTool()
      {
          refresh();
      }
     
    
      /**
       * Sets the request to get the <code>Accept-Language</code> header
       * from (reset on each request).
       */
      public final void init(Object data)
      {
          if (data instanceof RunData)
          {
              // Pull necessary information out of RunData while we have
              // a reference to it.
              user = ((RunData)data).getUser();
            
          }
      }
      /**
       * No-op.
       */
      public void refresh()
      {
          user = null;
      }
      
      public List retrieveWorkflows(String status) throws WorkflowException{
          List workflows = new ArrayList();
          String caller = user.getName();
          long workflowIds []= getWorkflowService().retrieveWorkflows(caller,status);
          Workflow workflow = getWorkflowService().retrieveWorkflow(caller);
          for (int i =0;i<workflowIds.length;i++) {
              WorkflowInstance workflowInstance = new WorkflowInstance(workflow,workflowIds[i]);
              workflows.add(workflowInstance);
          }
          return workflows;
      }
      
      
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


/conf/master/*.master files

Posted by Eric Pugh <ep...@upstate.com>.
Well,

After I merrily deleted them, now I finally grok why the various are
required...  They are used by the maven Turbine plugin!  And you can't build
the maven turbine plugin with out them!

So, what I think the upshot of the ring around the rosies that was the
removal of the .master properties is to to move them explicitly into the
src/maven-plugin/src/plugin-resources directory...

Eric


/conf/master/*.master files

Posted by Eric Pugh <ep...@upstate.com>.
Well,

After I merrily deleted them, now I finally grok why the various are
required...  They are used by the maven Turbine plugin!  And you can't build
the maven turbine plugin with out them!

So, what I think the upshot of the ring around the rosies that was the
removal of the .master properties is to to move them explicitly into the
src/maven-plugin/src/plugin-resources directory...

Eric


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


RE: cvs commit: jakarta-turbine-fulcrum/osworkflow/example/src/java/org/apache/fulcrum/osworkflow/example/tools WorkflowTool.java

Posted by Eric Pugh <ep...@upstate.com>.
I am going through and cleaning up these errors.  Also, I'll run checkstyle
and see what I can find in terms of tweaking all the settings...  I guess
since this was 'example' code, I didn't keep an eye on the quality like I
should have.

I made a bunch of fixes, however some of the checkstyle errors like the
"should be marked final" I don't quite get..

Eric

> -----Original Message-----
> From: Daniel L. Rall [mailto:dlr@finemaltcoding.com]
> Sent: Friday, September 26, 2003 10:16 PM
> To: Turbine Developers List
> Subject: Re: cvs commit:
> jakarta-turbine-fulcrum/osworkflow/example/src/java/org/apache
> /fulcrum/o
> sworkflow/example/tools WorkflowTool.java
>
>
> Eric, were you using Eclipse for all these commits?
> Formatting seems a bit
> off on most of'em.  Can the editor be configured to
> auto-format?  More
> comments inline.
>
> epugh@apache.org wrote:
> > epugh       2003/09/26 08:22:03
> >
> >   Added:
> osworkflow/example/src/java/org/apache/fulcrum/osworkflow/exam
> ple/modules/actions
> >                         Index.java WorkflowAction.java
> >
> osworkflow/example/src/java/org/apache/fulcrum/osworkflow/exam
> ple/tools
> >                         WorkflowTool.java
> >   Log:
> >   Add in renamed code.
> >
> >   Revision  Changes    Path
> >   1.1
> jakarta-turbine-fulcrum/osworkflow/example/src/java/org/apache
> /fulcrum/osworkflow/example/modules/actions/Index.java
> >
> >   Index: Index.java
> >
> ===================================================================
> >   package org.apache.fulcrum.osworkflow.example.modules.actions;
> >
> >   import org.apache.turbine.modules.actions.VelocityAction;
> >   import org.apache.turbine.util.RunData;
> >   import org.apache.velocity.context.Context;
> >
> >
> >
> >   /**
> >    * @author     <a href="mailto:epugh@upstate.com">Eric Pugh</a>
> >    * @created    October 11, 2002
> >    */
> >   public class Index extends VelocityAction {
> >
> >   	/**
> >   	 *  Default action is to load up the default template
> and list out the locations to go to:
> >   	 <ol><li>Inventory Add Request<li>Inventory Delete
> Request<li>General Admin of Request</ol>
> >   	 *
> >   	 * @param  data           Current RunData information
> >   	 * @param  context        Context to populate
> >   	 * @exception  Exception  Thrown on error
> >   	 */
> >   	public void doPerform(RunData data, Context context)
> throws Exception {
> >
> >   		System.out.println("Doperform called");
> >   		data.setScreenTemplate("Index.vm");
> >
> >   	}
>
> Doesn't match Turbine's formatting conventions.
>
> >   1.1
> jakarta-turbine-fulcrum/osworkflow/example/src/java/org/apache
> /fulcrum/osworkflow/example/modules/actions/WorkflowAction.java
> >
> >   Index: WorkflowAction.java
> >
> ===================================================================
> >   package org.apache.fulcrum.osworkflow.example.modules.actions;
> >   import java.util.Collections;
> >
> >   import org.apache.avalon.framework.component.ComponentException;
> >   import org.apache.commons.logging.Log;
> >   import org.apache.commons.logging.LogFactory;
> >   import org.apache.fulcrum.osworkflow.WorkflowInstance;
> >   import org.apache.fulcrum.osworkflow.WorkflowService;
> >   import org.apache.turbine.modules.actions.VelocityAction;
> >   import org.apache.turbine.services.InstantiationException;
> >   import org.apache.turbine.services.TurbineServices;
> >   import
> org.apache.turbine.services.avaloncomponent.AvalonComponentService;
> >   import org.apache.turbine.util.RunData;
> >   import org.apache.velocity.context.Context;
> >   import com.opensymphony.module.user.Group;
> >   import com.opensymphony.module.user.User;
> >   import com.opensymphony.module.user.UserManager;
> >   import com.opensymphony.workflow.Workflow;
> >   /**
> >    * @author     <a href="mailto:epugh@upstate.com">Eric Pugh</a>
> >    * @created    October 11, 2002
> >    */
> >   public class WorkflowAction extends VelocityAction
> >   {
> >       private static Log log =
> LogFactory.getLog(WorkflowAction.class);
> >       private WorkflowService workflowService;
> >       /**
> >        *  This guy deals with actions related to workflows.
> >        *
> >        * @param  data           Current RunData information
> >        * @param  context        Context to populate
> >        * @exception  Exception  Thrown on error
> >        */
> >       public void doPerform(RunData data, Context context)
> throws Exception
> >       {
> >           System.out.println("Doperform called");
>
> I suspect that you didn't mean for that println to be in there.  =)
>
> >           data.setScreenTemplate("Index.vm");
> >       }
> >
> >   	/**
> >   		 *  This sets logs you in as user "test"
> >   		 *
> >   		 * @param  data           Current RunData information
> >   		 * @param  context        Context to populate
> >   		 * @exception  Exception  Thrown on error
> >   		 */
> >   		public void doLogin(RunData data, Context
> context) throws Exception
> >   		{
> >   			data.getUser().setName("test");
> >
> >
> >   			data.getMessages().setMessage("",
> "INFO", "You are logged in as user test!");
> >   		}
>
> Tabs and 8 char rather than 4 char indent?
>
> >       /**
> >        *  This sets up the user "test/test"
> >        *
> >        * @param  data           Current RunData information
> >        * @param  context        Context to populate
> >        * @exception  Exception  Thrown on error
> >        */
> >       public void doSetupuser(RunData data, Context
> context) throws Exception
> >       {
> >
> >           data.setScreenTemplate("Index.vm");
> >           UserManager um = UserManager.getInstance();
> >           User test = um.createUser("test");
> >           test.setPassword("test");
> >           Group foos = um.createGroup("foos");
> >           Group bars = um.createGroup("bars");
> >           Group bazs = um.createGroup("bazs");
> >           test.addToGroup(foos);
> >           test.addToGroup(bars);
> >           test.addToGroup(bazs);
> >
> >           data.getMessages().setMessage("", "INFO", "User
> test/test is setup in system.  Don't forget to login!");
> >       }
> >
> >
> >       /**
> >        *  Create a new Workflow
> >        *
> >        * @param  data           Current RunData information
> >        * @param  context        Context to populate
> >        * @exception  Exception  Thrown on error
> >        */
> >       public void doNew(RunData data, Context context)
> throws Exception
> >       {
> >           System.out.println("doNew called");
>
> Use of a logging class might be more appropriate.
>
> >           data.setScreenTemplate("Index.vm");
> >           try
> >           {
> >               Workflow wf =
> getWorkflowService().retrieveWorkflow(data.getUser().getName());
> >               long id = wf.initialize("example", 1, null);
> >               data.getMessages().setMessage("", "INFO",
> "New Workflow id " + id + " created and initialized!");
> >           }
> >           catch (Exception e)
> >           {
> >               log.error(e);
> >               data.getMessages().setMessage("", "ERROR",
> e.getMessage());
> >           }
> >       }
>
> Odd formatting follows.
>
> >       /**
> >           *  Create a new Workflow
> >           *
> >           * @param  data           Current RunData information
> >           * @param  context        Context to populate
> >           * @exception  Exception  Thrown on error
> >           */
> >       public void doViewdetail(RunData data, Context
> context) throws Exception
> >       {
> >           System.out.println("doViewdetail called");
> >           data.setScreenTemplate("WorkflowDetail.vm");
> >           try
> >           {
> >               context.put("wf", getWorkflowInstance(data, context));
> >           }
> >           catch (Exception e)
> >           {
> >               log.error(e);
> >               data.getMessages().setMessage("", "ERROR",
> e.getMessage());
> >           }
> >       }
> >       /**
> >           * Lazy load the WorkflowService.
> >           * @return a fulcrum WorkflowService
> >           */
> >       public WorkflowService getWorkflowService()
> >       {
> >           if (workflowService == null)
> >           {
> >               AvalonComponentService acs =
> >                   (AvalonComponentService)
> TurbineServices.getInstance().getService(AvalonComponentServic
> e.SERVICE_NAME);
> >               try
> >               {
> >                   workflowService = (WorkflowService)
> acs.lookup(WorkflowService.ROLE);
> >               }
> >               catch (ComponentException ce)
> >               {
> >                   throw new InstantiationException("Problem
> looking up Workflow Service:" + ce.getMessage());
> >               }
> >           }
> >           return workflowService;
> >       }
> >       /**
> >           *  Perform an action
> >           *
> >           * @param  data           Current RunData information
> >           * @param  context        Context to populate
> >           * @exception  Exception  Thrown on error
> >           */
> >       public void doAction(RunData data, Context context)
> throws Exception
> >       {
> >
> >           try
> >           {
> >               WorkflowInstance wf =
> getWorkflowInstance(data, context);
> >               int action = data.getParameters().getInt("actionId");
> >               wf.doAction(action, Collections.EMPTY_MAP);
> >
> >           }
> >           catch (Exception e)
> >           {
> >               log.error(e);
> >               data.getMessages().setMessage("", "ERROR",
> e.getMessage());
> >           }
> >           doViewdetail(data,context);
> >       }
> >       protected WorkflowInstance
> getWorkflowInstance(RunData data, Context context)
> >       {
> >           long workflowId = data.getParameters().getLong("id");
> >           Workflow workflow =
> getWorkflowService().retrieveWorkflow(data.getUser().getName());
> >           WorkflowInstance wf = new
> WorkflowInstance(workflow, workflowId);
> >           return wf;
> >       }
> >   }
> >
> >
> >
> >   1.1
> jakarta-turbine-fulcrum/osworkflow/example/src/java/org/apache
> /fulcrum/osworkflow/example/tools/WorkflowTool.java
> >
> >   Index: WorkflowTool.java
> >
> ===================================================================
> >   package org.apache.fulcrum.osworkflow.example.tools;
> >   /*
> ====================================================================
> >    * The Apache Software License, Version 1.1
> >    *
> >    * Copyright (c) 2001-2003 The Apache Software
> Foundation.  All rights
> >    * reserved.
> >    *
> >    * Redistribution and use in source and binary forms,
> with or without
> >    * modification, are permitted provided that the
> following conditions
> >    * are met:
> >    *
> >    * 1. Redistributions of source code must retain the
> above copyright
> >    *    notice, this list of conditions and the following
> disclaimer.
> >    *
> >    * 2. Redistributions in binary form must reproduce the
> above copyright
> >    *    notice, this list of conditions and the following
> disclaimer in
> >    *    the documentation and/or other materials provided with the
> >    *    distribution.
> >    *
> >    * 3. The end-user documentation included with the redistribution,
> >    *    if any, must include the following acknowledgment:
> >    *       "This product includes software developed by the
> >    *        Apache Software Foundation (http://www.apache.org/)."
> >    *    Alternately, this acknowledgment may appear in the
> software itself,
> >    *    if and wherever such third-party acknowledgments
> normally appear.
> >    *
> >    * 4. The names "Apache" and "Apache Software Foundation" and
> >    *    "Apache Turbine" must not be used to endorse or
> promote products
> >    *    derived from this software without prior written
> permission. For
> >    *    written permission, please contact apache@apache.org.
> >    *
> >    * 5. Products derived from this software may not be
> called "Apache",
> >    *    "Apache Turbine", nor may "Apache" appear in their
> name, without
> >    *    prior written permission of the Apache Software Foundation.
> >    *
> >    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED
> OR IMPLIED
> >    * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
> WARRANTIES
> >    * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
> >    * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE
> FOUNDATION OR
> >    * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
> INCIDENTAL,
> >    * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
> (INCLUDING, BUT NOT
> >    * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
> SERVICES; LOSS OF
> >    * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
> HOWEVER CAUSED AND
> >    * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
> STRICT LIABILITY,
> >    * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
> ANY WAY OUT
> >    * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
> POSSIBILITY OF
> >    * SUCH DAMAGE.
> >    *
> ====================================================================
> >    *
> >    * This software consists of voluntary contributions made by many
> >    * individuals on behalf of the Apache Software
> Foundation.  For more
> >    * information on the Apache Software Foundation, please see
> >    * <http://www.apache.org/>.
> >    */
> >
> >
> >   import java.util.ArrayList;
> >   import java.util.List;
> >
> >   import org.apache.avalon.framework.component.ComponentException;
> >   import org.apache.commons.logging.Log;
> >   import org.apache.commons.logging.LogFactory;
> >   import org.apache.fulcrum.osworkflow.WorkflowInstance;
> >   import org.apache.fulcrum.osworkflow.WorkflowService;
> >   import org.apache.turbine.om.security.User;
> >   import org.apache.turbine.services.InstantiationException;
> >   import org.apache.turbine.services.TurbineServices;
> >   import
> org.apache.turbine.services.avaloncomponent.AvalonComponentService;
> >   import org.apache.turbine.services.pull.ApplicationTool;
> >   import org.apache.turbine.util.RunData;
> >
> >   import com.opensymphony.workflow.Workflow;
> >   import com.opensymphony.workflow.WorkflowException;
> >   /**
> >    * A pull tool which provides lookups of workflows by delegating
> >    * to the configured Fulcrum <code>WorkflowService</code>.
> >    *
> >    * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
> >    */
> >   public class WorkflowTool implements ApplicationTool
> >   {
> >       /** Logging */
> >       private static Log log =
> LogFactory.getLog(WorkflowTool.class);
> >       /** Fulcrum Localization component */
> >       private WorkflowService workflowService;
> >       private User user;
> >
> >
> >       /**
> >        * Lazy load the WorkflowService.
> >        * @return a fulcrum WorkflowService
> >        */
> >       public WorkflowService getWorkflowService()
> >       {
> >           if (workflowService == null)
> >           {
> >               AvalonComponentService acs =
> >                   (AvalonComponentService)
> TurbineServices.getInstance().getService(AvalonComponentServic
> e.SERVICE_NAME);
> >                   try {
> >               workflowService =
> (WorkflowService)acs.lookup(WorkflowService.ROLE);
> >                   }
> >                   catch (ComponentException ce) {
> >                       throw new
> InstantiationException("Problem looking up Localization
> Service:"+ce.getMessage());
> >                   }
> >           }
> >           return workflowService;
> >       }
>
> Odd formatting above.
>
> >       /**
> >        * Creates a new instance.  Used by <code>PullService</code>.
> >        */
> >       public WorkflowTool()
> >       {
> >           refresh();
> >       }
> >
> >
> >       /**
> >        * Sets the request to get the
> <code>Accept-Language</code> header
> >        * from (reset on each request).
> >        */
> >       public final void init(Object data)
> >       {
> >           if (data instanceof RunData)
> >           {
> >               // Pull necessary information out of RunData
> while we have
> >               // a reference to it.
> >               user = ((RunData)data).getUser();
> >
> >           }
> >       }
> >       /**
> >        * No-op.
> >        */
> >       public void refresh()
> >       {
> >           user = null;
> >       }
> >
> >       public List retrieveWorkflows(String status) throws
> WorkflowException{
> >           List workflows = new ArrayList();
> >           String caller = user.getName();
> >           long workflowIds []=
> getWorkflowService().retrieveWorkflows(caller,status);
> >           Workflow workflow =
> getWorkflowService().retrieveWorkflow(caller);
> >           for (int i =0;i<workflowIds.length;i++) {
>
> Brace placement.
>
> >               WorkflowInstance workflowInstance = new
> WorkflowInstance(workflow,workflowIds[i]);
> >               workflows.add(workflowInstance);
> >           }
> >           return workflows;
> >       }
> >
> >
> >   }
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


RE: cvs commit: jakarta-turbine-fulcrum/osworkflow/example/src/java/org/apache/fulcrum/osworkflow/example/tools WorkflowTool.java

Posted by Eric Pugh <ep...@upstate.com>.
I am going through and cleaning up these errors.  Also, I'll run checkstyle
and see what I can find in terms of tweaking all the settings...  I guess
since this was 'example' code, I didn't keep an eye on the quality like I
should have.

I made a bunch of fixes, however some of the checkstyle errors like the
"should be marked final" I don't quite get..

Eric

> -----Original Message-----
> From: Daniel L. Rall [mailto:dlr@finemaltcoding.com]
> Sent: Friday, September 26, 2003 10:16 PM
> To: Turbine Developers List
> Subject: Re: cvs commit:
> jakarta-turbine-fulcrum/osworkflow/example/src/java/org/apache
> /fulcrum/o
> sworkflow/example/tools WorkflowTool.java
>
>
> Eric, were you using Eclipse for all these commits?
> Formatting seems a bit
> off on most of'em.  Can the editor be configured to
> auto-format?  More
> comments inline.
>
> epugh@apache.org wrote:
> > epugh       2003/09/26 08:22:03
> >
> >   Added:
> osworkflow/example/src/java/org/apache/fulcrum/osworkflow/exam
> ple/modules/actions
> >                         Index.java WorkflowAction.java
> >
> osworkflow/example/src/java/org/apache/fulcrum/osworkflow/exam
> ple/tools
> >                         WorkflowTool.java
> >   Log:
> >   Add in renamed code.
> >
> >   Revision  Changes    Path
> >   1.1
> jakarta-turbine-fulcrum/osworkflow/example/src/java/org/apache
> /fulcrum/osworkflow/example/modules/actions/Index.java
> >
> >   Index: Index.java
> >
> ===================================================================
> >   package org.apache.fulcrum.osworkflow.example.modules.actions;
> >
> >   import org.apache.turbine.modules.actions.VelocityAction;
> >   import org.apache.turbine.util.RunData;
> >   import org.apache.velocity.context.Context;
> >
> >
> >
> >   /**
> >    * @author     <a href="mailto:epugh@upstate.com">Eric Pugh</a>
> >    * @created    October 11, 2002
> >    */
> >   public class Index extends VelocityAction {
> >
> >   	/**
> >   	 *  Default action is to load up the default template
> and list out the locations to go to:
> >   	 <ol><li>Inventory Add Request<li>Inventory Delete
> Request<li>General Admin of Request</ol>
> >   	 *
> >   	 * @param  data           Current RunData information
> >   	 * @param  context        Context to populate
> >   	 * @exception  Exception  Thrown on error
> >   	 */
> >   	public void doPerform(RunData data, Context context)
> throws Exception {
> >
> >   		System.out.println("Doperform called");
> >   		data.setScreenTemplate("Index.vm");
> >
> >   	}
>
> Doesn't match Turbine's formatting conventions.
>
> >   1.1
> jakarta-turbine-fulcrum/osworkflow/example/src/java/org/apache
> /fulcrum/osworkflow/example/modules/actions/WorkflowAction.java
> >
> >   Index: WorkflowAction.java
> >
> ===================================================================
> >   package org.apache.fulcrum.osworkflow.example.modules.actions;
> >   import java.util.Collections;
> >
> >   import org.apache.avalon.framework.component.ComponentException;
> >   import org.apache.commons.logging.Log;
> >   import org.apache.commons.logging.LogFactory;
> >   import org.apache.fulcrum.osworkflow.WorkflowInstance;
> >   import org.apache.fulcrum.osworkflow.WorkflowService;
> >   import org.apache.turbine.modules.actions.VelocityAction;
> >   import org.apache.turbine.services.InstantiationException;
> >   import org.apache.turbine.services.TurbineServices;
> >   import
> org.apache.turbine.services.avaloncomponent.AvalonComponentService;
> >   import org.apache.turbine.util.RunData;
> >   import org.apache.velocity.context.Context;
> >   import com.opensymphony.module.user.Group;
> >   import com.opensymphony.module.user.User;
> >   import com.opensymphony.module.user.UserManager;
> >   import com.opensymphony.workflow.Workflow;
> >   /**
> >    * @author     <a href="mailto:epugh@upstate.com">Eric Pugh</a>
> >    * @created    October 11, 2002
> >    */
> >   public class WorkflowAction extends VelocityAction
> >   {
> >       private static Log log =
> LogFactory.getLog(WorkflowAction.class);
> >       private WorkflowService workflowService;
> >       /**
> >        *  This guy deals with actions related to workflows.
> >        *
> >        * @param  data           Current RunData information
> >        * @param  context        Context to populate
> >        * @exception  Exception  Thrown on error
> >        */
> >       public void doPerform(RunData data, Context context)
> throws Exception
> >       {
> >           System.out.println("Doperform called");
>
> I suspect that you didn't mean for that println to be in there.  =)
>
> >           data.setScreenTemplate("Index.vm");
> >       }
> >
> >   	/**
> >   		 *  This sets logs you in as user "test"
> >   		 *
> >   		 * @param  data           Current RunData information
> >   		 * @param  context        Context to populate
> >   		 * @exception  Exception  Thrown on error
> >   		 */
> >   		public void doLogin(RunData data, Context
> context) throws Exception
> >   		{
> >   			data.getUser().setName("test");
> >
> >
> >   			data.getMessages().setMessage("",
> "INFO", "You are logged in as user test!");
> >   		}
>
> Tabs and 8 char rather than 4 char indent?
>
> >       /**
> >        *  This sets up the user "test/test"
> >        *
> >        * @param  data           Current RunData information
> >        * @param  context        Context to populate
> >        * @exception  Exception  Thrown on error
> >        */
> >       public void doSetupuser(RunData data, Context
> context) throws Exception
> >       {
> >
> >           data.setScreenTemplate("Index.vm");
> >           UserManager um = UserManager.getInstance();
> >           User test = um.createUser("test");
> >           test.setPassword("test");
> >           Group foos = um.createGroup("foos");
> >           Group bars = um.createGroup("bars");
> >           Group bazs = um.createGroup("bazs");
> >           test.addToGroup(foos);
> >           test.addToGroup(bars);
> >           test.addToGroup(bazs);
> >
> >           data.getMessages().setMessage("", "INFO", "User
> test/test is setup in system.  Don't forget to login!");
> >       }
> >
> >
> >       /**
> >        *  Create a new Workflow
> >        *
> >        * @param  data           Current RunData information
> >        * @param  context        Context to populate
> >        * @exception  Exception  Thrown on error
> >        */
> >       public void doNew(RunData data, Context context)
> throws Exception
> >       {
> >           System.out.println("doNew called");
>
> Use of a logging class might be more appropriate.
>
> >           data.setScreenTemplate("Index.vm");
> >           try
> >           {
> >               Workflow wf =
> getWorkflowService().retrieveWorkflow(data.getUser().getName());
> >               long id = wf.initialize("example", 1, null);
> >               data.getMessages().setMessage("", "INFO",
> "New Workflow id " + id + " created and initialized!");
> >           }
> >           catch (Exception e)
> >           {
> >               log.error(e);
> >               data.getMessages().setMessage("", "ERROR",
> e.getMessage());
> >           }
> >       }
>
> Odd formatting follows.
>
> >       /**
> >           *  Create a new Workflow
> >           *
> >           * @param  data           Current RunData information
> >           * @param  context        Context to populate
> >           * @exception  Exception  Thrown on error
> >           */
> >       public void doViewdetail(RunData data, Context
> context) throws Exception
> >       {
> >           System.out.println("doViewdetail called");
> >           data.setScreenTemplate("WorkflowDetail.vm");
> >           try
> >           {
> >               context.put("wf", getWorkflowInstance(data, context));
> >           }
> >           catch (Exception e)
> >           {
> >               log.error(e);
> >               data.getMessages().setMessage("", "ERROR",
> e.getMessage());
> >           }
> >       }
> >       /**
> >           * Lazy load the WorkflowService.
> >           * @return a fulcrum WorkflowService
> >           */
> >       public WorkflowService getWorkflowService()
> >       {
> >           if (workflowService == null)
> >           {
> >               AvalonComponentService acs =
> >                   (AvalonComponentService)
> TurbineServices.getInstance().getService(AvalonComponentServic
> e.SERVICE_NAME);
> >               try
> >               {
> >                   workflowService = (WorkflowService)
> acs.lookup(WorkflowService.ROLE);
> >               }
> >               catch (ComponentException ce)
> >               {
> >                   throw new InstantiationException("Problem
> looking up Workflow Service:" + ce.getMessage());
> >               }
> >           }
> >           return workflowService;
> >       }
> >       /**
> >           *  Perform an action
> >           *
> >           * @param  data           Current RunData information
> >           * @param  context        Context to populate
> >           * @exception  Exception  Thrown on error
> >           */
> >       public void doAction(RunData data, Context context)
> throws Exception
> >       {
> >
> >           try
> >           {
> >               WorkflowInstance wf =
> getWorkflowInstance(data, context);
> >               int action = data.getParameters().getInt("actionId");
> >               wf.doAction(action, Collections.EMPTY_MAP);
> >
> >           }
> >           catch (Exception e)
> >           {
> >               log.error(e);
> >               data.getMessages().setMessage("", "ERROR",
> e.getMessage());
> >           }
> >           doViewdetail(data,context);
> >       }
> >       protected WorkflowInstance
> getWorkflowInstance(RunData data, Context context)
> >       {
> >           long workflowId = data.getParameters().getLong("id");
> >           Workflow workflow =
> getWorkflowService().retrieveWorkflow(data.getUser().getName());
> >           WorkflowInstance wf = new
> WorkflowInstance(workflow, workflowId);
> >           return wf;
> >       }
> >   }
> >
> >
> >
> >   1.1
> jakarta-turbine-fulcrum/osworkflow/example/src/java/org/apache
> /fulcrum/osworkflow/example/tools/WorkflowTool.java
> >
> >   Index: WorkflowTool.java
> >
> ===================================================================
> >   package org.apache.fulcrum.osworkflow.example.tools;
> >   /*
> ====================================================================
> >    * The Apache Software License, Version 1.1
> >    *
> >    * Copyright (c) 2001-2003 The Apache Software
> Foundation.  All rights
> >    * reserved.
> >    *
> >    * Redistribution and use in source and binary forms,
> with or without
> >    * modification, are permitted provided that the
> following conditions
> >    * are met:
> >    *
> >    * 1. Redistributions of source code must retain the
> above copyright
> >    *    notice, this list of conditions and the following
> disclaimer.
> >    *
> >    * 2. Redistributions in binary form must reproduce the
> above copyright
> >    *    notice, this list of conditions and the following
> disclaimer in
> >    *    the documentation and/or other materials provided with the
> >    *    distribution.
> >    *
> >    * 3. The end-user documentation included with the redistribution,
> >    *    if any, must include the following acknowledgment:
> >    *       "This product includes software developed by the
> >    *        Apache Software Foundation (http://www.apache.org/)."
> >    *    Alternately, this acknowledgment may appear in the
> software itself,
> >    *    if and wherever such third-party acknowledgments
> normally appear.
> >    *
> >    * 4. The names "Apache" and "Apache Software Foundation" and
> >    *    "Apache Turbine" must not be used to endorse or
> promote products
> >    *    derived from this software without prior written
> permission. For
> >    *    written permission, please contact apache@apache.org.
> >    *
> >    * 5. Products derived from this software may not be
> called "Apache",
> >    *    "Apache Turbine", nor may "Apache" appear in their
> name, without
> >    *    prior written permission of the Apache Software Foundation.
> >    *
> >    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED
> OR IMPLIED
> >    * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
> WARRANTIES
> >    * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
> >    * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE
> FOUNDATION OR
> >    * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
> INCIDENTAL,
> >    * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
> (INCLUDING, BUT NOT
> >    * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
> SERVICES; LOSS OF
> >    * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
> HOWEVER CAUSED AND
> >    * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
> STRICT LIABILITY,
> >    * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
> ANY WAY OUT
> >    * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
> POSSIBILITY OF
> >    * SUCH DAMAGE.
> >    *
> ====================================================================
> >    *
> >    * This software consists of voluntary contributions made by many
> >    * individuals on behalf of the Apache Software
> Foundation.  For more
> >    * information on the Apache Software Foundation, please see
> >    * <http://www.apache.org/>.
> >    */
> >
> >
> >   import java.util.ArrayList;
> >   import java.util.List;
> >
> >   import org.apache.avalon.framework.component.ComponentException;
> >   import org.apache.commons.logging.Log;
> >   import org.apache.commons.logging.LogFactory;
> >   import org.apache.fulcrum.osworkflow.WorkflowInstance;
> >   import org.apache.fulcrum.osworkflow.WorkflowService;
> >   import org.apache.turbine.om.security.User;
> >   import org.apache.turbine.services.InstantiationException;
> >   import org.apache.turbine.services.TurbineServices;
> >   import
> org.apache.turbine.services.avaloncomponent.AvalonComponentService;
> >   import org.apache.turbine.services.pull.ApplicationTool;
> >   import org.apache.turbine.util.RunData;
> >
> >   import com.opensymphony.workflow.Workflow;
> >   import com.opensymphony.workflow.WorkflowException;
> >   /**
> >    * A pull tool which provides lookups of workflows by delegating
> >    * to the configured Fulcrum <code>WorkflowService</code>.
> >    *
> >    * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
> >    */
> >   public class WorkflowTool implements ApplicationTool
> >   {
> >       /** Logging */
> >       private static Log log =
> LogFactory.getLog(WorkflowTool.class);
> >       /** Fulcrum Localization component */
> >       private WorkflowService workflowService;
> >       private User user;
> >
> >
> >       /**
> >        * Lazy load the WorkflowService.
> >        * @return a fulcrum WorkflowService
> >        */
> >       public WorkflowService getWorkflowService()
> >       {
> >           if (workflowService == null)
> >           {
> >               AvalonComponentService acs =
> >                   (AvalonComponentService)
> TurbineServices.getInstance().getService(AvalonComponentServic
> e.SERVICE_NAME);
> >                   try {
> >               workflowService =
> (WorkflowService)acs.lookup(WorkflowService.ROLE);
> >                   }
> >                   catch (ComponentException ce) {
> >                       throw new
> InstantiationException("Problem looking up Localization
> Service:"+ce.getMessage());
> >                   }
> >           }
> >           return workflowService;
> >       }
>
> Odd formatting above.
>
> >       /**
> >        * Creates a new instance.  Used by <code>PullService</code>.
> >        */
> >       public WorkflowTool()
> >       {
> >           refresh();
> >       }
> >
> >
> >       /**
> >        * Sets the request to get the
> <code>Accept-Language</code> header
> >        * from (reset on each request).
> >        */
> >       public final void init(Object data)
> >       {
> >           if (data instanceof RunData)
> >           {
> >               // Pull necessary information out of RunData
> while we have
> >               // a reference to it.
> >               user = ((RunData)data).getUser();
> >
> >           }
> >       }
> >       /**
> >        * No-op.
> >        */
> >       public void refresh()
> >       {
> >           user = null;
> >       }
> >
> >       public List retrieveWorkflows(String status) throws
> WorkflowException{
> >           List workflows = new ArrayList();
> >           String caller = user.getName();
> >           long workflowIds []=
> getWorkflowService().retrieveWorkflows(caller,status);
> >           Workflow workflow =
> getWorkflowService().retrieveWorkflow(caller);
> >           for (int i =0;i<workflowIds.length;i++) {
>
> Brace placement.
>
> >               WorkflowInstance workflowInstance = new
> WorkflowInstance(workflow,workflowIds[i]);
> >               workflows.add(workflowInstance);
> >           }
> >           return workflows;
> >       }
> >
> >
> >   }
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-turbine-fulcrum/osworkflow/example/src/java/org/apache/fulcrum/osworkflow/example/tools WorkflowTool.java

Posted by "Daniel L. Rall" <dl...@finemaltcoding.com>.
Eric, were you using Eclipse for all these commits?  Formatting seems a bit 
off on most of'em.  Can the editor be configured to auto-format?  More 
comments inline.

epugh@apache.org wrote:
> epugh       2003/09/26 08:22:03
> 
>   Added:       osworkflow/example/src/java/org/apache/fulcrum/osworkflow/example/modules/actions
>                         Index.java WorkflowAction.java
>                osworkflow/example/src/java/org/apache/fulcrum/osworkflow/example/tools
>                         WorkflowTool.java
>   Log:
>   Add in renamed code.
>   
>   Revision  Changes    Path
>   1.1                  jakarta-turbine-fulcrum/osworkflow/example/src/java/org/apache/fulcrum/osworkflow/example/modules/actions/Index.java
>   
>   Index: Index.java
>   ===================================================================
>   package org.apache.fulcrum.osworkflow.example.modules.actions;
>   
>   import org.apache.turbine.modules.actions.VelocityAction;
>   import org.apache.turbine.util.RunData;
>   import org.apache.velocity.context.Context;
>   
>   
>   
>   /**
>    * @author     <a href="mailto:epugh@upstate.com">Eric Pugh</a>
>    * @created    October 11, 2002
>    */
>   public class Index extends VelocityAction {
>   
>   	/**
>   	 *  Default action is to load up the default template and list out the locations to go to:
>   	 <ol><li>Inventory Add Request<li>Inventory Delete Request<li>General Admin of Request</ol>
>   	 *
>   	 * @param  data           Current RunData information
>   	 * @param  context        Context to populate
>   	 * @exception  Exception  Thrown on error
>   	 */
>   	public void doPerform(RunData data, Context context) throws Exception {
>   
>   		System.out.println("Doperform called");
>   		data.setScreenTemplate("Index.vm");
>   
>   	}

Doesn't match Turbine's formatting conventions.

>   1.1                  jakarta-turbine-fulcrum/osworkflow/example/src/java/org/apache/fulcrum/osworkflow/example/modules/actions/WorkflowAction.java
>   
>   Index: WorkflowAction.java
>   ===================================================================
>   package org.apache.fulcrum.osworkflow.example.modules.actions;
>   import java.util.Collections;
>   
>   import org.apache.avalon.framework.component.ComponentException;
>   import org.apache.commons.logging.Log;
>   import org.apache.commons.logging.LogFactory;
>   import org.apache.fulcrum.osworkflow.WorkflowInstance;
>   import org.apache.fulcrum.osworkflow.WorkflowService;
>   import org.apache.turbine.modules.actions.VelocityAction;
>   import org.apache.turbine.services.InstantiationException;
>   import org.apache.turbine.services.TurbineServices;
>   import org.apache.turbine.services.avaloncomponent.AvalonComponentService;
>   import org.apache.turbine.util.RunData;
>   import org.apache.velocity.context.Context;
>   import com.opensymphony.module.user.Group;
>   import com.opensymphony.module.user.User;
>   import com.opensymphony.module.user.UserManager;
>   import com.opensymphony.workflow.Workflow;
>   /**
>    * @author     <a href="mailto:epugh@upstate.com">Eric Pugh</a>
>    * @created    October 11, 2002
>    */
>   public class WorkflowAction extends VelocityAction
>   {
>       private static Log log = LogFactory.getLog(WorkflowAction.class);
>       private WorkflowService workflowService;
>       /**
>        *  This guy deals with actions related to workflows.
>        *
>        * @param  data           Current RunData information
>        * @param  context        Context to populate
>        * @exception  Exception  Thrown on error
>        */
>       public void doPerform(RunData data, Context context) throws Exception
>       {
>           System.out.println("Doperform called");

I suspect that you didn't mean for that println to be in there.  =)

>           data.setScreenTemplate("Index.vm");
>       }
>       
>   	/**
>   		 *  This sets logs you in as user "test"
>   		 *
>   		 * @param  data           Current RunData information
>   		 * @param  context        Context to populate
>   		 * @exception  Exception  Thrown on error
>   		 */
>   		public void doLogin(RunData data, Context context) throws Exception
>   		{
>   			data.getUser().setName("test");
>   	
>           
>   			data.getMessages().setMessage("", "INFO", "You are logged in as user test!");
>   		}

Tabs and 8 char rather than 4 char indent?

>       /**
>        *  This sets up the user "test/test"
>        *
>        * @param  data           Current RunData information
>        * @param  context        Context to populate
>        * @exception  Exception  Thrown on error
>        */
>       public void doSetupuser(RunData data, Context context) throws Exception
>       {
>   	
>           data.setScreenTemplate("Index.vm");
>           UserManager um = UserManager.getInstance();
>           User test = um.createUser("test");
>           test.setPassword("test");
>           Group foos = um.createGroup("foos");
>           Group bars = um.createGroup("bars");
>           Group bazs = um.createGroup("bazs");
>           test.addToGroup(foos);
>           test.addToGroup(bars);
>           test.addToGroup(bazs);
>           
>           data.getMessages().setMessage("", "INFO", "User test/test is setup in system.  Don't forget to login!");
>       }
>       
>       
>       /**
>        *  Create a new Workflow
>        *
>        * @param  data           Current RunData information
>        * @param  context        Context to populate
>        * @exception  Exception  Thrown on error
>        */
>       public void doNew(RunData data, Context context) throws Exception
>       {
>           System.out.println("doNew called");

Use of a logging class might be more appropriate.

>           data.setScreenTemplate("Index.vm");
>           try
>           {
>               Workflow wf = getWorkflowService().retrieveWorkflow(data.getUser().getName());
>               long id = wf.initialize("example", 1, null);
>               data.getMessages().setMessage("", "INFO", "New Workflow id " + id + " created and initialized!");
>           }
>           catch (Exception e)
>           {
>               log.error(e);
>               data.getMessages().setMessage("", "ERROR", e.getMessage());
>           }
>       }

Odd formatting follows.

>       /**
>           *  Create a new Workflow
>           *
>           * @param  data           Current RunData information
>           * @param  context        Context to populate
>           * @exception  Exception  Thrown on error
>           */
>       public void doViewdetail(RunData data, Context context) throws Exception
>       {
>           System.out.println("doViewdetail called");
>           data.setScreenTemplate("WorkflowDetail.vm");
>           try
>           {
>               context.put("wf", getWorkflowInstance(data, context));
>           }
>           catch (Exception e)
>           {
>               log.error(e);
>               data.getMessages().setMessage("", "ERROR", e.getMessage());
>           }
>       }
>       /**
>           * Lazy load the WorkflowService.
>           * @return a fulcrum WorkflowService
>           */
>       public WorkflowService getWorkflowService()
>       {
>           if (workflowService == null)
>           {
>               AvalonComponentService acs =
>                   (AvalonComponentService) TurbineServices.getInstance().getService(AvalonComponentService.SERVICE_NAME);
>               try
>               {
>                   workflowService = (WorkflowService) acs.lookup(WorkflowService.ROLE);
>               }
>               catch (ComponentException ce)
>               {
>                   throw new InstantiationException("Problem looking up Workflow Service:" + ce.getMessage());
>               }
>           }
>           return workflowService;
>       }
>       /**
>           *  Perform an action
>           *
>           * @param  data           Current RunData information
>           * @param  context        Context to populate
>           * @exception  Exception  Thrown on error
>           */
>       public void doAction(RunData data, Context context) throws Exception
>       {
>           
>           try
>           {
>               WorkflowInstance wf = getWorkflowInstance(data, context);
>               int action = data.getParameters().getInt("actionId");
>               wf.doAction(action, Collections.EMPTY_MAP);
>           
>           }
>           catch (Exception e)
>           {
>               log.error(e);
>               data.getMessages().setMessage("", "ERROR", e.getMessage());
>           }
>           doViewdetail(data,context);
>       }
>       protected WorkflowInstance getWorkflowInstance(RunData data, Context context)
>       {
>           long workflowId = data.getParameters().getLong("id");
>           Workflow workflow = getWorkflowService().retrieveWorkflow(data.getUser().getName());
>           WorkflowInstance wf = new WorkflowInstance(workflow, workflowId);
>           return wf;
>       }
>   }
>   
>   
>   
>   1.1                  jakarta-turbine-fulcrum/osworkflow/example/src/java/org/apache/fulcrum/osworkflow/example/tools/WorkflowTool.java
>   
>   Index: WorkflowTool.java
>   ===================================================================
>   package org.apache.fulcrum.osworkflow.example.tools;
>   /* ====================================================================
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
>    * reserved.
>    *
>    * Redistribution and use in source and binary forms, with or without
>    * modification, are permitted provided that the following conditions
>    * are met:
>    *
>    * 1. Redistributions of source code must retain the above copyright
>    *    notice, this list of conditions and the following disclaimer.
>    *
>    * 2. Redistributions in binary form must reproduce the above copyright
>    *    notice, this list of conditions and the following disclaimer in
>    *    the documentation and/or other materials provided with the
>    *    distribution.
>    *
>    * 3. The end-user documentation included with the redistribution,
>    *    if any, must include the following acknowledgment:
>    *       "This product includes software developed by the
>    *        Apache Software Foundation (http://www.apache.org/)."
>    *    Alternately, this acknowledgment may appear in the software itself,
>    *    if and wherever such third-party acknowledgments normally appear.
>    *
>    * 4. The names "Apache" and "Apache Software Foundation" and
>    *    "Apache Turbine" must not be used to endorse or promote products
>    *    derived from this software without prior written permission. For
>    *    written permission, please contact apache@apache.org.
>    *
>    * 5. Products derived from this software may not be called "Apache",
>    *    "Apache Turbine", nor may "Apache" appear in their name, without
>    *    prior written permission of the Apache Software Foundation.
>    *
>    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>    * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>    * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>    * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>    * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>    * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>    * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>    * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>    * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>    * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>    * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>    * SUCH DAMAGE.
>    * ====================================================================
>    *
>    * This software consists of voluntary contributions made by many
>    * individuals on behalf of the Apache Software Foundation.  For more
>    * information on the Apache Software Foundation, please see
>    * <http://www.apache.org/>.
>    */
>   
>   
>   import java.util.ArrayList;
>   import java.util.List;
>   
>   import org.apache.avalon.framework.component.ComponentException;
>   import org.apache.commons.logging.Log;
>   import org.apache.commons.logging.LogFactory;
>   import org.apache.fulcrum.osworkflow.WorkflowInstance;
>   import org.apache.fulcrum.osworkflow.WorkflowService;
>   import org.apache.turbine.om.security.User;
>   import org.apache.turbine.services.InstantiationException;
>   import org.apache.turbine.services.TurbineServices;
>   import org.apache.turbine.services.avaloncomponent.AvalonComponentService;
>   import org.apache.turbine.services.pull.ApplicationTool;
>   import org.apache.turbine.util.RunData;
>   
>   import com.opensymphony.workflow.Workflow;
>   import com.opensymphony.workflow.WorkflowException;
>   /**
>    * A pull tool which provides lookups of workflows by delegating
>    * to the configured Fulcrum <code>WorkflowService</code>.
>    *
>    * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
>    */
>   public class WorkflowTool implements ApplicationTool
>   {
>       /** Logging */
>       private static Log log = LogFactory.getLog(WorkflowTool.class);
>       /** Fulcrum Localization component */
>       private WorkflowService workflowService;
>       private User user;
>   
>   
>       /**
>        * Lazy load the WorkflowService.
>        * @return a fulcrum WorkflowService
>        */
>       public WorkflowService getWorkflowService()
>       {
>           if (workflowService == null)
>           {
>               AvalonComponentService acs =
>                   (AvalonComponentService) TurbineServices.getInstance().getService(AvalonComponentService.SERVICE_NAME);
>                   try {
>               workflowService = (WorkflowService)acs.lookup(WorkflowService.ROLE);
>                   }
>                   catch (ComponentException ce) {
>                       throw new InstantiationException("Problem looking up Localization Service:"+ce.getMessage());
>                   }
>           }
>           return workflowService;
>       }

Odd formatting above.

>       /**
>        * Creates a new instance.  Used by <code>PullService</code>.
>        */
>       public WorkflowTool()
>       {
>           refresh();
>       }
>      
>     
>       /**
>        * Sets the request to get the <code>Accept-Language</code> header
>        * from (reset on each request).
>        */
>       public final void init(Object data)
>       {
>           if (data instanceof RunData)
>           {
>               // Pull necessary information out of RunData while we have
>               // a reference to it.
>               user = ((RunData)data).getUser();
>             
>           }
>       }
>       /**
>        * No-op.
>        */
>       public void refresh()
>       {
>           user = null;
>       }
>       
>       public List retrieveWorkflows(String status) throws WorkflowException{
>           List workflows = new ArrayList();
>           String caller = user.getName();
>           long workflowIds []= getWorkflowService().retrieveWorkflows(caller,status);
>           Workflow workflow = getWorkflowService().retrieveWorkflow(caller);
>           for (int i =0;i<workflowIds.length;i++) {

Brace placement.

>               WorkflowInstance workflowInstance = new WorkflowInstance(workflow,workflowIds[i]);
>               workflows.add(workflowInstance);
>           }
>           return workflows;
>       }
>       
>       
>   }


Re: cvs commit: jakarta-turbine-fulcrum/osworkflow/example/src/java/org/apache/fulcrum/osworkflow/example/tools WorkflowTool.java

Posted by "Daniel L. Rall" <dl...@finemaltcoding.com>.
Eric, were you using Eclipse for all these commits?  Formatting seems a bit 
off on most of'em.  Can the editor be configured to auto-format?  More 
comments inline.

epugh@apache.org wrote:
> epugh       2003/09/26 08:22:03
> 
>   Added:       osworkflow/example/src/java/org/apache/fulcrum/osworkflow/example/modules/actions
>                         Index.java WorkflowAction.java
>                osworkflow/example/src/java/org/apache/fulcrum/osworkflow/example/tools
>                         WorkflowTool.java
>   Log:
>   Add in renamed code.
>   
>   Revision  Changes    Path
>   1.1                  jakarta-turbine-fulcrum/osworkflow/example/src/java/org/apache/fulcrum/osworkflow/example/modules/actions/Index.java
>   
>   Index: Index.java
>   ===================================================================
>   package org.apache.fulcrum.osworkflow.example.modules.actions;
>   
>   import org.apache.turbine.modules.actions.VelocityAction;
>   import org.apache.turbine.util.RunData;
>   import org.apache.velocity.context.Context;
>   
>   
>   
>   /**
>    * @author     <a href="mailto:epugh@upstate.com">Eric Pugh</a>
>    * @created    October 11, 2002
>    */
>   public class Index extends VelocityAction {
>   
>   	/**
>   	 *  Default action is to load up the default template and list out the locations to go to:
>   	 <ol><li>Inventory Add Request<li>Inventory Delete Request<li>General Admin of Request</ol>
>   	 *
>   	 * @param  data           Current RunData information
>   	 * @param  context        Context to populate
>   	 * @exception  Exception  Thrown on error
>   	 */
>   	public void doPerform(RunData data, Context context) throws Exception {
>   
>   		System.out.println("Doperform called");
>   		data.setScreenTemplate("Index.vm");
>   
>   	}

Doesn't match Turbine's formatting conventions.

>   1.1                  jakarta-turbine-fulcrum/osworkflow/example/src/java/org/apache/fulcrum/osworkflow/example/modules/actions/WorkflowAction.java
>   
>   Index: WorkflowAction.java
>   ===================================================================
>   package org.apache.fulcrum.osworkflow.example.modules.actions;
>   import java.util.Collections;
>   
>   import org.apache.avalon.framework.component.ComponentException;
>   import org.apache.commons.logging.Log;
>   import org.apache.commons.logging.LogFactory;
>   import org.apache.fulcrum.osworkflow.WorkflowInstance;
>   import org.apache.fulcrum.osworkflow.WorkflowService;
>   import org.apache.turbine.modules.actions.VelocityAction;
>   import org.apache.turbine.services.InstantiationException;
>   import org.apache.turbine.services.TurbineServices;
>   import org.apache.turbine.services.avaloncomponent.AvalonComponentService;
>   import org.apache.turbine.util.RunData;
>   import org.apache.velocity.context.Context;
>   import com.opensymphony.module.user.Group;
>   import com.opensymphony.module.user.User;
>   import com.opensymphony.module.user.UserManager;
>   import com.opensymphony.workflow.Workflow;
>   /**
>    * @author     <a href="mailto:epugh@upstate.com">Eric Pugh</a>
>    * @created    October 11, 2002
>    */
>   public class WorkflowAction extends VelocityAction
>   {
>       private static Log log = LogFactory.getLog(WorkflowAction.class);
>       private WorkflowService workflowService;
>       /**
>        *  This guy deals with actions related to workflows.
>        *
>        * @param  data           Current RunData information
>        * @param  context        Context to populate
>        * @exception  Exception  Thrown on error
>        */
>       public void doPerform(RunData data, Context context) throws Exception
>       {
>           System.out.println("Doperform called");

I suspect that you didn't mean for that println to be in there.  =)

>           data.setScreenTemplate("Index.vm");
>       }
>       
>   	/**
>   		 *  This sets logs you in as user "test"
>   		 *
>   		 * @param  data           Current RunData information
>   		 * @param  context        Context to populate
>   		 * @exception  Exception  Thrown on error
>   		 */
>   		public void doLogin(RunData data, Context context) throws Exception
>   		{
>   			data.getUser().setName("test");
>   	
>           
>   			data.getMessages().setMessage("", "INFO", "You are logged in as user test!");
>   		}

Tabs and 8 char rather than 4 char indent?

>       /**
>        *  This sets up the user "test/test"
>        *
>        * @param  data           Current RunData information
>        * @param  context        Context to populate
>        * @exception  Exception  Thrown on error
>        */
>       public void doSetupuser(RunData data, Context context) throws Exception
>       {
>   	
>           data.setScreenTemplate("Index.vm");
>           UserManager um = UserManager.getInstance();
>           User test = um.createUser("test");
>           test.setPassword("test");
>           Group foos = um.createGroup("foos");
>           Group bars = um.createGroup("bars");
>           Group bazs = um.createGroup("bazs");
>           test.addToGroup(foos);
>           test.addToGroup(bars);
>           test.addToGroup(bazs);
>           
>           data.getMessages().setMessage("", "INFO", "User test/test is setup in system.  Don't forget to login!");
>       }
>       
>       
>       /**
>        *  Create a new Workflow
>        *
>        * @param  data           Current RunData information
>        * @param  context        Context to populate
>        * @exception  Exception  Thrown on error
>        */
>       public void doNew(RunData data, Context context) throws Exception
>       {
>           System.out.println("doNew called");

Use of a logging class might be more appropriate.

>           data.setScreenTemplate("Index.vm");
>           try
>           {
>               Workflow wf = getWorkflowService().retrieveWorkflow(data.getUser().getName());
>               long id = wf.initialize("example", 1, null);
>               data.getMessages().setMessage("", "INFO", "New Workflow id " + id + " created and initialized!");
>           }
>           catch (Exception e)
>           {
>               log.error(e);
>               data.getMessages().setMessage("", "ERROR", e.getMessage());
>           }
>       }

Odd formatting follows.

>       /**
>           *  Create a new Workflow
>           *
>           * @param  data           Current RunData information
>           * @param  context        Context to populate
>           * @exception  Exception  Thrown on error
>           */
>       public void doViewdetail(RunData data, Context context) throws Exception
>       {
>           System.out.println("doViewdetail called");
>           data.setScreenTemplate("WorkflowDetail.vm");
>           try
>           {
>               context.put("wf", getWorkflowInstance(data, context));
>           }
>           catch (Exception e)
>           {
>               log.error(e);
>               data.getMessages().setMessage("", "ERROR", e.getMessage());
>           }
>       }
>       /**
>           * Lazy load the WorkflowService.
>           * @return a fulcrum WorkflowService
>           */
>       public WorkflowService getWorkflowService()
>       {
>           if (workflowService == null)
>           {
>               AvalonComponentService acs =
>                   (AvalonComponentService) TurbineServices.getInstance().getService(AvalonComponentService.SERVICE_NAME);
>               try
>               {
>                   workflowService = (WorkflowService) acs.lookup(WorkflowService.ROLE);
>               }
>               catch (ComponentException ce)
>               {
>                   throw new InstantiationException("Problem looking up Workflow Service:" + ce.getMessage());
>               }
>           }
>           return workflowService;
>       }
>       /**
>           *  Perform an action
>           *
>           * @param  data           Current RunData information
>           * @param  context        Context to populate
>           * @exception  Exception  Thrown on error
>           */
>       public void doAction(RunData data, Context context) throws Exception
>       {
>           
>           try
>           {
>               WorkflowInstance wf = getWorkflowInstance(data, context);
>               int action = data.getParameters().getInt("actionId");
>               wf.doAction(action, Collections.EMPTY_MAP);
>           
>           }
>           catch (Exception e)
>           {
>               log.error(e);
>               data.getMessages().setMessage("", "ERROR", e.getMessage());
>           }
>           doViewdetail(data,context);
>       }
>       protected WorkflowInstance getWorkflowInstance(RunData data, Context context)
>       {
>           long workflowId = data.getParameters().getLong("id");
>           Workflow workflow = getWorkflowService().retrieveWorkflow(data.getUser().getName());
>           WorkflowInstance wf = new WorkflowInstance(workflow, workflowId);
>           return wf;
>       }
>   }
>   
>   
>   
>   1.1                  jakarta-turbine-fulcrum/osworkflow/example/src/java/org/apache/fulcrum/osworkflow/example/tools/WorkflowTool.java
>   
>   Index: WorkflowTool.java
>   ===================================================================
>   package org.apache.fulcrum.osworkflow.example.tools;
>   /* ====================================================================
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
>    * reserved.
>    *
>    * Redistribution and use in source and binary forms, with or without
>    * modification, are permitted provided that the following conditions
>    * are met:
>    *
>    * 1. Redistributions of source code must retain the above copyright
>    *    notice, this list of conditions and the following disclaimer.
>    *
>    * 2. Redistributions in binary form must reproduce the above copyright
>    *    notice, this list of conditions and the following disclaimer in
>    *    the documentation and/or other materials provided with the
>    *    distribution.
>    *
>    * 3. The end-user documentation included with the redistribution,
>    *    if any, must include the following acknowledgment:
>    *       "This product includes software developed by the
>    *        Apache Software Foundation (http://www.apache.org/)."
>    *    Alternately, this acknowledgment may appear in the software itself,
>    *    if and wherever such third-party acknowledgments normally appear.
>    *
>    * 4. The names "Apache" and "Apache Software Foundation" and
>    *    "Apache Turbine" must not be used to endorse or promote products
>    *    derived from this software without prior written permission. For
>    *    written permission, please contact apache@apache.org.
>    *
>    * 5. Products derived from this software may not be called "Apache",
>    *    "Apache Turbine", nor may "Apache" appear in their name, without
>    *    prior written permission of the Apache Software Foundation.
>    *
>    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>    * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>    * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>    * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>    * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>    * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>    * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>    * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>    * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>    * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>    * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>    * SUCH DAMAGE.
>    * ====================================================================
>    *
>    * This software consists of voluntary contributions made by many
>    * individuals on behalf of the Apache Software Foundation.  For more
>    * information on the Apache Software Foundation, please see
>    * <http://www.apache.org/>.
>    */
>   
>   
>   import java.util.ArrayList;
>   import java.util.List;
>   
>   import org.apache.avalon.framework.component.ComponentException;
>   import org.apache.commons.logging.Log;
>   import org.apache.commons.logging.LogFactory;
>   import org.apache.fulcrum.osworkflow.WorkflowInstance;
>   import org.apache.fulcrum.osworkflow.WorkflowService;
>   import org.apache.turbine.om.security.User;
>   import org.apache.turbine.services.InstantiationException;
>   import org.apache.turbine.services.TurbineServices;
>   import org.apache.turbine.services.avaloncomponent.AvalonComponentService;
>   import org.apache.turbine.services.pull.ApplicationTool;
>   import org.apache.turbine.util.RunData;
>   
>   import com.opensymphony.workflow.Workflow;
>   import com.opensymphony.workflow.WorkflowException;
>   /**
>    * A pull tool which provides lookups of workflows by delegating
>    * to the configured Fulcrum <code>WorkflowService</code>.
>    *
>    * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
>    */
>   public class WorkflowTool implements ApplicationTool
>   {
>       /** Logging */
>       private static Log log = LogFactory.getLog(WorkflowTool.class);
>       /** Fulcrum Localization component */
>       private WorkflowService workflowService;
>       private User user;
>   
>   
>       /**
>        * Lazy load the WorkflowService.
>        * @return a fulcrum WorkflowService
>        */
>       public WorkflowService getWorkflowService()
>       {
>           if (workflowService == null)
>           {
>               AvalonComponentService acs =
>                   (AvalonComponentService) TurbineServices.getInstance().getService(AvalonComponentService.SERVICE_NAME);
>                   try {
>               workflowService = (WorkflowService)acs.lookup(WorkflowService.ROLE);
>                   }
>                   catch (ComponentException ce) {
>                       throw new InstantiationException("Problem looking up Localization Service:"+ce.getMessage());
>                   }
>           }
>           return workflowService;
>       }

Odd formatting above.

>       /**
>        * Creates a new instance.  Used by <code>PullService</code>.
>        */
>       public WorkflowTool()
>       {
>           refresh();
>       }
>      
>     
>       /**
>        * Sets the request to get the <code>Accept-Language</code> header
>        * from (reset on each request).
>        */
>       public final void init(Object data)
>       {
>           if (data instanceof RunData)
>           {
>               // Pull necessary information out of RunData while we have
>               // a reference to it.
>               user = ((RunData)data).getUser();
>             
>           }
>       }
>       /**
>        * No-op.
>        */
>       public void refresh()
>       {
>           user = null;
>       }
>       
>       public List retrieveWorkflows(String status) throws WorkflowException{
>           List workflows = new ArrayList();
>           String caller = user.getName();
>           long workflowIds []= getWorkflowService().retrieveWorkflows(caller,status);
>           Workflow workflow = getWorkflowService().retrieveWorkflow(caller);
>           for (int i =0;i<workflowIds.length;i++) {

Brace placement.

>               WorkflowInstance workflowInstance = new WorkflowInstance(workflow,workflowIds[i]);
>               workflows.add(workflowInstance);
>           }
>           return workflows;
>       }
>       
>       
>   }


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org