Page 1 of 1

Automation Script for execution at "doc_move" Event in 6.2.3

PostPosted:Tue Apr 16, 2013 3:32 pm
by armber
Hi,
I would like to implement an Automation Rule for execution at a "doc_move" Event.
Reading what has been reported for post "openkm6.2.2 automation file move java.lang.NullPointerExcept" ( viewtopic.php?f=4&t=9293 ) it seems that this automation of "doc_move" Event has some problems to execute. Is this correct?

If it is possble, what should be the key structure of the automation script for "doc_move" Event that automatically changes rights to all users and roles that have rights on it when a Document is moved to a Folder?

Many thanks,
Armando

Re: Automation Script for execution at "doc_move" Event in 6

PostPosted:Wed Apr 17, 2013 9:50 pm
by pavila
So you can reproduce this problem in OpenKM Community 6.2.3?

Re: Automation Script for execution at "doc_move" Event in 6

PostPosted:Thu May 23, 2013 11:17 am
by armber
Hi,
I have tried to verify this problem using OpenKM Community 6.2.4 DEV (Build 8051), to which I have upgraded in the meantime.

I am trying to implement an Automation Rule that is executed when a document is moved from a generic location to a specific location.

The Rule is defined to be executed at "doc_move" event , as "Post" step.
The Validation condition is "PathContains" and the Action is "ExecuteScripting".
The "PathContains" folder value and the Script to execute for "ExecuteScripting" are the same that I have used for a different "doc_create" rule that is functional.
"PathContains" folder that I have specified is the target location of the move action.
The text of the Script is:
Code: Select all
import javax.jcr.*;
import com.openkm.core.*;
import com.openkm.bean.*;
import com.openkm.module.*;

import java.util.Map;
import com.openkm.api.OKMAuth;
import com.openkm.bean.Permission;
import com.openkm.api.OKMRepository;
 

	String path = OKMRepository.getInstance().getNodePath(null,  uuid);
	OKMAuth oKMAuth = OKMAuth.getInstance();
 
	// All Roles only will continue having read grants
	Map hm = oKMAuth.getGrantedRoles(null, path);
	for (String roleName : hm.keySet()) {
		oKMAuth.revokeRole(null, path, roleName, Permission.WRITE, false);
		oKMAuth.revokeRole(null, path, roleName, Permission.DELETE, false);
		oKMAuth.revokeRole(null, path, roleName, Permission.SECURITY, false);
	}
 
	// All users only will continue having read grants
	hm = oKMAuth.getGrantedUsers(null, path);
	for (String userName : hm.keySet()) {
	//	if (!session.getUserID().equals(userName)) {
			oKMAuth.revokeUser(null, path, userName, Permission.WRITE, false);
			oKMAuth.revokeUser(null, path, userName, Permission.DELETE, false);
			oKMAuth.revokeUser(null, path, userName, Permission.SECURITY, false);
	//	}
	}
When a document is moved to the target location, the following error is recorded in the catalina.log and none of the expected modifications on the document's security is executed.
Code: Select all
	2013-05-23 13:06:11,744 [http-bio-0.0.0.0-8080-exec-33] ERROR com.openkm.automation.validation.PathContains - 
java.lang.NullPointerException
	at com.openkm.automation.validation.PathContains.isValid(PathContains.java:51)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.openkm.util.cl.ClassLoaderUtils.invokeAutomationMethod(ClassLoaderUtils.java:159)
	at com.openkm.automation.AutomationManager.getValidActions(AutomationManager.java:104)
	at com.openkm.automation.AutomationManager.fireEvent(AutomationManager.java:58)
	at com.openkm.module.db.DbDocumentModule.move(DbDocumentModule.java:1045)
	at com.openkm.api.OKMDocument.move(OKMDocument.java:292)
	at com.openkm.servlet.frontend.DocumentServlet.move(DocumentServlet.java:370)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:569)
	at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
	at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
	at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:101)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:182)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:173)
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
	at java.lang.Thread.run(Thread.java:662)

a) Can you please suggest how to overcome the error?

b) With this opportunity, can you please suggest how to make a Property group to be attached to the document as part of the Script executed?

Many thanks,
Armando

Re: Automation Script for execution at "doc_move" Event in 6

PostPosted:Tue May 28, 2013 6:44 am
by armber
Hi,
as concerns my first question, the error
Code: Select all
"ERROR com.openkm.automation.validation.PathContains - 
java.lang.NullPointerException"
seems specifically related to the Validation condition "PathContains" used in association with the "doc_move" event.
Should enabling of additional automation functionalities or other configurations be executed in order for the "PathContains" validation condition be functional for the "doc_move" event?

Many thanks,
Armando


Comment: as for now two records have been added in the OKM_AUTO_METADATA table as specified to enable the automation functionalities.

Re: Automation Script for execution at "doc_move" Event in 6

PostPosted:Wed May 29, 2013 7:58 pm
by jllort
Seems when is executing internal code is getting null.
Code: Select all
String path = OKMRepository.getInstance().getNodePath(null, uuid);
I suggest create the entire automation rule again, because in first automation version we saved path in database and later we save uuid, if you have older definition you can get this kind of error. Try create entire rule again.

Re: Automation Script for execution at "doc_move" Event in 6

PostPosted:Thu May 30, 2013 9:53 am
by armber
Hi jllort,
as suggested I have deleted and recreated the entire automation rule again but
"ERROR com.openkm.automation.validation.PathContains - java.lang.NullPointerException"
is still preventing the successful execution of the procedure.
Attached please find documentation of the tests I made.
Many thanks,
Armando

Re: Automation Script for execution at "doc_move" Event in 6

PostPosted:Sun Jun 02, 2013 6:00 pm
by jllort

Re: Automation Script for execution at "doc_move" Event in 6

PostPosted:Wed Jun 05, 2013 11:16 am
by armber
Hi jllort,
when is the final 6.2.4 version of OpenKM expected to be released?
Do you think that this bug will be fixed with that release?
Many thanks,
Armando

Re: Automation Script for execution at "doc_move" Event in 6

PostPosted:Fri Jun 07, 2013 9:33 am
by jllort
We're thinking to release in few weeks. I'm not sure if it'll be already solved on 6.2.4

Re: Automation Script for execution at "doc_move" Event in 6

PostPosted:Fri Jun 07, 2013 12:51 pm
by armber
OK jllort, thank you.
I'll look at the release notes for info about it.
Best regards, Armando

Re: Automation Script for execution at "doc_move" Event in 6

PostPosted:Thu May 22, 2014 9:12 am
by gcosta
Hi, I have the same problem that you when I can try to execute and automation move script. Can you solve this issue?

I'm using OpenKM Community Edition 6.2.5 version.

Thank you very much!

Re: Automation Script for execution at "doc_move" Event in 6

PostPosted:Fri May 23, 2014 6:46 pm
by jllort
I suggest you migrate to version 6.3 what comes with better support for automation, take a look here because from version 6.3 we've included almost action & validations to community version now you can enable it directly http://wiki.openkm.com/index.php/Enable_automation

Re: Automation Script for execution at "doc_move" Event in 6.2.3

PostPosted:Fri Feb 16, 2018 4:08 pm
by dferguson
I am still seeing this error in CE 6.3.4 when using the PathContains validation for a document move...
Code: Select all
2018-02-16 10:59:31,361 [http-bio-10.30.40.185-8180-exec-1023] [] ERROR c.o.a.validation.PathContains - null
java.lang.NullPointerException: null
	at com.openkm.automation.validation.PathContains.isValid(PathContains.java:49) ~[PathContains.class:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_161]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_161]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_161]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_161]
	at com.openkm.util.cl.ClassLoaderUtils.invokeAutomationMethod(ClassLoaderUtils.java:164) [ClassLoaderUtils.class:na]
	at com.openkm.automation.AutomationManager.getValidActions(AutomationManager.java:104) [AutomationManager.class:na]
	at com.openkm.automation.AutomationManager.fireEvent(AutomationManager.java:58) [AutomationManager.class:na]
	at com.openkm.module.db.DbDocumentModule.move(DbDocumentModule.java:1236) [DbDocumentModule.class:na]
	at com.openkm.api.OKMDocument.move(OKMDocument.java:294) [OKMDocument.class:na]
	at com.openkm.servlet.frontend.DocumentServlet.move(DocumentServlet.java:351) [DocumentServlet.class:na]
	at sun.reflect.GeneratedMethodAccessor786.invoke(Unknown Source) ~[na:na]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_161]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_161]
	at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:569) [gwt-servlet-2.4.0.jar:na]
	at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208) [gwt-servlet-2.4.0.jar:na]
	at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248) [gwt-servlet-2.4.0.jar:na]
	at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62) [gwt-servlet-2.4.0.jar:na]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:650) [servlet-api.jar:na]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) [servlet-api.jar:na]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) [catalina.jar:7.0.61]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.61]
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat7-websocket.jar:7.0.61]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [catalina.jar:7.0.61]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.61]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
	at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
	at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
	at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
	at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
	at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-3.2.8.RELEASE.jar:3.2.8.RELEASE]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
	at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160) [spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343) [spring-web-3.2.8.RELEASE.jar:3.2.8.RELEASE]
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260) [spring-web-3.2.8.RELEASE.jar:3.2.8.RELEASE]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [catalina.jar:7.0.61]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.61]
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) [catalina.jar:7.0.61]
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) [catalina.jar:7.0.61]
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) [catalina.jar:7.0.61]
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170) [catalina.jar:7.0.61]
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) [catalina.jar:7.0.61]
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950) [catalina.jar:7.0.61]
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) [catalina.jar:7.0.61]
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423) [catalina.jar:7.0.61]
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079) [tomcat-coyote.jar:7.0.61]
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620) [tomcat-coyote.jar:7.0.61]
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318) [tomcat-coyote.jar:7.0.61]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_161]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_161]
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-coyote.jar:7.0.61]
	at java.lang.Thread.run(Thread.java:748) [na:1.8.0_161]

Re: Automation Script for execution at "doc_move" Event in 6.2.3

PostPosted:Sat Feb 17, 2018 5:34 pm
by jllort
Add an issue for it here https://github.com/openkm/document-mana ... tem/issues
Please indicate the details for doing similar test:
- node a from path /okm:root/etc/b is moving to node b with path /okm:root/etc/b
- how did you configured the path contains ( at pre or post, all the details please ).

Screenshots are always welcome.