mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-12 12:33:18 +00:00
Port DS-3579_Context-mode-and-cache-management-CLI-commands to master
This commit is contained in:
@@ -34,6 +34,8 @@ public class MetadataExport
|
||||
|
||||
protected ItemService itemService;
|
||||
|
||||
protected Context context;
|
||||
|
||||
/** Whether to export all metadata, or just normally edited metadata */
|
||||
protected boolean exportAll;
|
||||
|
||||
@@ -55,6 +57,7 @@ public class MetadataExport
|
||||
// Store the export settings
|
||||
this.toExport = toExport;
|
||||
this.exportAll = exportAll;
|
||||
this.context = c;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,6 +76,7 @@ public class MetadataExport
|
||||
// Try to export the community
|
||||
this.toExport = buildFromCommunity(c, toExport, 0);
|
||||
this.exportAll = exportAll;
|
||||
this.context = c;
|
||||
}
|
||||
catch (SQLException sqle)
|
||||
{
|
||||
@@ -144,13 +148,19 @@ public class MetadataExport
|
||||
{
|
||||
try
|
||||
{
|
||||
Context.Mode originalMode = context.getCurrentMode();
|
||||
context.setMode(Context.Mode.READ_ONLY);
|
||||
|
||||
// Process each item
|
||||
DSpaceCSV csv = new DSpaceCSV(exportAll);
|
||||
while (toExport.hasNext())
|
||||
{
|
||||
csv.addItem(toExport.next());
|
||||
Item item = toExport.next();
|
||||
csv.addItem(item);
|
||||
context.uncacheEntity(item);
|
||||
}
|
||||
|
||||
context.setMode(originalMode);
|
||||
// Return the results
|
||||
return csv;
|
||||
}
|
||||
@@ -224,7 +234,7 @@ public class MetadataExport
|
||||
String filename = line.getOptionValue('f');
|
||||
|
||||
// Create a context
|
||||
Context c = new Context();
|
||||
Context c = new Context(Context.Mode.READ_ONLY);
|
||||
c.turnOffAuthorisationSystem();
|
||||
|
||||
// The things we'll export
|
||||
|
@@ -31,6 +31,7 @@ import org.dspace.eperson.EPerson;
|
||||
import org.dspace.eperson.factory.EPersonServiceFactory;
|
||||
import org.dspace.handle.factory.HandleServiceFactory;
|
||||
import org.dspace.handle.service.HandleService;
|
||||
import org.dspace.workflow.WorkflowItem;
|
||||
import org.dspace.workflow.WorkflowService;
|
||||
import org.dspace.workflow.factory.WorkflowServiceFactory;
|
||||
|
||||
@@ -122,6 +123,9 @@ public class MetadataImport
|
||||
// Make the changes
|
||||
try
|
||||
{
|
||||
Context.Mode originalMode = c.getCurrentMode();
|
||||
c.setMode(Context.Mode.BATCH_EDIT);
|
||||
|
||||
// Process each change
|
||||
for (DSpaceCSVLine line : toImport)
|
||||
{
|
||||
@@ -134,11 +138,15 @@ public class MetadataImport
|
||||
throw new MetadataImportException("'action' not allowed for new items!");
|
||||
}
|
||||
|
||||
WorkspaceItem wsItem = null;
|
||||
WorkflowItem wfItem = null;
|
||||
Item item = null;
|
||||
|
||||
// Is this a new item?
|
||||
if (id != null)
|
||||
{
|
||||
// Get the item
|
||||
Item item = itemService.find(c, id);
|
||||
item = itemService.find(c, id);
|
||||
if (item == null)
|
||||
{
|
||||
throw new MetadataImportException("Unknown item ID " + id);
|
||||
@@ -345,8 +353,8 @@ public class MetadataImport
|
||||
// Create the item
|
||||
String collectionHandle = line.get("collection").get(0);
|
||||
collection = (Collection) handleService.resolveToObject(c, collectionHandle);
|
||||
WorkspaceItem wsItem = workspaceItemService.create(c, collection, useTemplate);
|
||||
Item item = wsItem.getItem();
|
||||
wsItem = workspaceItemService.create(c, collection, useTemplate);
|
||||
item = wsItem.getItem();
|
||||
|
||||
// Add the metadata to the item
|
||||
for (BulkEditMetadataValue dcv : whatHasChanged.getAdds())
|
||||
@@ -364,9 +372,9 @@ public class MetadataImport
|
||||
if(useWorkflow){
|
||||
WorkflowService workflowService = WorkflowServiceFactory.getInstance().getWorkflowService();
|
||||
if (workflowNotify) {
|
||||
workflowService.start(c, wsItem);
|
||||
wfItem = workflowService.start(c, wsItem);
|
||||
} else {
|
||||
workflowService.startWithoutNotify(c, wsItem);
|
||||
wfItem = workflowService.startWithoutNotify(c, wsItem);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -394,8 +402,17 @@ public class MetadataImport
|
||||
// Record the changes
|
||||
changes.add(whatHasChanged);
|
||||
}
|
||||
|
||||
if (change) {
|
||||
//only clear cache if changes have been made.
|
||||
c.uncacheEntity(wsItem);
|
||||
c.uncacheEntity(wfItem);
|
||||
c.uncacheEntity(item);
|
||||
}
|
||||
}
|
||||
|
||||
c.setMode(originalMode);
|
||||
}
|
||||
catch (MetadataImportException mie)
|
||||
{
|
||||
throw mie;
|
||||
|
@@ -7,36 +7,32 @@
|
||||
*/
|
||||
package org.dspace.app.harvest;
|
||||
|
||||
import org.apache.commons.cli.*;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.CollectionService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.eperson.factory.EPersonServiceFactory;
|
||||
import org.dspace.eperson.service.EPersonService;
|
||||
import org.dspace.handle.factory.HandleServiceFactory;
|
||||
import org.dspace.harvest.HarvestedCollection;
|
||||
import org.dspace.harvest.HarvestingException;
|
||||
import org.dspace.harvest.OAIHarvester;
|
||||
import org.dspace.harvest.factory.HarvestServiceFactory;
|
||||
import org.dspace.harvest.service.HarvestedCollectionService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.CollectionService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.eperson.factory.EPersonServiceFactory;
|
||||
import org.dspace.eperson.service.EPersonService;
|
||||
import org.dspace.handle.factory.HandleServiceFactory;
|
||||
import org.dspace.harvest.HarvestedCollection;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.harvest.HarvestingException;
|
||||
import org.dspace.harvest.OAIHarvester;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.harvest.factory.HarvestServiceFactory;
|
||||
import org.dspace.harvest.service.HarvestedCollectionService;
|
||||
|
||||
/**
|
||||
* Test class for harvested collections.
|
||||
*
|
||||
@@ -96,7 +92,7 @@ public class Harvest
|
||||
{
|
||||
HelpFormatter myhelp = new HelpFormatter();
|
||||
myhelp.printHelp("Harvest\n", options);
|
||||
System.out.println("\nPING OAI server: Harvest -g -s oai_source -i oai_set_id");
|
||||
System.out.println("\nPING OAI server: Harvest -g -a oai_source -i oai_set_id");
|
||||
System.out.println("RUNONCE harvest with arbitrary options: Harvest -o -e eperson -c collection -t harvest_type -a oai_source -i oai_set_id -m metadata_format");
|
||||
System.out.println("SETUP a collection for harvesting: Harvest -s -c collection -t harvest_type -a oai_source -i oai_set_id -m metadata_format");
|
||||
System.out.println("RUN harvest once: Harvest -r -e eperson -c collection");
|
||||
@@ -160,7 +156,7 @@ public class Harvest
|
||||
|
||||
// Instantiate our class
|
||||
Harvest harvester = new Harvest();
|
||||
harvester.context = new Context();
|
||||
harvester.context = new Context(Context.Mode.BATCH_EDIT);
|
||||
|
||||
|
||||
// Check our options
|
||||
@@ -373,7 +369,7 @@ public class Harvest
|
||||
Item item = it.next();
|
||||
System.out.println("Deleting: " + item.getHandle());
|
||||
collectionService.removeItem(context, collection, item);
|
||||
// Dispatch events every 50 items
|
||||
context.uncacheEntity(item);// Dispatch events every 50 items
|
||||
if (i%50 == 0) {
|
||||
context.dispatchEvents();
|
||||
i=0;
|
||||
|
@@ -176,7 +176,7 @@ public class ItemExportCLITool {
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
Context c = new Context();
|
||||
Context c = new Context(Context.Mode.READ_ONLY);
|
||||
c.turnOffAuthorisationSystem();
|
||||
|
||||
if (myType == Constants.ITEM)
|
||||
|
@@ -7,44 +7,28 @@
|
||||
*/
|
||||
package org.dspace.app.itemexport;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.SQLException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import javax.mail.MessagingException;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.dspace.app.itemexport.service.ItemExportService;
|
||||
import org.dspace.content.*;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.service.BitstreamService;
|
||||
import org.dspace.content.service.CommunityService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.I18nUtil;
|
||||
import org.dspace.core.LogManager;
|
||||
import org.dspace.core.Utils;
|
||||
import org.dspace.core.Email;
|
||||
import org.dspace.core.*;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.eperson.service.EPersonService;
|
||||
import org.dspace.handle.service.HandleService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import javax.mail.MessagingException;
|
||||
import java.io.*;
|
||||
import java.sql.SQLException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
/**
|
||||
* Item exporter to create simple AIPs for DSpace content. Currently exports
|
||||
* individual items, or entire collections. For instructions on use, see
|
||||
@@ -129,7 +113,9 @@ public class ItemExportServiceImpl implements ItemExportService
|
||||
}
|
||||
|
||||
System.out.println("Exporting item to " + mySequenceNumber);
|
||||
exportItem(c, i.next(), fullPath, mySequenceNumber, migrate, excludeBitstreams);
|
||||
Item item = i.next();
|
||||
exportItem(c, item, fullPath, mySequenceNumber, migrate, excludeBitstreams);
|
||||
c.uncacheEntity(item);
|
||||
mySequenceNumber++;
|
||||
}
|
||||
}
|
||||
|
@@ -294,7 +294,7 @@ public class ItemImportCLITool {
|
||||
myloader.setQuiet(isQuiet);
|
||||
|
||||
// create a context
|
||||
Context c = new Context();
|
||||
Context c = new Context(Context.Mode.BATCH_EDIT);
|
||||
|
||||
// find the EPerson, assign to context
|
||||
EPerson myEPerson = null;
|
||||
|
@@ -14,21 +14,6 @@ import gr.ekt.bte.core.TransformationSpec;
|
||||
import gr.ekt.bte.dataloader.FileDataLoader;
|
||||
import gr.ekt.bteio.generators.DSpaceOutputGenerator;
|
||||
import gr.ekt.bteio.loaders.OAIPMHDataLoader;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.sql.SQLException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.zip.ZipFile;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
import javax.mail.MessagingException;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.TransformerException;
|
||||
|
||||
import org.apache.commons.collections.ComparatorUtils;
|
||||
import org.apache.commons.io.FileDeleteStrategy;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
@@ -46,18 +31,14 @@ import org.dspace.authorize.service.ResourcePolicyService;
|
||||
import org.dspace.content.*;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.service.*;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.Email;
|
||||
import org.dspace.core.I18nUtil;
|
||||
import org.dspace.core.LogManager;
|
||||
import org.dspace.core.*;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.eperson.Group;
|
||||
import org.dspace.eperson.service.EPersonService;
|
||||
import org.dspace.eperson.service.GroupService;
|
||||
import org.dspace.handle.service.HandleService;
|
||||
import org.dspace.utils.DSpace;
|
||||
import org.dspace.workflow.WorkflowItem;
|
||||
import org.dspace.workflow.WorkflowService;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -67,6 +48,19 @@ import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import javax.mail.MessagingException;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.sql.SQLException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
|
||||
/**
|
||||
* Import items into DSpace. The conventional use is upload files by copying
|
||||
@@ -343,7 +337,7 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
|
||||
{
|
||||
clist = mycollections;
|
||||
}
|
||||
addItem(c, clist, sourceDir, dircontents[i], mapOut, template);
|
||||
Item item =addItem(c, clist, sourceDir, dircontents[i], mapOut, template);c.uncacheEntity(item);
|
||||
System.out.println(i + " " + dircontents[i]);
|
||||
}
|
||||
}
|
||||
@@ -416,7 +410,9 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
|
||||
handleOut.close();
|
||||
|
||||
deleteItem(c, oldItem);
|
||||
addItem(c, mycollections, sourceDir, newItemName, null, template);
|
||||
Item newItem = addItem(c, mycollections, sourceDir, newItemName, null, template);
|
||||
c.uncacheEntity(oldItem);
|
||||
c.uncacheEntity(newItem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -447,6 +443,7 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
|
||||
Item myitem = itemService.findByIdOrLegacyId(c, itemID);
|
||||
System.out.println("Deleting item " + itemID);
|
||||
deleteItem(c, myitem);
|
||||
c.uncacheEntity(myitem);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -473,6 +470,7 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
|
||||
// create workspace item
|
||||
Item myitem = null;
|
||||
WorkspaceItem wi = null;
|
||||
WorkflowItem wfi = null;
|
||||
|
||||
if (!isTest)
|
||||
{
|
||||
@@ -498,9 +496,9 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
|
||||
{
|
||||
// Should we send a workflow alert email or not?
|
||||
if (useWorkflowSendEmail) {
|
||||
workflowService.start(c, wi);
|
||||
wfi = workflowService.start(c, wi);
|
||||
} else {
|
||||
workflowService.startWithoutNotify(c, wi);
|
||||
wfi = workflowService.startWithoutNotify(c, wi);
|
||||
}
|
||||
|
||||
// send ID to the mapfile
|
||||
@@ -556,6 +554,10 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
|
||||
mapOut.println(mapOutputString);
|
||||
}
|
||||
|
||||
//Clear intermediary objects from the cache
|
||||
c.uncacheEntity(wi);
|
||||
c.uncacheEntity(wfi);
|
||||
|
||||
return myitem;
|
||||
}
|
||||
|
||||
@@ -593,6 +595,7 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
|
||||
else
|
||||
{
|
||||
deleteItem(c, myitem);
|
||||
c.uncacheEntity(myitem);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -7,21 +7,7 @@
|
||||
*/
|
||||
package org.dspace.app.itemupdate;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.Option;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
import org.apache.commons.cli.*;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.ItemService;
|
||||
@@ -31,6 +17,9 @@ import org.dspace.eperson.EPerson;
|
||||
import org.dspace.eperson.factory.EPersonServiceFactory;
|
||||
import org.dspace.eperson.service.EPersonService;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* Provides some batch editing capabilities for items in DSpace:
|
||||
@@ -353,7 +342,7 @@ public class ItemUpdate {
|
||||
|
||||
pr("ItemUpdate - initializing run on " + (new Date()).toString());
|
||||
|
||||
context = new Context();
|
||||
context = new Context(Context.Mode.BATCH_EDIT);
|
||||
iu.setEPerson(context, iu.eperson);
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
@@ -461,7 +450,7 @@ public class ItemUpdate {
|
||||
{
|
||||
Item item = itarch.getItem();
|
||||
itemService.update(context, item); //need to update before commit
|
||||
}
|
||||
context.uncacheEntity(item);}
|
||||
ItemUpdate.pr("Item " + dirname + " completed");
|
||||
successItemCount++;
|
||||
}
|
||||
|
@@ -7,9 +7,6 @@
|
||||
*/
|
||||
package org.dspace.app.mediafilter;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
|
||||
import org.dspace.app.mediafilter.service.MediaFilterService;
|
||||
import org.dspace.authorize.service.AuthorizeService;
|
||||
import org.dspace.content.*;
|
||||
@@ -24,6 +21,9 @@ import org.dspace.services.ConfigurationService;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* MediaFilterManager is the class that invokes the media/format filters over the
|
||||
* repository's content. A few command line flags affect the operation of the
|
||||
@@ -161,6 +161,7 @@ public class MediaFilterServiceImpl implements MediaFilterService, InitializingB
|
||||
++processed;
|
||||
}
|
||||
// clear item objects from context cache and internal cache
|
||||
c.uncacheEntity(currentItem);
|
||||
currentItem = null;
|
||||
}
|
||||
}
|
||||
|
@@ -7,26 +7,14 @@
|
||||
*/
|
||||
package org.dspace.app.packager;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
import org.apache.commons.cli.*;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.crosswalk.CrosswalkException;
|
||||
import org.dspace.content.packager.PackageDisseminator;
|
||||
import org.dspace.content.packager.PackageException;
|
||||
import org.dspace.content.packager.PackageParameters;
|
||||
import org.dspace.content.packager.PackageIngester;
|
||||
import org.dspace.content.packager.PackageParameters;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.factory.CoreServiceFactory;
|
||||
@@ -36,6 +24,10 @@ import org.dspace.eperson.factory.EPersonServiceFactory;
|
||||
import org.dspace.handle.factory.HandleServiceFactory;
|
||||
import org.dspace.workflow.WorkflowException;
|
||||
|
||||
import java.io.*;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Command-line interface to the Packager plugin.
|
||||
* <p>
|
||||
@@ -331,6 +323,7 @@ public class Packager
|
||||
//If we are in REPLACE mode
|
||||
if(pkgParams.replaceModeEnabled())
|
||||
{
|
||||
context.setMode(Context.Mode.BATCH_EDIT);
|
||||
PackageIngester sip = (PackageIngester) pluginService
|
||||
.getNamedPlugin(PackageIngester.class, myPackager.packageType);
|
||||
if (sip == null)
|
||||
@@ -394,6 +387,8 @@ public class Packager
|
||||
//else if normal SUBMIT mode (or basic RESTORE mode -- which is a special type of submission)
|
||||
else if (myPackager.submit || pkgParams.restoreModeEnabled())
|
||||
{
|
||||
context.setMode(Context.Mode.BATCH_EDIT);
|
||||
|
||||
PackageIngester sip = (PackageIngester) pluginService
|
||||
.getNamedPlugin(PackageIngester.class, myPackager.packageType);
|
||||
if (sip == null)
|
||||
@@ -445,6 +440,8 @@ public class Packager
|
||||
}// else, if DISSEMINATE mode
|
||||
else
|
||||
{
|
||||
context.setMode(Context.Mode.READ_ONLY);
|
||||
|
||||
//retrieve specified package disseminator
|
||||
PackageDisseminator dip = (PackageDisseminator) pluginService
|
||||
.getNamedPlugin(PackageDisseminator.class, myPackager.packageType);
|
||||
|
@@ -7,28 +7,9 @@
|
||||
*/
|
||||
package org.dspace.app.sitemap;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.cli.*;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.Community;
|
||||
@@ -42,6 +23,16 @@ import org.dspace.core.LogManager;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Command-line utility for generating HTML and Sitemaps.org protocol Sitemaps.
|
||||
*
|
||||
@@ -188,7 +179,7 @@ public class GenerateSitemaps
|
||||
+ "?map=", null);
|
||||
}
|
||||
|
||||
Context c = new Context();
|
||||
Context c = new Context(Context.Mode.READ_ONLY);
|
||||
|
||||
List<Community> comms = communityService.findAll(c);
|
||||
|
||||
@@ -201,6 +192,8 @@ public class GenerateSitemaps
|
||||
if (makeSitemapOrg) {
|
||||
sitemapsOrg.addURL(url, null);
|
||||
}
|
||||
|
||||
c.uncacheEntity(comm);
|
||||
}
|
||||
|
||||
List<Collection> colls = collectionService.findAll(c);
|
||||
@@ -214,6 +207,8 @@ public class GenerateSitemaps
|
||||
if (makeSitemapOrg) {
|
||||
sitemapsOrg.addURL(url, null);
|
||||
}
|
||||
|
||||
c.uncacheEntity(coll);
|
||||
}
|
||||
|
||||
Iterator<Item> allItems = itemService.findAll(c);
|
||||
@@ -234,6 +229,8 @@ public class GenerateSitemaps
|
||||
sitemapsOrg.addURL(url, lastMod);
|
||||
}
|
||||
|
||||
c.uncacheEntity(i);
|
||||
|
||||
itemCount++;
|
||||
}
|
||||
|
||||
|
@@ -145,6 +145,7 @@ public class DSpaceAuthorityIndexer implements AuthorityIndexerInterface, Initia
|
||||
} else {
|
||||
|
||||
// 3. iterate over the items
|
||||
context.uncacheEntity(currentItem);
|
||||
|
||||
if (itemIterator.hasNext()) {
|
||||
currentItem = itemIterator.next();
|
||||
|
@@ -460,7 +460,6 @@ public class AuthorizeServiceImpl implements AuthorizeService
|
||||
return groupService.isMember(c, Group.ADMIN);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAdmin(Context c, EPerson e) throws SQLException
|
||||
{
|
||||
@@ -478,7 +477,6 @@ public class AuthorizeServiceImpl implements AuthorizeService
|
||||
return groupService.isMember(c, e, Group.ADMIN);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCommunityAdmin(Context c) throws SQLException
|
||||
{
|
||||
EPerson e = c.getCurrentUser();
|
||||
|
@@ -7,11 +7,6 @@
|
||||
*/
|
||||
package org.dspace.checker;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.checker.factory.CheckerServiceFactory;
|
||||
@@ -23,6 +18,11 @@ import org.dspace.core.Context;
|
||||
import org.dspace.storage.bitstore.factory.StorageServiceFactory;
|
||||
import org.dspace.storage.bitstore.service.BitstreamStorageService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Main class for the checksum checker tool, which calculates checksums for each
|
||||
@@ -127,6 +127,7 @@ public final class CheckerCommand
|
||||
collector.collect(context, info);
|
||||
}
|
||||
|
||||
context.uncacheEntity(bitstream);
|
||||
bitstream = dispatcher.next();
|
||||
}
|
||||
}
|
||||
|
@@ -7,20 +7,7 @@
|
||||
*/
|
||||
package org.dspace.checker;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import javax.mail.MessagingException;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
import org.apache.commons.cli.*;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.checker.factory.CheckerServiceFactory;
|
||||
import org.dspace.checker.service.SimpleReporterService;
|
||||
@@ -28,6 +15,14 @@ import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.Email;
|
||||
|
||||
import javax.mail.MessagingException;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* The email reporter creates and sends emails to an administrator. This only
|
||||
@@ -168,7 +163,7 @@ public class DailyReportEmailer
|
||||
|
||||
try
|
||||
{
|
||||
context = new Context();
|
||||
context = new Context(Context.Mode.READ_ONLY);
|
||||
|
||||
// the number of bitstreams in report
|
||||
int numBitstreams = 0;
|
||||
|
@@ -13,8 +13,6 @@ import org.dspace.content.service.CollectionService;
|
||||
import org.dspace.core.*;
|
||||
import org.dspace.eperson.Group;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import org.hibernate.annotations.Sort;
|
||||
import org.hibernate.annotations.SortType;
|
||||
import org.hibernate.proxy.HibernateProxyHelper;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
@@ -15,8 +15,6 @@ import org.dspace.content.service.CommunityService;
|
||||
import org.dspace.core.*;
|
||||
import org.dspace.eperson.Group;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import org.hibernate.annotations.Sort;
|
||||
import org.hibernate.annotations.SortType;
|
||||
import org.hibernate.proxy.HibernateProxyHelper;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
@@ -21,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -98,7 +99,7 @@ public class MetadataValueServiceImpl implements MetadataValueService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MetadataValue> findByValueLike(Context context, String value) throws SQLException {
|
||||
public Iterator<MetadataValue> findByValueLike(Context context, String value) throws SQLException {
|
||||
return metadataValueDAO.findByValueLike(context, value);
|
||||
}
|
||||
|
||||
|
@@ -13,6 +13,7 @@ import org.dspace.core.Context;
|
||||
import org.dspace.core.GenericDAO;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -26,7 +27,7 @@ public interface MetadataValueDAO extends GenericDAO<MetadataValue> {
|
||||
|
||||
public List<MetadataValue> findByField(Context context, MetadataField fieldId) throws SQLException;
|
||||
|
||||
public List<MetadataValue> findByValueLike(Context context, String value) throws SQLException;
|
||||
public Iterator<MetadataValue> findByValueLike(Context context, String value) throws SQLException;
|
||||
|
||||
public void deleteByMetadataField(Context context, MetadataField metadataField) throws SQLException;
|
||||
|
||||
|
@@ -18,6 +18,7 @@ import org.hibernate.Query;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -48,14 +49,14 @@ public class MetadataValueDAOImpl extends AbstractHibernateDAO<MetadataValue> im
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MetadataValue> findByValueLike(Context context, String value) throws SQLException {
|
||||
Criteria criteria = createCriteria(context, MetadataValue.class);
|
||||
criteria.add(
|
||||
Restrictions.like("value", "%" + value + "%")
|
||||
);
|
||||
criteria.setFetchMode("metadataField", FetchMode.JOIN);
|
||||
public Iterator<MetadataValue> findByValueLike(Context context, String value) throws SQLException {
|
||||
String queryString = "SELECT m FROM MetadataValue m JOIN m.metadataField f " +
|
||||
"WHERE m.value like concat('%', concat(:searchString,'%')) ORDER BY m.id ASC";
|
||||
|
||||
return list(criteria);
|
||||
Query query = createQuery(context, queryString);
|
||||
query.setString("searchString", value);
|
||||
|
||||
return iterate(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -15,6 +15,7 @@ import org.dspace.core.Context;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -82,7 +83,7 @@ public interface MetadataValueService {
|
||||
*/
|
||||
public void delete(Context context, MetadataValue metadataValue) throws SQLException;
|
||||
|
||||
public List<MetadataValue> findByValueLike(Context context, String value) throws SQLException;
|
||||
public Iterator<MetadataValue> findByValueLike(Context context, String value) throws SQLException;
|
||||
|
||||
public void deleteByMetadataField(Context context, MetadataField metadataField) throws SQLException;
|
||||
|
||||
|
@@ -362,9 +362,14 @@ public class Context
|
||||
try
|
||||
{
|
||||
// As long as we have a valid, writeable database connection,
|
||||
// commit any changes made as part of the transaction
|
||||
// rollback any changes if we are in read-only mode,
|
||||
// otherwise, commit any changes made as part of the transaction
|
||||
if(isReadOnly()) {
|
||||
abort();
|
||||
} else {
|
||||
commit();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if(dbConnection != null)
|
||||
|
@@ -7,16 +7,7 @@
|
||||
*/
|
||||
package org.dspace.curate;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
|
||||
import org.apache.commons.cli.*;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.factory.CoreServiceFactory;
|
||||
@@ -25,6 +16,10 @@ import org.dspace.eperson.EPerson;
|
||||
import org.dspace.eperson.factory.EPersonServiceFactory;
|
||||
import org.dspace.eperson.service.EPersonService;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* CurationCli provides command-line access to Curation tools and processes.
|
||||
*
|
||||
@@ -142,7 +137,7 @@ public class CurationCli
|
||||
}
|
||||
EPersonService ePersonService = EPersonServiceFactory.getInstance().getEPersonService();
|
||||
|
||||
Context c = new Context();
|
||||
Context c = new Context(Context.Mode.BATCH_EDIT);
|
||||
if (ePersonName != null)
|
||||
{
|
||||
EPerson ePerson = ePersonService.findByEmail(c, ePersonName);
|
||||
|
@@ -512,10 +512,14 @@ public class Curator
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Iterator<Item> iter = itemService.findByCollection(curationContext(), coll);
|
||||
Context context = curationContext();
|
||||
Iterator<Item> iter = itemService.findByCollection(context, coll);
|
||||
while (iter.hasNext())
|
||||
{
|
||||
if (! tr.run(iter.next()))
|
||||
Item item = iter.next();
|
||||
boolean shouldContinue = tr.run(item);
|
||||
context.uncacheEntity(item);
|
||||
if (!shouldContinue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@@ -115,7 +115,7 @@ public class EmbargoCLITool {
|
||||
Context context = null;
|
||||
try
|
||||
{
|
||||
context = new Context();
|
||||
context = new Context(Context.Mode.BATCH_EDIT);
|
||||
context.turnOffAuthorisationSystem();
|
||||
Date now = new Date();
|
||||
|
||||
@@ -149,10 +149,12 @@ public class EmbargoCLITool {
|
||||
Iterator<Item> ii = embargoService.findItemsByLiftMetadata(context);
|
||||
while (ii.hasNext())
|
||||
{
|
||||
if (processOneItem(context, ii.next(), line, now))
|
||||
Item item = ii.next();
|
||||
if (processOneItem(context, item, line, now))
|
||||
{
|
||||
status = 1;
|
||||
}
|
||||
context.uncacheEntity(item);
|
||||
}
|
||||
}
|
||||
context.complete();
|
||||
|
@@ -302,7 +302,7 @@ public class SubscribeCLITool {
|
||||
Context context = null;
|
||||
|
||||
try {
|
||||
context = new Context();
|
||||
context = new Context(Context.Mode.READ_ONLY);
|
||||
processDaily(context, test);
|
||||
context.complete();
|
||||
} catch (Exception e) {
|
||||
|
@@ -231,6 +231,10 @@ public class HandleServiceImpl implements HandleService
|
||||
// can verify during a restore whether the same *type* of resource
|
||||
// is reusing this handle!
|
||||
handle.setDSpaceObject(null);
|
||||
|
||||
//Also remove the handle from the DSO list to keep a consistent model
|
||||
dso.getHandles().remove(handle);
|
||||
|
||||
handleDAO.save(context, handle);
|
||||
|
||||
if (log.isDebugEnabled())
|
||||
@@ -241,7 +245,7 @@ public class HandleServiceImpl implements HandleService
|
||||
}
|
||||
else
|
||||
{
|
||||
log.warn("Cannot find Handle entry to unbind for object " + Constants.typeText[dso.getType()] + " id=" + dso.getID());
|
||||
log.trace("Cannot find Handle entry to unbind for object " + Constants.typeText[dso.getType()] + " id=" + dso.getID() + ". Handle could have been unbinded before.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -7,10 +7,6 @@
|
||||
*/
|
||||
package org.dspace.handle;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.content.MetadataValue;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
@@ -19,6 +15,13 @@ import org.dspace.core.Context;
|
||||
import org.dspace.discovery.IndexClient;
|
||||
import org.dspace.handle.factory.HandleServiceFactory;
|
||||
import org.dspace.handle.service.HandleService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* A script to update the handle values in the database. This is typically used
|
||||
@@ -32,6 +35,7 @@ public class UpdateHandlePrefix
|
||||
{
|
||||
|
||||
private static final Logger log = Logger.getLogger(UpdateHandlePrefix.class);
|
||||
private static final ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
|
||||
/**
|
||||
* When invoked as a command-line tool, updates handle prefix
|
||||
@@ -94,12 +98,19 @@ public class UpdateHandlePrefix
|
||||
|
||||
System.out.print("Updating metadatavalues table... ");
|
||||
MetadataValueService metadataValueService = ContentServiceFactory.getInstance().getMetadataValueService();
|
||||
List<MetadataValue> metadataValues = metadataValueService.findByValueLike(context, "http://hdl.handle.net/");
|
||||
int updMeta = metadataValues.size();
|
||||
for (MetadataValue metadataValue : metadataValues) {
|
||||
metadataValue.setValue(metadataValue.getValue().replace("http://hdl.handle.net/" + oldH, "http://hdl.handle.net/" + newH));
|
||||
|
||||
String handlePrefix = configurationService.getProperty("handle.canonical.prefix");
|
||||
Iterator<MetadataValue> metadataValues = metadataValueService.findByValueLike(context, handlePrefix);
|
||||
|
||||
int updMeta = 0;
|
||||
while(metadataValues.hasNext()) {
|
||||
MetadataValue metadataValue = metadataValues.next();
|
||||
metadataValue.setValue(metadataValue.getValue().replace(handlePrefix + oldH, handlePrefix + newH));
|
||||
metadataValueService.update(context, metadataValue, true);
|
||||
context.uncacheEntity(metadataValue);
|
||||
updMeta++;
|
||||
}
|
||||
|
||||
System.out.println(
|
||||
updMeta + " metadata value" + ((updMeta > 1) ? "s" : "") + " updated"
|
||||
);
|
||||
|
@@ -646,6 +646,11 @@ public class OAIHarvester {
|
||||
log.info(String.format("Item %s (%s) has been ingested (item %d of %d). The whole process took: %d ms.",
|
||||
item.getHandle(), item.getID(), currentRecord, totalListSize, timeTaken));
|
||||
|
||||
//Clear the context cache
|
||||
ourContext.uncacheEntity(wi);
|
||||
ourContext.uncacheEntity(hi);
|
||||
ourContext.uncacheEntity(item);
|
||||
|
||||
// Stop ignoring authorization
|
||||
ourContext.restoreAuthSystemState();
|
||||
}
|
||||
|
@@ -8,28 +8,12 @@
|
||||
|
||||
package org.dspace.identifier.doi;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.Option;
|
||||
import org.apache.commons.cli.OptionBuilder;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
import org.apache.commons.cli.*;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.Email;
|
||||
import org.dspace.core.I18nUtil;
|
||||
import org.dspace.core.*;
|
||||
import org.dspace.handle.factory.HandleServiceFactory;
|
||||
import org.dspace.handle.service.HandleService;
|
||||
import org.dspace.identifier.DOI;
|
||||
@@ -39,6 +23,11 @@ import org.dspace.identifier.factory.IdentifierServiceFactory;
|
||||
import org.dspace.identifier.service.DOIService;
|
||||
import org.dspace.utils.DSpace;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -203,6 +192,7 @@ public class DOIOrganiser {
|
||||
|
||||
for (DOI doi : dois) {
|
||||
organiser.reserve(doi);
|
||||
context.uncacheEntity(doi);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
System.err.println("Error in database connection:" + ex.getMessage());
|
||||
@@ -223,6 +213,7 @@ public class DOIOrganiser {
|
||||
for (DOI doi : dois)
|
||||
{
|
||||
organiser.register(doi);
|
||||
context.uncacheEntity(doi);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
System.err.println("Error in database connection:" + ex.getMessage());
|
||||
@@ -247,6 +238,7 @@ public class DOIOrganiser {
|
||||
for (DOI doi : dois)
|
||||
{
|
||||
organiser.update(doi);
|
||||
context.uncacheEntity(doi);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
System.err.println("Error in database connection:" + ex.getMessage());
|
||||
@@ -270,6 +262,7 @@ public class DOIOrganiser {
|
||||
DOI doi = iterator.next();
|
||||
iterator.remove();
|
||||
organiser.delete(doi.getDoi());
|
||||
context.uncacheEntity(doi);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
System.err.println("Error in database connection:" + ex.getMessage());
|
||||
|
@@ -9,29 +9,11 @@
|
||||
package org.dspace.rdf;
|
||||
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.Option;
|
||||
import org.apache.commons.cli.OptionBuilder;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
import org.apache.commons.cli.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.Community;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.Site;
|
||||
import org.dspace.content.*;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.CommunityService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
@@ -44,6 +26,14 @@ import org.dspace.rdf.storage.RDFStorage;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
/**
|
||||
* This class manages the handling of RDF data in DSpace. It generates
|
||||
* identifiers, it loads data, it manages the conversion of DSpace Objects into
|
||||
@@ -467,6 +457,7 @@ public class RDFizer {
|
||||
callback.callback(dso);
|
||||
report("Processed " + contentServiceFactory.getDSpaceObjectService(dso).getTypeText(dso) + " " + dso.getID()
|
||||
+ " (handle " + dso.getHandle() + ").");
|
||||
context.uncacheEntity(dso);
|
||||
}
|
||||
|
||||
protected boolean isProcessed(DSpaceObject dso)
|
||||
|
@@ -68,7 +68,7 @@ public class BitStoreMigrate {
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
Context context = new Context();
|
||||
Context context = new Context(Context.Mode.BATCH_EDIT);
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
if(line.hasOption('p')) {
|
||||
|
@@ -223,7 +223,7 @@ public class BitstreamStorageServiceImpl implements BitstreamStorageService, Ini
|
||||
|
||||
try
|
||||
{
|
||||
context = new Context();
|
||||
context = new Context(Context.Mode.BATCH_EDIT);
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
List<Bitstream> storage = bitstreamService.findDeletedBitstreams(context);
|
||||
@@ -254,6 +254,7 @@ public class BitstreamStorageServiceImpl implements BitstreamStorageService, Ini
|
||||
}
|
||||
bitstreamService.expunge(context, bitstream);
|
||||
}
|
||||
context.uncacheEntity(bitstream);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -262,6 +263,7 @@ public class BitstreamStorageServiceImpl implements BitstreamStorageService, Ini
|
||||
if (isRecent(Long.valueOf(receivedMetadata.get("modified").toString())))
|
||||
{
|
||||
log.debug("file is recent");
|
||||
context.uncacheEntity(bitstream);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -281,6 +283,7 @@ public class BitstreamStorageServiceImpl implements BitstreamStorageService, Ini
|
||||
}
|
||||
|
||||
if (isRegisteredBitstream(bitstream.getInternalId())) {
|
||||
context.uncacheEntity(bitstream);
|
||||
continue; // do not delete registered bitstreams
|
||||
}
|
||||
|
||||
@@ -310,6 +313,8 @@ public class BitstreamStorageServiceImpl implements BitstreamStorageService, Ini
|
||||
{
|
||||
context.dispatchEvents();
|
||||
}
|
||||
|
||||
context.uncacheEntity(bitstream);
|
||||
}
|
||||
|
||||
System.out.print("Committing changes to the database...");
|
||||
@@ -393,6 +398,8 @@ public class BitstreamStorageServiceImpl implements BitstreamStorageService, Ini
|
||||
}
|
||||
|
||||
processedCounter++;
|
||||
context.uncacheEntity(bitstream);
|
||||
|
||||
//modulo
|
||||
if ((processedCounter % batchCommitSize) == 0) {
|
||||
log.info("Migration Commit Checkpoint: " + processedCounter);
|
||||
|
@@ -9,12 +9,13 @@ package org.dspace.workflow;
|
||||
|
||||
|
||||
import org.dspace.content.InProgressSubmission;
|
||||
import org.dspace.core.ReloadableEntity;
|
||||
|
||||
/**
|
||||
* Interface representing a workflowitem, each workflowItem implementation must implement this interface.
|
||||
*
|
||||
* @author kevinvandevelde at atmire.com
|
||||
*/
|
||||
public interface WorkflowItem extends InProgressSubmission {
|
||||
public interface WorkflowItem extends InProgressSubmission, ReloadableEntity<Integer> {
|
||||
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@ import java.sql.SQLException;
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "workflowitem")
|
||||
public class BasicWorkflowItem implements WorkflowItem, ReloadableEntity<Integer>
|
||||
public class BasicWorkflowItem implements WorkflowItem
|
||||
{
|
||||
|
||||
@Id
|
||||
|
@@ -166,9 +166,10 @@ public class VersioningTest extends AbstractUnitTest {
|
||||
@Test
|
||||
public void testVersionDelete() throws Exception {
|
||||
context.turnOffAuthorisationSystem();
|
||||
String handle = versionedItem.getHandle();
|
||||
versionService.removeVersion(context, versionedItem);
|
||||
assertThat("Test_version_delete", itemService.find(context, versionedItem.getID()), nullValue());
|
||||
assertThat("Test_version_handle_delete", handleService.resolveToObject(context, versionedItem.getHandle()), nullValue());
|
||||
assertThat("Test_version_handle_delete", handleService.resolveToObject(context, handle), nullValue());
|
||||
context.restoreAuthSystemState();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user