@Override public void delete(Context context, Site dso) throws SQLException, AuthorizeException, IOException { throw new AuthorizeException("Site object cannot be deleted"); }
public void addBody(Body body) throws SAXException, WingException, SQLException, IOException, AuthorizeException { if(!authorized) throw new AuthorizeException("You are not authorized to perform this task"); xmluiActionUI.addBody(body); }
/** * Throw an AuthorizeException if the current user is not a System Admin * * @param context the DSpace Context Object * @throws AuthorizeException if authorization error * if the current user is not a System Admin * @throws SQLException if database error * if a db error occur */ public static void requireAdminRole(Context context) throws AuthorizeException, SQLException { if (!authorizeService.isAdmin(context)) { throw new AuthorizeException( "Only system admin are allowed to perform this action"); } }
@Override public void delete(Context context, MetadataSchema metadataSchema) throws SQLException, AuthorizeException { // Check authorisation: Only admins may create DC types if (!authorizeService.isAdmin(context)) { throw new AuthorizeException( "Only administrators may modify the metadata registry"); } log.info(LogManager.getHeader(context, "delete_metadata_schema", "metadata_schema_id=" + metadataSchema.getID())); metadataSchemaDAO.delete(context, metadataSchema); }
@Override public void update(Context context, List<BitstreamFormat> bitstreamFormats) throws SQLException, AuthorizeException { if (CollectionUtils.isNotEmpty(bitstreamFormats)) { // Check authorisation - only administrators can change formats if (!authorizeService.isAdmin(context)) { throw new AuthorizeException( "Only administrators can modify bitstream formats"); } for (BitstreamFormat bitstreamFormat : bitstreamFormats) { log.info(LogManager.getHeader(context, "update_bitstream_format", "bitstream_format_id=" + bitstreamFormat.getID())); bitstreamFormatDAO.save(context, bitstreamFormat); } } }
protected void doDSPost(Context c, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException, AuthorizeException { // check to see if the statistics are restricted to administrators boolean publicise = ConfigurationManager.getBooleanProperty("report.public"); // determine the navigation bar to be displayed String navbar = (!publicise ? "admin" : "default"); request.setAttribute("navbar", navbar); // is the user a member of the Administrator (1) group boolean admin = Group.isMember(c, 1); if (publicise || admin) { showStatistics(c, request, response); } else { throw new AuthorizeException(); } }
protected void doDSGet(Context context, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException, AuthorizeException { // is the statistics data publically viewable? boolean privatereport = ConfigurationManager.getBooleanProperty("solr-statistics", "authorization.admin"); // is the user a member of the Administrator (1) group? boolean admin = Group.isMember(context, 1); if (!privatereport || admin) { displayStatistics(context, request, response); } else { throw new AuthorizeException(); } }
@Override public BitstreamFormat create(Context context) throws SQLException, AuthorizeException { // Check authorisation - only administrators can create new formats if (!authorizeService.isAdmin(context)) { throw new AuthorizeException( "Only administrators can create bitstream formats"); } // Create a table row BitstreamFormat bitstreamFormat = bitstreamFormatDAO.create(context, new BitstreamFormat()); log.info(LogManager.getHeader(context, "create_bitstream_format", "bitstream_format_id=" + bitstreamFormat.getID())); return bitstreamFormat; }
/** * Is allowed manage (create, remove, edit) community's policies in the * current context? * * @param context the DSpace Context Object * @param community the community that the policy refer to * @throws AuthorizeException if authorization error * if the current context (current user) is not allowed to * manage the community's policies * @throws SQLException if database error * if a db error occur */ public static void authorizeManageCommunityPolicy(Context context, Community community) throws AuthorizeException, SQLException { if (AuthorizeConfiguration.canCommunityAdminManagePolicies()) { authorizeService.authorizeAction(context, community, Constants.ADMIN); } else if (!authorizeService.isAdmin(context)) { throw new AuthorizeException( "Only system admin are allowed to manage community policies"); } }
public void addBody(Body body) throws SAXException, WingException, SQLException, IOException, AuthorizeException { Context context = ContextUtil.obtainContext(ObjectModelHelper.getRequest(objectModel)); if(!AuthorizeManager.isAdmin(context)){ throw new AuthorizeException(); } Division div = body.addInteractiveDivision("xmlworkflowoverview", contextPath + "/admin/xmlworkflowoverview", Division.METHOD_POST, "primary"); this.buildSearchResultsDivision(div); }
@Override public void delete(Context context, BitstreamFormat bitstreamFormat) throws SQLException, AuthorizeException { // Check authorisation - only administrators can delete formats if (!authorizeService.isAdmin(context)) { throw new AuthorizeException( "Only administrators can delete bitstream formats"); } // Find "unknown" type BitstreamFormat unknown = findUnknown(context); if (unknown.getID() == bitstreamFormat.getID()) { throw new IllegalArgumentException("The Unknown bitstream format may not be deleted."); } // Set bitstreams with this format to "unknown" int numberChanged = bitstreamFormatDAO.updateRemovedBitstreamFormat(context, bitstreamFormat, unknown); // Delete this format from database bitstreamFormatDAO.delete(context, bitstreamFormat); log.info(LogManager.getHeader(context, "delete_bitstream_format", "bitstream_format_id=" + bitstreamFormat.getID() + ",bitstreams_changed=" + numberChanged)); }
@Override public EPerson create(Context context) throws SQLException, AuthorizeException { // authorized? if (!authorizeService.isAdmin(context)) { throw new AuthorizeException( "You must be an admin to create an EPerson"); } // Create a table row EPerson e = ePersonDAO.create(context, new EPerson()); log.info(LogManager.getHeader(context, "create_eperson", "eperson_id=" + e.getID())); context.addEvent(new Event(Event.CREATE, Constants.EPERSON, e.getID(), null, getIdentifiers(context, e))); return e; }
@Override public Group create(Context context) throws SQLException, AuthorizeException { // FIXME - authorization? if (!authorizeService.isAdmin(context)) { throw new AuthorizeException( "You must be an admin to create an EPerson Group"); } // Create a table row Group g = groupDAO.create(context, new Group()); log.info(LogManager.getHeader(context, "create_group", "group_id=" + g.getID())); context.addEvent(new Event(Event.CREATE, Constants.GROUP, g.getID(), null, getIdentifiers(context, g))); update(context, g); return g; }
@Override public WorkspaceItem abort(Context context, BasicWorkflowItem workflowItem, EPerson e) throws SQLException, AuthorizeException, IOException { // authorize a DSpaceActions.ABORT if (!authorizeService.isAdmin(context)) { throw new AuthorizeException( "You must be an admin to abort a workflow"); } // stop workflow regardless of its state taskListItemService.deleteByWorkflowItem(context, workflowItem); log.info(LogManager.getHeader(context, "abort_workflow", "workflow_item_id=" + workflowItem.getID() + "item_id=" + workflowItem.getItem().getID() + "collection_id=" + workflowItem.getCollection().getID() + "eperson_id=" + e.getID())); // convert into personal workspace return returnToWorkspace(context, workflowItem); }
@Override public void subscribe(Context context, EPerson eperson, Collection collection) throws SQLException, AuthorizeException { // Check authorisation. Must be administrator, or the eperson. if (authorizeService.isAdmin(context) || ((context.getCurrentUser() != null) && (context .getCurrentUser().getID().equals(eperson.getID())))) { if (!isSubscribed(context, eperson, collection)) { Subscription subscription = subscriptionDAO.create(context, new Subscription()); subscription.setCollection(collection); subscription.setePerson(eperson); } } else { throw new AuthorizeException( "Only admin or e-person themselves can subscribe"); } }
@Override public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws Exception { Request request = ObjectModelHelper.getRequest(objectModel); Context context = ContextUtil.obtainContext(request); if(!AuthorizeManager.isAdmin(context)){ throw new AuthorizeException(); } int[] workflowIdentifiers = Util.getIntParameters(request, "workflow_id"); if(workflowIdentifiers != null){ for (int workflowIdentifier : workflowIdentifiers) { XmlWorkflowItem workflowItem = XmlWorkflowItem.find(context, workflowIdentifier); if (workflowItem != null) { XmlWorkflowManager.sendWorkflowItemBackSubmission(context, workflowItem, context.getCurrentUser(), "Item sent back to the submisson process by admin", null); } } } return null; } }
@Override public WorkspaceItem abort(Context c, XmlWorkflowItem wi, EPerson e) throws AuthorizeException, SQLException, IOException { if (!authorizeService.isAdmin(c)) { throw new AuthorizeException( "You must be an admin to abort a workflow"); } c.turnOffAuthorisationSystem(); //Restore permissions for the submitter // convert into personal workspace WorkspaceItem wsi = returnToWorkspace(c, wi); log.info(LogManager.getHeader(c, "abort_workflow", "workflow_item_id=" + wi.getID() + "item_id=" + wsi.getItem().getID() + "collection_id=" + wi.getCollection().getID() + "eperson_id=" + e.getID())); c.restoreAuthSystemState(); return wsi; }
@Override public WorkflowActionConfig doState(Context c, EPerson user, HttpServletRequest request, int workflowItemId, Workflow workflow, WorkflowActionConfig currentActionConfig) throws SQLException, AuthorizeException, IOException, MessagingException, WorkflowException { try { XmlWorkflowItem wi = xmlWorkflowItemService.find(c, workflowItemId); Step currentStep = currentActionConfig.getStep(); if (currentActionConfig.getProcessingAction().isAuthorized(c, request, wi)) { ActionResult outcome = currentActionConfig.getProcessingAction().execute(c, wi, currentStep, request); return processOutcome(c, user, workflow, currentStep, currentActionConfig, outcome, wi, false); } else { throw new AuthorizeException("You are not allowed to to perform this task."); } } catch (WorkflowConfigurationException e) { log.error(LogManager.getHeader(c, "error while executing state", "workflow: " + workflow.getID() + " action: " + currentActionConfig .getId() + " workflowItemId: " + workflowItemId), e); WorkflowUtils.sendAlert(request, e); throw new WorkflowException(e); } }
@Override public void update(Context context, MetadataField metadataField) throws SQLException, AuthorizeException, NonUniqueMetadataException, IOException { // Check authorisation: Only admins may update the metadata registry if (!authorizeService.isAdmin(context)) { throw new AuthorizeException( "Only administrators may modiffy the Dublin Core registry"); } // Ensure the element and qualifier are unique within a given schema. if (hasElement(context, metadataField.getID(), metadataField.getMetadataSchema(), metadataField.getElement(), metadataField.getQualifier())) { throw new NonUniqueMetadataException( "Please make " + metadataField.getMetadataSchema().getName() + "." + metadataField.getElement() + "." + metadataField.getQualifier()); } metadataFieldDAO.save(context, metadataField); log.info(LogManager.getHeader(context, "update_metadatafieldregistry", "metadata_field_id=" + metadataField.getID() + "element=" + metadataField .getElement() + "qualifier=" + metadataField.getQualifier())); }
@Override public void update(Context context, Site site) throws SQLException, AuthorizeException { if (!authorizeService.isAdmin(context)) { throw new AuthorizeException(); } super.update(context, site); if (site.isMetadataModified()) { context.addEvent(new Event(Event.MODIFY_METADATA, site.getType(), site.getID(), site.getDetails(), getIdentifiers(context, site))); } if (site.isModified()) { context.addEvent(new Event(Event.MODIFY, site.getType(), site.getID(), site.getDetails(), getIdentifiers(context, site))); } site.clearModified(); site.clearDetails(); siteDAO.save(context, site); }