• Upload and Download Form Element In Workflow

  • 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.
 #41312  by jllort
 
In portable dev environment you have portable firefox what comes with GWT plugin. Also you should have at Debug Configurations > Java > GWT Shell ( yet configured ). The url for debugging should be http://localhost:8080/OpenKM/frontend/i ... 0.0.1:9997 . We have configured GWT Shell because we think for almost people is more easier rather GWT super dev mode.

Also here you can find more information about gwt debuging http://wiki.openkm.com/index.php/Debugging_with_GWT
 #41317  by alexwgordon
 
Alright, after all that, was finally able to get something. But now, with the portable edition firefox included in the portable edition and the GWT, I had to allow unsigned extensions, and then I get "Development mode requires GWT Developer Plugin..." "Sorry, the GWT Developer Plugin only supports 3.0-26.0" And the one included with the portable dev is 44.

Also, the GWT config in the portable dev is set to port 8180 by default. Not sure if you guys want to adjust those things for the portable dev or not. I'll report back with whether I can do some further troubleshooting from here

Oh and this link has the wrong address as well...
http://wiki.openkm.com/index.php/Debugging_with_GWT

At the bottom it should read 127.0.0.1 not 127.0.1.1
 #41320  by alexwgordon
 
Okay, I believe I have the GWT working fine now.

But I'm starting to think that the order the information is processed is different than I thought.

Currently I have a my uploadUpdate.java being processed on the transition between a task node and a decision node. The task node has this form:
Code: Select all
<workflow-form task="Review and Re-submit">
  	<upload name="updateFile" label="Update File" type="update" data="updateFile"></upload>
  	<select label="Assign User" name="username" className="com.openkm.select.values.ListRole" />
  	<button name="resubmit" label="Resubmit" transition="resubmit" style="yes" />
  	<button name="cancel" label="Cancel" transition="cancel" style="no" />
  </workflow-form>
I'm noticing that even the upload form element is being processed regardless of the transition my workflow takes. This is my first clue that the information is being processed not how I'd like and why the path and such do not match.

How can I inject the new upload information prior to the upload form element being processed?
 #41322  by jllort
 
This will be a fixed xml for updating a document:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE workflow-forms PUBLIC "-//OpenKM//DTD Workflow Forms 2.6//EN"
                                "http://www.openkm.com/dtd/workflow-forms-2.6.dtd">
<workflow-forms>
  <workflow-form task="upload test">
    <upload name="upload" label="Upload document" type="update" documentUuid="e6a06309-c1cf-42be-98fd-7d7ed83ebda8" />
  </workflow-form>
</workflow-forms>
This will be a dynamic xml for updating a document:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE workflow-forms PUBLIC "-//OpenKM//DTD Workflow Forms 2.6//EN"
                                "http://www.openkm.com/dtd/workflow-forms-2.6.dtd">
<workflow-forms>
  <workflow-form task="upload test">
    <upload name="upload" label="Upload document" data="updData" />
  </workflow-form>
</workflow-forms>
Take a look here for injecting variables between tasks ( updData should be a UploadFormElement object what is used for mapping ):
http://docs.openkm.com/kcenter/view/wfg ... rcise.html
 #41323  by alexwgordon
 
Hi jllort,

Yes, you've shown me the difference between the dynamic and fixed xml files in a previous post here. I believe that I have injected the variables just fine now.

But after digging around a bit, I noticed that in my FileUploadServlet.java my PathUtils.getName = "". How can I set/send the PathUtils.getName to be correct in the FileUploadServlet?

During the FOR loop, it is printing:
Code: Select all
Item is form field: true
Item: name=null, StoreLocation=C:\Temp\upload_39643143_152f17cad2a__8000_00000000.tmp, size=0bytes, isFormField=true, FieldName=path
FOR path: 
Item is form field: true
Item: name=null, StoreLocation=C:\Temp\upload_39643143_152f17cad2a__8000_00000001.tmp, size=1bytes, isFormField=true, FieldName=action
Item is form field: true
Item: name=null, StoreLocation=C:\Temp\upload_39643143_152f17cad2a__8000_00000002.tmp, size=8bytes, isFormField=true, FieldName=rename
Item is form field: true
Item: name=null, StoreLocation=C:\Temp\upload_39643143_152f17cad2a__8000_00000003.tmp, size=0bytes, isFormField=true, FieldName=comment
Item is form field: true
Item: name=null, StoreLocation=C:\Temp\upload_39643143_152f17cad2a__8000_00000004.tmp, size=0bytes, isFormField=true, FieldName=mails
Item is form field: true
Item: name=null, StoreLocation=C:\Temp\upload_39643143_152f17cad2a__8000_00000005.tmp, size=0bytes, isFormField=true, FieldName=users
Item is form field: true
Item: name=null, StoreLocation=C:\Temp\upload_39643143_152f17cad2a__8000_00000006.tmp, size=0bytes, isFormField=true, FieldName=roles
Item is form field: true
Item: name=null, StoreLocation=C:\Temp\upload_39643143_152f17cad2a__8000_00000007.tmp, size=0bytes, isFormField=true, FieldName=message
Item is form field: true
Item: name=null, StoreLocation=C:\Temp\upload_39643143_152f17cad2a__8000_00000008.tmp, size=1bytes, isFormField=true, FieldName=increaseVersion
Item is form field: false
Item: name=test.pdf, StoreLocation=C:\Temp\upload_39643143_152f17cad2a__8000_00000009.tmp, size=157890bytes, isFormField=false, FieldName=uploadFormElement

The upload form element basically isn't doing anything it seems with the new file, am I correct? When I do a normal EDIT and UPDATE without the workflow, the path is correct (which makes sense).

Why would it be that the Upload Form Element isn't pushing the information to the FileUploadServlet correctly?
 #41326  by jllort
 
updData should be an UploadFormElement. Share the piece of code where you are injecting the variable to be sure your are doing it. And also the xml piece where you are setting the <upload
 #41327  by alexwgordon
 
Code: Select all
<workflow-form task="Review and Re-submit">
  	<upload name="upload" label="Update FIle" type="update" data="dynamic"></upload>
  	<button name="upload" label="Upload" transition="resubmit" style="yes" />
  	<button name="cancel" label="Cancel" transition="cancel" style="no" />
  </workflow-form>
Code: Select all
public class uploadUpdate implements ActionHandler {

	private static final long serialVersionUID = 1L;

		@Override
		public void execute(ExecutionContext context) throws Exception {
	      
			String uuid = (String) context.getContextInstance().getVariable("uuid");
			String token = DbSessionManager.getInstance().getSystemToken();
			String docPath = OKMRepository.getInstance().getNodePath (token, uuid);
			String documentName = PathUtils.getName(docPath);

			Upload up = new Upload();
			up.setName("upload");
			up.setLabel("Update File");
			up.setType("update");
			up.setData("dynamic");
			up.setDocumentUuid(uuid);
			up.setDocumentName(documentName);
			context.getContextInstance().setVariable("dynamic", up);
	   }
}
Attachments
Screen Shot 2016-02-18 at 12.01.55.png
Screen Shot 2016-02-18 at 12.01.55.png (47.71 KiB) Viewed 4791 times
 #41328  by alexwgordon
 
Actually I've modified a few things and now I'm getting an error OKM-005004 – Uploader error caused by lock. I've checked and since the document is not marked as "autoCheckOut" there's a lock.

I would think that selecting "update" in the upload form element in the workflow would set the file as "autoCheckOut", but this doesn't seem to be the case. How can we set the file to be autoCheckOut?
Code: Select all
public class uploadUpdate implements ActionHandler {

	private static final long serialVersionUID = 1L;

		@Override
		public void execute(ExecutionContext context) throws Exception {
	  
			String uuid = (String) context.getContextInstance().getVariable("uuid");
			String token = DbSessionManager.getInstance().getSystemToken();
			String docPath = OKMRepository.getInstance().getNodePath (token, uuid);
			
			Upload up = new Upload();
			up.setFolderPath(docPath);   //if I don't set this, I get OKM-005015
			up.setName("upload");
			up.setLabel("Update File");
			up.setType("update");
			up.setData("dynamic");
			up.setDocumentUuid(uuid);
			context.getContextInstance().setVariable("dynamic", up);
	   }
}
Code: Select all
  <workflow-form task="Review and Re-submit">
  	<select name="username" label="Assign User" className="com.openkm.select.values.ListRole" />
  	<upload name="upload" label="Update File" type="update" data="dynamic"></upload>
  	<button name="upload" label="Upload" transition="resubmit" style="yes" />
  	<button name="cancel" label="Cancel" transition="cancel" style="no" />
  </workflow-form>
 #41339  by jllort
 
folderPath should not be set sure.
up.setFolderPath(docPath); //if I don't set this, I get OKM-005015

The name should be dynamic ( not "upload" ).
up.setName("dynamic");

Do not set setData("dynamic");

Should be something like this one:
Code: Select all
Upload up = new Upload();
         up.setName("dynamic");
         up.setLabel("Update File");
         up.setType("update");
         up.setDocumentUuid(uuid);
         context.getContextInstance().setVariable("dynamic", up);
 #41341  by alexwgordon
 
Okay, I tried your changes, and I get "test.pdf: Document Name is different". If I disable the mismatch check I get OKM-005-015.

The call PathUtils.getName(path) = "" now and AutoCheckOut is still false.

Any other ideas for what might be causing the error?
Code: Select all
public class uploadUpdate implements ActionHandler {

	   private static final long serialVersionUID = 1L;

	   @Override
	   public void execute(ExecutionContext context) throws Exception {
		   
		   String uuid = (String) context.getContextInstance().getVariable("uuid");
		   
		   Upload up = new Upload();
		   up.setName("dynamic");
		   up.setLabel("Update File");
		   up.setType("update");
		   up.setDocumentUuid(uuid);
		   context.getContextInstance().setVariable("dynamic", up);
	    }
	}
Code: Select all
<workflow-form task="Review and Re-submit">
  	<select name="username" label="Assign User" className="com.openkm.select.values.ListRole" />
  	<upload name="dynamic" label="Update File" type="update" data="dynamic"></upload>
  	<button name="upload" label="Upload" transition="resubmit" style="yes" />
  	<button name="cancel" label="Cancel" transition="cancel" style="no" />
  </workflow-form>
 #41352  by jllort
 
The name of the document you are uploading is the same you have into the repository ( exactly the same, take in mind application is case sensitive ) ?

There is a property to disable this comparation named system.document.name.mismatch.check ( at Administration > configuration parameters )
 #41353  by alexwgordon
 
Yes, that's correct. The name is literally the exact same: "test.pdf". I've tried turning it off as well. We've tried all this back on page 1 of this thread.

Mismatch ON and Document Path declared: - OKM-005004 - PathUtils.getName() = ""
Mismatch ON and Document Path not declared: "Name is Different" – This is caused because PathUtils.getName returns "" - have to set DocumentPath
Mismatch OFF and Document Path declared: OKM-005004 - This is caused because AutoCheckOut is "false"
Mismatch OFF and Document Path not declared: OKM005015 - PathUtils.getName() = ""


OpenKM is not setting the document to be checked out prior to trying to trying to check it back in through the FileUploadServlet. AutoCheckOut is "false." This is the problem we're running into. So what causes a document to be marked as AutoCheckOut or not? If I manually do a checkout everything works, but that is a very clumsy way of doing things.
 #41373  by jllort
 
About auto setting checkout automatically when you are uploading in your scenario could be right but not in other. When you want to take control is always good idea checkout the document, what means is locked for everybody and then check-in ( what is the upgrading document process ). This scenario is better rather than doing transparent checkout-check-in because on similar time frame several users can edit document at the same time overlaping their changes. We have not invented the wheel, everybody is doing the same for some reason.

There's only on place in application where we are doing automatic document upgrading ( bulk upload ), but in this scenario we are indicating we have found a document named equals you are uploading and then always we ask about upload new version ( for same reasons )
 #41375  by alexwgordon
 
Okay sure, I could understand that doing a transparent check-out/check-in could cause some issue if multiple people are editing. I think that's fine that the user is prompted to tell them that the document already exists and then they can choose to upload it. Is it possible to implement the bulk upload in this situation?

Also, what is the point of the workflow upload form element having an "update" type if it can't actually update a file on its own? Are we supposed to know that we have to complete a manual check-out somewhere before the upload? I think that would be really beneficial to have in the documentation somewhere. I've been working on this since the first post in here (I think I started in September!) off and on and am now just finding out that I need to do a manual check-out!
 #41404  by jllort
 
Bulk upload asks for updating when detects an existing file. About workflow and upload document we will think on the actual behavior, because as you indicate in this scenario could take sense automatic checkout for updating. We need to think for it.

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.