Package org.dspace.app.itemimport
Class ItemImport
- java.lang.Object
-
- org.dspace.scripts.DSpaceRunnable<ItemImportScriptConfiguration>
-
- org.dspace.app.itemimport.ItemImport
-
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
ItemImportCLI
public class ItemImport extends DSpaceRunnable<ItemImportScriptConfiguration>
Import items into DSpace. The conventional use is upload files by copying them. DSpace writes the item's bitstreams into its assetstore. Metadata is also loaded to the DSpace database.A second use assumes the bitstream files already exist in a storage resource accessible to DSpace. In this case the bitstreams are 'registered'. That is, the metadata is loaded to the DSpace database and DSpace is given the location of the file which is subsumed into DSpace.
The distinction is controlled by the format of lines in the 'contents' file. See comments in processContentsFile() below.
Modified by David Little, UCSD Libraries 12/21/04 to allow the registration of files (bitstreams) into DSpace.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.dspace.scripts.DSpaceRunnable
DSpaceRunnable.StepResult
-
-
Field Summary
Fields Modifier and Type Field Description protected String[]collectionsprotected static CollectionServicecollectionServiceprotected Stringcommandprotected booleancommandLineCollectionsprotected Stringepersonprotected static EPersonServiceepersonServiceprotected static HandleServicehandleServiceprotected booleanhelpprotected booleanisExcludeContentprotected booleanisQuietprotected booleanisResumeprotected booleanisTestprotected Stringmapfilestatic StringMAPFILE_BITSTREAM_TYPEstatic StringMAPFILE_FILENAMEprotected booleanremoteUrlprotected Stringsourcedirstatic StringTEMP_DIRprotected booleantemplateprotected booleanuseWorkflowprotected booleanuseWorkflowSendEmailprotected FileworkDirprotected FileworkFileprotected booleanzipprotected Stringzipfilenameprotected booleanzipvalid-
Fields inherited from class org.dspace.scripts.DSpaceRunnable
commandLine, handler, helpCommandLine
-
-
Constructor Summary
Constructors Constructor Description ItemImport()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ItemImportScriptConfigurationgetScriptConfiguration()This method will return the Configuration that the implementing DSpaceRunnable usesvoidinternalRun()This method has to be included in every script and this will be the main execution block for the script that'll contain all the logic neededprotected voidprocess(Context context, ItemImportService itemImportService, List<Collection> collections)Process the importprotected voidreadMapfile(Context context)Read the mapfileprotected voidreadZip(Context context, ItemImportService itemImportService)Read the ZIP archive in SAF formatprotected voidsetEPerson(Context context)Set the eperson in the contextprotected voidsetMapFile()Set the mapfile optionvoidsetup()This method has to be included in every script and handles the setup of the script by parsing the CommandLine and setting the variablesprotected voidsetZip()Set the zip optionprotected voidvalidate(Context context)Validate the optionsprotected voidvalidateZip(InputStream inputStream)Confirm that the zip file has the correct MIME type-
Methods inherited from class org.dspace.scripts.DSpaceRunnable
getEpersonIdentifier, getFileNamesFromInputStreamOptions, initialize, printHelp, run, setEpersonIdentifier
-
-
-
-
Field Detail
-
TEMP_DIR
public static String TEMP_DIR
-
MAPFILE_FILENAME
public static String MAPFILE_FILENAME
-
MAPFILE_BITSTREAM_TYPE
public static String MAPFILE_BITSTREAM_TYPE
-
template
protected boolean template
-
command
protected String command
-
sourcedir
protected String sourcedir
-
mapfile
protected String mapfile
-
eperson
protected String eperson
-
collections
protected String[] collections
-
isTest
protected boolean isTest
-
isExcludeContent
protected boolean isExcludeContent
-
isResume
protected boolean isResume
-
useWorkflow
protected boolean useWorkflow
-
useWorkflowSendEmail
protected boolean useWorkflowSendEmail
-
isQuiet
protected boolean isQuiet
-
commandLineCollections
protected boolean commandLineCollections
-
zip
protected boolean zip
-
remoteUrl
protected boolean remoteUrl
-
zipfilename
protected String zipfilename
-
zipvalid
protected boolean zipvalid
-
help
protected boolean help
-
workDir
protected File workDir
-
workFile
protected File workFile
-
collectionService
protected static final CollectionService collectionService
-
epersonService
protected static final EPersonService epersonService
-
handleService
protected static final HandleService handleService
-
-
Method Detail
-
getScriptConfiguration
public ItemImportScriptConfiguration getScriptConfiguration()
Description copied from class:DSpaceRunnableThis method will return the Configuration that the implementing DSpaceRunnable uses- Specified by:
getScriptConfigurationin classDSpaceRunnable<ItemImportScriptConfiguration>- Returns:
- The
ScriptConfigurationthat this implementing DspaceRunnable uses
-
setup
public void setup() throws org.apache.commons.cli.ParseExceptionDescription copied from class:DSpaceRunnableThis method has to be included in every script and handles the setup of the script by parsing the CommandLine and setting the variables- Specified by:
setupin classDSpaceRunnable<ItemImportScriptConfiguration>- Throws:
org.apache.commons.cli.ParseException- If something goes wrong
-
internalRun
public void internalRun() throws ExceptionDescription copied from class:DSpaceRunnableThis method has to be included in every script and this will be the main execution block for the script that'll contain all the logic needed- Specified by:
internalRunin classDSpaceRunnable<ItemImportScriptConfiguration>- Throws:
Exception- If something goes wrong
-
validate
protected void validate(Context context)
Validate the options- Parameters:
context-
-
process
protected void process(Context context, ItemImportService itemImportService, List<Collection> collections) throws Exception
Process the import- Parameters:
context-itemImportService-collections-- Throws:
Exception
-
readZip
protected void readZip(Context context, ItemImportService itemImportService) throws Exception
Read the ZIP archive in SAF format- Parameters:
context-itemImportService-- Throws:
Exception
-
validateZip
protected void validateZip(InputStream inputStream)
Confirm that the zip file has the correct MIME type- Parameters:
inputStream-
-
readMapfile
protected void readMapfile(Context context)
Read the mapfile- Parameters:
context-
-
setMapFile
protected void setMapFile() throws IOExceptionSet the mapfile option- Throws:
IOException
-
setZip
protected void setZip()
Set the zip option
-
setEPerson
protected void setEPerson(Context context) throws SQLException
Set the eperson in the context- Parameters:
context-- Throws:
SQLException
-
-