1 5 6 package com.raptus.owxv3.modules.filemgr; 7 8 import javax.servlet.http.HttpServletRequest ; 9 10 import org.apache.struts.action.*; 11 import org.apache.struts.upload.FormFile; 12 13 import com.raptus.owxv3.LoggingManager; 14 import com.raptus.owxv3.api.*; 15 16 45 public class EAFileMgrUploadBean extends OmniaWebBean 46 { 47 50 protected int categorytype=FileMgrConstants.EXISTING_CATEGORY; 51 52 55 protected String catname=""; 56 57 60 protected String newcatname=""; 61 62 65 protected FormFile uploadfile=null; 66 67 71 protected String overwrite=null; 72 73 74 77 protected AllFileSelector fileSelector=null; 78 79 80 83 protected int uploadFileCount=0; 84 85 86 87 90 public int getCategorytype() { return categorytype; } 91 92 95 public void setCategorytype(int c) { this.categorytype = c; } 96 97 100 public String getCatname() { return catname; } 101 102 105 public void setCatname(String name) { this.catname = name; } 106 107 110 public String getNewcatname() { return newcatname; } 111 112 115 public void setNewcatname(String name) { this.newcatname = name; } 116 117 120 public FormFile getUploadfile() { return uploadfile; } 121 122 125 public void setUploadfile(FormFile file) { this.uploadfile = file; } 126 127 130 public void setOverwrite(String val) { this.overwrite=val; } 131 132 135 public String getOverwrite() { return this.overwrite; } 136 137 138 141 public AllFileSelector getFileSelector() { return fileSelector; } 142 143 146 public void setFileSelector(AllFileSelector fs) { this.fileSelector=fs; } 147 148 151 public String getCategoryName() 152 { 153 if(categorytype==FileMgrConstants.EXISTING_CATEGORY && ! catname.equals("0") ) return catname; 154 155 if(categorytype==FileMgrConstants.NEW_CATEGORY && ! newcatname.equals("")) return newcatname; 156 157 if(catname.equals("0") && ! newcatname.equals("")) return newcatname; 158 159 if(!catname.equals("0") && newcatname.equals("")) return newcatname; 160 161 return catname; 162 } 163 164 165 168 public void reset(ActionMapping mapping, HttpServletRequest request) 169 { 170 super.reset(mapping, request); 171 this.categorytype=FileMgrConstants.EXISTING_CATEGORY; 172 this.catname=""; 173 this.newcatname=""; 174 this.uploadfile=null; 175 176 } 177 178 179 public void reset() 180 { 181 this.categorytype=FileMgrConstants.EXISTING_CATEGORY; 182 this.catname=""; 183 this.newcatname=""; 184 this.uploadfile=null; 185 this.overwrite=null; 186 } 187 188 189 196 197 public ActionErrors validate(HttpServletRequest request) 198 { 199 ActionErrors ret=new ActionErrors(); 200 201 if(catname.equals("0") && newcatname.equals("")) 202 { 203 if( categorytype==FileMgrConstants.EXISTING_CATEGORY && catname.equals("0") ) 204 { 205 ret.add(ActionErrors.GLOBAL_ERROR,new ActionError("module.upload.error.catnotselected")); 206 207 } 208 209 210 if(categorytype==FileMgrConstants.NEW_CATEGORY && newcatname.equals("")) 211 { 212 ret.add(ActionErrors.GLOBAL_ERROR,new ActionError("module.upload.error.emptynewcatname")); 213 214 } 215 } 217 if(uploadfile!=null) 218 if(uploadfile.getFileName().equals("")) 219 { 220 LoggingManager.log("Invalid filename used for upload!", this); 221 ret.add( ActionErrors.GLOBAL_ERROR,new ActionError("module.upload.error.emptyfile") ); 222 } 223 if(!ret.empty()) uploadfile=null; 224 return ret; 225 226 } 227 228 public void incUploadFileCount(){ 229 uploadFileCount++; 230 } 231 232 public int getUploadFileCount(){ 233 return uploadFileCount; 234 } 235 236 } 237 238 | Popular Tags |