Difference between revisions of "Extend automation 6.4"

From OpenKM Documentation
Jump to: navigation, search
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 +
{{TOCright}} __TOC__
 +
 
The Plug-in system of OpenKM allows you to quickly expand the functionality offered by the platform, extending the available Automation without having to rebuild the system to add/change the existing functionality.  
 
The Plug-in system of OpenKM allows you to quickly expand the functionality offered by the platform, extending the available Automation without having to rebuild the system to add/change the existing functionality.  
 
  
 
== Step 1 - Create class ==
 
== Step 1 - Create class ==
Line 6: Line 7:
 
* If you make a new action the new class should be under com.openkm.automation.action ( this is mandatory )
 
* If you make a new action the new class should be under com.openkm.automation.action ( this is mandatory )
 
* '''Important''' do not forget to set the tag '''@PluginImplementation''' before the class definition  
 
* '''Important''' do not forget to set the tag '''@PluginImplementation''' before the class definition  
 +
* Pack all classes into jar file and copy into $TOMCAT_HOME/plugins
 +
* Restart openkm server
  
  

Latest revision as of 17:24, 3 May 2014

The Plug-in system of OpenKM allows you to quickly expand the functionality offered by the platform, extending the available Automation without having to rebuild the system to add/change the existing functionality.

Step 1 - Create class

  • If you make a new validation the new class should be under com.openkm.automation.validation ( this is mandatory )
  • If you make a new action the new class should be under com.openkm.automation.action ( this is mandatory )
  • Important do not forget to set the tag @PluginImplementation before the class definition
  • Pack all classes into jar file and copy into $TOMCAT_HOME/plugins
  • Restart openkm server


Validation PathContains example

package com.openkm.automation.validation;

import java.util.HashMap;

import net.xeoh.plugins.base.annotations.PluginImplementation;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.openkm.api.OKMRepository;
import com.openkm.dao.bean.Automation;
import com.openkm.automation.AutomationUtils;
import com.openkm.automation.Validation;

/**
 * Check if the current parent path contains a designed one. The only
 * parameter is a path and will test if this one is included in the
 * actual parent.
 * 
 */
@PluginImplementation
public class PathContains implements Validation {
	private static Logger log = LoggerFactory.getLogger(PathContains.class);
	
	@Override
	public boolean isValid(HashMap<String, Object> env, Object... params) {
		String uuid = AutomationUtils.getString(0, params);
		String parentPath = AutomationUtils.getParentPath(env);
		
		try {
			String path = OKMRepository.getInstance().getNodePath(null, uuid);
			
			if (parentPath.startsWith(path)) {
				return true;
			} else {
			 return false;
			}
		} catch (Exception e) {
			log.error(e.getMessage(), e);
		}
		
		return false;
	}
	
	@Override
	public boolean hasPost() {
		return true;
	}

	@Override
	public boolean hasPre() {
		return false;
	}

	@Override
	public String getName() {
		return "PathContains";
	}

	@Override
	public String getParamType00() {
		return Automation.PARAM_TYPE_TEXT;
	}

	@Override
	public String getParamSrc00() {
		return Automation.PARAM_SOURCE_FOLDER;
	}

	@Override
	public String getParamDesc00() {
		return "String";
	}

	@Override
	public String getParamType01() {
		return Automation.PARAM_TYPE_EMPTY;
	}

	@Override
	public String getParamSrc01() {
		return Automation.PARAM_SOURCE_EMPTY;
	}

	@Override
	public String getParamDesc01() {
		return "";
	}

	@Override
	public String getParamType02() {
		return Automation.PARAM_TYPE_EMPTY;
	}

	@Override
	public String getParamSrc02() {
		return Automation.PARAM_SOURCE_EMPTY;
	}

	@Override
	public String getParamDesc02() {
		return "";
	}
}


Step 2 - Publish

Create your own jar and copy into $TOMCAT_HOME/lib folder.