Create new trigger code

You can add your own triggers to the list of preconfigured triggers, which you can then enable.

Note: This can be applied within a Hosted environment, but only within a test server.
Note: You can create triggers for all actions except the localization operations.

The code for custom triggers is loaded through configuration; the IXIASOFT CCMS installation is not modified. At any time, you can return to the standard CCMS behavior by returning to the original configuration.

To create new triggers:
  • Create a Java archive (.jar) with the trigger code.
  • Copy the .jar file to the Content Store.
  • Configure CCMS to add the trigger to the list of preconfigured triggers (in file /system/ext/dita.cms.extensions.xml).
  • Enable the trigger (in file /system/conf/triggers.xml).
These steps are described below.
  1. Create a Java class with the trigger code.
    For example, the following code shows a class (AddPrepublishFlagTrigger.java) that adds a flag to content objects that are nearing Published:done status.
    package com.ixiasoft.cms.triggers;
    
    import java.util.ArrayList;
    import java.util.Collection;
    import java.util.HashSet;
    import java.util.List;
    import java.util.Set;
    
    import org.apache.log4j.Logger;
    
    import com.ixiasoft.cms.actions.ActionCmsDataObject;
    import com.ixiasoft.cms.cdo.CdoCache;
    import com.ixiasoft.cms.cdo.CmsDataObject;
    import com.ixiasoft.cms.util.DitaReferenceResolver;
    
    public class AddPrepublishFlagTrigger extends StatusTrigger {
    	private static Logger logger = Logger.getLogger(AddPrepublishFlagTrigger.class);
    	public AddPrepublishFlagTrigger(String name, int objType, int schedule, String applyto) {
    		super(name, objType, schedule, applyto);
    	}
    
    	@Override
    	public void statusExecute(ActionCmsDataObject acdo) {
    		
    		logger.debug("Adding Prepublish Flag on MAP " + acdo.getCdo().getTitleAndId() );
    		CmsDataObject map = acdo.getCdo();
    		
    		Collection<CmsDataObject> childrenContentDependencies = DitaReferenceResolver.getChildrenContentDependencies( map, null );
    		Set<String> children = new HashSet<String>();
    		for (CmsDataObject cdo : childrenContentDependencies){
    			children.add(cdo.getFullPath());
    		}
    		//Add current map, so it gets the props.
    		children.add( map.getFullPath() );
    		
    		CdoCache.lockDocuments( new ArrayList<String>( children ) );
    		List<CmsDataObject> documents = new ArrayList<CmsDataObject>( children.size() );
    		for( String reference : children ) {
    			CmsDataObject childcdo = CdoCache.getCmsDataObject( reference );
    			childcdo.addUserProperty( CmsDataObject.PREPUBLISH, map.getFullPath() );
    			documents.add( childcdo );
    		}
    		
    		CdoCache.setDocuments(documents, true );
    		CdoCache.unlockDocuments( documents );
    		
    	}
    }
  2. Create a Java archive (.jar) that includes the new class for the trigger.
  3. Open the TEXTML Administration perspective by clicking the TEXTML Administration shortcut on the tool bar. If the shortcut is not displayed, follow these steps:
    1. Select Window > Perspective > Open Perspective > Other
    2. Click TEXTML Administration.
    3. Click Open.
  4. In the TEXTML Administration view, double-click the server. If your server is not displayed in the view, you must add it to the view.
  5. When the Connect as dialog opens, type your username and password and click OK.
  6. Double-click the name of your Content Store to open a connection to it.
  7. Expand the Content Store's Repository node and browse to /system/ext.
  8. Import the .jar file to this directory.
  9. In /system/ext, right-click dita.cms.extensions.xml and select Check Out.
    Note: If the file is called dita.cms.extensions.xml.orig, rename it to dita.cms.extensions.xml.
  10. Open the file in an XML editor.
  11. Locate the <libraries> element.
    This element specifies the classes that are added to the standard set of classes. You need to add your trigger classes to this element to make your triggers available.
  12. Add a new <library> element, as follows:
    <library id="library_id">
    	<classpath>
    		<jar>trigger_jar_file_name</jar>
    	</classpath>
    	<classes>
    		<class>trigger_class_name(s)</class>
    	</classes>
    </library>
    OptionDescription
    library_id ID that identifies the library (for logging purposes).
    trigger_jar_file_name Name of the .jar file that contains the trigger classes.
    trigger_class_name Name of the trigger class inside the .jar file. If the .jar file contains more than one trigger classes, enter a <class> element for each trigger class.
    For example:
    <libraries>
    	<!-- every library will become its own classloader -->
    	<library id="com.ixiasoft.service.extensions.new.triggers">
    		<classpath>
    			<jar>com.ixiasoft.service.extensions.new.triggers.jar</jar>
    		</classpath>
    		<!-- list of public classes that dynamic classloading can use -->
    		<classes>
    			<class>com.ixiasoft.service.extensions.new.triggers.MapRelease</class>
    			<class>com.ixiasoft.service.extensions.new.triggers.TopicRelease</class>
    		</classes>
    	</library>
    </libraries>
  13. Save, close, and check in the file.
  14. Inform users of the changes and request that they close and reopen their CCMS Desktop to apply the changes.
  15. Enable the new trigger (see links at the end of this topic for the procedure).