• Adding my own automation validation

  • OpenKM has many interesting features, but requires some configuration process to show its full potential.
OpenKM has many interesting features, but requires some configuration process to show its full potential.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #43400  by nelis
 
So i want to add my own validation in automation.
I saw something in the wiki entitled "Extend Automation 6.4" (https://www.openkm.com/wiki/index.php/E ... mation_6.4), the steps are the ff:
Step 1 - Create Class
Step 2 - Publish

Can someone help me by elaborating these steps?
How can I create my own class? Suppose I have created a class called UserHasProfile, Should I save it as .java file then compile it to create the .class file?
 #43401  by nelis
 
Update:
I installed OpenKM dev and successfully generated my .class file, can i just paste it on tomcat\webapps\OpenKM\WEB-INF\classes\com\openkm\automation\validation directory of my openKM?
 #43402  by nelis
 
Update 2:
Never mind, it works now. I just paste the .class file in my OpenKM directory.
BTW this is the validation I created to check the profile of the user
Code: Select all
package com.openkm.automation.validation;

import java.util.HashMap;

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

import com.openkm.automation.AutomationUtils;
import com.openkm.automation.Validation;
import com.openkm.spring.PrincipalUtils;
import com.openkm.core.DatabaseException;
import com.openkm.dao.ProfileDAO;

public class UserHasProfile implements Validation {
	private static Logger log = LoggerFactory.getLogger(UserHasProfile.class);
	
	@Override
	public boolean isValid(HashMap<String, Object> env, Object... params) {
		String profile = AutomationUtils.getString(0, params);
		
		try {
			return hasProfile(profile);
		} catch (Exception e) {
			log.error(e.getMessage(), e);
			return false;
		}
	}
	public boolean hasProfile(String profile)
	{
		try 
		{
			return ProfileDAO.findByUser(PrincipalUtils.getUser()).getName().equals(profile);
		} catch (DatabaseException e) {
			log.error(e.getMessage(), e);
			return false;
		}		
	}
}
 #43412  by jllort
 
Might be the OpenKM.war file not included the class or was not exploded when openkm started.

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.