01: /**
02: * Copyright 2006 Webmedia Group Ltd.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: **/package org.araneaframework.http.core;
16:
17: import java.util.Collections;
18: import java.util.HashMap;
19: import java.util.Map;
20: import org.apache.commons.fileupload.FileItem;
21: import org.araneaframework.core.Assert;
22: import org.araneaframework.http.FileUploadInputExtension;
23:
24: /**
25: * @author Jevgeni Kabanov (ekabanov <i>at</i> araneaframework <i>dot</i> org)
26: */
27: public class StandardFileUploadInputExtension implements
28: FileUploadInputExtension {
29: private Exception uploadException;
30: private Map fileItems = new HashMap();
31:
32: public StandardFileUploadInputExtension(Map fileItems,
33: Exception uploadException) {
34: Assert
35: .isTrue(fileItems != null || uploadException != null,
36: "FileItems should be present or uploadException non-null.");
37:
38: this .fileItems = fileItems;
39: this .uploadException = uploadException;
40: }
41:
42: public FileItem getUploadedFile(String fieldName) {
43: return (FileItem) fileItems.get(fieldName);
44: }
45:
46: public Map getUploadedFiles() {
47: return Collections.unmodifiableMap(fileItems);
48: }
49:
50: public boolean uploadSucceeded() {
51: return uploadException == null;
52: }
53:
54: public Exception getUploadException() {
55: return uploadException;
56: }
57: }
|