Mailing List svn-list@magnolia.info Message #6989
From: svn@magnolia.info
Subject: [16923] upgrading to our latest code
Date: Sat, 19 Jul 2008 12:56:16 +0200 (CEST)
To: svn-list@magnolia.info

[16923] upgrading to our latest code ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; } #logmsg pre { background: #eee; padding: 1em; } #logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;} #logmsg dl { margin: 0; } #logmsg dt { font-weight: bold; } #logmsg dd { margin: 0; padding: 0 0 0.5em 0; } #logmsg dd:before { content:'\00bb';} #logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; } #logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; } #logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; } #logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; } #logmsg table th.Corner { text-align: left; } #logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; } #header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; } #patch { width: 100%; } #patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;} #patch .propset h4, #patch .binary h4 {margin:0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;} #patch .propset .diff, #patch .binary .diff {padding:10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;} #patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;} #patch .lines, .info {color:#888;background:#fff;} -->
Revision
16923
Author
jmettraux
Date
2008-07-19 12:56:15 +0200 (Sat, 19 Jul 2008)

Log Message

upgrading to our latest code

Modified Paths

Diff

Modified: modules/community/magnolia-module-workflow/branches/magnolia-module-workflow-openwfe-ruby-3.0/pom.xml (16922 => 16923)


--- modules/community/magnolia-module-workflow/branches/magnolia-module-workflow-openwfe-ruby-3.0/pom.xml	2008-07-18 19:52:16 UTC (rev 16922)
+++ modules/community/magnolia-module-workflow/branches/magnolia-module-workflow-openwfe-ruby-3.0/pom.xml	2008-07-19 10:56:15 UTC (rev 16923)
@@ -1,21 +1,17 @@
-<project 
-    xmlns="http://maven.apache.org/POM/4.0.0" 
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
-    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
->
-
-  <parent>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <properties>
+      <!--openwfe.version>1.7.2pre11</openwfe.version-->
+  </properties>
+   <parent>
     <artifactId>magnolia-project</artifactId>
     <groupId>info.magnolia</groupId>
-    <version>3.1-SNAPSHOT</version>
+    <version>3.0-6596-rev3-SNAPSHOT</version>
     <relativePath>../pom.xml</relativePath>
   </parent>
-
   <modelVersion>4.0.0</modelVersion>
   <artifactId>magnolia-module-workflow</artifactId>
   <name>magnolia-module-workflow</name>
-  <version>3.1-SNAPSHOT</version>
-
+  <version>3.0-6596-rev3-SNAPSHOT</version>
   <dependencies>
     <dependency>
       <groupId>javax.servlet</groupId>
@@ -25,7 +21,7 @@
     <dependency>
       <groupId>info.magnolia</groupId>
       <artifactId>magnolia-core</artifactId>
-      <version>3.1-SNAPSHOT</version>
+      <version>3.0-rc3-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>javax.servlet</groupId>
@@ -39,7 +35,7 @@
     <dependency>
       <groupId>info.magnolia</groupId>
       <artifactId>magnolia-module-admininterface</artifactId>
-      <version>3.1-SNAPSHOT</version>
+      <version>3.0-6596-rev3-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>jaxen</groupId>
@@ -63,33 +59,25 @@
     <dependency>
       <groupId>info.magnolia</groupId>
       <artifactId>magnolia-exchange-simple</artifactId>
-      <version>3.1-SNAPSHOT</version>
+      <version>3.0-6596-rev3-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>info.magnolia</groupId>
       <artifactId>magnolia-gui</artifactId>
-      <version>3.1-SNAPSHOT</version>
+      <version>3.0-6596-rev3-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-log4j12</artifactId>
     </dependency>
 
-    <!--
     <dependency>
-      <groupId>org.jruby</groupId>
-      <artifactId>jruby-complete</artifactId>
-      <version>1.1-SNAPSHOT</version>
-    </dependency>
-    -->
-    <dependency>
       <groupId>org.openwfe</groupId>
       <artifactId>openwferu</artifactId>
-      <version>0.9.16-SNAPSHOT</version>
+      <version>0.9.19-SNAPSHOT</version>
     </dependency>
 
   </dependencies>
-
   <distributionManagement>
     <site>
       <id>magnolia</id>
@@ -100,7 +88,7 @@
 
   <repositories>
     <repository>
-      <!-- where JRuby and OpenWFEru are -->
+      <!-- where OpenWFEru is -->
       <id>maven.openwfe.org.snapshots</id>
       <url>http://maven.openwfe.org/snapshots</url>
       <snapshots>
@@ -108,4 +96,5 @@
       </snapshots>
     </repository>
   </repositories>
+
 </project>

Modified: modules/community/magnolia-module-workflow/branches/magnolia-module-workflow-openwfe-ruby-3.0/src/main/java/info/magnolia/module/workflow/WorkflowModule.java (16922 => 16923)


--- modules/community/magnolia-module-workflow/branches/magnolia-module-workflow-openwfe-ruby-3.0/src/main/java/info/magnolia/module/workflow/WorkflowModule.java	2008-07-18 19:52:16 UTC (rev 16922)
+++ modules/community/magnolia-module-workflow/branches/magnolia-module-workflow-openwfe-ruby-3.0/src/main/java/info/magnolia/module/workflow/WorkflowModule.java	2008-07-19 10:56:15 UTC (rev 16923)
@@ -20,6 +20,7 @@
 import info.magnolia.cms.util.NodeDataUtil;
 import info.magnolia.commands.CommandsManager;
 import info.magnolia.context.Context;
+import info.magnolia.context.MgnlContext;
 import info.magnolia.module.admininterface.AbstractAdminModule;
 
 import java.util.HashMap;
@@ -85,6 +86,10 @@
         if (path != null)
             launchitem.put(Context.ATTRIBUTE_PATH, path);
 
+        //String uuid = getUuid(repository, path);
+        //if (uuid != null)
+        //    launchitem.put(Context.ATTRIBUTE_UUID, uuid);
+
         launchitem.put(WorkflowConstants.ATT_WORKFLOW, flowName);
 
         return launchFlow(launchitem);
@@ -165,6 +170,11 @@
     //
     // WORKLIST METHODS
 
+    public List getUserInbox () {
+
+        return getInbox("user", MgnlContext.getUser().getName());
+    }
+
     public List getUserInbox (String name) {
 
         return getInbox("user", name);
@@ -190,6 +200,16 @@
              Object.class);
     }
 
+    public List getWorkitems () {
+
+        return (List) JavaEmbedUtils.invokeMethod
+            (this.rubyRuntime, 
+             this.worklist, 
+             "get_workitems",
+             new Object[] {},
+             Object.class);
+    }
+
     /**
      * Returns the path of the content object associated with the workitem
      * (wi identified by its fei - FlowExpressionId).
@@ -313,6 +333,31 @@
     //
     // PRIVATE METHODS
 
+    /*
+    private String getUuid (String repository, String path) {
+
+        if (repository == null) return null;
+
+        try {
+
+            Content c = ContentRepository.getHierarchyManager(repository)
+                .getContent(path);
+
+            return c.getUUID();
+        }
+        catch (Throwable t) {
+
+            log.info
+                ("getUuid() "+
+                 "failed to find UUID for path '"+path+
+                 "' in repository '"+repository+"'\n"+
+                 "("+t.getMessage()+")");
+
+            return null;
+        }
+    }
+    */
+
     private void registerCacheUrl() {
 
         Content node = ContentUtil

Modified: modules/community/magnolia-module-workflow/branches/magnolia-module-workflow-openwfe-ruby-3.0/src/main/resources/workflower/engine.rb (16922 => 16923)


--- modules/community/magnolia-module-workflow/branches/magnolia-module-workflow-openwfe-ruby-3.0/src/main/resources/workflower/engine.rb	2008-07-18 19:52:16 UTC (rev 16922)
+++ modules/community/magnolia-module-workflow/branches/magnolia-module-workflow-openwfe-ruby-3.0/src/main/resources/workflower/engine.rb	2008-07-19 10:56:15 UTC (rev 16923)
@@ -26,579 +26,560 @@
 require 'openwfe/expool/errorjournal'
 
 require 'openwfe/storage/yamlcustom'
-    # very important, else the to_yaml() function serializes too much...
+  # very important, else the to_yaml() function serializes too much...
 
 require 'workflower/worklist'
 
 
 module Workflower
 
-    #
-    # Some constants.
-    # Their names are new, their values are old.
+  #
+  # Some constants.
+  # Their names are new, their values are old.
 
-    EXPRESSION_WORKSPACE = 'Expressions'
+  EXPRESSION_WORKSPACE = 'Expressions'
 
+  #
+  # The JCR based OpenWFEru engine.
+  #
+  class JcrPersistedEngine < OpenWFE::Engine
+
     #
-    # The JCR based OpenWFEru engine.
+    # A dedicated Magnlia launch flow method.
+    # It accepts as Hash[Map] as a launchitem.
     #
-    class JcrPersistedEngine < OpenWFE::Engine
+    # To make things simple, it returns the flow expression id
+    # of the root of the process newly launched as a string.
+    #
+    def launch_flow (hash)
 
-        #
-        # A dedicated Magnlia launch flow method.
-        # It accepts as Hash[Map] as a launchitem.
-        #
-        # To make things simple, it returns the flow expression id
-        # of the root of the process newly launched as a string.
-        #
-        def launch_flow (hash)
+      li = OpenWFE::LaunchItem.new
 
-            li = OpenWFE::LaunchItem.new
+      li.workflow_definition_url = hash[WfConstants::WFD_URL]
 
-            li.workflow_definition_url = hash[WfConstants::WFD_URL]
+      linfo { "launch_flow() for '#{li.workflow_definition_url}'" }
 
-            linfo { "launch_flow() for '#{li.workflow_definition_url}'" }
+      hash.remove WfConstants::WFD_URL
 
-            hash.remove WfConstants::WFD_URL
+      li.attributes = {}
+      hash.each { |k, v| li.attributes[k] = v }
 
-            li.attributes = {}
-            hash.each { |k, v| li.attributes[k] = v }
+      fei = launch li
 
-            fei = launch li
+      fei.to_s
+    end
 
-            fei.to_s
-        end
+    #
+    # As the name implies.
+    #
+    def cancel_flow (sid)
 
-        #
-        # As the name implies.
-        #
-        def cancel_flow (sid)
+      linfo { "cancel_flow() for '#{sid}'" }
 
-            linfo { "cancel_flow() for '#{sid}'" }
+      wfid = if sid.match("^.fei ")
+        OpenWFE::FlowExpressionId.from_s(sid).wfid
+      else
+        sid
+      end
 
-            wfid = if sid.match("^.fei ")
-                OpenWFE::FlowExpressionId.from_s(sid).wfid
-            else
-                sid
-            end
+      cancel_process sid
+    end
 
-            cancel_process sid
-        end
+    protected
 
-        protected
+      #
+      # Uses a JCR based expression storage
+      #
+      def build_expression_storage
 
-            #
-            # Uses a JCR based expression storage
-            #
-            def build_expression_storage
+        @application_context[:expression_cache_size] = 1000
 
-                @application_context[:expression_cache_size] = 1000
+        init_service(
+          OpenWFE::S_EXPRESSION_STORAGE, 
+          OpenWFE::CacheExpressionStorage)
+      
+        init_service(
+          OpenWFE::S_EXPRESSION_STORAGE + ".1",
+          JcrExpressionStorage)
+      end
 
-                init_service(
-                    S_EXPRESSION_STORAGE, 
-                    OpenWFE::CacheExpressionStorage)
-            
-                init_service(
-                    S_EXPRESSION_STORAGE + ".1",
-                    JcrExpressionStorage)
-            end
+      #
+      # Uses a JCR based error journal
+      #
+      def build_error_journal
 
-            #
-            # Uses a JCR based error journal
-            #
-            def build_error_journal
+        init_service OpenWFE::S_ERROR_JOURNAL, JcrErrorJournal
+        #init_service OpenWFE::S_ERROR_JOURNAL, OpenWFE::YamlErrorJournal
+      end
+  end
 
-                init_service S_ERROR_JOURNAL, JcrErrorJournal
-                #init_service S_ERROR_JOURNAL, OpenWFE::YamlErrorJournal
-            end
-    end
+  #
+  # Using HttpClient to get https document instead of openssl.rb
+  #
+  class OpenWFE::ExpressionPool
 
-    #
-    # Using HttpClient to get https document instead of openssl.rb
-    #
-    class OpenWFE::ExpressionPool
+    alias :original_read_uri :read_uri
 
-        alias :original_read_uri :read_uri
+    def read_uri (uri)
 
-        def read_uri (uri)
+      suri = uri.to_s
 
-            suri = uri.to_s
+      if suri.match("^magnolia:")
 
-            if suri.match("^magnolia:")
+        JCRFlowUtil.getFlowDefAsString suri[11..-1]
 
-                JCRFlowUtil.getFlowDefAsString suri[11..-1]
+      elsif suri.match("^https:")
 
-            elsif suri.match("^https:")
+        hc = HttpClient.new
+        gm = GetMethod.new uri
+        hc.executeMethod gm
 
-                hc = HttpClient.new
-                gm = GetMethod.new uri
-                hc.executeMethod gm
+        gm.getResponseBodyAsString
 
-                gm.getResponseBodyAsString
+      else
 
-            else
-
-                original_read_uri uri
-            end
-        end
+        original_read_uri uri
+      end
     end
+  end
 
-    #
-    # Stores the workflow expressions (atomic pieces of workflow instances)
-    # in a JCR repository).
-    #
-    class JcrExpressionStorage
-        include MonitorMixin
-        include OpenWFE::ServiceMixin
-        include OpenWFE::OwfeServiceLocator
-        include OpenWFE::ExpressionStorageBase
+  #
+  # Stores the workflow expressions (atomic pieces of workflow instances)
+  # in a JCR repository).
+  #
+  class JcrExpressionStorage
+    include MonitorMixin
+    include OpenWFE::ServiceMixin
+    include OpenWFE::OwfeServiceLocator
+    include OpenWFE::ExpressionStorageBase
 
 
-        ENGINE_ENV = '/engine_environment'
-        EXPRESSIONS_QUERY = '//*[@ID]'
+    ENGINE_ENV = '/engine_environment'
+    EXPRESSIONS_QUERY = '//*[@ID]'
 
 
-        def initialize (service_name, application_context)
+    def initialize (service_name, application_context)
 
-            super()
-                #
-                # this call, is very important as this class includes
-                # the MonitorMixin.
+      super()
+        #
+        # this call, is very important as this class includes
+        # the MonitorMixin.
 
-            service_init service_name, application_context
+      service_init service_name, application_context
 
-            @hm = ContentRepository.getHierarchyManager(EXPRESSION_WORKSPACE)
+      @hm = ContentRepository.getHierarchyManager(EXPRESSION_WORKSPACE)
 
-            raise "failed to get HierarchyManager '#{EXPRESSION_WORKSPACE}'" \
-                unless @hm
+      raise "failed to get HierarchyManager '#{EXPRESSION_WORKSPACE}'" \
+        unless @hm
 
-            observe_expool
+      observe_expool
 
-            linfo { "initialize() expression storage ready" }
-        end
+      linfo { "initialize() expression storage ready" }
+    end
 
-        def []= (fei, fe)
+    def []= (fei, fe)
 
-            ldebug { "[]= storing #{fei.to_s}" }
+      ldebug { "[]= storing #{fei.to_s}" }
 
-            synchronize do
+      synchronize do
 
-                c = locate_expression fei, true
+        c = locate_expression fei, true
 
-                vf = c.getJCRNode.getSession.getValueFactory
+        vf = c.getJCRNode.getSession.getValueFactory
 
-                c.createNodeData(
-                    WfConstants::NODEDATA_ID, vf.createValue(fei.to_s))
-                c.createNodeData(
-                    WfConstants::NODEDATA_WFID, vf.createValue(fei.wfid))
-                c.createNodeData(
-                    WfConstants::NODEDATA_EXPCLASS, vf.createValue(fe.class.name))
+        c.createNodeData(
+          WfConstants::NODEDATA_ID, vf.createValue(fei.to_s))
+        c.createNodeData(
+          WfConstants::NODEDATA_WFID, vf.createValue(fei.wfid))
+        c.createNodeData(
+          WfConstants::NODEDATA_EXPCLASS, vf.createValue(fe.class.name))
 
-                c.createNodeData(
-                    WfConstants::NODEDATA_VALUE, vf.createValue(YAML.dump(fe)))
+        c.createNodeData(
+          WfConstants::NODEDATA_VALUE, vf.createValue(YAML.dump(fe)))
 
-                @hm.save
-            end
-        end
+        @hm.save
+      end
+    end
 
-        def [] (fei)
-            synchronize do
+    def [] (fei)
+      synchronize do
 
-                cExpression = locate_expression fei
+        cExpression = locate_expression fei
 
-                return nil unless cExpression
+        return nil unless cExpression
 
-                load_expression cExpression
-            end
-        end
+        load_expression cExpression
+      end
+    end
 
-        def delete (fei)
-            synchronize do
+    def delete (fei)
+      synchronize do
 
-                cExpression = locate_expression fei
+        cExpression = locate_expression fei
 
-                if cExpression
+        if cExpression
 
-                    cExpression.delete
-                    @hm.save
-                end
-            end
+          cExpression.delete
+          @hm.save
         end
+      end
+    end
 
-        #
-        # Returns the size of this expression storage (returns the count
-        # of expressions stored).
-        #
-        def size
+    #
+    # Returns the size of this expression storage (returns the count
+    # of expressions stored).
+    #
+    def size
 
-            query_for_expression(EXPRESSIONS_QUERY).size + 1
-                # plus one for the engive environment expression
-        end
+      query_for_expression(EXPRESSIONS_QUERY).size + 1
+        # plus one for the engive environment expression
+    end
 
-        alias :length :size
+    alias :length :size
 
-        def each (wfid_prefix=nil, &block)
+    #
+    # The 0.9.17 method for expstorage implementations. Replaces each and
+    # each_of_kind.
+    #
+    def find_expressions (options={})
 
-            #query_string = if wfid_prefix
-            #    "//*[@ID and starts-with(local-name(), '#{wfid_prefix}')]"
-            #else
-            #    EXPRESSIONS_QUERY
-            #end
-                #
-                # the current JCR impl doesn't support starts-with() grrrr....
-                #
-            query_string = EXPRESSIONS_QUERY
+      ic = options[:include_classes]
 
-            c = query_for_expressions(query_string)
+      qs = if ic
 
-            ldebug { "each() will consider #{c.size} expressions" }
+        classes = get_expression_map.get_expression_classes ic
 
-            c.each do |content|
+        s = classes.collect { |expclass|
+          "@expressionClass='#{expclass.to_s}'"
+        }.join(" or ")
 
-                #ldebug { "each() considering #{content.getHandle}" }
-                #ldebug { "each() considering #{content.getName}" }
+        "//*[#{s}]"
+      else
 
-                next if wfid_prefix \
-                    and (not content.getName.match("^"+wfid_prefix))
-                        #
-                        # grrrr...
+        EXPRESSIONS_QUERY
+      end
 
-                fexp = load_expression content
-                block.call fexp.fei, fexp
-            end
-        end
+      linfo { "find_expressions() qs is >#{qs}<" }
 
-        #
-        # a minimalistic implementation : will load all the nodes...
-        #
-        def each_of_kind (kind, &block)
+      c = query_for_expressions qs
 
-            classes = get_expression_map.get_expression_classes kind
+      c.inject([]) do |r, content|
 
-            qs = classes.collect { |expclass|
-                "@expressionClass='#{expclass.to_s}'"
-            }.join(" or ")
+        linfo { "each_of_kind() considering #{content.getHandle}" }
+        #ldebug { "each_of_kind() considering #{content.getName}" }
 
-            qs = "//*[#{qs}]"
+        fexp = load_expression content
 
-            linfo { "each_of_kind() qs is >#{qs}<" }
+        r << fexp if does_match?(options, fexp)
 
-            c = query_for_expressions qs
+        r
+      end
+    end
 
-            c.each do |content|
+    #
+    # A 0.9.17 method, getting quicker to the heart of a process definition.
+    #
+    # (not yet proven...)
+    #
+    def fetch_root (wfid)
 
-                ldebug { "each_of_kind() considering #{content.getHandle}" }
-                ldebug { "each_of_kind() considering #{content.getName}" }
+      qs = \
+        "//*["+
+        "@expressionClass='OpenWFE::DefineExpression' and "+
+        "@wfid='#{wfid}'"+
+        "]"
 
-                fexp = load_expression content
-                block.call fexp.fei, fexp
-            end
-        end
+      linfo { "fetch_root() qs is >#{qs}<" }
 
-        #
-        # A 0.9.17 method, getting quicker to the heart of a process definition.
-        #
-        # (not yet proven...)
-        #
-        def fetch_root (wfid)
+      c = query_for_expressions qs
 
-            qs = \
-                "//*["+
-                "@expressionClass='OpenWFE::DefineExpression' and "+
-                "@wfid='#{wfid}'"+
-                "]"
+      return nil if c.size < 1
 
-            linfo { "fetch_root() qs is >#{qs}<" }
+      exps = c.collect do |content|
 
-            c = query_for_expressions qs
+        load_expression content
+      end
 
-            return nil if c.size < 1
+      exps.sort { |a, b| a.fei.expid <=> b.fei.expid }[0]
+    end
 
-            exps = c.collect do |content|
+    protected
 
-                load_expression content
-            end
+      #
+      # Returns an array of Content instances matching the query_string
+      #
+      def query_for_expressions (query_string)
 
-            exps.sort { |a, b| a.fei.expid <=> b.fei.expid }[0]
-        end
+        qr = MgnlContext.getQueryManager(EXPRESSION_WORKSPACE)\
+          .createQuery(query_string, Query::XPATH).execute
 
-        protected
+        qr.getContent(WfConstants::NODENAME_EXPRESSION)
+      end
 
-            #
-            # Returns an array of Content instances matching the query_string
-            #
-            def query_for_expressions (query_string)
+      #
+      # Returns the Content instance where the expression has to be / is
+      # located.
+      #
+      def locate_expression (fei, create_if_missing=false)
 
-                qr = MgnlContext.getQueryManager(EXPRESSION_WORKSPACE)\
-                    .createQuery(query_string, Query::XPATH).execute
+        path = determine_path(fei)
 
-                qr.getContent(WfConstants::NODENAME_EXPRESSION)
-            end
+        if @hm.isExist(path)
 
-            #
-            # Returns the Content instance where the expression has to be / is
-            # located.
-            #
-            def locate_expression (fei, create_if_missing=false)
+          @hm.getContent path
 
-                path = determine_path(fei)
+        elsif create_if_missing
 
-                if @hm.isExist(path)
+          ContentUtil.createPath @hm, path, ItemType::EXPRESSION
 
-                    @hm.getContent path
+        else
 
-                elsif create_if_missing
+          nil
+        end
+      end
 
-                    ContentUtil.createPath @hm, path, ItemType::EXPRESSION
+      def determine_path (fei)
 
-                else
+        return ENGINE_ENV if fei.workflow_instance_id == '0'
+          #
+          # the environment common to all the process instances
+          # in the process engine
 
-                    nil
-                end
-            end
+        wfid = fei.parent_workflow_instance_id
 
-            def determine_path (fei)
+        a_wfid = get_wfid_generator.split_wfid(wfid)
 
-                return ENGINE_ENV if fei.workflow_instance_id == '0'
-                    #
-                    # the environment common to all the process instances
-                    # in the process engine
+        path =  '/'
+        path << a_wfid[-2]
+        path << '/'
+        path << a_wfid[-1]
+        path << '/'
+        path << fei.workflow_instance_id
+        path << '__'
+        path << OpenWFE.ensure_for_filename(fei.wfname)
+        path << '__'
+        path << fei.expression_id
+        path << '_'
+        path << fei.expression_name
 
-                wfid = fei.parent_workflow_instance_id
+        path
+      end
 
-                a_wfid = get_wfid_generator.split_wfid(wfid)
+      #
+      # Loads the engine environment expression.
+      #
+      #def load_engine_env
+      #  return nil unless @hm.isExist(ENGINE_ENV)
+      #  load_expression(@hm.getContent(ENGINE_ENV))
+      #end
 
-                path =  '/'
-                path << a_wfid[-2]
-                path << '/'
-                path << a_wfid[-1]
-                path << '/'
-                path << fei.workflow_instance_id
-                path << '__'
-                path << OpenWFE.ensure_for_filename(fei.wfname)
-                path << '__'
-                path << fei.expression_id
-                path << '_'
-                path << fei.expression_name
+      def load_expression (content)
 
-                path
-            end
+        s = content.getNodeData(WfConstants::NODEDATA_VALUE).getString
+        expression = YAML.load(s)
 
-            #
-            # Loads the engine environment expression.
-            #
-            #def load_engine_env
-            #    return nil unless @hm.isExist(ENGINE_ENV)
-            #    load_expression(@hm.getContent(ENGINE_ENV))
-            #end
+        #return nil unless expression
 
-            def load_expression (content)
+        expression.application_context = @application_context
 
-                s = content.getNodeData(WfConstants::NODEDATA_VALUE).getString
-                expression = YAML.load(s)
+        expression
+      end
+  end
 
-                #return nil unless expression
+  #
+  # A perf version of the JcrPersistedEngine, uses a cache and a 
+  # threaded version of the JcrExpressionStorage.
+  #
+  class CachedJcrPersistedEngine < JcrPersistedEngine
 
-                expression.application_context = @application_context
+    protected
 
-                expression
-            end
-    end
+      def build_expression_storage
 
-    #
-    # A perf version of the JcrPersistedEngine, uses a cache and a 
-    # threaded version of the JcrExpressionStorage.
-    #
-    class CachedJcrPersistedEngine < JcrPersistedEngine
+        @application_context[:expression_cache_size] ||= 777
 
-        protected
+        init_service(
+          OpenWFE::S_EXPRESSION_STORAGE,
+          OpenWFE::CacheExpressionStorage)
 
-            def build_expression_storage
+        init_service(
+          OpenWFE::S_EXPRESSION_STORAGE + ".1",
+          ThreadedJcrExpressionStorage)
+      end
+  end
 
-                @application_context[:expression_cache_size] ||= 777
+  #
+  # A threaded version of the JcrExpressionStorage.
+  # For performance.
+  #
+  class ThreadedJcrExpressionStorage < JcrExpressionStorage
+    include OpenWFE::ThreadedStorageMixin
 
-                init_service(
-                    S_EXPRESSION_STORAGE,
-                    CacheExpressionStorage)
+    def initialize (service_name, application_context)
 
-                init_service(
-                    S_EXPRESSION_STORAGE + ".1",
-                    ThreadedJcrExpressionStorage)
-            end
-    end
+      super
 
-    #
-    # A threaded version of the JcrExpressionStorage.
-    # For performance.
-    #
-    class ThreadedJcrExpressionStorage < JcrExpressionStorage
-        include OpenWFE::ThreadedStorageMixin
-
-        def initialize (service_name, application_context)
-
-            super
-
-            start_processing_thread()
-        end
+      start_queue()
     end
+  end
 
-    #
-    # Keeping track of potential workflow troubles in the JCR.
-    #
-    # For now, workflow errors go into the Expressions workspace.
-    #
-    class JcrErrorJournal < OpenWFE::ErrorJournal
+  #
+  # Keeping track of potential workflow troubles in the JCR.
+  #
+  # For now, workflow errors go into the Expressions workspace.
+  #
+  class JcrErrorJournal < OpenWFE::ErrorJournal
 
-        EJOURNAL_PATH = '/error_journal'
+    EJOURNAL_PATH = '/error_journal'
 
-        def initialize (service_name, application_context)
+    def initialize (service_name, application_context)
 
-            super
+      super
 
-            @hm = ContentRepository.getHierarchyManager(EXPRESSION_WORKSPACE)
+      @hm = ContentRepository.getHierarchyManager(EXPRESSION_WORKSPACE)
 
-            raise "failed to get HierarchyManager '#{EXPRESSION_WORKSPACE}'" \
-                unless @hm
+      raise "failed to get HierarchyManager '#{EXPRESSION_WORKSPACE}'" \
+        unless @hm
 
-            @mutex = Mutex.new
-        end
+      @mutex = Mutex.new
+    end
 
-        #
-        # Returns a list (older error first) of the errors for a process
-        # instance identified by its fei or wfid.
-        #
-        def get_error_log (wfid)
+    #
+    # Returns a list (older error first) of the errors for a process
+    # instance identified by its fei or wfid.
+    #
+    def get_error_log (wfid)
 
-            #wfid = to_wfid(wfid)
+      #wfid = to_wfid(wfid)
 
-            c = locate_content(wfid)
+      c = locate_content(wfid)
 
-            return [] unless c
+      return [] unless c
 
-            h = {}
+      h = {}
 
-            c.getNodeDataCollection.each do |d|
+      c.getNodeDataCollection.each do |d|
 
-                index = Integer(d.getName)
-                error = YAML.load(d.getString)
+        index = Integer(d.getName)
+        error = YAML.load(d.getString)
 
-                h[index] = error
-            end
+        h[index] = error
+      end
 
-            # making sure we return the errors in the original order
-            # (order of occurrence)
+      # making sure we return the errors in the original order
+      # (order of occurrence)
 
-            h.keys.sort.collect { |k| h[k] }
-        end
+      h.keys.sort.collect { |k| h[k] }
+    end
 
-        def remove_error_log (wfid)
+    def remove_error_log (wfid)
 
-            @mutex.synchronize do
+      @mutex.synchronize do
 
-                c = locate_content(wfid)
+        c = locate_content(wfid)
 
-                return unless c
+        return unless c
 
-                c.delete
-                @hm.save
-            end
-        end
+        c.delete
+        @hm.save
+      end
+    end
 
-        def remove_errors (wfid, errors)
+    def remove_errors (wfid, errors)
 
-            errors = Array(errors)
+      errors = Array(errors)
 
-            @mutex.synchronize do
+      @mutex.synchronize do
 
-                c = locate_content wfid, false
+        c = locate_content wfid, false
 
-                return unless c
+        return unless c
 
-                c.getNodeDataCollection.each do |cerror|
+        c.getNodeDataCollection.each do |cerror|
 
-                    error = YAML.load(cerror.getString)
-                    cerror.delete if errors.include?(error)
-                end
-            end
+          error = YAML.load(cerror.getString)
+          cerror.delete if errors.include?(error)
         end
+      end
+    end
 
-        #
-        # Returns a hash wfid --> error list
-        #
-        def get_error_logs
+    #
+    # Returns a hash wfid --> error list
+    #
+    def get_error_logs
 
-            journal = @hm.getQueryManager.createQuery(
-                'error_journal/*/*', Query::XPATH).execute
-            journal = journal.getContent(
-                WfConstants::NODENAME_WORKFLOW_ERRORS)
+      journal = @hm.getQueryManager.createQuery(
+        'error_journal/*/*', Query::XPATH).execute
+      journal = journal.getContent(
+        WfConstants::NODENAME_WORKFLOW_ERRORS)
 
-            ldebug { "get_error_logs() found #{journal.size} error journals" }
+      ldebug { "get_error_logs() found #{journal.size} error journals" }
 
-            result = {}
+      result = {}
 
-            journal.each do |n|
+      journal.each do |n|
 
-                wfid = n.getName
-                errors = get_error_log wfid
+        wfid = n.getName
+        errors = get_error_log wfid
 
-                result[wfid] = errors
-            end
+        result[wfid] = errors
+      end
 
-            result
-        end
+      result
+    end
 
-        protected
+    protected
 
-            def locate_content (wfid, create_if_missing=false)
+      def locate_content (wfid, create_if_missing=false)
 
-                wfid = wfid.parent_workflow_instance_id \
-                    if wfid.is_a?(OpenWFE::FlowExpressionId)
+        wfid = wfid.parent_workflow_instance_id \
+          if wfid.is_a?(OpenWFE::FlowExpressionId)
 
-                a_wfid = get_wfid_generator.split_wfid(wfid)
+        a_wfid = get_wfid_generator.split_wfid(wfid)
 
-                path =  ''
-                path << EJOURNAL_PATH
-                path << '/'
-                path << a_wfid[-1]
-                path << '/'
-                path << wfid
+        path =  ''
+        path << EJOURNAL_PATH
+        path << '/'
+        path << a_wfid[-1]
+        path << '/'
+        path << wfid
 
-                if @hm.isExist(path)
+        if @hm.isExist(path)
 
-                    @hm.getContent path
+          @hm.getContent path
 
-                elsif create_if_missing
+        elsif create_if_missing
 
-                    ContentUtil.createPath(
-                        @hm, 
-                        path, 
-                        ItemType.new(WfConstants::NODENAME_WORKFLOW_ERRORS))
+          ContentUtil.createPath(
+            @hm, 
+            path, 
+            ItemType.new(WfConstants::NODENAME_WORKFLOW_ERRORS))
 
-                else
+        else
 
-                    nil
-                end
-            end
+          nil
+        end
+      end
 
-            #
-            # Will dump the error into the JCR as a YAML string.
-            #
-            def record_error (error)
+      #
+      # Will dump the error into the JCR as a YAML string.
+      #
+      def record_error (error)
 
-                @mutex.synchronize do
+        @mutex.synchronize do
 
-                    c = locate_content(error.wfid, true)
+          c = locate_content(error.wfid, true)
 
-                    #i = c.getNodeDataCollection.size
-                    i = Integer(Time.now.to_f * 1000)
+          #i = c.getNodeDataCollection.size
+          i = Integer(Time.now.to_f * 1000)
 
-                    vf = c.getJCRNode.getSession.getValueFactory
-                    c.createNodeData(i.to_s, vf.createValue(YAML.dump(error)))
+          vf = c.getJCRNode.getSession.getValueFactory
+          c.createNodeData(i.to_s, vf.createValue(YAML.dump(error)))
 
-                    @hm.save
+          @hm.save
 
-                    ldebug { "record_error() for #{error.wfid}" }
-                end
-            end
-    end
+          ldebug { "record_error() for #{error.wfid}" }
+        end
+      end
+  end
 end

Modified: modules/community/magnolia-module-workflow/branches/magnolia-module-workflow-openwfe-ruby-3.0/src/main/resources/workflower/logging.rb (16922 => 16923)


--- modules/community/magnolia-module-workflow/branches/magnolia-module-workflow-openwfe-ruby-3.0/src/main/resources/workflower/logging.rb	2008-07-18 19:52:16 UTC (rev 16922)
+++ modules/community/magnolia-module-workflow/branches/magnolia-module-workflow-openwfe-ruby-3.0/src/main/resources/workflower/logging.rb	2008-07-19 10:56:15 UTC (rev 16923)
@@ -10,29 +10,38 @@
 
 module Workflower
 
+  #
+  # Wrapping an sl4j logger inside a Ruby envelope.
+  #
+  class Logger
+
+    def initialize (logpath)
+
+      @slogger = Factory.getLogger(logpath)
+
+      @slogger.info "  -ooo-  Logger ready to log"
+    end
+
     #
-    # Wrapping an sl4j logger inside a Ruby envelope.
+    # warn is a Kernel method in ruby... Doesn't work via method_messing
+    # have to code it in hard.
     #
-    class Logger
+    def warn (&block)
 
-        def initialize (logpath)
+      @slogger.warn block.call
+    end
 
-            @slogger = Factory.getLogger(logpath)
+    def method_missing (m, *args, &block)
 
-            @slogger.info "  -ooo-  Logger ready to log"
-        end
+      return if (m == :debug) and (not @slogger.isDebugEnabled)
+        # slight optimization
 
-        def method_missing (m, *args, &block)
+      message = block.call
+        # string concatenation only occurs here,
+        # hence the optimization
 
-            return if (m == :debug) and (not @slogger.isDebugEnabled)
-                # slight optimization
-
-            message = block.call
-                # string concatenation only occurs here,
-                # hence the optimization
-
-            @slogger.send m, message
-        end
+      @slogger.send m, message
     end
+  end
 
 end

Modified: modules/community/magnolia-module-workflow/branches/magnolia-module-workflow-openwfe-ruby-3.0/src/main/resources/workflower/participants.rb (16922 => 16923)


--- modules/community/magnolia-module-workflow/branches/magnolia-module-workflow-openwfe-ruby-3.0/src/main/resources/workflower/participants.rb	2008-07-18 19:52:16 UTC (rev 16922)
+++ modules/community/magnolia-module-workflow/branches/magnolia-module-workflow-openwfe-ruby-3.0/src/main/resources/workflower/participants.rb	2008-07-19 10:56:15 UTC (rev 16923)
@@ -14,72 +14,78 @@
 
 module Workflower
 
-    #
-    # This participant stores the workitem it receives in the 
-    # JCR repo.
-    #
-    class MgnlParticipant
-        include OpenWFE::LocalParticipant
+  #
+  # This participant stores the workitem it receives in the 
+  # JCR repo.
+  #
+  class MgnlParticipant
+    include OpenWFE::LocalParticipant
 
-        #def initialize
-        #    super()
-        #end
+    #def initialize
+    #  super()
+    #end
 
-        def consume (workitem)
+    def consume (workitem)
 
-            get_worklist.store workitem
+      get_worklist.store workitem
 
-            # do not reply to engine
-            # workitem is now stored in the JCR worklist, job done.
-        end
+      # do not reply to engine
+      # workitem is now stored in the JCR worklist, job done.
+    end
 
-        def cancel (cancelitem)
+    def cancel (cancelitem)
 
-            # remove workitem from JCR worklist...
+      # remove workitem from JCR worklist...
 
-            get_worklist.remove cancelitem.fei
-        end
+      linfo { "cancel() removing workitem for #{cancelitem.fei.to_s}" }
+
+      get_worklist.remove cancelitem.fei
     end
+  end
 
-    #
-    # This participant triggers Magnolia commands.
-    #
-    class MgnlCommandParticipant
-        include OpenWFE::LocalParticipant
+  #
+  # This participant triggers Magnolia commands.
+  #
+  class MgnlCommandParticipant
+    include OpenWFE::LocalParticipant
 
-        #def initialize
-        #    super()
-        #end
+    #def initialize
+    #  super()
+    #end
 
-        def consume (workitem)
+    def consume (workitem)
 
-            command_name = workitem.participant_name[8..-1]
+      command_name = workitem.participant_name[8..-1]
 
-            command = CommandsManager.getInstance.getCommand(command_name)
+      command = CommandsManager.getInstance.getCommand(command_name)
 
-            unless command
-                lerror { "consume() no command named '#{command_name}'" }
-                return
-            end
+      unless command
+        lerror { "consume() no command named '#{command_name}'" }
+        return
+      end
 
-            linfo { "consume() command class is #{command.getClass.getName}" }
+      linfo do 
+        "consume() command '#{command_name}' "+
+        "class is #{command.getClass.getName}"
+      end
 
-            context = MgnlContext.getSystemContext
-            context = WorkItemContext.new context, workitem.toMap
+      context = MgnlContext.getSystemContext
+      context = WorkItemContext.new context, workitem.toMap
 
-            MgnlContext.setInstance context
-                # I hate this one, a full blown command pattern and that...
+      MgnlContext.setInstance context
+        # I hate this one, a full blown command pattern and that...
 
-            command.execute context
-            
-            # in fine...
+      result = command.execute context
+      workitem.attributes['command_result'] = result
 
-            reply_to_engine workitem
-        end
+      # in fine...
 
-        def cancel (cancelitem)
+      reply_to_engine workitem
+    end
 
-            # nothing to do...
-        end
+    def cancel (cancelitem)
+
+      # nothing to do...
     end
+  end
 end

Modified: modules/community/magnolia-module-workflow/branches/magnolia-module-workflow-openwfe-ruby-3.0/src/main/resources/workflower/startup.rb (16922 => 16923)


--- modules/community/magnolia-module-workflow/branches/magnolia-module-workflow-openwfe-ruby-3.0/src/main/resources/workflower/startup.rb	2008-07-18 19:52:16 UTC (rev 16922)
+++ modules/community/magnolia-module-workflow/branches/magnolia-module-workflow-openwfe-ruby-3.0/src/main/resources/workflower/startup.rb	2008-07-19 10:56:15 UTC (rev 16923)
@@ -12,7 +12,7 @@
 
 
 S_WORKLIST = 'worklist'
-    # the name of the worklist service
+  # the name of the worklist service
 
 
 #
@@ -32,10 +32,10 @@
 $engine.register_participant "user-.*", MgnlParticipant.new
 $engine.register_participant "group-.*", MgnlParticipant.new
 $engine.register_participant "role-.*", MgnlParticipant.new
-    # human participants
+  # human participants
 
 $engine.register_participant "command-.*", MgnlCommandParticipant.new
-    # magnolia commands
+  # magnolia commands
 
 $worklist = Worklist.new(S_WORKLIST, ac)
 
@@ -45,23 +45,23 @@
 # Opening the service locator to add the get_worklist lookup method.
 #
 module OpenWFE::OwfeServiceLocator
-    def get_worklist
-        @application_context[S_WORKLIST]
-    end
+  def get_worklist
+    @application_context[S_WORKLIST]
+  end
 end
 
 #
 # for grabbing the workflow engine very easily from the Ruby runtime
 #
 def get_workflow_engine
-    $engine
+  $engine
 end
 
 #
 # for grabbing the worklist instance very easily from the Ruby runtime
 #
 def get_worklist
-    $worklist
+  $worklist
 end
 
 
@@ -72,8 +72,8 @@
 # Hooks can, for example, add specific participant to the workflow engine
 #
 begin
-    require 'workflower/hooks'
+  require 'workflower/hooks'
 rescue LoadError
-    # no hooks
+  # no hooks
 end
 

Modified: modules/community/magnolia-module-workflow/branches/magnolia-module-workflow-openwfe-ruby-3.0/src/main/resources/workflower/worklist.rb (16922 => 16923)


--- modules/community/magnolia-module-workflow/branches/magnolia-module-workflow-openwfe-ruby-3.0/src/main/resources/workflower/worklist.rb	2008-07-18 19:52:16 UTC (rev 16922)
+++ modules/community/magnolia-module-workflow/branches/magnolia-module-workflow-openwfe-ruby-3.0/src/main/resources/workflower/worklist.rb	2008-07-19 10:56:15 UTC (rev 16923)
@@ -13,8 +13,8 @@
 #MgnlContext = Java::info.magnolia.context.MgnlContext
 #Query = Java::info.magnolia.cms.core.search.Query
 #WfConstants = Java::info.magnolia.module.workflow.WorkflowConstants
-    #
-    # they are all already loaded in engine.rb
+  #
+  # they are all already loaded in engine.rb
 
 require 'thread'
 require 'yaml'
@@ -26,319 +26,338 @@
 #
 class OpenWFE::InFlowItem
 
-    #
-    # Turns the workitem into a Map (hash).
-    #
-    def toMap
+  #
+  # Turns the workitem into a Map (hash).
+  #
+  def toMap
 
-        m = HashMap.new
+    m = HashMap.new
 
-        @attributes.each do |k, v| 
+    @attributes.each do |k, v| 
 
-            v.each { |kk, vv| m[kk] = vv } if k == 'params'
-                # flattening...
+      v.each { |kk, vv| m[kk] = vv } if k == 'params'
+        # flattening...
 
-            m[k] = v
-        end
+      m[k] = v
+    end
 
-        m[WfConstants::ATT_ID] = fei.to_s
-        m[WfConstants::ATT_WORKFLOW] = fei.workflow_definition_name
-        m[WfConstants::ATT_LAST_MODIFIED] = @last_modified
+    m[WfConstants::ATT_ID] = fei.to_s
+    m[WfConstants::ATT_WFID] = fei.wfid
+    m[WfConstants::ATT_WI_ID] = fei.workflow_instance_id + "__" + fei.expression_id
+    m[WfConstants::ATT_WORKFLOW] = fei.workflow_definition_name
+    m[WfConstants::ATT_LAST_MODIFIED] = @last_modified
 
-        m
-    end
+    m
+  end
 end
 
 
 module Workflower
 
-    WORKLIST_WORKSPACE = 'Store'
+  WORKLIST_WORKSPACE = 'Store'
 
+  #
+  # Methods formerly gathered in the JCRWorkItemAPI java class...
+  #
+  class Worklist
+    include OpenWFE::ServiceMixin
+    include OpenWFE::OwfeServiceLocator
+
+    def initialize (service_name, application_context)
+
+      service_init service_name, application_context
+
+      @hm = ContentRepository.getHierarchyManager(WORKLIST_WORKSPACE)
+
+      raise "failed to get HierarchyManager '#{WORKLIST_WORKSPACE}'" \
+        unless @hm
+
+      @mutex = Mutex.new
+    end
+
     #
-    # Methods formerly gathered in the JCRWorkItemAPI java class...
+    # Stores a workitem in the JCR repo.
     #
-    class Worklist
-        include OpenWFE::ServiceMixin
-        include OpenWFE::OwfeServiceLocator
+    def store (workitem)
 
-        def initialize (service_name, application_context)
+      @mutex.synchronize do
 
-            service_init service_name, application_context
+        workitem.touch
 
-            @hm = ContentRepository.getHierarchyManager(WORKLIST_WORKSPACE)
-
-            raise "failed to get HierarchyManager '#{WORKLIST_WORKSPACE}'" \
-                unless @hm
-
-            @mutex = Mutex.new
+        path = determine_path workitem.fei
+        begin
+          c = @hm.getContent path
+          c.delete if c
+            # erases previous versions of the workitem...
+        rescue Exception => e
+          ldebug { "store() #{path} did not exist" }
         end
 
-        #
-        # Stores a workitem in the JCR repo.
-        #
-        def store (workitem)
+        c = ContentUtil.createPath(@hm, path, ItemType::WORKITEM)
 
-            @mutex.synchronize do
+        workitem.attributes[WfConstants::ATT_WORKITEM_PATH] = path
+          # as a convenience, store the path in the 
+          # workitem attributes as well
 
-                workitem.touch
+        vf = c.getJCRNode.getSession.getValueFactory
 
-                path = determine_path workitem.fei
-                begin
-                    c = @hm.getContent path
-                    c.delete if c
-                        # erases previous versions of the workitem...
-                rescue Exception => e
-                    ldebug { "store() #{path} did not exist" }
-                end
+        c.createNodeData(
+          WfConstants::NODEDATA_ID, 
+          vf.createValue(workitem.fei.to_s))
+        c.createNodeData(
+          WfConstants::NODEDATA_WFID,
+          vf.createValue(workitem.fei.wfid))
+        c.createNodeData(
+          WfConstants::NODEDATA_PATH,
+          vf.createValue(workitem.path))
+        c.createNodeData(
+          WfConstants::NODEDATA_PARTICIPANT, 
+          vf.createValue(workitem.participant_name))
 
-                c = ContentUtil.createPath(@hm, path, ItemType::WORKITEM)
+        assign_to = workitem\
+          .attributes[WfConstants::ATTRIBUTE_ASSIGN_TO]
 
-                workitem.attributes[WfConstants::ATT_WORKITEM_PATH] = path
-                    # as a convenience, store the path in the 
-                    # workitem attributes as well
+        c.createNodeData(
+          WfConstants::ATTRIBUTE_ASSIGN_TO,
+          vf.createValue(assign_to)) if assign_to
 
-                vf = c.getJCRNode.getSession.getValueFactory
+        #
+        # for now, dump the workitem as yaml stuff...
 
-                c.createNodeData(
-                    WfConstants::NODEDATA_ID, 
-                    vf.createValue(workitem.fei.to_s))
-                c.createNodeData(
-                    WfConstants::NODEDATA_WFID,
-                    vf.createValue(workitem.fei.wfid))
-                c.createNodeData(
-                    WfConstants::NODEDATA_PATH,
-                    vf.createValue(workitem.path))
-                c.createNodeData(
-                    WfConstants::NODEDATA_PARTICIPANT, 
-                    vf.createValue(workitem.participant_name))
+        # TODO : use an XPATH-friendlier encoding scheme
 
-                assign_to = workitem\
-                    .attributes[WfConstants::ATTRIBUTE_ASSIGN_TO]
+        c.createNodeData(
+          WfConstants::NODEDATA_VALUE,
+          vf.createValue(YAML.dump(workitem)))
 
-                c.createNodeData(
-                    WfConstants::ATTRIBUTE_ASSIGN_TO,
-                    vf.createValue(assign_to)) if assign_to
+        @hm.save
 
-                #
-                # for now, dump the workitem as yaml stuff...
+        linfo { "store() saved workitem at #{path}" }
+      end
+    end
 
-                # TODO : use an XPATH-friendlier encoding scheme
+    #
+    # Removes the workitem from the worklist and proceeds it to the engine
+    #
+    # This method has to be called, not the one from the engine.
+    #
+    def proceed_flow (sfei, action, comment)
 
-                c.createNodeData(
-                    WfConstants::NODEDATA_VALUE,
-                    vf.createValue(YAML.dump(workitem)))
+      linfo { "proceed_flow() for '#{sfei}'" }
 
-                @hm.save
+      fei = OpenWFE::FlowExpressionId.from_s sfei
+      wi = get_worklist.fetch fei
 
-                linfo { "store() saved workitem at #{path}" }
-            end
-        end
+      raise "no workitem found for '#{sfei}'" unless wi
 
-        #
-        # Removes the workitem from the worklist and proceeds it to the engine
-        #
-        # This method has to be called, not the one from the engine.
-        #
-        def proceed_flow (sfei, action, comment)
+      get_worklist.remove fei
+        # removes workitem from JCR storage
 
-            linfo { "proceed_flow() for '#{sfei}'" }
+      wi.touch 
+        # setting last_modified to now
 
-            fei = OpenWFE::FlowExpressionId.from_s sfei
-            wi = get_worklist.fetch fei
+      wi.attributes.delete Context::ATTRIBUTE_EXCEPTION
+      wi.attributes.delete Context::ATTRIBUTE_MESSAGE
 
-            raise "no workitem found for '#{sfei}'" unless wi
+      wi.attributes[WfConstants::ATTRIBUTE_ACTION] = \
+        action
+      wi.attributes[WfConstants::ATTRIBUTE_USERNAME] = \
+        MgnlContext.getUser.getName
 
-            get_worklist.remove fei
-                # removes workitem from JCR storage
+      wi.attributes[Context::ATTRIBUTE_COMMENT] = comment \
+        if comment and comment != ''
 
-            wi.touch 
-                # setting last_modified to now
+      get_engine.proceed wi
+    end
 
-            wi.attributes.delete Context::ATTRIBUTE_EXCEPTION
-            wi.attributes.delete Context::ATTRIBUTE_MESSAGE
+    def remove (fei)
 
-            wi.attributes[WfConstants::ATTRIBUTE_ACTION] = \
-                action
-            wi.attributes[WfConstants::ATTRIBUTE_USERNAME] = \
-                MgnlContext.getUser.getName
+      @mutex.synchronize do
 
-            wi.attributes[Context::ATTRIBUTE_COMMENT] = comment \
-                if comment and comment != ''
+        begin
 
-            get_engine.proceed wi
-        end
+          c = fetch_content fei
 
-        def remove (fei)
+          c.delete
+          @hm.save
 
-            @mutex.synchronize do
+          ldebug { "remove() removed workitem  #{fei}" }
 
-                c = fetch_content fei
-                c.delete
-                @hm.save
-            end
+        rescue Exception => e
 
-            ldebug { "store() removed workitem  #{fei}" }
+          linfo { "remove() can't remove 'missing' workitem  #{fei}" }
         end
+      end
+    end
 
-        #
-        # Returns the workitem with the given fei
-        #
-        def fetch (fei)
+    #
+    # Returns the workitem with the given fei
+    #
+    def fetch (fei)
 
-            fei = OpenWFE::FlowExpressionId.from_s(fei) if fei.is_a?(String)
+      fei = OpenWFE::FlowExpressionId.from_s(fei) if fei.is_a?(String)
 
-            fetch_from_content(fetch_content(fei))
-        end
+      fetch_from_content(fetch_content(fei))
+    end
 
-        def get_user_inbox (username)
+    def get_user_inbox (username)
 
-            current_user = MgnlContext.getUser
+      current_user = MgnlContext.getUser
 
-            s = '//*[(@assignTo="'+username+'") or '+
-                '(@participant="user-'+username+'" and not(@assignTo))'
+      s = '//*[(@assignTo="'+username+'") or '+
+        '(@participant="user-'+username+'" and not(@assignTo))'
 
-            current_user.getGroups.each do |groupname|
-                s << ' or (@participant="group-'+groupname+'")'
-            end
-            current_user.getRoles.each do |rolename|
-                s << ' or (@participant="role-'+rolename+'")'
-            end
-            s << ']'
+      current_user.getGroups.each do |groupname|
+        s << ' or (@participant="group-'+groupname+'")'
+      end
+      current_user.getRoles.each do |rolename|
+        s << ' or (@participant="role-'+rolename+'")'
+      end
+      s << ']'
 
-            query s
-        end
+      query s
+    end
 
-        def get_group_inbox (groupname)
+    def get_group_inbox (groupname)
 
-            query '//*[@participant="group-'+groupname+'"]'
-        end
+      query '//*[@participant="group-'+groupname+'"]'
+    end
 
-        def get_role_inbox (rolename)
+    def get_role_inbox (rolename)
 
-            query '//*[@participant="role-'+rolename+'"]'
-        end
+      query '//*[@participant="role-'+rolename+'"]'
+    end
 
-        #
-        # Returns a array of workflow instance ids. Those are the ids of
-        # the workflow instances associated with the given path.
-        #
-        def get_workflow_ids (path)
+    #
+    # returns all the workitems
+    #
+    def get_workitems
 
-            query '//*[@path="'+path+'"]'
+      query '//*[@participant]'
+    end
 
-            # TODO : terminate me
-        end
+    #
+    # Returns a array of workflow instance ids. Those are the ids of
+    # the workflow instances associated with the given path.
+    #
+    def get_workflow_ids (path)
 
-        #
-        # Returns the JCR path of the workitem (with that fei).
-        #
-        def determine_path (fei)
+      query '//*[@path="'+path+'"]'
 
-            fei = OpenWFE::FlowExpressionId.from_s(fei) if fei.is_a?(String)
+      # TODO : terminate me
+    end
 
-            wfid = fei.parent_workflow_instance_id
-            a_wfid = get_wfid_generator.split_wfid(wfid)
+    #
+    # Returns the JCR path of the workitem (with that fei).
+    #
+    def determine_path (fei)
 
-            path =  '/'
-            path << a_wfid[-2]
-            path << '/'
-            path << a_wfid[-1]
-            path << '/'
-            path << OpenWFE.ensure_for_filename(fei.wfname)
-            path << '__'
-            path << fei.workflow_instance_id
-            path << '__'
-            path << fei.expression_id
+      fei = OpenWFE::FlowExpressionId.from_s(fei) if fei.is_a?(String)
 
-            path
-        end
+      wfid = fei.parent_workflow_instance_id
+      a_wfid = get_wfid_generator.split_wfid(wfid)
 
-        #
-        # Returns the path of the content item pointed at by the workitem
-        # (given by its string flow expression id).
-        #
-        def get_content_path (sfei)
+      path =  '/'
+      path << a_wfid[-2]
+      path << '/'
+      path << a_wfid[-1]
+      path << '/'
+      path << OpenWFE.ensure_for_filename(fei.wfname)
+      path << '__'
+      path << fei.workflow_instance_id
+      path << '__'
+      path << fei.expression_id
 
-            workitem = fetch sfei
-            workitem.path
-        end
+      path
+    end
 
-        #
-        # Fetches a workitem a returns the content of the given field.
-        # Complex designations are possible, for example "customers.0.name" or
-        # "car.motor.combustion_chambers.2"
-        #
-        def lookup_workitem_field (sfei, fieldname)
+    #
+    # Returns the path of the content item pointed at by the workitem
+    # (given by its string flow expression id).
+    #
+    def get_content_path (sfei)
 
-            ldebug { "lookup_workitem_field() at #{sfei}" }
+      workitem = fetch sfei
+      workitem.path
+    end
 
-            wi = fetch sfei
-            wi.lookup_attribute fieldname
-        end
+    #
+    # Fetches a workitem a returns the content of the given field.
+    # Complex designations are possible, for example "customers.0.name" or
+    # "car.motor.combustion_chambers.2"
+    #
+    def lookup_workitem_field (sfei, fieldname)
 
-        #
-        # Returns the fields (attributes) of the workitem given by the
-        # string version of its flow expression id.
-        #
-        def get_workitem_fields (sfei)
+      ldebug { "lookup_workitem_field() at #{sfei}" }
 
-            wi = fetch sfei
-            wi.attributes
-        end
+      wi = fetch sfei
+      wi.lookup_attribute fieldname
+    end
 
-        protected
+    #
+    # Returns the fields (attributes) of the workitem given by the
+    # string version of its flow expression id.
+    #
+    def get_workitem_fields (sfei)
 
-            #
-            # Extracts the workitem in the given Content instance
-            #
-            def fetch_from_content (content)
+      wi = fetch sfei
+      wi.attributes
+    end
 
-                return nil unless content
+    protected
 
-                s = content.getNodeData(WfConstants::NODEDATA_VALUE).getString
-                YAML.load(s)
-            end
+      #
+      # Extracts the workitem in the given Content instance
+      #
+      def fetch_from_content (content)
 
-            #
-            # Fetches the content node for the given 'flow expression id'
-            #
-            def fetch_content (fei)
+        return nil unless content
 
-                path = determine_path fei
-                @hm.getContent path
-            end
+        s = content.getNodeData(WfConstants::NODEDATA_VALUE).getString
+        YAML.load(s)
+      end
 
-            def query (xpath_query_string)
+      #
+      # Fetches the content node for the given 'flow expression id'
+      #
+      def fetch_content (fei)
 
-                ldebug { "query() : #{xpath_query_string}" }
+        path = determine_path fei
+        @hm.getContent path
+          # this will throw an error if the path is missing :(
+      end
 
-                qm = MgnlContext.getSystemContext.getQueryManager(
-                    WORKLIST_WORKSPACE)
-                #qm = MgnlContext.getInstance.getQueryManager(
-                #    WORKLIST_WORKSPACE)
+      def query (xpath_query_string)
 
-                q = qm.createQuery xpath_query_string, Query::XPATH
+        linfo { "query() : #{xpath_query_string}" }
 
-                @mutex.synchronize do
+        qm = MgnlContext.getSystemContext.getQueryManager(
+          WORKLIST_WORKSPACE)
+        #qm = MgnlContext.getInstance.getQueryManager(
+        #  WORKLIST_WORKSPACE)
 
-                    result = q.execute
-                    result = result.getContent(WfConstants::NODENAME_WORKITEM)
+        q = qm.createQuery xpath_query_string, Query::XPATH
 
-                    ldebug { "query() found #{result.size} results" }
+        @mutex.synchronize do
 
-                    workitems = java.util.ArrayList.new
+          result = q.execute
+          result = result.getContent(WfConstants::NODENAME_WORKITEM)
 
-                    result.each do |c|
+          linfo { "query() found #{result.size} results" }
 
-                        next unless @hm.isExist(c.getHandle)
+          workitems = java.util.ArrayList.new
 
-                        workitem = fetch_from_content c
+          result.each do |c|
 
-                        workitems.add(workitem.toMap)
-                    end
+            next unless @hm.isExist(c.getHandle)
 
-                    workitems
-                end
-            end
-    end
+            workitem = fetch_from_content c
+
+            workitems.add(workitem.toMap)
+          end
+
+          workitems
+        end
+      end
+  end
 end
Subscribe (FEED) Subscribe (DIGEST) Subscribe (INDEX) Unsubscribe Mail to Listmaster