public void addBody(Body body) throws WingException, SQLException, AuthorizeException {
    // Get all our parameters
    MetadataSchema[] schemas = MetadataSchema.findAll(context);
    String idsString = parameters.getParameter("fieldIDs", null);

    ArrayList<MetadataField> fields = new ArrayList<MetadataField>();
    for (String id : idsString.split(",")) {
      MetadataField field = MetadataField.find(context, Integer.valueOf(id));
      fields.add(field);
    }

    // DIVISION: metadata-field-move
    Division moved =
        body.addInteractiveDivision(
            "metadata-field-move",
            contextPath + "/admin/metadata-registry",
            Division.METHOD_POST,
            "primary administrative metadata-registry");
    moved.setHead(T_head1);
    moved.addPara(T_para1);

    Table table = moved.addTable("metadata-field-move", fields.size() + 1, 3);
    Row header = table.addRow(Row.ROLE_HEADER);
    header.addCell().addContent(T_column1);
    header.addCell().addContent(T_column2);
    header.addCell().addContent(T_column3);

    for (MetadataField field : fields) {
      String fieldID = String.valueOf(field.getID());
      String fieldEelement = field.getElement();
      String fieldQualifier = field.getQualifier();

      MetadataSchema schema = MetadataSchema.find(context, field.getSchemaID());
      String schemaName = schema.getName();

      String fieldName = schemaName + "." + fieldEelement;
      if (fieldQualifier != null && fieldQualifier.length() > 0) fieldName += "." + fieldQualifier;

      String fieldScopeNote = field.getScopeNote();

      Row row = table.addRow();
      row.addCell().addContent(fieldID);
      row.addCell().addContent(fieldName);
      row.addCell().addContent(fieldScopeNote);
    }

    Row row = table.addRow();
    Cell cell = row.addCell(1, 3);
    cell.addContent(T_para2);
    Select toSchema = cell.addSelect("to_schema");
    for (MetadataSchema schema : schemas) {
      toSchema.addOption(schema.getID(), schema.getNamespace());
    }

    Para buttons = moved.addPara();
    buttons.addButton("submit_move").setValue(T_submit_move);
    buttons.addButton("submit_cancel").setValue(T_submit_cancel);

    moved.addHidden("administrative-continue").setValue(knot.getId());
  }
  public void addBody(Body body) throws WingException, SQLException, AuthorizeException {
    // Get all our parameters
    String idsString = parameters.getParameter("formatIDs", null);

    ArrayList<BitstreamFormat> formats = new ArrayList<BitstreamFormat>();
    for (String id : idsString.split(",")) {
      BitstreamFormat format = BitstreamFormat.find(context, Integer.valueOf(id));
      formats.add(format);
    }

    // DIVISION: bitstream-format-confirm-delete
    Division deleted =
        body.addInteractiveDivision(
            "bitstream-format-confirm-delete",
            contextPath + "/admin/format-registry",
            Division.METHOD_POST,
            "primary administrative format-registry");
    deleted.setHead(T_head);
    deleted.addPara(T_para1);

    Table table = deleted.addTable("format-confirm-delete", formats.size() + 1, 3);
    Row header = table.addRow(Row.ROLE_HEADER);
    header.addCell().addContent(T_column1);
    header.addCell().addContent(T_column2);
    header.addCell().addContent(T_column3);

    for (BitstreamFormat format : formats) {
      if (format == null) {
        continue;
      }

      String formatID = String.valueOf(format.getID());
      String mimetype = format.getMIMEType();
      String name = format.getShortDescription();

      Row row = table.addRow();
      row.addCell().addContent(formatID);
      row.addCell().addContent(mimetype);
      row.addCell().addContent(name);
    }
    Para buttons = deleted.addPara();
    buttons.addButton("submit_confirm").setValue(T_submit_delete);
    buttons.addButton("submit_cancel").setValue(T_submit_cancel);

    deleted.addHidden("administrative-continue").setValue(knot.getId());
  }
  public void addBody(Body body) throws WingException, SQLException, AuthorizeException {
    // Get all our parameters
    String idsString = parameters.getParameter("schemaIDs", null);

    ArrayList<MetadataSchema> schemas = new ArrayList<MetadataSchema>();
    for (String id : idsString.split(",")) {
      MetadataSchema schema = MetadataSchema.find(context, Integer.valueOf(id));
      schemas.add(schema);
    }

    // DIVISION: metadata-schema-confirm-delete
    Division deleted =
        body.addInteractiveDivision(
            "metadata-schema-confirm-delete",
            contextPath + "/admin/metadata-registry",
            Division.METHOD_POST,
            "primary administrative metadata-registry");
    deleted.setHead(T_head);
    deleted.addPara(T_para1);
    Para warning = deleted.addPara();
    warning.addHighlight("bold").addContent(T_warning);
    warning.addContent(T_para2);

    Table table = deleted.addTable("schema-confirm-delete", schemas.size() + 1, 3);
    Row header = table.addRow(Row.ROLE_HEADER);
    header.addCell().addContent(T_column1);
    header.addCell().addContent(T_column2);
    header.addCell().addContent(T_column3);

    for (MetadataSchema schema : schemas) {
      Row row = table.addRow();
      row.addCell().addContent(schema.getSchemaID());
      row.addCell().addContent(schema.getNamespace());
      row.addCell().addContent(schema.getName());
    }
    Para buttons = deleted.addPara();
    buttons.addButton("submit_confirm").setValue(T_submit_delete);
    buttons.addButton("submit_cancel").setValue(T_submit_cancel);

    deleted.addHidden("administrative-continue").setValue(knot.getId());
  }
Beispiel #4
0
  /**
   * Attach a division to the given search division named "search-results" which contains results
   * for this search query.
   *
   * @param search The search division to contain the search-results division.
   */
  protected void buildSearchResultsDivision(Division search)
      throws IOException, SQLException, WingException {
    if (getQuery().length() > 0) {

      // Perform the actual search
      performSearch();
      DSpaceObject searchScope = getScope();

      Para para = search.addPara("result-query", "result-query");

      String query = getQuery();
      int hitCount = queryResults.getHitCount();
      para.addContent(T_result_query.parameterize(query, hitCount));

      Division results = search.addDivision("search-results", "primary");

      if (searchScope instanceof Community) {
        Community community = (Community) searchScope;
        String communityName = community.getMetadata("name");
        results.setHead(T_head1_community.parameterize(communityName));
      } else if (searchScope instanceof Collection) {
        Collection collection = (Collection) searchScope;
        String collectionName = collection.getMetadata("name");
        results.setHead(T_head1_collection.parameterize(collectionName));
      } else {
        results.setHead(T_head1_none);
      }

      if (queryResults.getHitCount() > 0) {
        // Pagination variables.
        int itemsTotal = queryResults.getHitCount();
        int firstItemIndex = queryResults.getStart() + 1;
        int lastItemIndex = queryResults.getStart() + queryResults.getPageSize();
        if (itemsTotal < lastItemIndex) {
          lastItemIndex = itemsTotal;
        }
        int currentPage = (queryResults.getStart() / queryResults.getPageSize()) + 1;
        int pagesTotal = ((queryResults.getHitCount() - 1) / queryResults.getPageSize()) + 1;
        Map<String, String> parameters = new HashMap<String, String>();
        parameters.put("page", "{pageNum}");
        String pageURLMask = generateURL(parameters);

        results.setMaskedPagination(
            itemsTotal, firstItemIndex, lastItemIndex, currentPage, pagesTotal, pageURLMask);

        // Look for any communities or collections in the mix
        ReferenceSet referenceSet = null;
        boolean resultsContainsBothContainersAndItems = false;

        @SuppressWarnings("unchecked") // This cast is correct
        java.util.List<String> containerHandles = queryResults.getHitHandles();
        for (String handle : containerHandles) {
          DSpaceObject resultDSO = HandleManager.resolveToObject(context, handle);

          if (resultDSO instanceof Community || resultDSO instanceof Collection) {
            if (referenceSet == null) {
              referenceSet =
                  results.addReferenceSet(
                      "search-results-repository",
                      ReferenceSet.TYPE_SUMMARY_LIST,
                      null,
                      "repository-search-results");
              // Set a heading showing that we will be listing containers that matched:
              referenceSet.setHead(T_head2);
              resultsContainsBothContainersAndItems = true;
            }
            referenceSet.addReference(resultDSO);
          }
        }

        // Look for any items in the result set.
        referenceSet = null;

        @SuppressWarnings("unchecked") // This cast is correct
        java.util.List<String> itemHandles = queryResults.getHitHandles();
        for (String handle : itemHandles) {
          DSpaceObject resultDSO = HandleManager.resolveToObject(context, handle);

          if (resultDSO instanceof Item) {
            if (referenceSet == null) {
              referenceSet =
                  results.addReferenceSet(
                      "search-results-repository",
                      ReferenceSet.TYPE_SUMMARY_LIST,
                      null,
                      "repository-search-results");
              // Only set a heading if there are both containers and items.
              if (resultsContainsBothContainersAndItems) {
                referenceSet.setHead(T_head3);
              }
            }
            referenceSet.addReference(resultDSO);
          }
        }

      } else {
        results.addPara(T_no_results);
      }
    } // Empty query
  }
Beispiel #5
0
 private void addButtons(Division main) throws WingException {
   Para buttons = main.addPara();
   buttons.addButton("submit_restore").setValue(T_submit_restore);
   buttons.addButton("submit_cancel").setValue(T_submit_cancel);
 }
  public void addBody(Body body)
      throws SAXException, WingException, UIException, SQLException, IOException,
          AuthorizeException {
    Request request = ObjectModelHelper.getRequest(objectModel);
    boolean help = false, error = false;
    if (request.getParameter("help") != null) {
      help = true;
    }
    if (request.getParameter("error") != null) {
      error = true;
    }

    Division div = body.addInteractiveDivision("test", "", "post", "primary");
    div.setHead("Inline form test");
    div.addPara(
        "There are two options you can use to control how this page is generated. First is the help parameter, if this is present then help text will be provided for all fields. Next is the error parameter, if it is provided then all fields will be generated in error conditions.");

    if (help) {
      div.addPara().addXref(makeURL(false, error), "Turn help OFF");
    } else {
      div.addPara().addXref(makeURL(true, error), "Turn help ON");
    }

    if (error) {
      div.addPara().addXref(makeURL(help, false), "Turn errors OFF");
    } else {
      div.addPara().addXref(makeURL(help, true), "Turn errors ON");
    }

    Division suited = body.addDivision("suited");
    suited.setHead("Fields suited towards being used inline");

    suited.addPara(
        "Below are a list of embedded fields that are normally considered usefully in an inline context.");

    // Text field
    Para p = suited.addPara();
    p.addContent("This is a plain 'Text' field, ");
    Text text = p.addText("text");
    text.setLabel("Text");
    if (help) {
      text.setHelp("This is helpfull text.");
    }
    if (error) {
      text.addError("This field is in error.");
    }
    text.setValue("Current raw value");
    p.addContent(", embedded in a paragraph.");

    // Single Checkbox field
    p = suited.addPara();
    p.addContent("This is a singe 'CheckBox' field, ");
    CheckBox checkBox = p.addCheckBox("yes-or-no");
    if (help) {
      checkBox.setHelp("Select either yes or no.");
    }
    if (error) {
      checkBox.addError("You are incorrect, try again.");
    }
    checkBox.setLabel("Yes or no");
    checkBox.addOption("yes");
    p.addContent(", embedded in a paragraph.");

    // File
    p = suited.addPara();
    p.addContent("This is a 'File' field, ");
    File file = p.addFile("file");
    file.setLabel("File");
    if (help) {
      file.setHelp("Upload a file.");
    }
    if (error) {
      file.addError("This field is in error.");
    }
    p.addContent(", embedded in a paragraph.");

    // Select (single)
    p = suited.addPara();
    p.addContent("This is single 'Select' (aka dropdown) field, ");
    Select select = p.addSelect("select");
    select.setLabel("Select (single)");
    if (help) {
      select.setHelp("Select one of the options");
    }
    if (error) {
      select.addError("This field is in error.");
    }
    select.addOption("one", "uno");
    select.addOption("two", "dos");
    select.addOption("three", "tres");
    select.addOption("four", "cuatro");
    select.addOption("five", "cinco");
    select.setOptionSelected("one");
    p.addContent(", embedded in a paragraph.");

    // Button
    p = suited.addPara();
    p.addContent("This is a 'Button' field, ");
    Button button = p.addButton("button");
    button.setLabel("Button");
    button.setValue("When you touch me I do things, lots of things");
    if (help) {
      button.setHelp("Submit buttons allow the user to submit the form.");
    }
    if (error) {
      button.addError("This button is in error.");
    }
    p.addContent(", embedded in a paragraph.");

    Division unsuited = body.addDivision("unsuited");
    unsuited.setHead("Fields typicaly unsuited towards being used inline");

    unsuited.addPara(
        "Below are a list of embedded fields that are normally considered useless in an inline context. This is because there widgets normally cross multiple lines making them hard to render inline. However these are all legal, but perhaps not advisable, and in some circumstances may be needed.");

    // Text Area Field
    p = unsuited.addPara();
    p.addContent("This is a 'Text Area' field, ");
    TextArea textArea = p.addTextArea("textarea");
    textArea.setLabel("Text Area");
    if (help) {
      textArea.setHelp("This is helpfull text.");
    }
    if (error) {
      textArea.addError("This field is in error.");
    }
    textArea.setValue("This is the raw value");
    p.addContent(", embedded in a paragraph.");

    // Multi-option Checkbox field
    p = unsuited.addPara();
    p.addContent("This is a multi-option 'CheckBox' field, ");
    checkBox = p.addCheckBox("fruit");
    if (help) {
      checkBox.setHelp("Select all the fruits that you like to eat");
    }
    if (error) {
      checkBox.addError("You are incorrect you actualy do like Tootse Rolls.");
    }
    checkBox.setLabel("fruits");
    checkBox.addOption("apple", "Apples");
    checkBox.addOption(true, "orange", "Oranges");
    checkBox.addOption("pear", "Pears");
    checkBox.addOption("tootsie", "Tootsie Roll");
    checkBox.addOption(true, "cherry", "Cherry");
    p.addContent(", embedded in a paragraph.");

    // multi-option Radio field
    p = unsuited.addPara();
    p.addContent("This is a multi-option 'Radio' field, ");
    Radio radio = p.addRadio("sex");
    radio.setLabel("Football colors");
    if (help) {
      radio.setHelp("Select the colors of the best (college) football team.");
    }
    if (error) {
      radio.addError("Error, Maroon & White is the only acceptable answer.");
    }
    radio.addOption("ut", "Burnt Orange & White");
    radio.addOption(true, "tamu", "Maroon & White");
    radio.addOption("ttu", "Tech Red & Black");
    radio.addOption("baylor", "Green & Gold");
    radio.addOption("rice", "Blue & Gray");
    radio.addOption("uh", "Scarlet Red & Albino White");
    p.addContent(", embedded in a paragraph.");

    // Select (multiple)
    p = unsuited.addPara();
    p.addContent("This is multiple 'Select' field, ");
    select = p.addSelect("multi-select");
    select.setLabel("Select (multiple)");
    select.setMultiple();
    select.setSize(4);
    if (help) {
      select.setHelp("Select one or more options");
    }
    if (error) {
      select.addError("This field is in error.");
    }
    select.addOption("one", "uno");
    select.addOption("two", "dos");
    select.addOption("three", "tres");
    select.addOption("four", "cuatro");
    select.addOption("five", "cinco");
    select.setOptionSelected("one");
    select.setOptionSelected("three");
    select.setOptionSelected("five");
    p.addContent(", embedded in a paragraph.");

    // Composite
    p = unsuited.addPara();
    p.addContent("This is a 'Composite' field of two text fields, ");
    Composite composite = p.addComposite("composite-2text");
    composite.setLabel("Composite (two text fields)");
    if (help) {
      composite.setHelp("I am the help for the entire composite");
    }
    if (error) {
      composite.addError("Just the composite is in error");
    }
    text = composite.addText("partA");
    text.setLabel("Part A");
    text.setValue("Value for part A");
    if (help) {
      text.setHelp("Part A");
    }
    text = composite.addText("partB");
    text.setLabel("Part B");
    text.setValue("Value for part B");
    if (help) {
      text.setHelp("Part B");
    }
    p.addContent(", embedded in a paragraph.");
  }
  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());
  }
Beispiel #8
0
  public void addBody(Body body) throws SAXException, WingException, SQLException {
    // Get our parameters and state;
    UUID collectionID = UUID.fromString(parameters.getParameter("collectionID", null));
    Collection collection = collectionService.find(context, collectionID);

    List<Item> items = getMappedItems(collection);

    // DIVISION: browse-items
    Division div =
        body.addInteractiveDivision(
            "browse-items",
            contextPath + "/admin/mapper",
            Division.METHOD_GET,
            "primary administrative mapper");
    div.setHead(T_head1);

    if (authorizeService.authorizeActionBoolean(context, collection, Constants.REMOVE)) {
      Para actions = div.addPara();
      actions.addButton("submit_unmap").setValue(T_submit_unmap);
      actions.addButton("submit_return").setValue(T_submit_return);
    } else {
      Para actions = div.addPara();
      Button button = actions.addButton("submit_unmap");
      button.setValue(T_submit_unmap);
      button.setDisabled();
      actions.addButton("submit_return").setValue(T_submit_return);

      div.addPara().addHighlight("fade").addContent(T_no_remove);
    }

    Table table = div.addTable("browse-items-table", 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);

    for (Item item : items) {
      String itemID = String.valueOf(item.getID());
      Collection owningCollection = item.getOwningCollection();
      String owning = owningCollection.getName();
      String author = "unknown";
      List<MetadataValue> dcAuthors =
          itemService.getMetadata(
              item, MetadataSchema.DC_SCHEMA, "contributor", Item.ANY, Item.ANY);
      if (dcAuthors != null && dcAuthors.size() >= 1) {
        author = dcAuthors.get(0).getValue();
      }

      String title = "untitled";
      List<MetadataValue> dcTitles =
          itemService.getMetadata(item, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY);
      if (dcTitles != null && dcTitles.size() >= 1) {
        title = dcTitles.get(0).getValue();
      }

      String url = contextPath + "/handle/" + item.getHandle();

      Row row = table.addRow();

      CheckBox select = row.addCell().addCheckBox("itemID");
      select.setLabel("Select");
      select.addOption(itemID);

      row.addCellContent(owning);
      row.addCell().addXref(url, author);
      row.addCell().addXref(url, title);
    }

    if (authorizeService.authorizeActionBoolean(context, collection, Constants.REMOVE)) {
      Para actions = div.addPara();
      actions.addButton("submit_unmap").setValue(T_submit_unmap);
      actions.addButton("submit_return").setValue(T_submit_return);
    } else {
      Para actions = div.addPara();
      Button button = actions.addButton("submit_unmap");
      button.setValue(T_submit_unmap);
      button.setDisabled();
      actions.addButton("submit_return").setValue(T_submit_return);

      div.addPara().addHighlight("fade").addContent(T_no_remove);
    }

    div.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());
  }
  /**
   * Add the controls to changing sorting and display options.
   *
   * @param div
   * @param info
   * @param params
   * @throws WingException
   */
  private void addBrowseControls(Division div, BrowseInfo info, BrowseParams params)
      throws WingException {
    // Prepare a Map of query parameters required for all links
    Map<String, String> queryParams = new HashMap<String, String>();

    queryParams.putAll(params.getCommonParameters());

    Division controls =
        div.addInteractiveDivision(
            "browse-controls", BROWSE_URL_BASE, Division.METHOD_POST, "browse controls");

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

    Para controlsForm = controls.addPara();

    // If we are browsing a list of items
    if (isItemBrowse(info)) //  && info.isSecondLevel()
    {
      try {
        // Create a drop down of the different sort columns available
        Set<SortOption> sortOptions = SortOption.getSortOptions();

        // Only generate the list if we have multiple columns
        if (sortOptions.size() > 1) {
          controlsForm.addContent(T_sort_by);
          Select sortSelect = controlsForm.addSelect(BrowseParams.SORT_BY);

          for (SortOption so : sortOptions) {
            sortSelect.addOption(
                so.equals(info.getSortOption()),
                so.getNumber(),
                message("xmlui.ArtifactBrowser.ConfigurableBrowse.sort_by." + so.getName()));
          }
        }
      } catch (BrowseException be) {
        throw new WingException("Unable to get sort options", be);
      }
    }

    // Create a control to changing ascending / descending order
    controlsForm.addContent(T_order);
    Select orderSelect = controlsForm.addSelect(BrowseParams.ORDER);
    orderSelect.addOption("ASC".equals(params.scope.getOrder()), "ASC", T_order_asc);
    orderSelect.addOption("DESC".equals(params.scope.getOrder()), "DESC", T_order_desc);

    // Create a control for the number of records to display
    controlsForm.addContent(T_rpp);
    Select rppSelect = controlsForm.addSelect(BrowseParams.RESULTS_PER_PAGE);
    for (int i = 5; i <= 100; i += 5) {
      rppSelect.addOption((i == info.getResultsPerPage()), i, Integer.toString(i));
    }

    // Create a control for the number of authors per item to display
    // FIXME This is currently disabled, as the supporting functionality
    // is not currently present in xmlui
    // if (isItemBrowse(info))
    // {
    //    controlsForm.addContent(T_etal);
    //    Select etalSelect = controlsForm.addSelect(BrowseParams.ETAL);
    //
    //    etalSelect.addOption((info.getEtAl() < 0), 0, T_etal_all);
    //    etalSelect.addOption(1 == info.getEtAl(), 1, Integer.toString(1));
    //
    //    for (int i = 5; i <= 50; i += 5)
    //    {
    //        etalSelect.addOption(i == info.getEtAl(), i, Integer.toString(i));
    //    }
    // }

    controlsForm.addButton("update").setValue(T_update);
  }
  /**
   * 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);
    }
  }
  /** 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);
      }
    }
  }
  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());
  }