mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 23:13:10 +00:00
Merge pull request #8562 from mwoodiupui/8561
Option to skip bitstreams on import, like 'export -x'
This commit is contained in:
@@ -67,6 +67,7 @@ public class ItemImport extends DSpaceRunnable<ItemImportScriptConfiguration> {
|
|||||||
protected String eperson = null;
|
protected String eperson = null;
|
||||||
protected String[] collections = null;
|
protected String[] collections = null;
|
||||||
protected boolean isTest = false;
|
protected boolean isTest = false;
|
||||||
|
protected boolean isExcludeContent = false;
|
||||||
protected boolean isResume = false;
|
protected boolean isResume = false;
|
||||||
protected boolean useWorkflow = false;
|
protected boolean useWorkflow = false;
|
||||||
protected boolean useWorkflowSendEmail = false;
|
protected boolean useWorkflowSendEmail = false;
|
||||||
@@ -119,6 +120,8 @@ public class ItemImport extends DSpaceRunnable<ItemImportScriptConfiguration> {
|
|||||||
handler.logInfo("**Test Run** - not actually importing items.");
|
handler.logInfo("**Test Run** - not actually importing items.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isExcludeContent = commandLine.hasOption('x');
|
||||||
|
|
||||||
if (commandLine.hasOption('p')) {
|
if (commandLine.hasOption('p')) {
|
||||||
template = true;
|
template = true;
|
||||||
}
|
}
|
||||||
@@ -204,6 +207,7 @@ public class ItemImport extends DSpaceRunnable<ItemImportScriptConfiguration> {
|
|||||||
.getItemImportService();
|
.getItemImportService();
|
||||||
try {
|
try {
|
||||||
itemImportService.setTest(isTest);
|
itemImportService.setTest(isTest);
|
||||||
|
itemImportService.setExcludeContent(isExcludeContent);
|
||||||
itemImportService.setResume(isResume);
|
itemImportService.setResume(isResume);
|
||||||
itemImportService.setUseWorkflow(useWorkflow);
|
itemImportService.setUseWorkflow(useWorkflow);
|
||||||
itemImportService.setUseWorkflowSendEmail(useWorkflowSendEmail);
|
itemImportService.setUseWorkflowSendEmail(useWorkflowSendEmail);
|
||||||
|
@@ -55,6 +55,9 @@ public class ItemImportCLIScriptConfiguration extends ItemImportScriptConfigurat
|
|||||||
options.addOption(Option.builder("v").longOpt("validate")
|
options.addOption(Option.builder("v").longOpt("validate")
|
||||||
.desc("test run - do not actually import items")
|
.desc("test run - do not actually import items")
|
||||||
.hasArg(false).required(false).build());
|
.hasArg(false).required(false).build());
|
||||||
|
options.addOption(Option.builder("x").longOpt("exclude-bitstreams")
|
||||||
|
.desc("do not load or expect content bitstreams")
|
||||||
|
.hasArg(false).required(false).build());
|
||||||
options.addOption(Option.builder("p").longOpt("template")
|
options.addOption(Option.builder("p").longOpt("template")
|
||||||
.desc("apply template")
|
.desc("apply template")
|
||||||
.hasArg(false).required(false).build());
|
.hasArg(false).required(false).build());
|
||||||
|
@@ -81,6 +81,9 @@ public class ItemImportScriptConfiguration<T extends ItemImport> extends ScriptC
|
|||||||
options.addOption(Option.builder("v").longOpt("validate")
|
options.addOption(Option.builder("v").longOpt("validate")
|
||||||
.desc("test run - do not actually import items")
|
.desc("test run - do not actually import items")
|
||||||
.hasArg(false).required(false).build());
|
.hasArg(false).required(false).build());
|
||||||
|
options.addOption(Option.builder("x").longOpt("exclude-bitstreams")
|
||||||
|
.desc("do not load or expect content bitstreams")
|
||||||
|
.hasArg(false).required(false).build());
|
||||||
options.addOption(Option.builder("p").longOpt("template")
|
options.addOption(Option.builder("p").longOpt("template")
|
||||||
.desc("apply template")
|
.desc("apply template")
|
||||||
.hasArg(false).required(false).build());
|
.hasArg(false).required(false).build());
|
||||||
|
@@ -62,6 +62,7 @@ import org.apache.commons.io.FileUtils;
|
|||||||
import org.apache.commons.lang3.RandomStringUtils;
|
import org.apache.commons.lang3.RandomStringUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.app.itemimport.service.ItemImportService;
|
import org.dspace.app.itemimport.service.ItemImportService;
|
||||||
import org.dspace.app.util.LocalSchemaFilenameFilter;
|
import org.dspace.app.util.LocalSchemaFilenameFilter;
|
||||||
@@ -135,7 +136,7 @@ import org.xml.sax.SAXException;
|
|||||||
* allow the registration of files (bitstreams) into DSpace.
|
* allow the registration of files (bitstreams) into DSpace.
|
||||||
*/
|
*/
|
||||||
public class ItemImportServiceImpl implements ItemImportService, InitializingBean {
|
public class ItemImportServiceImpl implements ItemImportService, InitializingBean {
|
||||||
private final Logger log = org.apache.logging.log4j.LogManager.getLogger(ItemImportServiceImpl.class);
|
private final Logger log = LogManager.getLogger();
|
||||||
|
|
||||||
private DSpaceRunnableHandler handler;
|
private DSpaceRunnableHandler handler;
|
||||||
|
|
||||||
@@ -181,6 +182,7 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
|
|||||||
protected String tempWorkDir;
|
protected String tempWorkDir;
|
||||||
|
|
||||||
protected boolean isTest = false;
|
protected boolean isTest = false;
|
||||||
|
protected boolean isExcludeContent = false;
|
||||||
protected boolean isResume = false;
|
protected boolean isResume = false;
|
||||||
protected boolean useWorkflow = false;
|
protected boolean useWorkflow = false;
|
||||||
protected boolean useWorkflowSendEmail = false;
|
protected boolean useWorkflowSendEmail = false;
|
||||||
@@ -1403,6 +1405,10 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
|
|||||||
protected void processContentFileEntry(Context c, Item i, String path,
|
protected void processContentFileEntry(Context c, Item i, String path,
|
||||||
String fileName, String bundleName, boolean primary) throws SQLException,
|
String fileName, String bundleName, boolean primary) throws SQLException,
|
||||||
IOException, AuthorizeException {
|
IOException, AuthorizeException {
|
||||||
|
if (isExcludeContent) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String fullpath = path + File.separatorChar + fileName;
|
String fullpath = path + File.separatorChar + fileName;
|
||||||
|
|
||||||
// get an input stream
|
// get an input stream
|
||||||
@@ -2342,6 +2348,11 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
|
|||||||
this.isTest = isTest;
|
this.isTest = isTest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setExcludeContent(boolean isExcludeContent) {
|
||||||
|
this.isExcludeContent = isExcludeContent;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setResume(boolean isResume) {
|
public void setResume(boolean isResume) {
|
||||||
this.isResume = isResume;
|
this.isResume = isResume;
|
||||||
|
@@ -211,6 +211,13 @@ public interface ItemImportService {
|
|||||||
*/
|
*/
|
||||||
public void setTest(boolean isTest);
|
public void setTest(boolean isTest);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set exclude-content flag.
|
||||||
|
*
|
||||||
|
* @param isExcludeContent true or false
|
||||||
|
*/
|
||||||
|
public void setExcludeContent(boolean isExcludeContent);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set resume flag
|
* Set resume flag
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user