ECM Scripts

Overview

As you probably already seen, there exist many different types of ECM groovy scripts. Indeed, if they all implements the CmsScript interface, there behavior is quite different. Therefor in the ECM Admin section dedicated to script management we have split the arganization in several areas.

package org.exoplatform.services.cms.scripts;

public interface CmsScript {

  public void execute(Object context);

  public void setParams(String[] params);
  
}

We first have split the scripts in two types, one for the Browse Content portlet scripts and one for the ECM explorer portlet scripts.

ECM explorer scripts

There are three different types of scripts:

  • the Action ones: which will be launched when an ECM action trigger them (refer to "Actions Concept" section for more information on those).
  • the Interceptor ones: which can be triggered before or after a JCR node creation or edition. They are used to either validate the user input from the form or to manipulate the newly created node (to map it with a forum thread or any other type of discussion areas)
  • the Widget ones: which are used to fill widgets - such as selectbox - in a dynamic way.
We are now going to describe the ECM Admin User Interface that allow the ECM admin to manage all different types of script through a single interface.

The form to add or edit a script is basically the same. Nevertheless, when you edit a script you can not change its type, which is not the case when you create it.

Browse Content Portlet Scripts

The Browse Content portlet is used to provide to the end user several ways to extract the content from the JCR. One of that way is to use a Groovy script that will be responsible of the extraction.

Note that the scripts are stored directly in the JCR tree under the production workspace at the path /jcr:system/exo:ecm/scripts. The scripts are Groovy ones and the JCR path there can be seen as the classpath as we modified the default Groovy classloader to look for the scripts directly in the relative JCR path. Each time a script is modified then the groovy classloader is reset.

Manage script service

Script service manage groovy scripts.

<component>
      <key>org.exoplatform.services.cms.scripts.ScriptService</key>  
      <type>org.exoplatform.services.cms.scripts.ScriptServiceImpl</type>
      .....................
    </component>

With the init params:

<init-params>
        <object-param>
          <name>predefined.scripts</name>
          <description>description</description>
          <object type="org.exoplatform.services.cms.impl.ResourceConfig">
            <field  name="workspace"><string>production</string></field>
            <field  name="resources">
              <collection type="java.util.ArrayList">
                <value>
                  <object type="org.exoplatform.services.cms.impl.ResourceConfig$Resource">
                    <field  name="name"><string>ecm-explorer/widget/FillSelectBoxWithWorkspaces.groovy</string></field>
                  </object>  
                </value> 
                <value>
                  <object type="org.exoplatform.services.cms.impl.ResourceConfig$Resource">
                    <field  name="name"><string>ecm-explorer/action/SendMailScript.groovy</string></field>
                  </object>  
                </value> 
                <value>
                  <object type="org.exoplatform.services.cms.impl.ResourceConfig$Resource">
                    <field  name="name"><string>ecm-explorer/action/RSSScript.groovy</string></field>
                  </object>  
                </value> 
                <value>
                  <object type="org.exoplatform.services.cms.impl.ResourceConfig$Resource">
                    <field  name="name"><string>ecm-explorer/widget/SetJCRBrowserForProductionWorkspaceAndRulesPath.groovy</string></field>
                  </object>  
                </value> 
                <value>
                  <object type="org.exoplatform.services.cms.impl.ResourceConfig$Resource">
                    <field  name="name"><string>ecm-explorer/widget/SetJCRBrowserForProductionWorkspaceAndScriptsPath.groovy</string></field>
                  </object>  
                </value> 
                <value>
                  <object type="org.exoplatform.services.cms.impl.ResourceConfig$Resource">
                    <field  name="name"><string>ecm-explorer/widget/FillSelectBoxWithNodeChildren.groovy</string></field>
                  </object>  
                </value>
                <value>
                  <object type="org.exoplatform.services.cms.impl.ResourceConfig$Resource">
                    <field  name="name"><string>ecm-explorer/action/TransformBinaryChildrenToTextScript.groovy</string></field>
                  </object>  
                </value> 
                <value>
                  <object type="org.exoplatform.services.cms.impl.ResourceConfig$Resource">
                    <field  name="name"><string>ecm-explorer/interceptor/PreNodeSaveInterceptor.groovy</string></field>
                  </object>  
                </value> 
                <value>
                  <object type="org.exoplatform.services.cms.impl.ResourceConfig$Resource">
                    <field  name="name"><string>ecm-explorer/interceptor/PostNodeSaveInterceptor.groovy</string></field>
                  </object>  
                </value> 
                <value>
                  <object type="org.exoplatform.services.cms.impl.ResourceConfig$Resource">
                    <field  name="name"><string>content-browser/GetDocumentsFromWorkspaceAndPath.groovy</string></field>
                  </object>  
                </value> 
              </collection>   
            </field>
          </object>
        </object-param>
      </init-params>
 
Navigation

Creator: Benjamin Mestrallet on 2007/05/23 08:58
Copyright (c) 2000-2009. Allright reserved - eXo platform SAS
1.6.13286