avatar

917

Expose access to a File object referring to the auction's contents on disk.

by mrs, 24 May, 2009 08:55 AM
909 917  
1717 import com.jbidwatcher.util.xml.XMLElement;
1818 
1919 import java.io.FileNotFoundException;
20 import java.io.File;
2021 import java.text.MessageFormat;
2122 import java.util.*;
2223 import java.net.InetAddress;
------
16471648   public boolean isOutbid() { return getAuction().isOutbid(); }
16481649 
16491650   public StringBuffer getContent() { return getAuction().getContent(); }
1651   public File getContentFile() { return getAuction().getContentFile(); }
16501652   public String getThumbnail() { return getAuction().getThumbnail(); }
16511653 
16521654   public boolean hasPaypal() { return getAuction().hasPaypal(); }
893 917  
311311     mLoadedPage = null;
312312   }
313313 
314   private GZip loadFile(String fileName) {
315     File fp = new File(fileName);
314   private GZip loadFile(File fp) {
316315     GZip localZip = new GZip();
317316 
318317     if(fp.exists()) {
------
322321           JConfig.log().logDebug("Loading from backing page (file is " + fp.length() + " bytes)!");
323322           localZip.load(fp);
324323         } catch(IOException ioe) {
325           JConfig.log().handleException("Couldn't read " + fileName, ioe);
324           JConfig.log().handleException("Couldn't read " + fp.getName(), ioe);
326325           return null;
327326         }
328327 
329328         return localZip;
330329       } else {
331         JConfig.log().logDebug("Can't load " + fileName + ", file is too large.");
330         JConfig.log().logDebug("Can't load " + fp.getName() + ", file is too large.");
332331       }
333332     }
334333     return null;
------
359358   }
360359 
361360   GZip getRealContent() {
361     File fp = getContentFile();
362     if(fp != null) return loadFile(fp);
363     return mLoadedPage;
364   }
365 
366   File getContentFile() {
367     File fp = null;
362368     String outPath = JConfig.queryConfiguration("auctions.savepath");
363369     if(outPath != null && outPath.length() != 0) {
364370       String filePath = outPath + System.getProperty("file.separator") + getIdentifier() + ".html.gz";
365371       JConfig.log().logDebug("filePath = " + filePath);
366       return loadFile(filePath);
372       fp = new File(filePath);
367373     }
368     return mLoadedPage;
374     return fp;
369375   }
370376 
371377   public void setContent(StringBuffer inContent, boolean final_data) {