int collectionID = parameters.getParameterAsInteger("collectionID", -1);
Collection thisCollection = Collection.find(context, collectionID);
String baseURL = contextPath + "/admin/collection?administrative-continue=" + knot.getId();
Group admins = thisCollection.getAdministrators();
Group wfStep1 = thisCollection.getWorkflowGroup(1);
Group wfStep2 = thisCollection.getWorkflowGroup(2);
Group wfStep3 = thisCollection.getWorkflowGroup(3);
Group submitters = thisCollection.getSubmitters();
Group defaultRead = null;
int defaultReadID = FlowContainerUtils.getCollectionDefaultRead(context, collectionID);
if (defaultReadID >= 0)
defaultRead = Group.find(context, defaultReadID);
// DIVISION: main
Division main = body.addInteractiveDivision("collection-assign-roles",contextPath+"/admin/collection",Division.METHOD_POST,"primary administrative collection");
main.setHead(T_main_head.parameterize(thisCollection.getMetadata("name")));
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_harvesting",T_options_harvest);
// 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 collection 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, thisCollection);
tableRow.addCell().addXref(baseURL + "&submit_edit_admin", admins.getName());
}
catch (AuthorizeException authex) {
// add a notice, the user is not authorized to create/edit collection's admin group
tableRow.addCell().addContent(T_not_allowed);
}
try
{
AuthorizeUtil.authorizeRemoveAdminGroup(context, thisCollection);
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);
try
{
AuthorizeUtil.authorizeManageAdminGroup(context, thisCollection);
tableRow.addCell().addButton("submit_create_admin").setValue(T_create);
}
catch (AuthorizeException authex) {
// add a notice, the user is not authorized to create/edit collection's admin group
tableRow.addCell().addContent(T_not_allowed);
}
}
// help and directions row
tableRow = rolesTable.addRow(Row.ROLE_DATA);
tableRow.addCell();
tableRow.addCell(1,2).addHighlight("fade offset").addContent(T_help_admins);
/*
* Workflow steps 1-3
*/
// data row
try
{
AuthorizeUtil.authorizeManageWorkflowsGroup(context, thisCollection);
tableRow = rolesTable.addRow(Row.ROLE_DATA);
tableRow.addCell(Cell.ROLE_HEADER).addContent(T_label_wf_step1);
if (wfStep1 != null)
{
tableRow.addCell().addXref(baseURL + "&submit_edit_wf_step1", wfStep1.getName());
tableRow.addCell().addButton("submit_delete_wf_step1").setValue(T_delete);
}
else
{
tableRow.addCell().addContent(T_no_role);
tableRow.addCell().addButton("submit_create_wf_step1").setValue(T_create);
}
// help and directions row
tableRow = rolesTable.addRow(Row.ROLE_DATA);
tableRow.addCell();
tableRow.addCell(1,2).addHighlight("fade offset").addContent(T_help_wf_step1);
// data row
tableRow = rolesTable.addRow(Row.ROLE_DATA);
tableRow.addCell(Cell.ROLE_HEADER).addContent(T_label_wf_step2);
if (wfStep2 != null)
{
tableRow.addCell().addXref(baseURL + "&submit_edit_wf_step2", wfStep2.getName());
tableRow.addCell().addButton("submit_delete_wf_step2").setValue(T_delete);
}
else
{
tableRow.addCell().addContent(T_no_role);
tableRow.addCell().addButton("submit_create_wf_step2").setValue(T_create);
}
// help and directions row
tableRow = rolesTable.addRow(Row.ROLE_DATA);
tableRow.addCell();
tableRow.addCell(1,2).addHighlight("fade offset").addContent(T_help_wf_step2);
// data row
tableRow = rolesTable.addRow(Row.ROLE_DATA);
tableRow.addCell(Cell.ROLE_HEADER).addContent(T_label_wf_step3);
if (wfStep3 != null)
{
tableRow.addCell().addXref(baseURL + "&submit_edit_wf_step3", wfStep3.getName());
tableRow.addCell().addButton("submit_delete_wf_step3").setValue(T_delete);
}
else
{
tableRow.addCell().addContent(T_no_role);
tableRow.addCell().addButton("submit_create_wf_step3").setValue(T_create);
}
// help and directions row
tableRow = rolesTable.addRow(Row.ROLE_DATA);
tableRow.addCell();
tableRow.addCell(1,2).addHighlight("fade offset").addContent(T_help_wf_step3);
}
catch (AuthorizeException authex) {
// add a notice, the user is not allowed to manage workflow group
tableRow = rolesTable.addRow(Row.ROLE_DATA);
tableRow.addCell(Cell.ROLE_HEADER).addContent(T_label_wf);
tableRow.addCell().addContent(T_not_allowed);
}
/*
* The collection submitters
*/
tableRow = rolesTable.addRow(Row.ROLE_DATA);
tableRow.addCell(Cell.ROLE_HEADER).addContent(T_label_submitters);
try
{
AuthorizeUtil.authorizeManageSubmittersGroup(context, thisCollection);
if (submitters != null)
{
tableRow.addCell().addXref(baseURL + "&submit_edit_submit", submitters.getName());
tableRow.addCell().addButton("submit_delete_submit").setValue(T_delete);
}
else
{
tableRow.addCell().addContent(T_no_role);
tableRow.addCell().addButton("submit_create_submit").setValue(T_create);
}
}
catch (AuthorizeException authex)
{
tableRow.addCell().addContent(T_not_allowed);
}
// help and directions row
tableRow = rolesTable.addRow(Row.ROLE_DATA);
tableRow.addCell();
tableRow.addCell(1,2).addHighlight("fade offset").addContent(T_help_submitters);
/*
* The collection's default read authorizations
*/
tableRow = rolesTable.addRow(Row.ROLE_DATA);
tableRow.addCell(Cell.ROLE_HEADER).addContent(T_label_default_read);
if (defaultRead == null)
{
// Custome reading permissions, we can't handle it, just provide a link to the
// authorizations manager.
tableRow.addCell(1,2).addContent(T_default_read_custom);
}
else if (defaultRead.getID() == 0) {
// Anonymous reading
tableRow.addCell().addContent(T_default_read_anonymous);
addAdministratorOnlyButton(tableRow.addCell(),"submit_create_default_read",T_restrict);
}
else
{
// A specific group is dedicated to reading.
tableRow.addCell().addXref(baseURL + "&submit_edit_default_read", defaultRead.getName());
addAdministratorOnlyButton(tableRow.addCell(),"submit_delete_default_read",T_delete);
}
// help and directions row
tableRow = rolesTable.addRow(Row.ROLE_DATA);