/** * Maintains integrity of the supervisory database. Should be more closely * integrated into the workspace code, perhaps * * @param context the context of the request * @param request the servlet request * @param response the servlet response */ private void cleanSupervisorDatabase(Context context, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException, AuthorizeException { // ditch any supervision orders that are no longer relevant Supervisor.removeRedundant(context); context.complete(); }
/** * Check if a context exists for this request, if so complete the context. * * @param request * The request object */ public static void completeContext(HttpServletRequest request) throws ServletException { Context context = (Context) request.getAttribute(DSPACE_CONTEXT); if (context != null && context.isValid()) { try { context.complete(); } catch (SQLException e) { throw new ServletException(e); } } }
private void showMainPage(Context c, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException, AuthorizeException { Group[] groups = Group.findAll(c, Group.NAME); // if( groups == null ) { System.out.println("groups are null"); } // else System.out.println("# of groups: " + groups.length); request.setAttribute("groups", groups); JSPManager.showJSP(request, response, "/tools/group-list.jsp"); c.complete(); } }
/** * Record that this application is not running. */ public void deregister() { // Remove the database entry try { Context context = new Context(); webAppService.delete(context, webApp); context.complete(); } catch (SQLException e) { log.error("Failed to record shutdown in Webapp table.", e); } }
/** * Record that this application is running. */ public void register() { // Create the database entry Timestamp now = new Timestamp(started.getTime()); try { Context context = new Context(); webApp = webAppService.create(context, kind, url, now, isUI() ? 1 : 0); context.complete(); } catch (SQLException e) { log.error("Failed to record startup in Webapp table.", e); } }
LogAnalyser.getNumItems(c))); c.complete();
@Override public synchronized void startNewScheduler() throws SQLException, AuthorizeException { Context c = new Context(); harvestedCollectionService.exists(c); c.complete(); if (mainHarvestThread != null && harvester != null) { stopScheduler(); } harvester = new HarvestScheduler(); HarvestScheduler.setInterrupt(HarvestScheduler.HARVESTER_INTERRUPT_NONE); mainHarvestThread = new Thread(harvester); mainHarvestThread.start(); }
public static void main(String[] args) { LOG.debug("Starting DOI organiser "); // setup Context Context context = new Context(); // Started from commandline, don't use the authentication system. context.turnOffAuthorisationSystem(); DOIOrganiser organiser = new DOIOrganiser(context, new DSpace().getSingletonService(DOIIdentifierProvider.class)); // run command line interface runCLI(context, organiser, args); try { context.complete(); } catch (SQLException sqle) { System.err.println("Cannot save changes to database: " + sqle.getMessage()); System.exit(-1); } }
c.complete(); System.out.println("Filiation complete. Community: '" + parent.getID() + "' is parent of community: '" + child.getID() + "'");
/** * Remove the supervisory group and its policies from the database * * @param context the context of the request * @param request the servlet request * @param response the servlet response */ void removeSupervisionOrder(Context context, HttpServletRequest request, HttpServletResponse response) throws SQLException, AuthorizeException, ServletException, IOException { // get the values from the request int wsItemID = UIUtil.getIntParameter(request,"siID"); int groupID = UIUtil.getIntParameter(request,"gID"); Supervisor.remove(context, wsItemID, groupID); log.info(LogManager.getHeader(context, "Supervision Order Removed", "workspace_item_id="+wsItemID+",eperson_group_id="+groupID)); context.complete(); }
/** * @param c context * @param parent parent Community * @param child child community * @throws SQLException if database error * @throws AuthorizeException if authorize error * @throws IOException if IO error */ public void defiliate(Context c, Community parent, Community child) throws SQLException, AuthorizeException, IOException { // verify that child is indeed a child of parent List<Community> parentKids = parent.getSubcommunities(); if (!parentKids.contains(child)) { System.out.println("Error, child community not a child of parent community"); System.exit(1); } // OK remove the mappings - but leave the community, which will become // top-level child.removeParentCommunity(parent); parent.removeSubCommunity(child); communityService.update(c, child); communityService.update(c, parent); // complete the pending transaction c.complete(); System.out.println("Defiliation complete. Community: '" + child.getID() + "' is no longer a child of community: '" + parent.getID() + "'"); }
public void initGroups() { // After every migrate, ensure default Groups are setup correctly. Context context = null; try { context = new Context(); context.turnOffAuthorisationSystem(); // While it's not really a formal "registry", we need to ensure the // default, required Groups exist in the DSpace database groupService.initDefaultGroupNames(context); context.restoreAuthSystemState(); // Commit changes and close context context.complete(); } catch (Exception e) { log.error("Error attempting to add/update default DSpace Groups", e); throw new RuntimeException(e); } finally { // Clean up our context, if it still exists & it was never completed if (context != null && context.isValid()) { context.abort(); } } }
/** * Adds supervisory settings to the database * * @param context the context of the request * @param request the servlet request * @param response the servlet response */ void addSupervisionOrder(Context context, HttpServletRequest request, HttpServletResponse response) throws SQLException, AuthorizeException, ServletException, IOException { // get the values from the request int groupID = UIUtil.getIntParameter(request,"TargetGroup"); int wsItemID = UIUtil.getIntParameter(request,"TargetWSItem"); int policyType = UIUtil.getIntParameter(request, "PolicyType"); Supervisor.add(context, groupID, wsItemID, policyType); log.info(LogManager.getHeader(context, "Supervision Order Set", "workspace_item_id="+wsItemID+",eperson_group_id="+groupID)); context.complete(); }
private void configureCollection(String collectionID, int type, String oaiSource, String oaiSetId, String mdConfigId) { System.out.println("Running: configure collection"); Collection collection = resolveCollection(collectionID); System.out.println(collection.getID()); try { HarvestedCollection hc = harvestedCollectionService.find(context, collection); if (hc == null) { hc = harvestedCollectionService.create(context, collection); } context.turnOffAuthorisationSystem(); hc.setHarvestParams(type, oaiSource, oaiSetId, mdConfigId); hc.setHarvestStatus(HarvestedCollection.STATUS_READY); harvestedCollectionService.update(context, hc); context.restoreAuthSystemState(); context.complete(); } catch (Exception e) { System.out.println("Changes could not be committed"); e.printStackTrace(); System.exit(1); } finally { if (context != null) { context.restoreAuthSystemState(); } } }
/** * Commit the primary context held by this class, and abort the authenticated * user's context if it is different. This ensures that only changes written * through the appropriate user's context is persisted, and all other * operations are flushed. You should, in general, not try to commit the contexts directly * when using the SWORD API. * * @throws DSpaceSWORDException on database error. */ public void commit() throws DSpaceSWORDException { try { // commit the primary context if (context != null && context.isValid()) { context.complete(); } // the secondary context is for filtering permissions by only, and is // never committed, so we abort here if (authenticatorContext != null && authenticatorContext.isValid()) { authenticatorContext.abort(); } } catch (SQLException e) { throw new DSpaceSWORDException(e); } } }
/** * Commit the primary context held by this class, and abort the authenticated * user's context if it is different. This ensures that only changes written * through the appropriate user's context is persisted, and all other * operations are flushed. You should, in general, not try to commit the contexts directly * when using the sword api. * * @throws DSpaceSwordException can be thrown by the internals of the DSpace SWORD implementation */ public void commit() throws DSpaceSwordException { try { // commit the primary context if (context != null && context.isValid()) { context.complete(); } // the secondary context is for filtering permissions by only, and is // never committed, so we abort here if (authenticatorContext != null && authenticatorContext.isValid()) { authenticatorContext.abort(); } } catch (SQLException e) { throw new DSpaceSwordException(e); } } }
context.complete();
public void initializeSiteObject() { // After every migrate, ensure default Site is setup correctly. Context context = null; try { context = new Context(); context.turnOffAuthorisationSystem(); // While it's not really a formal "registry", we need to ensure the // default, required Groups exist in the DSpace database if (siteService.findSite(context) == null) { siteService.createSite(context); } context.restoreAuthSystemState(); // Commit changes and close context context.complete(); } catch (Exception e) { log.error("Error attempting to add/update default DSpace Groups", e); } finally { // Clean up our context, if it still exists & it was never completed if (context != null && context.isValid()) { context.abort(); } } }
context.complete();