示例#1
0
  /**
   * Prüft die größe der Datei gegen die Berechtigung.
   *
   * @param file
   * @return true wenn gespeichert werden darf, sonst false
   * @throws ExceptionLP
   * @throws Throwable
   */
  private static boolean checkFileSize(File file) throws ExceptionLP, Throwable {

    ParametermandantDto param =
        DelegateFactory.getInstance()
            .getParameterDelegate()
            .getMandantparameter(
                LPMain.getTheClient().getMandant(),
                ParameterFac.KATEGORIE_ALLGEMEIN,
                ParameterFac.PARAMETER_ALLGEMEIN_DOKUMENTE_MAXIMALE_GROESSE);
    Integer lFileSize = (Integer) param.getCWertAsObject();
    // Umrechnung in Byte
    Integer lFileSizeByte = lFileSize * 1024;
    boolean bSpeichern = true;
    if (file.length() > lFileSizeByte) {
      boolean bHatRechtImmerZuSpeichern =
          DelegateFactory.getInstance()
              .getTheJudgeDelegate()
              .hatRecht(
                  RechteFac.RECHT_DOKUMENTE_DARF_DOKUMENTE_GROESSER_ALS_MAX_ZULAESSIG_SPEICHERN);
      if (bHatRechtImmerZuSpeichern) {
        if (!DialogFactory.showModalJaNeinDialog(
            null, LPMain.getTextRespectUISPr("lp.dokumente.datei.zugros.trotzdem.speichern")))
          bSpeichern = false;
      } else {
        bSpeichern = false;
        DialogFactory.showModalDialog(
            LPMain.getTextRespectUISPr("lp.hinweis"),
            LPMain.getTextRespectUISPr("lp.error.dateizugross")
                + "\n "
                + LPMain.getTextRespectUISPr("lp.datei.maxgroesse")
                + ": "
                + lFileSize
                + "Kb "
                + LPMain.getTextRespectUISPr("lp.datei.dateigroesse")
                + ": "
                + (file.length() / 1024)
                + "Kb");
      }
    }
    if (bSpeichern && Helper.getMime(file.getName()).isEmpty()) {
      bSpeichern =
          DialogFactory.showModalJaNeinDialog(
              null, LPMain.getTextRespectUISPr("lp.dokumente.keinedateiendung"));
    }
    return bSpeichern;
  }
示例#2
0
 private static List<JCRDocDto> createJCRDoc(File file, JCRDocDto vorlage) throws IOException {
   return getFileToJCRForMime(Helper.getMime(file.getName())).createJCR(file, vorlage);
 }