• SOLVED Move Workflow file to new location – edit/update/delete

  • We tried to make OpenKM as intuitive as possible, but an advice is always welcome.
We tried to make OpenKM as intuitive as possible, but an advice is always welcome.
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.
 #42610  by alexwgordon
 
Hi all!

So I'm working on a workflow and we've run into an issue. What we usually do is upload files that need to be reviewed to folder okmroot\"To Be Reviewed". The files go through a workflow and once fileB is approved, fileB needs to be moved into its correct directory and that could be anywhere in the folder tree. However, sometimes, this file already existences and the "To Be Reviewed" document is just an update to the existing file (fileA).

So my question is, is there a good way to handle this? Is there a way to "move" the fileB to the correct location and update fileA with fileB? Would really love some ideas on how to approach this! Thanks everybody for your thoughts and input!
Last edited by alexwgordon on Fri Dec 16, 2016 4:28 pm, edited 3 times in total.
 #42630  by jllort
 
Are serveral ways for doing it:
- You can set the path directly from workflow ( in the transition ).
- You can work with metadata -> change metadata values and with automation events fired by metadata changes.

I suggest take a look at :
https://docs.openkm.com/apidoc/com/okm/6.3.2/
https://wiki.openkm.com/index.php/Automation
 #42665  by alexwgordon
 
Hi jllort!

I've looked through the API docs before and I have a hard time navigating it to figure out where the exact methods are that I'll end up needing. I usually end up stumbling upon after a long long time.

1. But anyway, how can how can I set path directly from workflow in a transition if the file already exists? Would I still need to perform a checkout existing file, upload newly approved file, then delete the newly approved file?
2. For metadata, I could potentially alter some keyword, at which point that triggers an action to upload the file to the new location? Is that the correct procedure?

Thanks jllort for the response!
 #42677  by jllort
 
About uploading a document which yet exists, the answers is "you should update the document", probably is the best scenario. That mean you must doing a checkout before doing the checkin action.

About the event must use the event named "set property group" -> fired when metadata fields are set into the database.
The logic should be:
set metadata into the workflow which fires event "set property group" and then from the action ( I suggest post ) move document to ends location.
 #42689  by alexwgordon
 
Ah okay, I think I've got an idea of what I'm going to do now. However, I only have one snag, which is how to delete the file if I can't move it and must update the file. I've tried
Code: Select all
OKMDocument.getInstance().delete(token, path);
but I get the error, "can't delete document in a workflow". What an I do to delete this file once the workflow is completed other than deleting it manually?

Also is there a way to determine if a file exists in a given folder using the path? for example Can I check /okm:root/folder1/ for file.pdf using the filename "file.pdf"? I want my workflow to decide whether to move or update the file depending on whether the file already exists.
 #42692  by jllort
 
Yes, you are in a infinite loop while trying to delete a document from a workflow. We do not allow deleting a document which have a workflow running ( it's a security behavior, because in database you do not want to have information about a workflow which is pointing to a non existing document node -> it will raise a null pointer error ).

The solution for it, is create a /okm:root/wf-daily-purge folder , move the documents into, and finish the workflow. Then make an small script for deleting all the documents into. Also you can make these documents and the folder hidden for the other users -> changing security an only allowing super users accessing them.

Hope it can help you in some way.
 #42694  by alexwgordon
 
Ah that is brilliant and simple. Thanks Jllort! going to implement that today. Thank you!!

So I have 2 follow up questions:
1. To perform the checkin using an existing file within OpenKM what is my InputStream? See my attempt below (that doesn't work).
2. Is a try/catch the best way to do a quick check to see if the file already exists in its new location? I feel like it's the easiest way to attempt a move and if it gets an error to update instead.
Code: Select all
try {
	OKMDocument.getInstance().move(systemToken, nodePath, destination);
} catch (ItemExistsException e) {
	OKMDocument.getInstance().checkout(systemToken, existingNode);
	InputStream is = new FileInputStream("/okm:root/Alex1.pdf");
	OKMDocument.getInstance().checkin(systemToken, newDestinationPath, is, "Uploaded via workflow", 0);
	OKMDocument.getInstance().move(systemToken, "/okm:root/purge folder/");
}
 #42697  by alexwgordon
 
Ah okay that definitely works too. Thanks!

How can I upload do a checkin/update of a file with a file within OKM? I thought I would use
Code: Select all
OKMDocument.getInstance().checkin(systemToken, newDestinationPath, inputStream, comment, revUpdate);
But I'm not sure what the inputStream or revUpdate need to be. Thanks!
 #42698  by jllort
 
There's a checkin method with less variables, I suggest use it:
Code: Select all
OKMDocument.getInstance().checkin(String token, String docPath, InputStream is, String comment)
The checkin method you suggested, is used for setting specific version number ( not automatically assigned by the system ) and changing the document location. You do not need it.
 #42699  by alexwgordon
 
Ah okay, though I do need to denote which rev to update because I want it to be a major revision update and not a minor revision.
Code: Select all
OKMDocument.getInstance().checkin(systemToken, newDestinationPath, inputStream, comment, revUpdate);
And also I was confused about what the inputStream needed to be, but I've figured that one out using this command.
Code: Select all
InputStream is = OKMDocument.getInstance().getContent(systemToken, wfNodePath, false);
Thanks for your help in this jllort!
 #42700  by alexwgordon
 
So I get a "Could Not Execute JDBC Batch Update" error if I run my code on the same file a few times.
Code: Select all
2016-12-06 13:24:16,957 [http-bio-127.0.0.1-8080-exec-21] WARN  org.hibernate.util.JDBCExceptionReporter- SQL Error: 1406, SQLState: 22001
2016-12-06 13:24:16,957 [http-bio-127.0.0.1-8080-exec-21] ERROR org.hibernate.util.JDBCExceptionReporter- Data truncation: Data too long for column 'NPG_VALUE' at row 1
2016-12-06 13:24:16,957 [http-bio-127.0.0.1-8080-exec-21] ERROR org.jbpm.graph.def.GraphElement- action threw exception: Could not execute JDBC batch update
com.openkm.core.DatabaseException: Could not execute JDBC batch update
	at com.openkm.dao.NodeBaseDAO.setProperties(NodeBaseDAO.java:2137)
	at com.openkm.module.db.DbPropertyGroupModule.setProperties(DbPropertyGroupModule.java:510)
	at com.openkm.api.OKMPropertyGroup.setPropertiesSimple(OKMPropertyGroup.java:181)
	at com.openkm.api.OKMPropertyGroup.setPropertySimple(OKMPropertyGroup.java:133)
	at com.openkm.workflow.approval.GetNotes.execute(GetNotes.java:56)
	at org.jbpm.graph.def.Action.execute(Action.java:129)
	at org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:284)
	at org.jbpm.graph.def.GraphElement.executeActions(GraphElement.java:241)
	at org.jbpm.graph.def.GraphElement.fireAndPropagateEvent(GraphElement.java:213)
	at org.jbpm.graph.def.GraphElement.fireEvent(GraphElement.java:196)
	at org.jbpm.graph.def.Node.enter(Node.java:371)
	at sun.reflect.GeneratedMethodAccessor502.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:197)
	at org.jbpm.graph.def.Node_$$_javassist_119.enter(Node_$$_javassist_119.java)
	at org.jbpm.graph.def.Transition.take(Transition.java:167)
	at org.jbpm.graph.def.Node.leave(Node.java:479)
	at org.jbpm.graph.node.TaskNode.leave(TaskNode.java:213)
	at sun.reflect.GeneratedMethodAccessor507.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:197)
	at org.jbpm.graph.def.Node_$$_javassist_119.leave(Node_$$_javassist_119.java)
	at org.jbpm.graph.exe.Token.signal(Token.java:223)
	at org.jbpm.graph.exe.Token.signal(Token.java:188)
	at sun.reflect.GeneratedMethodAccessor524.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:197)
	at org.jbpm.graph.exe.Token_$$_javassist_10.signal(Token_$$_javassist_10.java)
	at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:495)
	at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:436)
	at com.openkm.module.common.CommonWorkflowModule.setTaskInstanceValues(CommonWorkflowModule.java:705)
	at com.openkm.module.db.DbWorkflowModule.setTaskInstanceValues(DbWorkflowModule.java:689)
	at com.openkm.api.OKMWorkflow.setTaskInstanceValues(OKMWorkflow.java:277)
	at com.openkm.servlet.frontend.WorkflowServlet.setTaskInstanceValues(WorkflowServlet.java:278)
	at sun.reflect.GeneratedMethodAccessor520.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	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:646)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	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:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:315)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.hibernate.exception.DataException: Could not execute JDBC batch update
	at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:102)
	at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:268)
	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:185)
	at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
	at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
	at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
	at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:383)
	at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:133)
	at com.openkm.dao.HibernateUtil.commit(HibernateUtil.java:303)
	at com.openkm.dao.NodeBaseDAO.setProperties(NodeBaseDAO.java:2123)
	... 87 more
Caused by: java.sql.BatchUpdateException: Data truncation: Data too long for column 'NPG_VALUE' at row 1
	at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2018)
	at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1454)
	at org.apache.tomcat.dbcp.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
	at org.apache.tomcat.dbcp.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
	at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
	... 96 more
2016-12-06 13:24:16,957 [http-bio-127.0.0.1-8080-exec-21] ERROR com.openkm.servlet.frontend.WorkflowServlet- Could not execute JDBC batch update
com.openkm.core.WorkflowException: Could not execute JDBC batch update
	at com.openkm.module.common.CommonWorkflowModule.setTaskInstanceValues(CommonWorkflowModule.java:716)
	at com.openkm.module.db.DbWorkflowModule.setTaskInstanceValues(DbWorkflowModule.java:689)
	at com.openkm.api.OKMWorkflow.setTaskInstanceValues(OKMWorkflow.java:277)
	at com.openkm.servlet.frontend.WorkflowServlet.setTaskInstanceValues(WorkflowServlet.java:278)
	at sun.reflect.GeneratedMethodAccessor520.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	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:646)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	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:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:315)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.jbpm.graph.def.DelegationException: Could not execute JDBC batch update
	at org.jbpm.graph.def.GraphElement.raiseException(GraphElement.java:388)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:197)
	at org.jbpm.graph.def.ProcessDefinition_$$_javassist_9.raiseException(ProcessDefinition_$$_javassist_9.java)
	at org.jbpm.graph.def.GraphElement.raiseException(GraphElement.java:379)
	at org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:301)
	at org.jbpm.graph.def.GraphElement.executeActions(GraphElement.java:241)
	at org.jbpm.graph.def.GraphElement.fireAndPropagateEvent(GraphElement.java:213)
	at org.jbpm.graph.def.GraphElement.fireEvent(GraphElement.java:196)
	at org.jbpm.graph.def.Node.enter(Node.java:371)
	at sun.reflect.GeneratedMethodAccessor502.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:197)
	at org.jbpm.graph.def.Node_$$_javassist_119.enter(Node_$$_javassist_119.java)
	at org.jbpm.graph.def.Transition.take(Transition.java:167)
	at org.jbpm.graph.def.Node.leave(Node.java:479)
	at org.jbpm.graph.node.TaskNode.leave(TaskNode.java:213)
	at sun.reflect.GeneratedMethodAccessor507.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:197)
	at org.jbpm.graph.def.Node_$$_javassist_119.leave(Node_$$_javassist_119.java)
	at org.jbpm.graph.exe.Token.signal(Token.java:223)
	at org.jbpm.graph.exe.Token.signal(Token.java:188)
	at sun.reflect.GeneratedMethodAccessor524.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:197)
	at org.jbpm.graph.exe.Token_$$_javassist_10.signal(Token_$$_javassist_10.java)
	at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:495)
	at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:436)
	at com.openkm.module.common.CommonWorkflowModule.setTaskInstanceValues(CommonWorkflowModule.java:705)
	... 54 more
Caused by: com.openkm.core.DatabaseException: Could not execute JDBC batch update
	at com.openkm.dao.NodeBaseDAO.setProperties(NodeBaseDAO.java:2137)
	at com.openkm.module.db.DbPropertyGroupModule.setProperties(DbPropertyGroupModule.java:510)
	at com.openkm.api.OKMPropertyGroup.setPropertiesSimple(OKMPropertyGroup.java:181)
	at com.openkm.api.OKMPropertyGroup.setPropertySimple(OKMPropertyGroup.java:133)
	at com.openkm.workflow.approval.GetNotes.execute(GetNotes.java:56)
	at org.jbpm.graph.def.Action.execute(Action.java:129)
	at org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:284)
	... 81 more
Caused by: org.hibernate.exception.DataException: Could not execute JDBC batch update
	at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:102)
	at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:268)
	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:185)
	at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
	at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
	at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
	at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:383)
	at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:133)
	at com.openkm.dao.HibernateUtil.commit(HibernateUtil.java:303)
	at com.openkm.dao.NodeBaseDAO.setProperties(NodeBaseDAO.java:2123)
	... 87 more
Caused by: java.sql.BatchUpdateException: Data truncation: Data too long for column 'NPG_VALUE' at row 1
	at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2018)
	at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1454)
	at org.apache.tomcat.dbcp.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
	at org.apache.tomcat.dbcp.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
	at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
	... 96 more
I'm not sure why it is happening. Does my code give any hint to causing a JDBC update error?
Code: Select all
public class MoveUpdate implements ActionHandler {

	private static final long serialVersionUID = 1L;
	public void execute(ExecutionContext context) throws Exception {
		String systemToken = DbSessionManager.getInstance().getSystemToken();
		// Get current file uuid
		String wfNodePath = (String) context.getContextInstance().getVariable("uuid");
		// Get the final destination of file
		String destination = (String) context.getContextInstance().getVariable("destination");
		// Get filename of workflow file and create new location path
		String wfNodeActualPath = OKMDocument.getInstance().getProperties(systemToken, wfNodePath).getPath();
		String wfDocName = PathUtils.getName(wfNodeActualPath);
		String docPath = destination + "/" + wfDocName;
		String updateNode = NodeBaseDAO.getInstance().getUuidFromPath(docPath);
		try {
			OKMDocument.getInstance().move(systemToken, wfNodePath, destination);
		} 
		catch (ItemExistsException e) {
			OKMDocument.getInstance().checkout(null, updateNode);
			// Copy notes and okg:CommentHistory
			OKMNote.getInstance().list(systemToken, wfNodePath);
			List<FormElement> wfCommentsList = OKMPropertyGroup.getInstance().getProperties(systemToken, wfNodePath, "okg:commentHistory");
			List<FormElement> updateCommentsList = OKMPropertyGroup.getInstance().getProperties(systemToken, updateNode, "okg:commentHistory");
			TextArea wfCommentsTA = (TextArea) wfCommentsList.get(0);
			TextArea updateCommentsTA = (TextArea) updateCommentsList.get(0);
			// Combine the original comments with the new ones
			OKMPropertyGroup.setPropertySimple(systemToken, updateNode, "okg:commentHistory", "okp:reviewerCommentArea", updateCommentsTA.getValue() + "\n" + wfCommentsTA.getValue() + "\n" );
			// Move new doc to purge folder
			OKMDocument.getInstance().move(systemToken, wfNodePath, "/okm:root/To Be Purged");
			// Update original doc with new Rev
			InputStream is = OKMDocument.getInstance().getContent(systemToken, wfNodePath, false);
			OKMDocument.getInstance().checkin(null, docPath, is, "Uploaded via workflow", 1);
		}
	}

}
 #42706  by alexwgordon
 
I don't want the file to be shown as checked out by the system ideally, and in this step the person checking out the doc will always be the same as the one the one checking it back in.

I'm fairly certain the setProperties is causing the JDBC error. But what is that and how can i fix it? The error reads "Data too long for column 'NPG_VALUE' at row 1. I'm guessing NPG is Node Property Group. What is the limitation of a TextArea?

Currently I'm attempting to combine the values of a TextArea property, but perhaps there's a better way to concatenate or save both without concatenating?
 #42710  by jllort
 
By default NPG_VALUE field from OKM_NODE_PROPERTY table has a limit of 2048 or less characters. You can increase it, altering the table definition default limit. By default we have this amount, because in 99% of cases covers them ( unfortunatelly we can not set as clob or similar database field type )

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.