• Error when using upload workflow form element

  • 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.
 #18425  by noxious
 
I created a simple worklfow that uploads files just to test upload form element.
When I select the file to be uploaded and press accept button, the upload window appears and when the upload process starts I get a
java.lang.stringIndexOutOfBoundsException!!! I use OpenKM 5.1.10 on windows 7 and I try to upload small size text file with small latin title with no special chars. When I try to upload the same file inside the application using the OpenKM UI no exception is thrown.
Why is this happening?
Here is the error stack:
Code: Select all
2012-09-08 12:16:17,144 ERROR [com.openkm.servlet.frontend.FileUploadServlet] String index out of range: -1
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
	at java.lang.String.substring(String.java:1958)
	at java.lang.String.substring(String.java:1925)
	at com.openkm.module.direct.DirectDocumentModule.create(DirectDocumentModule.java:142)
	at com.openkm.module.direct.DirectDocumentModule.create(DirectDocumentModule.java:97)
	at com.openkm.api.OKMDocument.create(OKMDocument.java:71)
	at com.openkm.servlet.frontend.FileUploadServlet.doPost(FileUploadServlet.java:225)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
	at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
	at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
	at java.lang.Thread.run(Thread.java:722)
I attach the workflow par file.
Attachments
Workflow
(8.2 KiB) Downloaded 297 times
 #18432  by jllort
 
Basically your form.xml is wrong, first take a look on possible update attibutes (http://www.openkm.com/dtd/workflow-forms-2.1.dtd):
Code: Select all
<!ELEMENT upload (validator*)>
<!ATTLIST upload
	label CDATA #REQUIRED
	name CDATA #REQUIRED
	width CDATA #IMPLIED
	height CDATA #IMPLIED
	folderPath CDATA #IMPLIED
	folderUuid CDATA #IMPLIED
	documentName CDATA #IMPLIED
	documentUuid CDATA #IMPLIED
	type (create | update) "create"
	data CDATA #IMPLIED
>
1- You should indicate are creating a new document, by default is yet set to create
2- The you should at least indicate the path where do you want tosame the document, by path or by uuid folderPath=/okm:root/ etc...
3- I'm not sure if documentName is mandatory or not, you should test it ( because same form element can be used to update or create ( in your case creation )
 #18433  by noxious
 
You were right jllort, folderPath or folderUUID is required.
DocumentName is not required because by default uses the name of the uploaded file.
I have an other question too. Let's say that I want to make the documentName parameter of upload element dynamic.
I tried
Code: Select all
<upload name="upload_param" label="Σήμα:" type="create" folderPath="/okm:root/SHMATA" documentName="#{newName}" type="create"></upload>
where newName an execution context variable that I create using an ActionHandler, but it's not working.
Then I tried
Code: Select all
public class RenameDocument implements ActionHandler{
	private static final long serialVersionUID = 1L;
	@Override
	public void execute(ExecutionContext context) throws Exception {
		// TODO Auto-generated method stub
		String newName = "a.txt";
		context.getContextInstance().setVariable("newName", newName);
		Upload up = new Upload();
		up.setDocumentName(newName);
		up.setFolderPath("/okm:root/SHMATA");
		up.setName("upload_param");
		up.setType("create");
	}
}
but I can't figure out how to add the upload element in my existing form. Can you please tell me how to do it?
 #18434  by noxious
 
Never mind, I solved it :D !!!

This is the form element:
Code: Select all
<upload name="upload_param" label="Σήμα:" data="upload_param"></upload>
and this is the ActionHandler:
Code: Select all
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;
import com.openkm.bean.form.*;
public class RenameDocument implements ActionHandler{
	private static final long serialVersionUID = 1L;
	@Override
	public void execute(ExecutionContext context) throws Exception {
		// TODO Auto-generated method stub
		String newName = "b.txt";
		Upload up = new Upload();
		up.setDocumentName(newName);
		up.setFolderPath("/okm:root/SHMATA");
		up.setName("upload_param");
		up.setType("create");
		context.getContextInstance().createVariable("upload_param", up);
	}
}
 #18436  by jllort
 
We're pleased you solved it. Workflow are not easy tasks to be implemented need some time and pacience to understanding what you got in your hands.

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.