KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jdon > strutsutil > file > filter > ImageCacheFilter


1 /**
2  * Copyright 2003-2006 the original author or authors.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6
7        http://www.apache.org/licenses/LICENSE-2.0
8
9   * Unless required by applicable law or agreed to in writing, software
10   * distributed under the License is distributed on an "AS IS" BASIS,
11   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   * See the License for the specific language governing permissions and
13   * limitations under the License.
14   */

15
16 package com.jdon.strutsutil.file.filter;
17
18 import com.jdon.strutsutil.file.*;
19
20 import java.util.*;
21 import com.jdon.util.Debug;
22
23 import javax.servlet.http.HttpServletRequest JavaDoc;
24
25 public class ImageCacheFilter implements ImageFilter {
26   public final static String JavaDoc module = ImageCacheFilter.class.getName();
27
28   private final static String JavaDoc modelClassName =
29       "com.jdon.strutsutil.file.UploadFile";
30
31   private ImageFilter imageFilter = null;
32
33   public ImageCacheFilter(ImageFilter imageFilter) {
34     this.imageFilter = imageFilter;
35
36   }
37
38   /**
39    * ID集å?ˆæš‚æ—¶ä¸?å?šç¼“å­˜
40    * @param request
41    * @return
42    */

43   public Collection getUploadFileID(HttpServletRequest JavaDoc request) {
44     Debug.logVerbose("[JdonFramework]--> enter cache filter ", module);
45     Collection uploadIDList = null;
46     try {
47       uploadIDList = imageFilter.getUploadFileID(request);
48     } catch (Exception JavaDoc ex) {
49       Debug.logError("[JdonFramework] not found the upload files in session", module);
50     }
51     return uploadIDList;
52
53   }
54
55   /**
56    * æ ¹æ?®UploadFileçš„id获得UploadFile实例
57    * @param request
58    * @param id
59    * @return
60    */

61   public UploadFile getUploadFile(HttpServletRequest JavaDoc request, String JavaDoc id) {
62     Debug.logVerbose("[JdonFramework]--> enter cache filter ", module);
63     UploadFile uploadFile = null;
64     try {
65 // uploadFile = (UploadFile) getImageFromCache(id);
66
if (uploadFile == null) {
67         uploadFile = imageFilter.getUploadFile(request, id);
68 // if (uploadFile != null)
69
// saveImageToCache(id, uploadFile); //空白图片�放入了缓存,
70
}
71     } catch (Exception JavaDoc ex) {
72       Debug.logError("[JdonFramework]getData error:" + ex, module);
73
74     }
75     return uploadFile;
76   }
77
78   /**
79    * æ ¹æ?®UploadFileçš„id删除UploadFile实例
80    * @param request
81    * @param id
82    */

83   public void deleteUploadFile(HttpServletRequest JavaDoc request,
84                                UploadFile uploadFile) {
85     try {
86 // removeImageFromCache(uploadFile.getId());
87
imageFilter.deleteUploadFile(request, uploadFile);
88     } catch (Exception JavaDoc ex) {
89       Debug.logError("[JdonFramework] deleteUploadFile error" + ex, module);
90     }
91
92   }
93
94   public void addUploadFile(HttpServletRequest JavaDoc request, UploadFile uploadFile) {
95
96   }
97
98   public Collection loadAllUploadFile(HttpServletRequest JavaDoc request) {
99     return null;
100   }
101 }
102
Popular Tags