01: package de.schlund.pfixcore.example;
02:
03: import org.w3c.dom.Element;
04:
05: import de.schlund.pfixcore.workflow.Context;
06: import de.schlund.pfixxml.ResultDocument;
07: import de.schlund.pfixxml.multipart.UploadFile;
08:
09: public class ContextFileUploadImpl implements ContextFileUpload {
10:
11: private UploadFile[] uploadedFiles;
12: private String comment;
13:
14: public void init(Context context) throws Exception {
15: }
16:
17: public void insertStatus(ResultDocument resdoc, Element elem)
18: throws Exception {
19: if (comment != null)
20: ResultDocument.addTextChild(elem, "comment", comment);
21: if (uploadedFiles != null) {
22: for (UploadFile file : uploadedFiles) {
23: Element fileElem = resdoc.createSubNode(elem, "file");
24: fileElem.setAttribute("name", file.getName());
25: fileElem.setAttribute("mimetype", file.getMimeType());
26: fileElem.setAttribute("exceedsSizeLimit", String
27: .valueOf(file.exceedsSizeLimit()));
28: if (!file.exceedsSizeLimit()) {
29: fileElem.setAttribute("localname", file
30: .getLocalFile().getName());
31: fileElem.setAttribute("size", String.valueOf(file
32: .getSize()));
33: }
34: }
35: }
36: }
37:
38: public void setFiles(UploadFile[] uploadedFiles) {
39: this .uploadedFiles = uploadedFiles;
40: }
41:
42: public void setComment(String comment) {
43: this.comment = comment;
44: }
45:
46: }
|