Пример #1
0
  void setRealContent(byte[] changedContent, boolean final_data) {
    String outPath = JConfig.queryConfiguration("auctions.savepath");

    if (changedContent != null) {
      mLoadedPage = new GZip();
      mLoadedPage.setData(changedContent);

      if (outPath != null && outPath.length() != 0) {
        if (final_data) {
          String filePath =
              outPath + System.getProperty("file.separator") + getIdentifier() + ".html.gz";
          mLoadedPage.save(filePath);
          mLoadedPage = null;
        }
      }
    }
  }
Пример #2
0
  protected StringBuffer getContent() {
    StringBuffer sb;

    if (mLoadedPage != null) {
      StringBuffer outSB = mLoadedPage.getUncompressedData(false);
      if (outSB == null) outSB = new StringBuffer("mLoadedPage.getUncompressedData is null");
      sb = outSB;
    } else {
      JConfig.log().logDebug("mLoadedPage is null, returning the 'real' cached copy!");
      GZip gz = getRealContent();
      if (gz != null) {
        sb = gz.getUncompressedData();
        JConfig.log().logDebug("Turned the uncompressed data into a StringBuffer!");
        if (sb == null) JConfig.log().logDebug(" Failed to uncompress for id " + getIdentifier());
      } else {
        sb = new StringBuffer("Error getting real content.");
      }
    }
    return (sb);
  }
Пример #3
0
  private GZip loadFile(File fp) {
    GZip localZip = new GZip();

    if (fp.exists()) {
      //  Okay, I don't allow loading auction data that's over 512K.  Duh.
      if (fp.length() < 512 * 1024) {
        try {
          JConfig.log().logDebug("Loading from backing page (file is " + fp.length() + " bytes)!");
          localZip.load(fp);
        } catch (IOException ioe) {
          JConfig.log().handleException("Couldn't read " + fp.getName(), ioe);
          return null;
        }

        return localZip;
      } else {
        JConfig.log().logDebug("Can't load " + fp.getName() + ", file is too large.");
      }
    }
    return null;
  }
Пример #4
0
  public void save() {
    String outPath = JConfig.queryConfiguration("auctions.savepath");
    if (outPath != null && outPath.length() != 0) {
      if (JConfig.queryConfiguration("store.auctionHTML", "true").equals("true")) {
        String filePath =
            outPath + System.getProperty("file.separator") + getIdentifier() + ".html.gz";

        if (mLoadedPage != null) {
          mLoadedPage.save(filePath);
        }
      }
    }
    mLoadedPage = null;
  }