Michiel Rop pushed to branch master at cms-community / hippo-cms

Commits:
85e3becd by Ard Schrijvers at 2017-11-10T11:39:26+01:00
CMS-10981 delegate the #hints to the WorkflowDescriptorModel and cache the 
result

- - - - -
8d0c7d2d by Michiel Rop at 2017-11-10T17:04:46+01:00
CMS-10981 Merge branch 'bugfix/CMS-10981'

- - - - -


3 changed files:

- api/src/main/java/org/hippoecm/addon/workflow/WorkflowDescriptorModel.java
- 
workflow/frontend/src/main/java/org/hippoecm/frontend/plugins/reviewedactions/AbstractDocumentWorkflowPlugin.java
- 
workflow/frontend/src/main/java/org/hippoecm/frontend/plugins/reviewedactions/EditingWorkflowPlugin.java


Changes:

=====================================
api/src/main/java/org/hippoecm/addon/workflow/WorkflowDescriptorModel.java
=====================================
--- a/api/src/main/java/org/hippoecm/addon/workflow/WorkflowDescriptorModel.java
+++ b/api/src/main/java/org/hippoecm/addon/workflow/WorkflowDescriptorModel.java
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2009-2013 Hippo B.V. (http://www.onehippo.com)
+ *  Copyright 2009-2017 Hippo B.V. (http://www.onehippo.com)
  * 
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -15,6 +15,11 @@
  */
 package org.hippoecm.addon.workflow;
 
+import java.io.Serializable;
+import java.rmi.RemoteException;
+import java.util.Collections;
+import java.util.Map;
+
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
@@ -26,14 +31,21 @@ import org.hippoecm.repository.api.HippoNodeType;
 import org.hippoecm.repository.api.HippoWorkspace;
 import org.hippoecm.repository.api.Workflow;
 import org.hippoecm.repository.api.WorkflowDescriptor;
+import org.hippoecm.repository.api.WorkflowException;
 import org.hippoecm.repository.api.WorkflowManager;
+import org.onehippo.repository.documentworkflow.DocumentWorkflow;
 import org.onehippo.repository.util.JcrConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class WorkflowDescriptorModel extends 
LoadableDetachableModel<WorkflowDescriptor> {
 
+    private static final Logger log = 
LoggerFactory.getLogger(WorkflowDescriptorModel.class);
+
     private String id;
     private String category;
     private transient Workflow workflow;
+    private transient Map<String, Serializable> hints;
 
     /**
      * deprecated: use the alternative constructor instead
@@ -105,9 +117,29 @@ public class WorkflowDescriptorModel extends 
LoadableDetachableModel<WorkflowDes
         }
     }
 
+
+
     @Override
     protected void onDetach() {
         super.onDetach();
         workflow = null;
+        hints = null;
+    }
+
+    public Map<String, Serializable> getHints() {
+        if (hints != null) {
+            return hints;
+        }
+        DocumentWorkflow workflow = getWorkflow();
+        if (workflow != null) {
+            try {
+                hints = workflow.hints();
+                return hints;
+            } catch (WorkflowException | RemoteException | RepositoryException 
e) {
+                log.error("Unable to retrieve workflow hints", e);
+            }
+        }
+        hints = Collections.emptyMap();
+        return hints;
     }
 }


=====================================
workflow/frontend/src/main/java/org/hippoecm/frontend/plugins/reviewedactions/AbstractDocumentWorkflowPlugin.java
=====================================
--- 
a/workflow/frontend/src/main/java/org/hippoecm/frontend/plugins/reviewedactions/AbstractDocumentWorkflowPlugin.java
+++ 
b/workflow/frontend/src/main/java/org/hippoecm/frontend/plugins/reviewedactions/AbstractDocumentWorkflowPlugin.java
@@ -165,14 +165,6 @@ public abstract class AbstractDocumentWorkflowPlugin 
extends RenderPlugin {
     }
 
     protected Map<String, Serializable> getHints() {
-        DocumentWorkflow workflow = getWorkflow();
-        if (workflow != null) {
-            try {
-                return workflow.hints();
-            } catch (WorkflowException | RemoteException | RepositoryException 
e) {
-                log.error("Unable to retrieve workflow hints", e);
-            }
-        }
-        return Collections.emptyMap();
+        return getModel().getHints();
     }
 }


=====================================
workflow/frontend/src/main/java/org/hippoecm/frontend/plugins/reviewedactions/EditingWorkflowPlugin.java
=====================================
--- 
a/workflow/frontend/src/main/java/org/hippoecm/frontend/plugins/reviewedactions/EditingWorkflowPlugin.java
+++ 
b/workflow/frontend/src/main/java/org/hippoecm/frontend/plugins/reviewedactions/EditingWorkflowPlugin.java
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2008-2015 Hippo B.V. (http://www.onehippo.com)
+ *  Copyright 2008-2017 Hippo B.V. (http://www.onehippo.com)
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -15,13 +15,9 @@
  */
 package org.hippoecm.frontend.plugins.reviewedactions;
 
-import java.text.DateFormat;
-import java.util.Date;
-
 import javax.jcr.Node;
 
 import org.apache.wicket.Component;
-import org.apache.wicket.model.IModel;
 import org.apache.wicket.model.StringResourceModel;
 import org.hippoecm.addon.workflow.StdWorkflow;
 import org.hippoecm.addon.workflow.WorkflowDescriptorModel;



View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-cms/compare/cbd2bfbb093bbce57e6dfcc8820f15a777338eac...8d0c7d2dd09754068d16564025ab98eefe75036f

---
View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-cms/compare/cbd2bfbb093bbce57e6dfcc8820f15a777338eac...8d0c7d2dd09754068d16564025ab98eefe75036f
You're receiving this email because of your account on code.onehippo.org.
_______________________________________________
Hippocms-svn mailing list
Hippocms-svn@lists.onehippo.org
https://lists.onehippo.org/mailman/listinfo/hippocms-svn

Reply via email to