Package org.openbravo.utils

Examples of org.openbravo.utils.FileUtility


    } catch (JRException e) {
      e.printStackTrace();
      throw new ServletException(e.getMessage());
    } catch (IOException ioe) {
      try {
        FileUtility f = new FileUtility(globalParameters.strFTPDirectory, fileName, false, true);
        if (f.exists())
          f.deleteFile();
      } catch (IOException ioex) {
        log4j.error("Error trying to delete temporary report file " + fileName + " : "
            + ioex.getMessage());
      }
    } finally {
View Full Code Here


      throws IOException, ServletException {

    if (report.contains("..") || report.contains(File.separator))
      throw new ServletException("Invalid report name");

    FileUtility f = new FileUtility(globalParameters.strFTPDirectory, report, false, true);
    if (!f.exists())
      return;
    int pos = report.indexOf("-");
    String filename = report.substring(0, pos);
    pos = report.lastIndexOf(".");
    String extension = report.substring(pos);
    if (extension.equalsIgnoreCase(".pdf")) {
      response.setContentType("application/pdf");
    } else if (extension.equalsIgnoreCase(".csv")) {
      response.setContentType("text/csv");
    } else if (extension.equalsIgnoreCase(".xls")) {
      response.setContentType("application/vnd.ms-excel");
    } else {
      response.setContentType("application/x-download");
    }
    response.setHeader("Content-Disposition", "attachment; filename=" + filename + extension);
    f.dumpFile(response.getOutputStream());
    response.getOutputStream().flush();
    response.getOutputStream().close();
    if (!f.deleteFile())
      log4j.error("Download report could not delete the file :" + report);
  }
View Full Code Here

        response.setContentLength(imageBytes.length);
        out.write(imageBytes);
        out.close();
      }
    } else { // If there is not image to show return blank.gif
      FileUtility f = new FileUtility(this.globalParameters.prefix, "web/images/blank.gif", false,
          true);
      f.dumpFile(response.getOutputStream());
      response.getOutputStream().flush();
      response.getOutputStream().close();
    }
  }
View Full Code Here

    try {
      conn = this.getTransactionConnection();
      final TabAttachmentsData[] data = TabAttachmentsData.selectReference(this, strFileReference);
      TabAttachmentsData.delete(conn, this, strFileReference);
      try {
        FileUtility f = new FileUtility();
        // FIXME: Get the directory separator from Java runtime
        final File file = new File(globalParameters.strFTPDirectory + "/" + data[0].adTableId + "-"
            + data[0].adRecordId, data[0].name);
        if (file.exists())
          f = new FileUtility(globalParameters.strFTPDirectory + "/" + data[0].adTableId + "-"
              + data[0].adRecordId, data[0].name, false);
        else
          f = new FileUtility(globalParameters.strFTPDirectory, strFileReference, false);
        if (!f.deleteFile()) {
          myMessage.setType("Error");
          myMessage.setMessage(Utility.messageBD(this, "ProcessRunError", vars.getLanguage()));
          return myMessage;
        }
      } catch (final Exception ex) {
View Full Code Here

  private void printPageFile(HttpServletResponse response, VariablesSecureApp vars,
      String strFileReference) throws IOException, ServletException {
    final TabAttachmentsData[] data = TabAttachmentsData.selectEdit(this, strFileReference);
    if (data == null || data.length == 0)
      throw new ServletException("Missing file");
    FileUtility f = new FileUtility();
    // FIXME: Get the directory separator from Java runtime
    final File file = new File(globalParameters.strFTPDirectory + "/" + data[0].adTableId + "-"
        + data[0].adRecordId, data[0].name);
    if (file.exists())
      f = new FileUtility(globalParameters.strFTPDirectory + "/" + data[0].adTableId + "-"
          + data[0].adRecordId, data[0].name, false, true);
    else
      f = new FileUtility(globalParameters.strFTPDirectory, strFileReference, false, true);
    if (data[0].datatypeContent.equals(""))
      response.setContentType("application/txt");
    else
      response.setContentType(data[0].datatypeContent);
    response.setHeader("Content-Disposition", "attachment; filename=" + data[0].name);

    f.dumpFile(response.getOutputStream());
    response.getOutputStream().flush();
    response.getOutputStream().close();
  }
View Full Code Here

        if (imagePath == null) {
          // If there is not image to show return blank.gif
          imagePath = "web/images/blank.gif";
        }

        FileUtility f = new FileUtility(this.globalParameters.prefix, imagePath, false, true);
        f.dumpFile(response.getOutputStream());
        response.getOutputStream().flush();
        response.getOutputStream().close();
      }

    } finally {
View Full Code Here

      activeLogo = opsLogo;
    } else {
      activeLogo = communityLogo;
    }

    FileUtility f = new FileUtility(this.globalParameters.prefix + "web/images", activeLogo, false,
        true);
    response.setContentType("image/png");
    // mark response as cache-forever
    response.addHeader("Expires", "Sun, 17 Jan 2038 19:14:07 GMT");
    response.addHeader("Cache-Control", "public");

    f.dumpFile(response.getOutputStream());
    response.getOutputStream().flush();
    response.getOutputStream().close();

  }
View Full Code Here

    } catch (final JRException e) {
      log4j.error("JR: Error: ", e);
      throw new ServletException(e.getMessage(), e);
    } catch (IOException ioe) {
      try {
        FileUtility f = new FileUtility(globalParameters.strFTPDirectory, strFileName + "-"
            + (reportId) + "." + strOutputType, false, true);
        if (f.exists())
          f.deleteFile();
      } catch (IOException ioex) {
        log4j.error("Error trying to delete temporary report file " + strFileName + "-"
            + (reportId) + "." + strOutputType + " : " + ioex.getMessage());
      }
    } catch (final Exception e) {
View Full Code Here

TOP

Related Classes of org.openbravo.utils.FileUtility

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.