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" );
// Only System Administrators can delete bitstreams
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());
}