Пример #1
0
  public void extensionsUpdate() {
    AttachmentDAO am = DataAccessDriver.getInstance().newAttachmentDAO();

    // Check for records to delete
    String[] delete = this.request.getParameterValues("delete");
    List deleteList = new ArrayList();

    if (delete != null) {
      deleteList = Arrays.asList(delete);
      am.removeExtensions(delete);
    }

    int total = this.request.getIntParameter("total_records");

    for (int i = 0; i < total; i++) {
      if (deleteList.contains(this.request.getParameter("id_" + i))) {
        continue;
      }

      AttachmentExtension e = new AttachmentExtension();
      e.setAllow(this.request.getParameter("allow_" + i) != null);
      e.setComment(this.request.getParameter("comment_" + i));
      e.setExtension(this.request.getParameter("extension_" + i));
      e.setExtensionGroupId(this.request.getIntParameter("extension_group_" + i));
      e.setId(this.request.getIntParameter("id_" + i));
      e.setUploadIcon(this.request.getParameter("upload_icon_" + i));

      am.updateExtension(e);
    }

    this.extensions();
  }
Пример #2
0
  public void extensionsSave() {
    AttachmentExtension e = new AttachmentExtension();
    e.setAllow(this.request.getParameter("allow") != null);
    e.setComment(this.request.getParameter("comment"));
    e.setExtension(this.request.getParameter("extension"));
    e.setUploadIcon(this.request.getParameter("upload_icon"));
    e.setExtensionGroupId(this.request.getIntParameter("extension_group"));

    if (e.getExtension().startsWith(".")) {
      e.setExtension(e.getExtension().substring(1));
    }

    DataAccessDriver.getInstance().newAttachmentDAO().addExtension(e);
    this.extensions();
  }