Пример #1
0
  public boolean doDeleteById(Long chungthucId) {

    try {
      TaiLieuChungThuc chungThuc =
          TaiLieuChungThucLocalServiceUtil.getTaiLieuChungThuc(chungthucId);
      if (chungThuc != null && chungThuc.getTrangThai() == Constants.DOCUMENT_NEW) {
        try {
          storage.deleteFile(chungThuc.getNoiLuuTruId());
        } catch (Exception e) {
          // TODO: handle exception
        }
        TaiLieuChungThucLocalServiceUtil.deleteTaiLieuChungThuc(chungThuc.getId());
        return true;
      }

    } catch (Exception e) {
      // TODO Auto-generated catch block

    }

    return false;
  }
Пример #2
0
  private boolean deleteTaiLieuChungThuc(TaiLieuChungThuc taiLieuChungThuc) {
    // TODO Auto-generated method stub
    // get last version
    if (TaiLieuChungThucLocalServiceUtil.isUsed(taiLieuChungThuc.getId())) {
      // if it was used by other table
      return true;
    }

    if (taiLieuChungThuc.getTrangThai() == Constants.DOCUMENT_NEW) {

      try {
        TaiLieuChungThuc chungThuc =
            TaiLieuChungThucLocalServiceUtil.getTaiLieuChungThuc(taiLieuChungThuc.getId());
        if (chungThuc != null) {

          // delete data
          TaiLieuChungThucLocalServiceUtil.deleteTaiLieuChungThuc(taiLieuChungThuc.getId());
          // delete file;

          if (storage.existFile(taiLieuChungThuc.getNoiLuuTruId())) {
            storage.deleteFile(taiLieuChungThuc.getNoiLuuTruId());
          }

        } else {
          // delete data

          if (storage.existFile(taiLieuChungThuc.getNoiLuuTruId())) {
            storage.deleteFile(taiLieuChungThuc.getNoiLuuTruId());
          }
        }

        return true;
      } catch (Exception e) {
        // TODO Auto-generated catch block
        // e.printStackTrace();
      }
    }
    return false;
  }