Beispiel #1
0
  private void createTable(Division main) throws WingException {
    // Get all our parameters
    String id = parameters.getParameter("versionID", null);

    Table table = main.addTable("version", 1, 1);

    Row header = table.addRow(Row.ROLE_HEADER);
    header.addCellContent(T_column1);
    header.addCellContent(T_column2);
    header.addCellContent(T_column3);
    header.addCellContent(T_column4);

    VersioningService versioningService = new DSpace().getSingletonService(VersioningService.class);
    Version version = versioningService.getVersion(context, Integer.parseInt(id));

    Row row = table.addRow();
    row.addCell().addContent(version.getVersionNumber());
    row.addCell().addContent(version.getEperson().getEmail());
    row.addCell().addContent(new DCDate(version.getVersionDate()).toString());
    row.addCell().addContent(version.getSummary());

    List fields = main.addList("fields", List.TYPE_FORM);
    Composite addComposite = fields.addItem().addComposite("summary");
    addComposite.setLabel(T_column4);
    addComposite.addTextArea("summary");
  }
Beispiel #2
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);
  }
Beispiel #3
0
  public void addListPolicies(List parent, DSpaceObject dso, Collection owningCollection)
      throws WingException, SQLException {
    if (!isAdvancedFormEnabled) {
      return;
    }
    parent.addLabel(T_head_policies_table);

    java.util.List<ResourcePolicy> resourcePolicies =
        authorizeService.findPoliciesByDSOAndType(context, dso, ResourcePolicy.TYPE_CUSTOM);
    if (resourcePolicies.isEmpty()) {
      parent.addItem(T_no_policies);
      return;
    }

    for (ResourcePolicy rp : resourcePolicies) {
      int id = rp.getID();

      String name = "";
      if (rp.getRpName() != null) name = rp.getRpName();

      String action = resourcePolicyService.getActionText(rp);

      // if it is the default policy for the Submitter don't show it.
      if (dso instanceof org.dspace.content.Item) {
        org.dspace.content.Item item = (org.dspace.content.Item) dso;
        if (rp.getEPerson() != null) {
          if (item.getSubmitter().equals(rp.getEPerson())) continue;
        }
      }

      String group = "";
      if (rp.getGroup() != null) group = rp.getGroup().getName();

      // start
      String startDate = "";
      if (rp.getStartDate() != null) {
        startDate = DateFormatUtils.format(rp.getStartDate(), "yyyy-MM-dd");
      }

      // endDate
      String endDate = "";
      if (rp.getEndDate() != null) {
        endDate = DateFormatUtils.format(rp.getEndDate(), "yyyy-MM-dd");
      }

      parent.addItem(T_policy.parameterize(name, action, group, startDate, endDate));
    }
  }
Beispiel #4
0
  /**
   * Add the basic navigational options:
   *
   * <p>Search - advanced search
   *
   * <p>browse - browse by Titles - browse by Authors - browse by Dates
   *
   * <p>language FIXME: add languages
   *
   * <p>context no context options are added.
   *
   * <p>action no action options are added.
   */
  public void addOptions(Options options)
      throws SAXException, WingException, UIException, SQLException, IOException,
          AuthorizeException {
    /* Create skeleton menu structure to ensure consistent order between aspects,
     * even if they are never used
     */
    List browse = options.addList("browse");
    options.addList("account");
    options.addList("context");
    options.addList("administrative");

    browse.setHead(T_head_browse);

    List browseGlobal = browse.addList("global");
    List browseContext = browse.addList("context");

    browseGlobal.setHead(T_head_all_of_dspace);

    browseGlobal.addItemXref(contextPath + "/community-list", T_communities_and_collections);

    // Add the configured browse lists for 'top level' browsing
    addBrowseOptions(browseGlobal, contextPath + "/browse");

    DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
    if (dso != null) {
      if (dso instanceof Item) {
        // If we are an item change the browse scope to the parent
        // collection.
        dso = ((Item) dso).getOwningCollection();
      }

      if (dso instanceof Collection) {
        browseContext.setHead(T_head_this_collection);
      }
      if (dso instanceof Community) {
        browseContext.setHead(T_head_this_community);
      }

      // Add the configured browse lists for scoped browsing
      String handle = dso.getHandle();
      addBrowseOptions(browseContext, contextPath + "/handle/" + handle + "/browse");
    }
  }
  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);
  }
Beispiel #6
0
  public void addName(String name_, List form, int errorFlag) throws WingException {
    if (isAdvancedFormEnabled) {
      Text name = form.addItem().addText("name");
      name.setSize(0, 30);
      name.setLabel(T_name);
      name.setHelp(T_name_help);

      if (name_ != null && errorFlag != org.dspace.submit.step.AccessStep.STATUS_COMPLETE)
        name.setValue(name_);
    }
  }
Beispiel #7
0
  public void addReason(String reason_, List form, int errorFlag) throws WingException {
    TextArea reason = form.addItem("reason", null).addTextArea("reason");
    reason.setLabel(T_reason);
    reason.setHelp(T_reason_help);

    if (!isAdvancedFormEnabled) {
      if (globalReason != null) reason.setValue(globalReason);
    } else {
      if (reason_ != null && errorFlag != org.dspace.submit.step.AccessStep.STATUS_COMPLETE)
        reason.setValue(reason_);
    }
  }
Beispiel #8
0
  public void addListGroups(String groupID, List form, int errorFlag, Collection owningCollection)
      throws WingException, SQLException {

    if (isAdvancedFormEnabled) {
      // currently set group
      form.addLabel(T_groups);
      Select groupSelect = form.addItem().addSelect("group_id");
      groupSelect.setMultiple(false);

      java.util.List<Group> loadedGroups = null;

      // retrieve groups
      String name = ConfigurationManager.getProperty("webui.submission.restrictstep.groups");
      if (name != null) {
        Group uiGroup = groupService.findByName(context, name);
        if (uiGroup != null) loadedGroups = uiGroup.getMemberGroups();
      }
      if (loadedGroups == null || loadedGroups.size() == 0) {
        loadedGroups = groupService.findAll(context, GroupService.NAME);
      }

      // if no group selected for default set anonymous
      if (groupID == null || groupID.equals("")) groupID = "0";
      // when we're just loading the main step, also default to anonymous
      if (errorFlag == AccessStep.STATUS_COMPLETE) {
        groupID = "0";
      }
      for (Group group : loadedGroups) {
        boolean selectGroup = group.getID().toString().equals(groupID);
        groupSelect.addOption(selectGroup, group.getID().toString(), group.getName());
      }

      if (errorFlag == AccessStep.STATUS_DUPLICATED_POLICY
          || errorFlag == AccessStep.EDIT_POLICY_STATUS_DUPLICATED_POLICY
          || errorFlag == UploadWithEmbargoStep.STATUS_EDIT_POLICIES_DUPLICATED_POLICY
          || errorFlag == UploadWithEmbargoStep.STATUS_EDIT_POLICY_DUPLICATED_POLICY) {
        groupSelect.addError(T_error_duplicated_policy);
      }
    }
  }
Beispiel #9
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;
  }
Beispiel #10
0
  public void addRioxxVersionSection(List upload, Item item) throws WingException {
    String version = item.getMetadata("rioxxterms.version");

    if (StringUtils.isNotBlank(version) && !"NA".equals(version)) {
      try {
        DCInputsReader a = new DCInputsReader();
        java.util.List<String> pairs = a.getPairs("rioxxterms_version");
        int humanReadable = pairs.indexOf(version) - 1;
        version = pairs.get(humanReadable);
      } catch (DCInputsReaderException e) {
        log.error(e.getMessage(), e);
      }
      upload
          .addItem("upload-rioxx-version-warning", "upload-rioxx-version-warning")
          .addContent(T_rioxx_version.parameterize(version));
    }
  }
Beispiel #11
0
  /**
   * Add navigation for the configured browse tables to the supplied list.
   *
   * @param browseList
   * @param browseURL
   * @throws WingException
   */
  private void addBrowseOptions(List browseList, String browseURL) throws WingException {
    // FIXME Exception handling
    try {
      // Get a Map of all the browse tables
      BrowseIndex[] bis = BrowseIndex.getBrowseIndices();
      for (BrowseIndex bix : bis) {
        // Create a Map of the query parameters for this link
        Map<String, String> queryParams = new HashMap<String, String>();

        queryParams.put("type", bix.getName());

        // Add a link to this browse
        browseList.addItemXref(
            super.generateURL(browseURL, queryParams),
            message("xmlui.ArtifactBrowser.Navigation.browse_" + bix.getName()));
      }
    } catch (BrowseException bex) {
      throw new UIException("Unable to get browse indicies", bex);
    }
  }
Beispiel #12
0
  public void addEmbargoDateSimpleForm(DSpaceObject dso, List form, int errorFlag)
      throws SQLException, WingException {

    String date = null;

    if (dso != null) {
      java.util.List<ResourcePolicy> policies =
          authorizeService.findPoliciesByDSOAndType(context, dso, ResourcePolicy.TYPE_CUSTOM);
      if (policies.size() > 0) {
        ResourcePolicy rp = policies.get(0);
        if (rp.getStartDate() != null) {
          date = DateFormatUtils.format(rp.getStartDate(), "yyyy-MM-dd");
        }
        globalReason = rp.getRpDescription();
      }
    }
    //        CheckBox privateCheckbox = form.addItem().addCheckBox("emabrgo_option");
    //        privateCheckbox.setLabel(T_item_embargoed);
    //        if(date!=null){
    //            privateCheckbox.addOption(true, CB_EMBARGOED, "");
    //        }
    //        else{
    //            privateCheckbox.addOption(false, CB_EMBARGOED, "");
    //        }

    // Date
    Text startDate = form.addItem().addText("embargo_until_date");
    startDate.setLabel(T_item_embargoed);
    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) {
      startDate.setValue(date);
    }
    startDate.setHelp(T_label_date_help);
  }
Beispiel #13
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, AuthorizeException {
    int communityID = parameters.getParameterAsInteger("communityID", -1);
    Community thisCommunity = Community.find(context, communityID);

    String baseURL = contextPath + "/admin/community?administrative-continue=" + knot.getId();

    Group admins = thisCommunity.getAdministrators();

    // DIVISION: main
    Division main =
        body.addInteractiveDivision(
            "community-assign-roles",
            contextPath + "/admin/community",
            Division.METHOD_POST,
            "primary administrative community");
    main.setHead(T_main_head.parameterize(thisCommunity.getName()));

    List options = main.addList("options", List.TYPE_SIMPLE, "horizontal");
    options.addItem().addXref(baseURL + "&submit_metadata", T_options_metadata);
    options.addItem().addHighlight("bold").addXref(baseURL + "&submit_roles", T_options_roles);
    options.addItem().addXref(baseURL + "&submit_curate", T_options_curate);

    // The table of admin roles
    Table rolesTable = main.addTable("roles-table", 6, 5);
    Row tableRow;

    // The header row
    Row tableHeader = rolesTable.addRow(Row.ROLE_HEADER);
    tableHeader.addCell().addContent(T_role_name);
    tableHeader.addCell().addContent(T_role_group);
    tableHeader.addCell().addContent(T_role_buttons);
    rolesTable.addRow();

    /*
     * The community admins
     */
    // data row
    tableRow = rolesTable.addRow(Row.ROLE_DATA);
    tableRow.addCell(Cell.ROLE_HEADER).addContent(T_label_admins);
    if (admins != null) {
      try {
        AuthorizeUtil.authorizeManageAdminGroup(context, thisCommunity);
        tableRow.addCell().addXref(baseURL + "&submit_edit_admin", admins.getName());
      } catch (AuthorizeException authex) {
        // add a notice, the user is not authorized to create/edit community's admin group
        tableRow.addCell().addContent(T_sysadmins_only);
      }
      try {
        AuthorizeUtil.authorizeRemoveAdminGroup(context, thisCommunity);
        tableRow.addCell().addButton("submit_delete_admin").setValue(T_delete);
      } catch (AuthorizeException authex) {
        // nothing to add, the user is not allowed to delete the group
      }
    } else {
      tableRow.addCell().addContent(T_no_role);
      Cell commAdminCell = tableRow.addCell();
      try {
        AuthorizeUtil.authorizeManageAdminGroup(context, thisCommunity);
        commAdminCell.addButton("submit_create_admin").setValue(T_create);
      } catch (AuthorizeException authex) {
        // add a notice, the user is not authorized to create/edit community's admin group
        addAdministratorOnlyButton(commAdminCell, "submit_create_admin", T_create);
      }
    }
    // help and directions row
    tableRow = rolesTable.addRow(Row.ROLE_DATA);
    tableRow.addCell();
    tableRow.addCell(1, 2).addHighlight("fade offset").addContent(T_help_admins);

    try {
      AuthorizeUtil.authorizeManageCommunityPolicy(context, thisCommunity);
      // add one last link to edit the raw authorizations
      Cell authCell = rolesTable.addRow().addCell(1, 3);
      authCell.addXref(baseURL + "&submit_authorizations", T_edit_authorizations);
    } catch (AuthorizeException authex) {
      // nothing to add, the user is not authorized to manage community's policies
    }

    Para buttonList = main.addPara();
    buttonList.addButton("submit_return").setValue(T_submit_return);

    main.addHidden("administrative-continue").setValue(knot.getId());
  }
  public void addBody(Body body) throws SQLException, WingException {
    // Get our parameters and state
    int itemID = parameters.getParameterAsInteger("itemID", -1);
    Item item = Item.find(context, itemID);
    String baseURL = contextPath + "/admin/item?administrative-continue=" + knot.getId();

    // DIVISION: main div
    Division main =
        body.addInteractiveDivision(
            "edit-item-status",
            contextPath + "/admin/item",
            Division.METHOD_POST,
            "primary administrative item");
    main.setHead(T_option_head);

    // LIST: options
    List options = main.addList("options", List.TYPE_SIMPLE, "horizontal");
    options.addItem().addXref(baseURL + "&submit_status", T_option_status);
    options
        .addItem()
        .addHighlight("bold")
        .addXref(baseURL + "&submit_bitstreams", T_option_bitstreams);
    options.addItem().addXref(baseURL + "&submit_metadata", T_option_metadata);
    options.addItem().addXref(baseURL + "&view_item", T_option_view);

    // TABLE: Bitstream summary
    Table files = main.addTable("editItemBitstreams", 1, 1);

    files.setHead(T_head1);

    Row header = files.addRow(Row.ROLE_HEADER);
    header.addCellContent(T_column1);
    header.addCellContent(T_column2);
    header.addCellContent(T_column3);
    header.addCellContent(T_column4);
    header.addCellContent(T_column5);

    Bundle[] bundles = item.getBundles();

    for (Bundle bundle : bundles) {

      Cell bundleCell = files.addRow().addCell(1, 5);
      bundleCell.addContent(T_bundle_label.parameterize(bundle.getName()));

      Bitstream[] bitstreams = bundle.getBitstreams();

      for (Bitstream bitstream : bitstreams) {
        boolean primary = (bundle.getPrimaryBitstreamID() == bitstream.getID());
        String name = bitstream.getName();

        if (name != null && name.length() > 50) {
          // If the fiel name is too long the shorten it so that it will display nicely.
          String shortName = name.substring(0, 15);
          shortName += " ... ";
          shortName += name.substring(name.length() - 25, name.length());
          name = shortName;
        }

        String description = bitstream.getDescription();
        String format = null;
        BitstreamFormat bitstreamFormat = bitstream.getFormat();
        if (bitstreamFormat != null) format = bitstreamFormat.getShortDescription();
        String editURL =
            contextPath
                + "/admin/item?administrative-continue="
                + knot.getId()
                + "&bitstreamID="
                + bitstream.getID()
                + "&submit_edit";
        String viewURL =
            contextPath + "/bitstream/id/" + bitstream.getID() + "/" + bitstream.getName();

        Row row = files.addRow();
        CheckBox remove = row.addCell().addCheckBox("remove");
        remove.setLabel("remove");
        remove.addOption(bundle.getID() + "/" + bitstream.getID());
        if (!AuthorizeManager.authorizeActionBoolean(context, item, Constants.REMOVE)) {
          remove.setDisabled();
        }

        if (AuthorizeManager.authorizeActionBoolean(context, bitstream, Constants.WRITE)) {
          // The user can edit the bitstream give them a link.
          Cell cell = row.addCell();
          cell.addXref(editURL, name);
          if (primary) cell.addXref(editURL, T_primary_label);

          row.addCell().addXref(editURL, description);
          row.addCell().addXref(editURL, format);
        } else {
          // The user can't edit the bitstream just show them it.
          Cell cell = row.addCell();
          cell.addContent(name);
          if (primary) cell.addContent(T_primary_label);

          row.addCell().addContent(description);
          row.addCell().addContent(format);
        }

        Highlight highlight = row.addCell().addHighlight("fade");
        highlight.addContent("[");
        highlight.addXref(viewURL, T_view_link);
        highlight.addContent("]");
      }
    }

    if (AuthorizeManager.authorizeActionBoolean(context, item, Constants.ADD)) {
      Cell cell = files.addRow().addCell(1, 5);
      cell.addXref(
          contextPath + "/admin/item?administrative-continue=" + knot.getId() + "&submit_add",
          T_submit_add);
    } else {
      Cell cell = files.addRow().addCell(1, 5);
      cell.addHighlight("fade").addContent(T_no_upload);
    }

    // PARA: actions
    Para actions = main.addPara("editItemActionsP", "editItemActionsP");
    if (AuthorizeManager.authorizeActionBoolean(context, item, Constants.REMOVE))
      actions.addButton("submit_delete").setValue(T_submit_delete);
    else {
      Button button = actions.addButton("submit_delete");
      button.setValue(T_submit_delete);
      button.setDisabled();

      main.addPara().addHighlight("fade").addContent(T_no_remove);
    }
    actions.addButton("submit_return").setValue(T_submit_return);

    main.addHidden("administrative-continue").setValue(knot.getId());
  }
  /** Display a single collection */
  public void addBody(Body body)
      throws SAXException, WingException, UIException, SQLException, IOException,
          AuthorizeException {
    DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
    if (!(dso instanceof Collection)) return;

    // Set up the major variables
    Collection collection = (Collection) dso;

    // Build the collection viewer division.
    Division home = body.addDivision("collection-home", "primary repository collection");
    home.setHead(collection.getMetadata("name"));

    // The search / browse box.
    {
      Division search = home.addDivision("collection-search-browse", "secondary search-browse");

      // Search query
      Division query =
          search.addInteractiveDivision(
              "collection-search",
              contextPath + "/handle/" + collection.getHandle() + "/search",
              Division.METHOD_POST,
              "secondary search");

      Para para = query.addPara("search-query", null);
      para.addContent(T_full_text_search);
      para.addContent(" ");
      para.addText("query");
      para.addContent(" ");
      para.addButton("submit").setValue(T_go);

      // Browse by list
      Division browseDiv = search.addDivision("collection-browse", "secondary browse");
      List browse = browseDiv.addList("collection-browse", List.TYPE_SIMPLE, "collection-browse");
      browse.setHead(T_head_browse);
      String url = contextPath + "/handle/" + collection.getHandle();
      browse.addItemXref(url + "/browse-title", T_browse_titles);
      browse.addItemXref(url + "/browse-author", T_browse_authors);
      browse.addItemXref(url + "/browse-date", T_browse_dates);
    }

    // Add the refrence
    {
      Division viewer = home.addDivision("collection-view", "secondary");
      ReferenceSet mainInclude =
          viewer.addReferenceSet("collection-view", ReferenceSet.TYPE_DETAIL_VIEW);
      mainInclude.addReference(collection);
    }

    // Reciently submitted items
    {
      java.util.List<BrowseItem> items = getRecientlySubmittedIems(collection);

      Division lastSubmittedDiv =
          home.addDivision("collection-recent-submission", "secondary recent-submission");
      lastSubmittedDiv.setHead(T_head_recent_submissions);
      ReferenceSet lastSubmitted =
          lastSubmittedDiv.addReferenceSet(
              "collection-last-submitted",
              ReferenceSet.TYPE_SUMMARY_LIST,
              null,
              "recent-submissions");
      for (BrowseItem item : items) {
        lastSubmitted.addReference(item);
      }
    }
  }
Beispiel #17
0
  /** Sherpa romeo submission support */
  public void make_sherpaRomeo_submission(Item item, Division divIn) throws WingException {

    if (ConfigurationManager.getBooleanProperty(
        "webui.submission.sherparomeo-policy-enabled", true)) {

      SHERPASubmitService sherpaSubmitService =
          new DSpace().getSingletonService(SHERPASubmitService.class);

      if (sherpaSubmitService.hasISSNs(context, item)) {
        List div = divIn.addList("submit-upload-new", List.TYPE_FORM);
        div.setHead(T_sherpa_title);

        // Since sherpa web service doesn't work reliable with more than 1 issn, perform the service
        // for each issn
        Set<String> issns = sherpaSubmitService.getISSNs(context, item);
        Iterator<String> issnsIterator = issns.iterator();

        int i = 0;
        while (issnsIterator.hasNext()) {
          SHERPAResponse shresp =
              sherpaSubmitService.searchRelatedJournalsByISSN(issnsIterator.next());
          java.util.List<SHERPAJournal> journals = shresp.getJournals();
          java.util.List<SHERPAPublisher> publishers = shresp.getPublishers();

          if (CollectionUtils.isNotEmpty(journals)) {
            for (SHERPAJournal journ : journals) {
              SHERPAPublisher pub = publishers.get(0);

              List sherpaList = div.addList("sherpaList" + (i + 1), "simple", "sherpaList");
              sherpaList
                  .addItem()
                  .addFigure(
                      contextPath + "/static/images/" + (i == 0 ? "romeosmall" : "clear") + ".gif",
                      "http://www.sherpa.ac.uk/romeo/",
                      "sherpaLogo");

              sherpaList.addItem().addHighlight("sherpaBold").addContent(T_sherpa_journal);
              sherpaList.addItem(journ.getTitle() + " (" + journ.getIssn() + ")");

              sherpaList.addItem().addHighlight("sherpaBold").addContent(T_sherpa_publisher);
              sherpaList.addItemXref(pub.getHomeurl(), pub.getName());

              sherpaList.addItem().addHighlight("sherpaBold").addContent(T_sherpa_colour);
              sherpaList
                  .addItem()
                  .addHighlight("sherpaStyle " + pub.getRomeocolour())
                  .addContent(message("xmlui.aspect.sherpa.submission." + pub.getRomeocolour()));
              sherpaList
                  .addItem()
                  .addXref(
                      "http://www.sherpa.ac.uk/romeo/search.php?issn=" + journ.getIssn(),
                      T_sherpa_more,
                      "sherpaMoreInfo");

              i = i + 1;
            }
          }
        }

        List sherpaList = div.addList("sherpaListEnd", "simple", "sherpaList");
        sherpaList.addItem(T_sherpa_consult);
      }
    }
  }
Beispiel #18
0
  public void addBody(Body body)
      throws SAXException, WingException, UIException, SQLException, IOException,
          AuthorizeException {
    // If we are actually editing information of an uploaded file,
    // then display that body instead!
    if (this.editFile != null) {
      editFile.addBody(body);
      return;
    }

    // Get a list of all files in the original bundle
    Item item = submission.getItem();
    Collection collection = submission.getCollection();
    String actionURL =
        contextPath + "/handle/" + collection.getHandle() + "/submit/" + knot.getId() + ".continue";
    boolean disableFileEditing =
        (submissionInfo.isInWorkflow())
            && !ConfigurationManager.getBooleanProperty("workflow", "reviewer.file-edit");
    Bundle[] bundles = item.getBundles("ORIGINAL");
    Bitstream[] bitstreams = new Bitstream[0];
    if (bundles.length > 0) {
      bitstreams = bundles[0].getBitstreams();
    }

    // Part A:
    //  First ask the user if they would like to upload a new file (may be the first one)
    Division div =
        body.addInteractiveDivision(
            "submit-upload", actionURL, Division.METHOD_MULTIPART, "primary submission");
    div.setHead(T_submission_head);
    addSubmissionProgressList(div);

    List upload = null;
    if (!disableFileEditing) {
      // Only add the upload capabilities for new item submissions
      upload = div.addList("submit-upload-new", List.TYPE_FORM);
      upload.setHead(T_head);
      addRioxxVersionSection(upload, item);

      File file = upload.addItem().addFile("file");
      file.setLabel(T_file);
      file.setHelp(T_file_help);
      file.setRequired();

      // if no files found error was thrown by processing class, display it!
      if (this.errorFlag == org.dspace.submit.step.UploadStep.STATUS_NO_FILES_ERROR) {
        file.addError(T_file_error);
      }

      // if an upload error was thrown by processing class, display it!
      if (this.errorFlag == org.dspace.submit.step.UploadStep.STATUS_UPLOAD_ERROR) {
        file.addError(T_upload_error);
      }

      // if virus checking was attempted and failed in error then let the user know
      if (this.errorFlag == org.dspace.submit.step.UploadStep.STATUS_VIRUS_CHECKER_UNAVAILABLE) {
        file.addError(T_virus_checker_error);
      }

      // if virus checking was attempted and a virus found then let the user know
      if (this.errorFlag == org.dspace.submit.step.UploadStep.STATUS_CONTAINS_VIRUS) {
        file.addError(T_virus_error);
      }

      Text description = upload.addItem().addText("description");
      description.setLabel(T_description);
      description.setHelp(T_description_help);

      Button uploadSubmit = upload.addItem().addButton("submit_upload");
      uploadSubmit.setValue(T_submit_upload);
    }

    make_sherpaRomeo_submission(item, div);

    // Part B:
    //  If the user has already uploaded files provide a list for the user.
    if (bitstreams.length > 0 || disableFileEditing) {
      Table summary = div.addTable("submit-upload-summary", (bitstreams.length * 2) + 2, 7);
      summary.setHead(T_head2);

      Row header = summary.addRow(Row.ROLE_HEADER);
      header.addCellContent(T_column0); // primary bitstream
      header.addCellContent(T_column1); // select checkbox
      header.addCellContent(T_column2); // file name
      header.addCellContent(T_column3); // size
      header.addCellContent(T_column4); // description
      header.addCellContent(T_column5); // format
      header.addCellContent(T_column6); // edit button

      for (Bitstream bitstream : bitstreams) {
        int id = bitstream.getID();
        String name = bitstream.getName();
        String url = makeBitstreamLink(item, bitstream);
        long bytes = bitstream.getSize();
        String desc = bitstream.getDescription();
        String algorithm = bitstream.getChecksumAlgorithm();
        String checksum = bitstream.getChecksum();

        Row row = summary.addRow();

        // Add radio-button to select this as the primary bitstream
        Radio primary = row.addCell().addRadio("primary_bitstream_id");
        primary.addOption(String.valueOf(id));

        // If this bitstream is already marked as the primary bitstream
        // mark it as such.
        if (bundles[0].getPrimaryBitstreamID() == id) {
          primary.setOptionSelected(String.valueOf(id));
        }

        if (!disableFileEditing) {
          // Workflow users can not remove files.
          CheckBox remove = row.addCell().addCheckBox("remove");
          remove.setLabel("remove");
          remove.addOption(id);
        } else {
          row.addCell();
        }

        row.addCell().addXref(url, name);
        row.addCellContent(bytes + " bytes");
        if (desc == null || desc.length() == 0) {
          row.addCellContent(T_unknown_name);
        } else {
          row.addCellContent(desc);
        }

        BitstreamFormat format = bitstream.getFormat();
        if (format == null) {
          row.addCellContent(T_unknown_format);
        } else {
          int support = format.getSupportLevel();
          Cell cell = row.addCell();
          cell.addContent(format.getMIMEType());
          cell.addContent(" ");
          switch (support) {
            case 1:
              cell.addContent(T_supported);
              break;
            case 2:
              cell.addContent(T_known);
              break;
            case 3:
              cell.addContent(T_unsupported);
              break;
          }
        }

        Button edit = row.addCell().addButton("submit_edit_" + id);
        edit.setValue(T_submit_edit);

        Row checksumRow = summary.addRow();
        checksumRow.addCell();
        Cell checksumCell = checksumRow.addCell(null, null, 0, 6, null);
        checksumCell.addHighlight("bold").addContent(T_checksum);
        checksumCell.addContent(" ");
        checksumCell.addContent(algorithm + ":" + checksum);
      }

      if (!disableFileEditing) {
        // Workflow users can not remove files.
        Row actionRow = summary.addRow();
        actionRow.addCell();
        Button removeSeleceted =
            actionRow.addCell(null, null, 0, 6, null).addButton("submit_remove_selected");
        removeSeleceted.setValue(T_submit_remove);
      }

      upload = div.addList("submit-upload-new-part2", List.TYPE_FORM);
    }

    // Part C:
    // add standard control/paging buttons
    addControlButtons(upload);
  }
  /**
   * Makes the jump-list navigation for the results
   *
   * @param div
   * @param info
   * @param params
   * @throws WingException
   */
  private void addBrowseJumpNavigation(Division div, BrowseInfo info, BrowseParams params)
      throws WingException {
    // Get the name of the index
    String type = info.getBrowseIndex().getName();

    // Prepare a Map of query parameters required for all links
    Map<String, String> queryParams = new HashMap<String, String>();
    queryParams.putAll(params.getCommonParameters());
    queryParams.putAll(params.getControlParameters());

    // Navigation aid (really this is a poor version of pagination)
    Division jump =
        div.addInteractiveDivision(
            "browse-navigation", BROWSE_URL_BASE, Division.METHOD_POST, "secondary navigation");

    // Add all the query parameters as hidden fields on the form
    for (String key : queryParams.keySet()) jump.addHidden(key).setValue(queryParams.get(key));

    // If this is a date based browse, render the date navigation
    if (isSortedByDate(info)) {
      Para jumpForm = jump.addPara();

      // Create a select list to choose a month
      jumpForm.addContent(T_jump_select);
      Select month = jumpForm.addSelect(BrowseParams.MONTH);
      month.addOption(false, "-1", T_choose_month);
      for (int i = 1; i <= 12; i++) {
        month.addOption(false, String.valueOf(i), DCDate.getMonthName(i, Locale.getDefault()));
      }

      // Create a select list to choose a year
      Select year = jumpForm.addSelect(BrowseParams.YEAR);
      year.addOption(false, "-1", T_choose_year);
      int currentYear = DCDate.getCurrent().getYear();
      int i = currentYear;

      // Calculate where to move from 1, 5 to 10 year jumps
      int oneYearBreak = ((currentYear - ONE_YEAR_LIMIT) / 5) * 5;
      int fiveYearBreak = ((currentYear - FIVE_YEAR_LIMIT) / 10) * 10;
      int tenYearBreak = (currentYear - TEN_YEAR_LIMIT);
      do {
        year.addOption(false, String.valueOf(i), String.valueOf(i));

        if (i <= fiveYearBreak) i -= 10;
        else if (i <= oneYearBreak) i -= 5;
        else i--;
      } while (i > tenYearBreak);

      // Create a free text entry box for the year
      jumpForm = jump.addPara();
      jumpForm.addContent(T_jump_year);
      jumpForm.addText("start_with").setHelp(T_jump_year_help);

      jumpForm.addButton("submit").setValue(T_go);
    } else {
      // Create a clickable list of the alphabet
      List jumpList = jump.addList("jump-list", List.TYPE_SIMPLE, "alphabet");
      for (char c = 'A'; c <= 'Z'; c++) {
        Map<String, String> cQuery = new HashMap<String, String>(queryParams);
        cQuery.put(BrowseParams.STARTS_WITH, Character.toString(c));
        jumpList.addItemXref(super.generateURL(BROWSE_URL_BASE, cQuery), Character.toString(c));
      }

      // Create a free text field for the initial characters
      Para jumpForm = jump.addPara();
      jumpForm.addContent(T_starts_with);
      jumpForm.addText(BrowseParams.STARTS_WITH).setHelp(T_starts_with_help);

      jumpForm.addButton("submit").setValue(T_go);
    }
  }
  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());
  }
  public void addBody(Body body) throws WingException, SQLException, AuthorizeException {
    int communityID = parameters.getParameterAsInteger("communityID", -1);
    Community parentCommunity = Community.find(context, communityID);

    // DIVISION: main
    Division main =
        body.addInteractiveDivision(
            "create-collection",
            contextPath + "/admin/collection",
            Division.METHOD_MULTIPART,
            "primary administrative collection");
    main.setHead(T_main_head.parameterize(parentCommunity.getMetadata("name")));

    // The grand list of metadata options
    List metadataList = main.addList("metadataList", "form");

    // collection name
    metadataList.addLabel(T_label_name);
    Text name = metadataList.addItem().addText("name");
    name.setSize(40);

    // short description
    metadataList.addLabel(T_label_short_description);
    Text short_description = metadataList.addItem().addText("short_description");
    short_description.setSize(40);

    // introductory text
    metadataList.addLabel(T_label_introductory_text);
    TextArea introductory_text = metadataList.addItem().addTextArea("introductory_text");
    introductory_text.setSize(6, 40);

    // copyright text
    metadataList.addLabel(T_label_copyright_text);
    TextArea copyright_text = metadataList.addItem().addTextArea("copyright_text");
    copyright_text.setSize(6, 40);

    // legacy sidebar text; may or may not be used for news
    metadataList.addLabel(T_label_side_bar_text);
    TextArea side_bar_text = metadataList.addItem().addTextArea("side_bar_text");
    side_bar_text.setSize(6, 40);

    // license text
    metadataList.addLabel(T_label_license);
    TextArea license = metadataList.addItem().addTextArea("license");
    license.setSize(6, 40);

    // provenance description
    metadataList.addLabel(T_label_provenance_description);
    TextArea provenance_description = metadataList.addItem().addTextArea("provenance_description");
    provenance_description.setSize(6, 40);

    // the row to upload a new logo
    metadataList.addLabel(T_label_logo);
    metadataList.addItem().addFile("logo");

    Para buttonList = main.addPara();
    buttonList.addButton("submit_save").setValue(T_submit_save);
    buttonList.addButton("submit_cancel").setValue(T_submit_cancel);

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