dynamic validation of documents upon publication

49 views
Skip to first unread message

sde...@gmail.com

unread,
Oct 21, 2014, 7:40:19 PM10/21/14
to hippo-c...@googlegroups.com, samuel...@gartner.com, reshma...@gartner.com
Hello Hippo Team,

Our organization is looking for some way to restrict publishing of a document until certain requirements are met. For example we have documents which go through a life-cycle, and at specific points in that life-cycle, we need to make certain fields required and dis-allow publishing until those fields have some content. We are looking to dynamically assign certain fields to be "required" based on where the document is in its life-cycle.

Some thoughts on this is that we could assign custom Java classes to specific document types to perform this validation based on a pre-defined set of rules upon attempting to publish the document. Another option we've been thinking is to extend the PublicationWorkFlowPlugin class and use this instead of the default... which doesn't seem like a great solution because we'd like to only apply rules to certain document types.

A few questions to you all... is there some way to achieve this? If so, where would be a good starting point?

Thanks,
Samuel

Woonsan Ko

unread,
Oct 23, 2014, 10:26:24 AM10/23/14
to hippo-c...@googlegroups.com, samuel...@gartner.com, reshma...@gartner.com
Hi Samuel,

It's a great question!
Actually, your requirement can be easily solved by adding a custom SCXML
action since Hippo CMS 7.9 innovated its document processing engine with
SCXML [1].

If you want to control the publishability of a document based on
specific business rules, then I think you can add your own custom action
like the following:

---
a) Add a custom action and replace the following line in the default
document workflow [2] SCXML definition with your own custom action:

[Before]

<hippo:action action="publish" enabledExpr="true"/>

[After]

<mycustom1:setPublishAction documentVariantExpr="unpublished" />

You might want to take a look at how the default hippo:action custom
action [3] was implemented. Basically, you can control the allowed
actions such as 'publish' in your custom action. You can define any tag
attributes that are automatically mapped Java POJO properties. If you
have your custom action extend AbstractDocumentTaskAction [4], then you
will be able to retrieve documentHandle and documentVariants easily to
read the underlying document node(s) like the following example:

Node node =
getVariant().getNode(getWorkflowContext().getInternalWorkflowSession());
// Please see [5] for a real example usage.)

b) Register your custom action:
You need to add a child element under
/hippo:configuration/hippo:modules/scxmlregistry/hippo:moduleconfig/hipposcxml:definitions/documentworkflow/.
For example,
/setPublishAction (hipposcxml:action)
- hipposcxml:classname: "org.example.repository.scxml.SetPublishAction"
- hipposcxml:namespace: "http://www.example.com/cms7/repository/scxml"

You also need to define the namespace in the default document workflow
scxml definition by adding something like this:

<scxml version="1.0"
xmlns="http://www.w3.org/2005/07/scxml"
xmlns:hippo="http://www.onehippo.org/cms7/repository/scxml"
xmlns:cs="http://commons.apache.org/scxml"
xmlns:mycustom1="http://www.example.com/cms7/repository/scxml">
---

If you have any further questions, let us know.

Hope it helps,

Woonsan

[1]
http://www.onehippo.org/library/concepts/workflow/scxml-workflow-engine.html
[2] http://www.onehippo.org/library/concepts/workflow/document-workflow.html
[3]
http://svn.onehippo.org/repos/hippo/hippo-cms7/repository/branches/hippo-repository-2.26.xx/workflow/src/main/java/org/onehippo/repository/scxml/ActionAction.java
[4]
http://svn.onehippo.org/repos/hippo/hippo-cms7/repository/branches/hippo-repository-2.26.xx/workflow/src/main/java/org/onehippo/repository/documentworkflow/action/AbstractDocumentTaskAction.java
[5]
http://svn.onehippo.org/repos/hippo/hippo-cms7/repository/branches/hippo-repository-2.26.xx/workflow/src/main/java/org/onehippo/repository/documentworkflow/action/VersionVariantAction.java
> --
> Hippo Community Group: The place for all discussions and announcements
> about Hippo CMS (and HST, repository etc. etc.)
>
> To post to this group, send email to hippo-c...@googlegroups.com
> RSS:
> https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
> ---
> You received this message because you are subscribed to the Google
> Groups "Hippo Community" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to hippo-communi...@googlegroups.com
> <mailto:hippo-communi...@googlegroups.com>.
> Visit this group at http://groups.google.com/group/hippo-community.
> For more options, visit https://groups.google.com/d/optout.


--
w....@onehippo.com www.onehippo.com
Boston - 101 Main Street, Cambridge, MA 02142
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466
Reply all
Reply to author
Forward
0 new messages