Skip to content

Commit 667a288

Browse files
committed
fixed (Issue #906)
1 parent e1cc0d2 commit 667a288

File tree

1 file changed

+38
-4
lines changed

1 file changed

+38
-4
lines changed

imixs-workflow-faces/src/main/java/org/imixs/workflow/faces/fileupload/FileUploadController.java

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import org.imixs.workflow.engine.DocumentEvent;
4444
import org.imixs.workflow.exceptions.AccessDeniedException;
4545
import org.imixs.workflow.exceptions.PluginException;
46+
import org.imixs.workflow.faces.data.WorkflowController;
4647
import org.imixs.workflow.faces.data.WorkflowEvent;
4748

4849
import jakarta.annotation.Priority;
@@ -77,6 +78,9 @@ public class FileUploadController implements Serializable {
7778
@Inject
7879
private Conversation conversation;
7980

81+
@Inject
82+
private WorkflowController workflowController;
83+
8084
public List<Part> getFiles() {
8185
return files;
8286
}
@@ -87,6 +91,9 @@ public void setFiles(List<Part> files) {
8791
}
8892

8993
public ItemCollection getWorkitem() {
94+
if (workitem == null || workflowController.getWorkitem() != null) {
95+
workitem = workflowController.getWorkitem();
96+
}
9097
return workitem;
9198
}
9299

@@ -191,6 +198,33 @@ public void attacheFiles(ItemCollection workitem) throws PluginException {
191198
isCompleted = true;
192199
}
193200

201+
/**
202+
* The method adds the file
203+
* to the workitem but also updates the list of temporary files, which are not
204+
* yet persisted.
205+
*
206+
* @param document
207+
* @param aFilename
208+
*/
209+
public void addAttachedFile(FileData filedata) {
210+
if (getWorkitem() != null) {
211+
getWorkitem().addFileData(filedata);
212+
}
213+
}
214+
215+
/**
216+
* Removes a attached file object from the tmp list of uploaded files.
217+
*
218+
* @param sFilename - filename to be removed
219+
* @return - null
220+
*/
221+
public void removeAttachedFile(String aFilename) {
222+
if (getWorkitem() != null) {
223+
getWorkitem().removeFile(aFilename);
224+
}
225+
226+
}
227+
194228
/**
195229
* get the file size for a given filename in human readable format
196230
* <p>
@@ -202,8 +236,8 @@ public void attacheFiles(ItemCollection workitem) throws PluginException {
202236
*/
203237
@SuppressWarnings("unchecked")
204238
public String getFileSize(String aFilename) {
205-
if (workitem != null) {
206-
FileData fileData = workitem.getFileData(aFilename);
239+
if (getWorkitem() != null) {
240+
FileData fileData = getWorkitem().getFileData(aFilename);
207241
double bytes = fileData.getContent().length;
208242
if (bytes == 0) {
209243
// test if we have the attribute size
@@ -269,8 +303,8 @@ public String getCID() {
269303
* @return - null
270304
*/
271305
public void removePersistedFile(String aFilename) {
272-
if (workitem != null) {
273-
workitem.removeFile(aFilename);
306+
if (getWorkitem() != null) {
307+
getWorkitem().removeFile(aFilename);
274308
}
275309
}
276310
}

0 commit comments

Comments
 (0)