• Upload form in workflow can't update a file

  • 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.
 #24554  by voragoth
 
Hello everyone, I try to make a simple workflow with upload forms, in one task I just upload a file with type="create", in another task I just upload another file with type="update".
The problem is, when I try to update the file, the system throws an error C:/fakepath/file_name OKM-005015.
Reading de source, the 005 is an error originated by "Upload Service" and the 015 is caused by "Path not found", but I define 2 variables for every upload form and the path or uuid for each one.
I use windows 7.

Forms.xml
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE workflow-forms PUBLIC "-//OpenKM//DTD Workflow Forms 2.4//EN"
                                "http://www.openkm.com/dtd/workflow-forms-2.4.dtd">
<workflow-forms>
<workflow-form task="creacion">
	<upload name="upload1" label="Subir archivo" data="data_upload1">
	</upload>
	<button name="aceptar1" label="aceptar"/>
</workflow-form>
<workflow-form task="actualizacion">
	<upload name="upload2" label="Subir archivo" data="data_upload2" type="update">
	</upload>
	<button name="aceptar2" label="aceptar"/>
</workflow-form>
</workflow-forms>
ActionHandler for the first upload
Code: Select all
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;

import com.openkm.api.OKMRepository;
import com.openkm.bean.form.Upload;


public class PrimerUpload 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 = context.getToken().toString();
		String folderPath = OKMRepository.getInstance().getNodePath(token, uuid);
		context.getContextInstance().setVariable("document-path", folderPath);
		
		Upload upload = new Upload();
		upload.setName("data_upload1");
		upload.setFolderPath(folderPath);
		context.getContextInstance().setVariable("data_upload1", upload);
	}

}
Actionhandler for the second upload
Code: Select all
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;

import com.openkm.bean.form.Upload;


public class SegundoUpload implements ActionHandler {

	private static final long serialVersionUID = 1L;

	@Override
	public void execute(ExecutionContext context) throws Exception {
		
		String documentUuid = ((Upload) context.getContextInstance().getVariable("upload1")).getDocumentUuid();
		String folderPath = ((Upload) context.getContextInstance().getVariable("upload1")).getFolderPath();
		
		Upload upload = new Upload();
		upload.setName("data_upload2");
		upload.setLabel("Subir archivo");
		upload.setDocumentUuid(documentUuid);
		upload.setFolderPath(folderPath);
		upload.setType(Upload.TYPE_UPDATE);
		context.getContextInstance().setVariable("data_upload2", upload);
	}

}
Attachments
source code
(13.54 KiB) Downloaded 298 times
Last edited by voragoth on Tue Aug 13, 2013 6:29 pm, edited 1 time in total.
 #24625  by voragoth
 
I'm using 6.2.3, and a discover a kind of bug (perhaps), I activate the DEBUG on class com.openkm.servlet.frontend.FileUploadServlet, and when try to update a file, the path of file disappears, and confuse the path of the document with, the path of the folder, so I set DocumentUuid in upload whith the DocumentUuid, and the FolderlUuid with the DocumentUuid too, but, throw an error OKM-005004 (ORIGIN UPLOAD, CAUSE UNLOCK), so I lock the document, and try to upload, and It's works!.
I think that this solution is very ugly, so, you have another ideas?
 #24649  by jllort
 
If you're only updating document should only set documentuuid and folder be empty. If you want to upload some new document into some path then should be set folderuuid, but never should be set both at same time.
 #24815  by jllort
 
I take a more deep look into source code and seems folder path is always mandatory ( I suspect the idea is you want to upload a file but this can be upload to several places, seems is mandatory set path and document uuid

Line of FormManager which controls it:
Code: Select all
if (gwtFormElement instanceof GWTUpload) {
			final GWTUpload upload = (GWTUpload) gwtFormElement;
			HorizontalPanel hPanel = new HorizontalPanel();
			FileUpload fileUpload = new FileUpload();
			fileUpload.setStyleName("okm-Input");
			fileUpload.getElement().setAttribute("size", "" + upload.getWidth());
			final Anchor documentLink = new Anchor();
			
			// Setting document link by uuid
			if (upload.getDocumentUuid() != null && !upload.getDocumentUuid().equals("")) {
				repositoryService.getPathByUUID(upload.getDocumentUuid(), new AsyncCallback<String>() {
					@Override
					public void onSuccess(String result) {
						documentService.getProperties(result, new AsyncCallback<GWTDocument>() {
							@Override
							public void onSuccess(GWTDocument result) {
								final String docPath = result.getPath();
								documentLink.setText(result.getName());
								documentLink.addClickHandler(new ClickHandler() {
									@Override
									public void onClick(ClickEvent event) {
										CommonUI.openPath(Util.getParent(docPath), docPath);
									}
								});
							}
							
							@Override
							public void onFailure(Throwable caught) {
								Main.get().showError("getDocument", caught);
							}
						});
					}
					
					@Override
					public void onFailure(Throwable caught) {
						Main.get().showError("getPathByUUID", caught);
					}
				});
			}
			
			documentLink.setStyleName("okm-Hyperlink");
			hPanel.add(documentLink);
			hPanel.add(fileUpload);
			hWidgetProperties.put(propertyName, hPanel);
			table.setHTML(row, 0, "<b>" + gwtFormElement.getLabel() + "</b>");
			table.setWidget(row, 1, new HTML(""));
			table.getCellFormatter().setVerticalAlignment(row, 0, VerticalPanel.ALIGN_TOP);
			table.getCellFormatter().setWidth(row, 1, "100%");
			setRowWordWarp(row, 2, true);
			
			// If folderPath is null must initialize value
			if (upload.getFolderPath() == null || upload.getFolderPath().equals("") && upload.getFolderUuid() != null
					&& !upload.getFolderUuid().equals("")) {
				repositoryService.getPathByUUID(upload.getFolderUuid(), new AsyncCallback<String>() {
					@Override
					public void onSuccess(String result) {
						upload.setFolderPath(result);
					}
					
					@Override
					public void onFailure(Throwable caught) {
						Main.get().showError("getPathByUUID", caught);
					}
				});
			}

Althought path could be calculated by uuid, can consider case want upload in other place.

I've take a look at http://www.openkm.com/dtd/workflow-forms-2.4.dtd
You set type=update that's correct

Well, the error 005015 obviously indicate path not exists. Should debug it to ensure path arrive from workflow to gwt and confirm not arrive to servlet. ( do you have development environment configured ? )
 #28019  by reynaldo
 
Tengo el mismo problema, en cada tarea de mi workflow, necesito subir un archivo, para guardarlo en mi carpeta inicialmente creado, no se han encontrado alguna solucion..
 #40073  by eduar
 
Funciona bien subir el archivo mediante el workflow, pero al querer actualizar el documento sale el siguiente error

c:\fakepath\nombredocumento.docx : El nombre del documento no coincide
 #40098  by jllort
 
Podemos ver un poco mas de la traza ?

Estas utilizando IE ? podrías probar a desactivar este parametro de la configuración que no realiza la validación del nombre al actualizar los ficheros "system.document.name.mismatch.check"
 #40131  by eduar
 
Code: Select all
String documentUuid = ((Upload) context.getContextInstance().getVariable("data_upload1")).getDocumentUuid();

String token = DbSessionManager.getInstance().getSystemToken();
String docPath = OKMRepository.getInstance().getNodePath (token, documentUuid);
String fldPath = PathUtils.getParent(docPath);
		
Upload upload = new Upload();
upload.setName("data_upload2");
upload.setLabel("Subir archivo");
upload.setDocumentUuid(documentUuid);
upload.setFolderPath(fldPath);
upload.setType(Upload.TYPE_UPDATE);
context.getContextInstance().setVariable("data_upload2", upload);
Code: Select all
<workflow-form task="actualizacion">
    <upload name="upload2" label="Subir archivo" folderPath="/okm:root/" data="data_upload2" type="update"></upload>
    <button name="aceptar2" label="aceptar"/>
</workflow-form>
Deshabilite la opción que mencionaste, pero me sale el siguiente mensaje:
Code: Select all
OKM-005-015

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.