A context is defined by simple rules. In Content, you can select to enroll the content in a specific lifecycle (for example, publication plugin) based on context parameters. There are three parameters used to define contexts:
Remote User: The current user who can create/edit the content.
Current site name: The site from where the content is created (not the storage but the navigation).
Node: The node which you want to enroll.
From these parameters, you can easily connect and define contexts based on:
Membership: Does the current user have this membership?
Site: On this particular site, you want to enroll contents in a specific lifecycle.
Path: You can enroll contents in the lifecycles based on their path (from the Node).
Type of content: You can enroll contents in the lifecycles based on their nodetype (from the Node).
Because each site has a content storage (categories + physical storage), you can select the right lifecycle for the right storage/site. To avoid conflicts on contexts, you can set a priority (the less is the best).
For example, Different Contexts:
<external-component-plugins>
<target-component>org.exoplatform.services.wcm.publication.PublicationManager</target-component>
<component-plugin>
<name>AddContext</name>
<set-method>addContext</set-method>
<type>org.exoplatform.services.wcm.publication.context.ContextPlugin</type>
<init-params>
<object-param>
<name>contexts</name>
<object type="org.exoplatform.services.wcm.publication.context.impl.ContextConfig">
<field name="contexts">
<collection type="java.util.ArrayList">
<value>
<object type="org.exoplatform.services.wcm.publication.context.impl.ContextConfig$Context">
<field name="name">
<string>contextdefault</string>
</field>
<field name="priority">
<string>200</string>
</field>
<field name="lifecycle">
<string>lifecycle1</string>
</field>
</object>
<object type="org.exoplatform.services.wcm.publication.context.impl.ContextConfig$Context">
<field name="name">
<string>context1</string>
</field>
<field name="priority">
<string>100</string>
</field>
<field name="lifecycle">
<string>lifecycle1</string>
</field>
<field name="membership">
<string>*:/platform/web-contributors</string>
</field>
<field name="site">
<string>acme</string>
</field>
<field name="path">
<string>repository:collaboration:/sites/acme/categories</string>
</field>
</object>
<object type="org.exoplatform.services.wcm.publication.context.impl.ContextConfig$Context">
<field name="name">
<string>context2</string>
</field>
<field name="priority">
<string>100</string>
</field>
<field name="lifecycle">
<string>lifecycle1</string>
</field>
<field name="site">
<string>classic</string>
</field>
</object>
<object type="org.exoplatform.services.wcm.publication.context.impl.ContextConfig$Context">
<field name="name">
<string>context3</string>
</field>
<field name="priority">
<string>80</string>
</field>
<field name="lifecycle">
<string>lifecycle3</string>
</field>
<field name="membership">
<string>manager:/company/finances</string>
</field>
<field name="path">
<string>repository:collaboration:/documents/company/finances</string>
</field>
</object>
<object type="org.exoplatform.services.wcm.publication.context.impl.ContextConfig$Context">
<field name="name">
<string>context4</string>
</field>
<field name="priority">
<string>50</string>
</field>
<field name="lifecycle">
<string>lifecycle4</string>
</field>
<field name="memberships">
<collection type="java.util.ArrayList">
<value>
<string>manager:/communication</string>
</value>
<value>
<string>manager:/sanitaryAlert</string>
</value>
<value>
<string>manager:/informations</string>
</value>
</collection>
</field>
<field name="path">
<string>repository:collaboration:/documents/company/finances</string>
</field>
<field name="nodetype">
<string>exo:webcontent</string>
</field>
</object>
</value>
</collection>
</field>
</object>
</object-param>
</init-params>
</component-plugin>
</external-component-plugins>
The logic is very simple. When the content is created, it should be attached with lifecycle and based on the lifecycle priority:
context4
is the most important (priority=50): you will enroll the content in the lifecycle "lifecycle4" if:
The content creator has the
manager:/company/finances
membership.
The content is stored in
repository:collaboration:/documents/company/finances
or any subfolders.
The content is a 'exo:article
'.
If not, you will continue with context3
.
The logic is very simple. When you create a content, go lifecycle by lifecycle starting with the better priority:
context4
is the most important (priority=50): you will enroll the content in the lifecycle "lifecycle4" if:
The content creator has the
manager:/company/finances
membership.
The content is stored in
repository:collaboration:/documents/company/finances
or any subfolders.
The content is a exo:article
.
If not, you will continue with context3
.
The contexts will be used only when the content is created and when you want to enroll it in a lifecycle for the first time. Once you have the corresponding lifecycle, you will set the lifecycle inside the content (see New Authoring Mixin) and the context service will not be called again for this content.