Extend automation 6.4
From OpenKM Documentation
The Plug-in system of OpenKM allows you to quickly expand the functionality offered by the platform, extending the availabel 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
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.