Пример #1
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;
  }
Пример #2
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;
  }
Пример #3
0
 /**
  * <br>
  * [機 能] 添付ファイルの名称を取得します。 <br>
  * [解 説] <br>
  * [備 考]
  *
  * @param tempDir 添付ディレクトリPATH
  * @return String ファイル名
  * @throws IOToolsException 添付ファイルへのアクセスに失敗
  */
 private String __getFileName(String tempDir) throws IOToolsException {
   String ret = null;
   List<String> fileList = IOTools.getFileNames(tempDir);
   if (fileList != null) {
     for (int i = 0; i < fileList.size(); i++) {
       // ファイル名を取得
       String fileName = fileList.get(i);
       if (!fileName.endsWith(GSConstCommon.ENDSTR_OBJFILE)) {
         continue;
       }
       // オブジェクトファイルを取得
       ObjectFile objFile = new ObjectFile(tempDir, fileName);
       Object fObj = objFile.load();
       if (fObj == null) {
         continue;
       }
       Cmn110FileModel fMdl = (Cmn110FileModel) fObj;
       ret = fMdl.getFileName();
       if (ret != null) {
         return ret;
       }
     }
   }
   log__.debug("添付ファイルの名称 = " + ret);
   return ret;
 }
Пример #4
0
  /**
   * <br>
   * [機 能] 送信メール情報の添付ファイル一覧を取得する <br>
   * [解 説] <br>
   * [備 考]
   *
   * @param tempRootDir テンポラリルートディレクトリ
   * @param reqMdl リクエスト情報
   * @return 添付ファイル情報
   * @throws IOToolsException 添付ファイル情報取得時に例外発生
   */
  private List<MailTempFileModel> __getSendMailFileData(String tempRootDir, RequestModel reqMdl)
      throws IOToolsException {

    List<MailTempFileModel> fileDataList = new ArrayList<MailTempFileModel>();

    String tempDir = getSendTempDir(tempRootDir, reqMdl);
    List<String> fileList = IOTools.getFileNames(tempDir);
    if (fileList != null && !fileList.isEmpty()) {

      Cmn110FileModel tempFileModel = null;
      CommonBiz cmnBiz = new CommonBiz();
      for (String fileName : fileList) {
        if (!fileName.endsWith(GSConstCommon.ENDSTR_OBJFILE)) {
          continue;
        }

        // オブジェクトファイルを取得
        ObjectFile objFile = new ObjectFile(tempDir, fileName);
        Object fObj = objFile.load();
        if (fObj == null) {
          continue;
        }

        tempFileModel = (Cmn110FileModel) fObj;
        MailTempFileModel sendFileData = new MailTempFileModel();
        sendFileData.setFileName(tempFileModel.getFileName());
        sendFileData.setFileSizeDsp(
            cmnBiz.getByteSizeString(new File(tempDir + tempFileModel.getSaveFileName()).length()));
        fileDataList.add(sendFileData);
      }
    }

    return fileDataList;
  }
Пример #5
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;
  }
Пример #6
0
  /**
   * <br>
   * [機 能] 取込みファイル名称を画面にセットする <br>
   * [解 説] <br>
   * [備 考]
   *
   * @param tempDir テンポラリファイルパス
   * @throws SQLException SQL実行例外
   * @throws IOToolsException CSVファイル取扱い時例外
   * @return String 保存しているファイル名
   */
  public String getImportFileName(String tempDir) throws SQLException, IOToolsException {

    String ret = null;
    List<String> fileList = IOTools.getFileNames(tempDir);
    if (fileList != null) {
      for (int i = 0; i < fileList.size(); i++) {
        // ファイル名を取得
        String fileName = fileList.get(i);
        if (!fileName.endsWith(GSConstCommon.ENDSTR_SAVEFILE)) {
          continue;
        }
        ret = fileName.substring(0, 11);
      }
    }
    return ret;
  }
Пример #7
0
  /**
   * <br>
   * [機 能] 初期表示処理 <br>
   * [解 説] <br>
   * [備 考]
   *
   * @param map ActionMapping
   * @param form Rng020Form
   * @param req HttpServletRequest
   * @param res HttpServletResponse
   * @param con DB Connection
   * @return ActionForward
   * @throws Exception 実行時例外
   */
  public ActionForward __doInit(
      ActionMapping map,
      Rng020Form form,
      HttpServletRequest req,
      HttpServletResponse res,
      Connection con)
      throws Exception {

    // テンポラリディレクトリの削除
    IOTools.deleteDir(_getRingiDir(req));

    Rng020ParamModel paramMdl = new Rng020ParamModel();
    paramMdl.setParam(form);
    Rng020Biz biz = new Rng020Biz(con, getRequestModel(req));
    biz.setInitData(req, paramMdl, getAppRootPath(), _getRingiDir(req), getSessionUserModel(req));
    paramMdl.setFormData(form);

    // トランザクショントークン設定
    saveToken(req);

    return map.getInputForward();
  }
Пример #8
0
  /**
   * <br>
   * [機 能] 添付ファイルダウンロードの処理 <br>
   * [解 説] <br>
   * [備 考]
   *
   * @param map アクションマッピング
   * @param form アクションフォーム
   * @param req リクエスト
   * @param res レスポンス
   * @param con コネクション
   * @throws SQLException SQL実行例外
   * @throws Exception 実行時例外
   * @return ActionForward
   */
  private ActionForward __doDownLoad(
      ActionMapping map,
      Rng020Form form,
      HttpServletRequest req,
      HttpServletResponse res,
      Connection con)
      throws SQLException, Exception {

    RequestModel reqMdl = getRequestModel(req);
    CommonBiz cmnBiz = new CommonBiz();
    String tempDir = cmnBiz.getTempDir(getTempPath(req), RngConst.PLUGIN_ID_RINGI, reqMdl);
    Rng020Biz biz = new Rng020Biz(reqMdl);
    tempDir = biz.getTemplateFileDir(tempDir);
    String fileId = form.getRng020TemplateFileId();

    // オブジェクトファイルを取得
    ObjectFile objFile = new ObjectFile(tempDir, fileId.concat(GSConstCommon.ENDSTR_OBJFILE));
    Object fObj = objFile.load();
    Cmn110FileModel fMdl = (Cmn110FileModel) fObj;
    // 添付ファイル保存用のパスを取得する(フルパス)
    String filePath = tempDir + fileId.concat(GSConstCommon.ENDSTR_SAVEFILE);
    filePath = IOTools.replaceFileSep(filePath);

    GsMessage gsMsg = new GsMessage(reqMdl);
    String msg = gsMsg.getMessage("cmn.download");

    // ログ出力処理
    RngBiz rngBiz = new RngBiz(con);
    rngBiz.outPutLog(map, msg, GSConstLog.LEVEL_INFO, fMdl.getFileName(), reqMdl);

    // 時間のかかる処理の前にコネクションを破棄
    JDBCUtil.closeConnectionAndNull(con);
    // ファイルをダウンロードする
    TempFileUtil.downloadAtachment(req, res, filePath, fMdl.getFileName(), Encoding.UTF_8);

    return null;
  }
Пример #9
0
  /**
   * <br>
   * [機 能] アクションを実行する <br>
   * [解 説] <br>
   * [備 考]
   *
   * @param map ActionMapping
   * @param form ActionForm
   * @param req HttpServletRequest
   * @param res HttpServletResponse
   * @param con DB Connection
   * @return ActionForward
   * @throws Exception 実行時例外
   */
  public ActionForward executeAction(
      ActionMapping map,
      ActionForm form,
      HttpServletRequest req,
      HttpServletResponse res,
      Connection con)
      throws Exception {

    ActionForward forward = null;

    // コマンドパラメータ取得
    String cmd = NullDefault.getString(req.getParameter("CMD"), "");
    log__.debug("CMD = " + cmd);

    Rng020Form thisForm = (Rng020Form) form;
    if (cmd.equals("rng010")) {
      log__.debug("*** 稟議一覧。");

      // テンポラリディレクトリの削除
      IOTools.deleteDir(_getRingiDir(req));

      if (thisForm.isRng020copyApply()) {
        forward = map.findForward("rng030");
      } else if (thisForm.getRng130searchFlg() == 1) {
        forward = map.findForward("search");
      } else {
        forward = map.findForward("rng010");
      }

    } else if (cmd.equals("rng060")) {
      log__.debug("*** 内容テンプレート一覧。");
      forward = map.findForward("rng060");

    } else if (cmd.equals("upAppr")) {
      log__.debug("上矢印(承認経路)ボタンクリック");
      forward = __doUpAppr(map, thisForm, req, res, con);

    } else if (cmd.equals("downAppr")) {
      log__.debug("下矢印(承認経路)ボタンクリック");
      forward = __doDownAppr(map, thisForm, req, res, con);

    } else if (cmd.equals("addAppr")) {
      log__.debug("追加(承認経路)ボタンクリック");
      thisForm.setRng020ScrollFlg("1");
      forward = __doAddAppr(map, thisForm, req, res, con);

    } else if (cmd.equals("delAppr")) {
      log__.debug("削除(承認経路)ボタンクリック");
      thisForm.setRng020ScrollFlg("1");
      forward = __doDelAppr(map, thisForm, req, res, con);

    } else if (cmd.equals("addConfirm")) {
      log__.debug("追加(最終確認)ボタンクリック");
      thisForm.setRng020ScrollFlg("1");
      forward = __doAddConfirm(map, thisForm, req, res, con);

    } else if (cmd.equals("delConfirm")) {
      log__.debug("削除(最終確認)ボタンクリック");
      thisForm.setRng020ScrollFlg("1");
      forward = __doDelConfirm(map, thisForm, req, res, con);

    } else if (cmd.equals("delTemp")) {
      log__.debug("削除(添付ファイル)ボタンクリック");
      forward = __doDelTemp(map, thisForm, req, res, con);

    } else if (cmd.equals("draft")) {
      log__.debug("草稿に保存ボタンクリック");
      forward = __doEntry(map, thisForm, req, res, con, 1);

    } else if (cmd.equals("approval")) {
      log__.debug("申請ボタンクリック");
      forward = __doEntry(map, thisForm, req, res, con, 0);

    } else if (cmd.equals("setChannel")) {
      log__.debug("経路に追加ボタンクリック");
      forward = __doSetChannel(map, thisForm, req, res, con);

    } else if (cmd.equals("rng020")) {
      log__.debug("確認画面戻るボタンクリック");
      forward = __doDsp(map, thisForm, req, res, con);

    } else if (cmd.equals("060back")) {
      log__.debug("内容テンプレート一覧画面戻るボタンクリック");
      forward = __doDsp(map, thisForm, req, res, con);

    } else if (cmd.equals("changeGroup")) {
      log__.debug("グループコンボ変更");
      forward = __doDsp(map, thisForm, req, res, con);

    } else if (cmd.equals("optbtn")) {
      log__.debug("テンプレート使用");
      forward = __doDsp(map, thisForm, req, res, con);

    } else if (cmd.equals("templateFileDownload")) {
      log__.debug("添付ファイルダウンロード");
      forward = __doDownLoad(map, thisForm, req, res, con);

    } else {
      log__.debug("*** 初期表示を行います。");
      forward = __doInit(map, thisForm, req, res, con);
    }

    return forward;
  }
Пример #10
0
  /**
   * <br>
   * [機 能] 稟議情報登録処理を行う <br>
   * [解 説] <br>
   * [備 考]
   *
   * @param map アクションマッピング
   * @param form アクションフォーム
   * @param req リクエスト
   * @param res レスポンス
   * @param con コネクション
   * @param mode 登録モード 0:申請 1:草稿に保存
   * @throws Exception 実行時例外
   * @return ActionForward
   */
  private ActionForward __doEntry(
      ActionMapping map,
      Rng020Form form,
      HttpServletRequest req,
      HttpServletResponse res,
      Connection con,
      int mode)
      throws Exception {

    if (!isTokenValid(req, true)) {
      log__.info("2重投稿");
      return getSubmitErrorPage(map, req);
    }

    // 入力チェックを行う
    ActionErrors errors = null;
    if (mode == 0) {
      errors = form.validateCheck(Rng020Form.CHECKTYPE_REQUEST, req);
    } else if (mode == 1) {
      errors = form.validateCheck(Rng020Form.CHECKTYPE_DRAFT, req);
    }
    if (errors != null && !errors.isEmpty()) {
      addErrors(req, errors);
      return __doDsp(map, form, req, res, con);
    }

    // 新規作成の場合、確認画面へ遷移する。
    if (mode == 0) {
      return map.findForward("rng020kn");
    }
    ActionForward forward = null;
    boolean commit = false;
    PluginConfig pconfig = getPluginConfigForMain(getPluginConfig(req), con);
    CommonBiz cmnBiz = new CommonBiz();
    boolean smailPluginUseFlg = cmnBiz.isCanUsePlugin(GSConstMain.PLUGIN_ID_SMAIL, pconfig);

    try {
      RequestModel reqMdl = getRequestModel(req);
      Rng020ParamModel paramMdl = new Rng020ParamModel();
      paramMdl.setParam(form);
      Rng020Biz biz = new Rng020Biz(con, reqMdl, getSessionUserSid(req));
      biz.entryRingiData(
          paramMdl,
          getCountMtController(req),
          getAppRootPath(),
          _getRingiDir(req),
          mode,
          getPluginConfig(req),
          smailPluginUseFlg,
          getRequestModel(req));
      paramMdl.setFormData(form);

      forward = __setCompPageParam(map, req, form);

      GsMessage gsMsg = new GsMessage(reqMdl);
      String msg = gsMsg.getMessage("cmn.entry");
      String msg2 = gsMsg.getMessage("cmn.save.draft");

      // ログ出力処理
      RngBiz rngBiz = new RngBiz(con);
      String opCode = msg;

      rngBiz.outPutLog(map, opCode, GSConstLog.LEVEL_TRACE, msg2, reqMdl);

      con.commit();
      commit = true;

      // テンポラリディレクトリの削除
      IOTools.deleteDir(_getRingiDir(req));
    } catch (Exception e) {
      log__.error("稟議情報の登録に失敗", e);
      throw e;
    } finally {
      if (!commit) {
        con.rollback();
      }
    }

    return forward;
  }
Пример #11
0
  /**
   * <br>
   * [機 能] 入力チェックを行う <br>
   * [解 説] <br>
   * [備 考]
   *
   * @param reqMdl リクエスト情報
   * @param tempDir 添付DIR
   * @param con DBコネクション
   * @param netSid ネットワークSID
   * @param mode インポートモード
   * @return エラー
   * @throws SQLException SQL実行例外
   * @throws IOToolsException SQL実行例外
   * @throws Exception 実行例外
   */
  public ActionErrors validateCheck(
      RequestModel reqMdl, String tempDir, Connection con, int netSid, String mode)
      throws IOToolsException, SQLException, Exception {

    log__.debug("=== 入力チェック ===");
    ActionErrors errors = new ActionErrors();
    GsMessage gsMsg = new GsMessage(reqMdl);
    String textSelectFile = gsMsg.getMessage("cmn.capture.file");
    String textCsvFile = gsMsg.getMessage("cmn.csv.file.format");

    // インポートファイルチェック
    // テンポラリディレクトリにあるファイル名称を取得
    List<String> fileList = IOTools.getFileNames(tempDir);
    String saveFileName = "";
    String baseFileName = "";
    String eprefix = "inputFile.";
    if (fileList == null) {
      ActionMessage msg = new ActionMessage("error.select.required.text", textSelectFile);
      StrutsUtil.addMessage(errors, msg, eprefix + "error.select.required.text");
    } else {
      for (int i = 0; i < fileList.size(); i++) {
        // ファイル名を取得
        String fileName = fileList.get(i);
        if (!fileName.endsWith(GSConstCommon.ENDSTR_OBJFILE)) {
          continue;
        }

        // オブジェクトファイルを取得
        ObjectFile objFile = new ObjectFile(tempDir, fileName);
        Object fObj = objFile.load();
        if (fObj == null) {
          continue;
        }
        Cmn110FileModel fMdl = (Cmn110FileModel) fObj;
        saveFileName = fMdl.getSaveFileName();
        baseFileName = fMdl.getFileName();
      }
      boolean csvError = false;
      // 複数選択エラー
      if (fileList.size() > 2) {
        ActionMessage msg = new ActionMessage("error.input.notfound.file", textSelectFile);
        StrutsUtil.addMessage(errors, msg, eprefix + "error.input.notfound.file");
        csvError = true;
      } else {
        // 拡張子チェック
        String strExt = StringUtil.getExtension(baseFileName);
        if (strExt == null || !strExt.toUpperCase().equals(".CSV")) {
          ActionMessage msg = new ActionMessage("error.select.required.text", textCsvFile);
          StrutsUtil.addMessage(errors, msg, eprefix + "error.select.required.text");
          csvError = true;
        }
      }
      if (!csvError) {
        String fullPath = tempDir + saveFileName;
        ArrayList<String> ipadListCsv = new ArrayList<String>();
        IpkCsvCheck csvCheck = new IpkCsvCheck(errors, con, netSid, mode, ipadListCsv, reqMdl);
        // CSVチェック
        csvCheck.isCsvDataOk(fullPath);
      }
    }
    return errors;
  }