3.1.2.2.2. Context

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:

From these parameters, you can easily connect and define contexts based on:

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:

The logic is very simple. When you create a content, go lifecycle by lifecycle starting with the better priority:

Note

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.

Copyright ©. All rights reserved. eXo Platform SAS
blog comments powered byDisqus