/** * Look up the id of a group authorized for one of the given roles. If no group is currently * authorized to perform this role then a new group will be created and assigned the role. * * @param context The current DSpace context. * @param collectionID The collection id. * @param roleName ADMIN, WF_STEP1, WF_STEP2, WF_STEP3, SUBMIT, DEFAULT_READ. * @return The id of the group associated with that particular role, or -1 if the role was not * found. */ public static int getCollectionRole(Context context, int collectionID, String roleName) throws SQLException, AuthorizeException, IOException, TransformerException, SAXException, WorkflowConfigurationException, ParserConfigurationException { Collection collection = Collection.find(context, collectionID); // Determine the group based upon wich role we are looking for. Group roleGroup = null; if (ROLE_ADMIN.equals(roleName)) { roleGroup = collection.getAdministrators(); if (roleGroup == null) { roleGroup = collection.createAdministrators(); } } else if (ROLE_SUBMIT.equals(roleName)) { roleGroup = collection.getSubmitters(); if (roleGroup == null) roleGroup = collection.createSubmitters(); } else { if (ConfigurationManager.getProperty("workflow", "workflow.framework") .equals("xmlworkflow")) { // Resolve our id to a role roleGroup = getXMLWorkflowRole(context, collectionID, roleName, collection, roleGroup); } else { roleGroup = getOriginalWorkflowRole(roleName, collection, roleGroup); } } // In case we needed to create a group, save our changes collection.update(); context.commit(); // If the role name was valid then role should be non null, if (roleGroup != null) return roleGroup.getID(); return -1; }
private void populateTableRowFromCollection(Collection collection, TableRow row) { int id = collection.getID(); Bitstream logo = collection.getLogo(); Item templateItem = collection.getTemplateItem(); Group admins = collection.getAdministrators(); Group[] workflowGroups = collection.getWorkflowGroups(); if (logo == null) { row.setColumnNull("logo_bitstream_id"); } else { row.setColumn("logo_bitstream_id", logo.getID()); } if (templateItem == null) { row.setColumnNull("template_item_id"); } else { row.setColumn("template_item_id", templateItem.getID()); } if (admins == null) { row.setColumnNull("admin"); } else { row.setColumn("admin", admins.getID()); } for (int i = 1; i <= workflowGroups.length; i++) { Group g = workflowGroups[i - 1]; if (g == null) { row.setColumnNull("workflow_step_" + i); } else { row.setColumn("workflow_step_" + i, g.getID()); } } // Now loop over all allowed metadata fields and set the value into the // TableRow. for (CollectionMetadataField field : CollectionMetadataField.values()) { String value = collection.getMetadata(field.toString()); if (value == null) { row.setColumnNull(field.toString()); } else { row.setColumn(field.toString(), value); } } row.setColumn("uuid", collection.getIdentifier().getUUID().toString()); }