Exemple #1
0
  /** Display the login form. */
  public void addBody(Body body) throws SQLException, SAXException, WingException {
    // Check if the user has previously attempted to login.
    Request request = ObjectModelHelper.getRequest(objectModel);
    HttpSession session = request.getSession();
    String previousUserName = request.getParameter("username");

    // Get any message parameters
    String header = (String) session.getAttribute(AuthenticationUtil.REQUEST_INTERRUPTED_HEADER);
    String message = (String) session.getAttribute(AuthenticationUtil.REQUEST_INTERRUPTED_MESSAGE);
    String characters =
        (String) session.getAttribute(AuthenticationUtil.REQUEST_INTERRUPTED_CHARACTERS);

    if (header != null || message != null || characters != null) {
      Division reason = body.addDivision("login-reason");

      if (header != null) {
        reason.setHead(message(header));
      } else {
        // Always have a head.
        reason.setHead("Authentication Required");
      }

      if (message != null) {
        reason.addPara(message(message));
      }

      if (characters != null) {
        reason.addPara(characters);
      }
    }

    Division login =
        body.addInteractiveDivision(
            "login", contextPath + "/ldap-login", Division.METHOD_POST, "primary");
    login.setHead(T_head1);

    List list = login.addList("ldap-login", List.TYPE_FORM);

    Text email = list.addItem().addText("username");
    email.setRequired();
    email.setAutofocus("autofocus");
    email.setLabel(T_userName);
    if (previousUserName != null) {
      email.setValue(previousUserName);
      email.addError(T_error_bad_login);
    }

    Item item = list.addItem();
    Password password = item.addPassword("ldap_password");
    password.setRequired();
    password.setLabel(T_password);

    list.addLabel();
    Item submit = list.addItem("login-in", null);
    submit.addButton("submit").setValue(T_submit);
  }
  private void renderRejectPage(Division div) throws WingException {
    Request request = ObjectModelHelper.getRequest(objectModel);

    List form = div.addList("reject-workflow", List.TYPE_FORM);

    form.addItem(T_info2);

    TextArea reason = form.addItem().addTextArea("reason");
    reason.setLabel(T_reason);
    reason.setRequired();
    reason.setSize(15, 50);

    if (Action.getErrorFields(request).contains("reason")) reason.addError(T_reason_required);

    div.addHidden("page").setValue(ReviewAction.REJECT_PAGE);

    org.dspace.app.xmlui.wing.element.Item actions = form.addItem();
    actions.addButton("submit_reject").setValue(T_submit_reject);
    actions.addButton("submit_cancel").setValue(T_submit_cancel);
  }
Exemple #3
0
  /**
   * Each submission step must define its own information to be reviewed during the final
   * Review/Verify Step in the submission process.
   *
   * <p>The information to review should be tacked onto the passed in List object.
   *
   * <p>NOTE: To remain consistent across all Steps, you should first add a sub-List object (with
   * this step's name as the heading), by using a call to reviewList.addList(). This sublist is the
   * list you return from this method!
   *
   * @param reviewList The List to which all reviewable information should be added
   * @return The new sub-List object created by this step, which contains all the reviewable
   *     information. If this step has nothing to review, then return null!
   */
  public List addReviewSection(List reviewList)
      throws SAXException, WingException, UIException, SQLException, IOException,
          AuthorizeException {
    // Create a new list section for this step (and set its heading)
    List uploadSection = reviewList.addList("submit-review-" + this.stepAndPage, List.TYPE_FORM);
    uploadSection.setHead(T_head);

    // Review all uploaded files
    Item item = submission.getItem();
    Bundle[] bundles = item.getBundles("ORIGINAL");
    Bitstream[] bitstreams = new Bitstream[0];
    if (bundles.length > 0) {
      bitstreams = bundles[0].getBitstreams();
    }

    for (Bitstream bitstream : bitstreams) {
      BitstreamFormat bitstreamFormat = bitstream.getFormat();

      String name = bitstream.getName();
      String url = makeBitstreamLink(item, bitstream);
      String format = bitstreamFormat.getShortDescription();
      Message support = ReviewStep.T_unknown;
      if (bitstreamFormat.getSupportLevel() == BitstreamFormat.KNOWN) {
        support = T_known;
      } else if (bitstreamFormat.getSupportLevel() == BitstreamFormat.SUPPORTED) {
        support = T_supported;
      }

      org.dspace.app.xmlui.wing.element.Item file = uploadSection.addItem();
      file.addXref(url, name);
      file.addContent(" - " + format + " ");
      file.addContent(support);
    }

    // return this new "upload" section
    return uploadSection;
  }
Exemple #4
0
  public void addAccessRadios(
      String selectedRadio, String date, List form, int errorFlag, DSpaceObject dso)
      throws WingException, SQLException {

    if (!isAdvancedFormEnabled) {
      addEmbargoDateSimpleForm(dso, form, errorFlag);
    } else {

      org.dspace.app.xmlui.wing.element.Item radiosAndDate = form.addItem();
      Radio openAccessRadios = radiosAndDate.addRadio("open_access_radios");
      openAccessRadios.setLabel(T_radios_embargo);
      if (selectedRadio != null
          && Integer.parseInt(selectedRadio) == RADIO_OPEN_ACCESS_ITEM_EMBARGOED
          && errorFlag != org.dspace.submit.step.AccessStep.STATUS_COMPLETE) {
        openAccessRadios.addOption(RADIO_OPEN_ACCESS_ITEM_VISIBLE, T_item_will_be_visible);
        openAccessRadios.addOption(true, RADIO_OPEN_ACCESS_ITEM_EMBARGOED, T_item_embargoed);
      } else {
        openAccessRadios.addOption(true, RADIO_OPEN_ACCESS_ITEM_VISIBLE, T_item_will_be_visible);
        openAccessRadios.addOption(RADIO_OPEN_ACCESS_ITEM_EMBARGOED, T_item_embargoed);
      }

      // Date
      Text startDate = radiosAndDate.addText("embargo_until_date");
      startDate.setLabel("");
      startDate.setHelp(T_label_date_help);
      if (errorFlag == org.dspace.submit.step.AccessStep.STATUS_ERROR_FORMAT_DATE) {
        startDate.addError(T_error_date_format);
      } else if (errorFlag == org.dspace.submit.step.AccessStep.STATUS_ERROR_MISSING_DATE) {
        startDate.addError(T_error_missing_date);
      }

      if (date != null && errorFlag != org.dspace.submit.step.AccessStep.STATUS_COMPLETE) {
        startDate.setValue(date);
      }
    }
  }
  public void addBody(Body body) throws WingException, SQLException {
    // Get all our parameters
    String baseURL = contextPath + "/admin/groups?administrative-continue=" + knot.getId();
    String query = parameters.getParameter("query", "");
    int page = parameters.getParameterAsInteger("page", 0);
    int highlightID = parameters.getParameterAsInteger("highlightID", -1);
    // FIXME: Bad!
    //        int resultCount = Group.searchResultCount(context, query);
    int resultCount = Group.search(context, query).length;
    Group[] groups = Group.search(context, query, page * PAGE_SIZE, PAGE_SIZE);

    // DIVISION: groups-main
    Division main =
        body.addInteractiveDivision(
            "groups-main",
            contextPath + "/admin/groups",
            Division.METHOD_POST,
            "primary administrative groups");
    main.setHead(T_main_head);

    // DIVISION: group-actions
    Division actions = main.addDivision("group-actions");
    actions.setHead(T_actions_head);

    // Browse Epeople
    List actionsList = actions.addList("actions");
    actionsList.addLabel(T_actions_create);
    actionsList.addItemXref(baseURL + "&submit_add", T_actions_create_link);
    actionsList.addLabel(T_actions_browse);
    actionsList.addItemXref(baseURL + "&query&submit_search", T_actions_browse_link);

    actionsList.addLabel(T_actions_search);
    org.dspace.app.xmlui.wing.element.Item actionItem = actionsList.addItem();
    Text queryField = actionItem.addText("query");
    if (query != null) queryField.setValue(query);
    queryField.setHelp(T_search_help);
    actionItem.addButton("submit_search").setValue(T_go);

    // DIVISION: group-search
    Division search = main.addDivision("group-search");
    search.setHead(T_search_head);

    if (resultCount > PAGE_SIZE) {
      // If there are enough results then paginate the results
      int firstIndex = page * PAGE_SIZE + 1;
      int lastIndex = page * PAGE_SIZE + groups.length;

      String nextURL = null, prevURL = null;
      if (page < (resultCount / PAGE_SIZE)) nextURL = baseURL + "&page=" + (page + 1);
      if (page > 0) prevURL = baseURL + "&page=" + (page - 1);

      search.setSimplePagination(resultCount, firstIndex, lastIndex, prevURL, nextURL);
    }

    Table table = search.addTable("groups-search-table", groups.length + 1, 1);
    Row header = table.addRow(Row.ROLE_HEADER);
    header.addCell().addContent(T_search_column1);
    header.addCell().addContent(T_search_column2);
    header.addCell().addContent(T_search_column3);
    header.addCell().addContent(T_search_column4);
    header.addCell().addContent(T_search_column5);

    for (Group group : groups) {
      Row row;
      if (group.getID() == highlightID) row = table.addRow(null, null, "highlight");
      else row = table.addRow();

      if (group.getID() > 1) {
        CheckBox select = row.addCell().addCheckBox("select_group");
        select.setLabel(new Integer(group.getID()).toString());
        select.addOption(new Integer(group.getID()).toString());
      } else {
        // Don't allow the user to remove the administrative (id:1) or
        // anonymous group (id:0)
        row.addCell();
      }

      row.addCell().addContent(group.getID());
      row.addCell().addXref(baseURL + "&submit_edit&groupID=" + group.getID(), group.getName());

      int memberCount = group.getMembers().length + group.getMemberGroups().length;
      row.addCell().addContent(memberCount == 0 ? "-" : String.valueOf(memberCount));

      Cell cell = row.addCell();
      if (FlowGroupUtils.getCollectionId(group.getName()) > -1) {
        Collection collection =
            Collection.find(context, FlowGroupUtils.getCollectionId(group.getName()));
        if (collection != null) {
          String collectionName = collection.getMetadata("name");

          if (collectionName == null) collectionName = "";
          else if (collectionName.length() > MAX_COLLECTION_NAME)
            collectionName = collectionName.substring(0, MAX_COLLECTION_NAME - 3) + "...";

          cell.addContent(collectionName + " ");

          Highlight highlight = cell.addHighlight("fade");

          highlight.addContent("[");
          highlight.addXref(
              contextPath + "/handle/" + collection.getExternalIdentifier().getCanonicalForm(),
              T_collection_link);
          highlight.addContent("]");
        }
      }
    }

    if (groups.length <= 0) {
      Cell cell = table.addRow().addCell(1, 5);
      cell.addHighlight("italic").addContent(T_no_results);
    } else {
      search.addPara().addButton("submit_delete").setValue(T_submit_delete);
    }

    search.addHidden("administrative-continue").setValue(knot.getId());
  }