/** * Enable or disable "batch processing mode" for this context. * * Enabling batch processing mode means that the database connection is configured so that it is optimized to * process a large number of records. * * Disabling batch processing mode restores the normal behaviour that is optimal for querying and updating a * small number of records. * * @param batchModeEnabled When true, batch processing mode will be enabled. If false, it will be disabled. * @throws SQLException When configuring the database connection fails. */ @Deprecated public void enableBatchMode(boolean batchModeEnabled) throws SQLException { if (batchModeEnabled) { setMode(Mode.BATCH_EDIT); } else { setMode(Mode.READ_WRITE); } }
/** * Run the export * * @return the exported CSV lines */ public DSpaceCSV export() { try { Context.Mode originalMode = context.getCurrentMode(); context.setMode(Context.Mode.READ_ONLY); // Process each item DSpaceCSV csv = new DSpaceCSV(exportAll); while (toExport.hasNext()) { Item item = toExport.next(); csv.addItem(item); context.uncacheEntity(item); } context.setMode(originalMode); // Return the results return csv; } catch (Exception e) { // Something went wrong... System.err.println("Error exporting to CSV:"); e.printStackTrace(); return null; } }
/** * Initializes a new context object. * * @throws SQLException if there was an error obtaining a database connection */ protected void init() { updateDatabase(); if (eventService == null) { eventService = EventServiceFactory.getInstance().getEventService(); } if (dbConnection == null) { // Obtain a non-auto-committing connection dbConnection = new DSpace().getServiceManager() .getServiceByName(null, DBConnection.class); if (dbConnection == null) { log.fatal("Cannot obtain the bean which provides a database connection. " + "Check previous entries in the dspace.log to find why the db failed to initialize."); } } currentUser = null; currentLocale = I18nUtil.DEFAULTLOCALE; extraLogInfo = ""; ignoreAuth = false; specialGroups = new ArrayList<>(); authStateChangeHistory = new Stack<>(); authStateClassCallHistory = new Stack<>(); setMode(this.mode); }
/** * Initialize the Duplicate Detector and trigger parsing and running the command * @param args Command Line arguments */ public static void main(String args[]) { log.debug("Starting Duplicate Detector"); DSpace dspace = new DSpace(); // get a context Context context = new Context(); context.setMode(Context.Mode.READ_ONLY); // turn off Auth context.turnOffAuthorisationSystem(); DuplicateDetector detector = new DuplicateDetector(); detector.runCLI(context, args, detector); context.restoreAuthSystemState(); context.abort(); }