Page 1 of 2

Upload form in workflow can't update a file

PostPosted:Fri Aug 09, 2013 4:53 pm
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);
	}

}

Re: Upload form in workflow can't update a file

PostPosted:Tue Aug 13, 2013 11:13 am
by pavila
Which OpenKM version are you using?

Re: Upload form in workflow can't update a file

PostPosted:Tue Aug 13, 2013 6:28 pm
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?

Re: Upload form in workflow can't update a file

PostPosted:Sun Aug 18, 2013 10:03 am
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.

Re: Upload form in workflow can't update a file

PostPosted:Thu Aug 22, 2013 8:08 pm
by voragoth
Well your solution didn't work (thanks for your time too), the problem remains 005015, because, in debug, the folder paht is missing. I still think it is bug.

Re: Upload form in workflow can't update a file

PostPosted:Sun Aug 25, 2013 11:40 am
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 ? )

Re: Upload form in workflow can't update a file

PostPosted:Tue Mar 04, 2014 4:48 pm
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..

Re: Upload form in workflow can't update a file

PostPosted:Sat Mar 08, 2014 9:42 am
by jllort
Please reynaldo in english post always use english or start new post for your questions, thanks.

Re: Upload form in workflow can't update a file

PostPosted:Mon Jun 22, 2015 9:19 pm
by eduar
that libraries are using to Upload?

import com.openkm.bean.form.Upload;

Might you put them to download ?

Re: Upload form in workflow can't update a file

PostPosted:Thu Jun 25, 2015 5:06 pm
by jllort
Yes the bean class Upload is used for uploading, but the clue is on form.xml file. You should use the upload element , take a look at dtd file http://www.openkm.com/dtd/workflow-forms-2.5.dtd

Re: Upload form in workflow can't update a file

PostPosted:Mon Jun 29, 2015 2:47 pm
by pavila
Are you able to reproduce the problem with a recent night build?

Re: Upload form in workflow can't update a file

PostPosted:Thu Jul 09, 2015 8:57 pm
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

Re: Upload form in workflow can't update a file

PostPosted:Mon Jul 13, 2015 10:25 am
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"

Re: Upload form in workflow can't update a file

PostPosted:Tue Jul 21, 2015 3:50 pm
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

Re: Upload form in workflow can't update a file

PostPosted:Wed Jul 22, 2015 1:38 pm
by eduar
Corregí el error q mencione anteriormente, ahora me sale:
Code: Select all
OKM 005-004