01: package de.schlund.pfixcore.example;
02:
03: import java.util.ArrayList;
04: import java.util.List;
05:
06: import de.schlund.pfixcore.example.iwrapper.MultiFileUpload;
07: import de.schlund.pfixcore.generator.IHandler;
08: import de.schlund.pfixcore.generator.IWrapper;
09: import de.schlund.pfixcore.workflow.Context;
10: import de.schlund.pfixxml.multipart.UploadFile;
11:
12: /**
13: * @author mleidig@schlund.de
14: */
15: public class MultiFileUploadHandler implements IHandler {
16:
17: public void handleSubmittedData(Context context, IWrapper wrapper)
18: throws Exception {
19: MultiFileUpload upload = (MultiFileUpload) wrapper;
20: ContextFileUpload ctxUpload = context
21: .getContextResourceManager().getResource(
22: ContextFileUpload.class);
23: if (upload.getComment() != null)
24: ctxUpload.setComment(upload.getComment());
25: List<UploadFile> files = new ArrayList<UploadFile>();
26: String[] keys = upload.getKeysFile();
27: for (String key : keys) {
28: UploadFile file = upload.getFile(key);
29: files.add(file);
30: }
31: if (files.size() > 0) {
32: UploadFile[] fileArray = new UploadFile[files.size()];
33: ctxUpload.setFiles(files.toArray(fileArray));
34: }
35: }
36:
37: public void retrieveCurrentStatus(Context context, IWrapper wrapper)
38: throws Exception {
39:
40: }
41:
42: public boolean needsData(Context context) throws Exception {
43: return false;
44: }
45:
46: public boolean prerequisitesMet(Context context) throws Exception {
47: return true;
48: }
49:
50: public boolean isActive(Context context) throws Exception {
51: return true;
52: }
53:
54: }
|