Пример #1
0
  /**
   * <br>
   * [機 能] PDFファイルダウンロード処理 <br>
   * [解 説] <br>
   * [備 考]
   *
   * @param map アクションマッピング
   * @param form アクションフォーム
   * @param req リクエスト
   * @param res レスポンス
   * @param con コネクション
   * @return ActionForward
   * @throws SQLException SQL実行時例外
   * @throws IOException ファイルの書き出しに失敗
   * @throws IOToolsException テンポラリディレクトリの削除に失敗
   * @throws TempFileException 添付ファイル情報の取得に失敗
   * @throws Exception 実行例外
   */
  private ActionForward __doDownLoadPdf(
      ActionMapping map,
      Rsv010Form form,
      HttpServletRequest req,
      HttpServletResponse res,
      Connection con)
      throws SQLException, IOException, IOToolsException, TempFileException, Exception {

    log__.debug("ファイルダウンロード処理(PDF)");
    // データ取得
    __doInit(map, form, req, res, con);

    RequestModel reqMdl = getRequestModel(req);

    // アプリケーションルートパス取得
    String appRootPath = getAppRootPath();
    // プラグイン固有のテンポラリパス取得
    CommonBiz cmnBiz = new CommonBiz();
    String outTempDir =
        IOTools.replaceFileSep(
            cmnBiz.getTempDir(getTempPath(req), GSConstReserve.PLUGIN_ID_RESERVE, reqMdl)
                + "expsyupdf/");

    Rsv010Biz biz = new Rsv010Biz(reqMdl, con);
    // PDF生成
    Rsv010ParamModel paramMdl = new Rsv010ParamModel();
    paramMdl.setParam(form);
    RsvSyuPdfModel pdfMdl = biz.createRsvSyuPdf(paramMdl, con, appRootPath, outTempDir);
    paramMdl.setFormData(form);

    String outBookName = pdfMdl.getFileName();
    String saveFileName = pdfMdl.getSaveFileName();

    String outFilePath = IOTools.setEndPathChar(outTempDir) + saveFileName;

    // ログ出力処理
    AbstractReserveBiz rsvBiz = new AbstractReserveBiz(con);
    GsMessage gsMsg = new GsMessage(req);
    String logCode = "週間 施設グループ PDF出力 " + form.getRsvSelectedGrpSid();
    rsvBiz.outPutLog(
        map, req, res, gsMsg.getMessage("cmn.pdf"), GSConstLog.LEVEL_TRACE, outBookName, logCode);

    TempFileUtil.downloadAtachment(req, res, outFilePath, outBookName, Encoding.UTF_8);
    // TEMPディレクトリ削除
    IOTools.deleteDir(IOTools.setEndPathChar(outTempDir));

    return null;
  }
Пример #2
0
  /**
   * <br>
   * [機 能] 送信メール情報ファイルのファイルパスを取得する <br>
   * [解 説] <br>
   * [備 考]
   *
   * @param reqMdl リクエスト情報
   * @param tempRootDir テンポラリルートディレクトリ
   * @return ファイルパス
   * @throws IOToolsException 送信メール情報の読み込みに失敗
   */
  private File __getSaveFilePath(RequestModel reqMdl, String tempRootDir) throws IOToolsException {
    String sendTempPath = getSendTempDir(tempRootDir, reqMdl);
    sendTempPath = IOTools.setEndPathChar(sendTempPath);
    sendTempPath += "confirm/sendMailData";
    File sendMailDataPath = new File(sendTempPath);
    IOTools.isDirCheck(sendMailDataPath.getParent(), true);

    return sendMailDataPath;
  }
Пример #3
0
  /**
   * <br>
   * [機 能] ファイルシステムで使用可能なファイル名にエスケープ処理を行う(ZIP圧縮ディレクトリ用) <br>
   * [解 説] ・使用不可文字は全て削除 ・zip解凍時にエラーが発生しないよう解凍時のファイルパス+ファイル名が 259バイト以内になるようにファイル名をカットする。 <br>
   * [備 考] filePathは {tempDir}/allFile/user001/test.txt があったとし、allFileをZIPする時
   * 「/allFile/user001/」を指定すること。
   *
   * @param filePath ZIP圧縮対象ディレクトリからファイルを保存するディレクトリまでのパス
   * @param fileName ファイル名(拡張子無しであること)
   * @param extension 拡張子
   * @return エスケープ後のファイル名 + 拡張子
   * @throws UnsupportedEncodingException URLのエンコード時エラー
   */
  private static String __getZipTempFileName(String filePath, String fileName, String extension)
      throws UnsupportedEncodingException {

    // セパレータチェック
    filePath = IOTools.setEndPathChar(filePath);
    // 使用可能ファイルかチェック
    fileName = __getUseTempName(fileName);
    // 拡張子チェック
    extension = __checkExtension(extension);

    // 使用済バイト数
    int zipPathByteNoExt = filePath.getBytes("Windows-31J").length;
    int maxByte = ZIP_MAX_BYTE;

    // 使用可能バイト数 拡張子有り
    int zipPathByteExt = maxByte - (zipPathByteNoExt + extension.getBytes("Windows-31J").length);

    int fullPathLength =
        zipPathByteNoExt
            + fileName.getBytes("Windows-31J").length
            + extension.getBytes("Windows-31J").length;

    String escFileName = null;

    // ファイルパス+
    if (fullPathLength > ZIP_MAX_BYTE) {

      String formatFileName = "";
      int cntByte = 0;

      while (cntByte < zipPathByteExt) {
        String value = fileName.substring(0, 1);
        cntByte += value.getBytes("Windows-31J").length;

        formatFileName += value;
        fileName = fileName.substring(1);

        if (zipPathByteExt - cntByte == 1) {
          break;
        }
      }

      escFileName = formatFileName + extension;

    } else {
      escFileName = fileName + extension;
    }

    return escFileName;
  }