public class ItemImportServiceImpl extends Object implements ItemImportService, org.springframework.beans.factory.InitializingBean
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.
| Modifier and Type | Field and Description |
|---|---|
protected AuthorizeService |
authorizeService |
protected BitstreamFormatService |
bitstreamFormatService |
protected BitstreamService |
bitstreamService |
protected BundleService |
bundleService |
protected CollectionService |
collectionService |
protected FilenameFilter |
directoryFilter |
protected EPersonService |
ePersonService |
protected GroupService |
groupService |
protected HandleService |
handleService |
protected InstallItemService |
installItemService |
protected boolean |
isQuiet |
protected boolean |
isResume |
protected boolean |
isTest |
protected ItemService |
itemService |
protected MetadataFieldService |
metadataFieldService |
protected FilenameFilter |
metadataFileFilter |
protected MetadataSchemaService |
metadataSchemaService |
protected ResourcePolicyService |
resourcePolicyService |
protected String |
tempWorkDir |
protected boolean |
useWorkflow |
protected boolean |
useWorkflowSendEmail |
protected WorkflowService |
workflowService |
protected WorkspaceItemService |
workspaceItemService |
| Modifier | Constructor and Description |
|---|---|
protected |
ItemImportServiceImpl() |
| Modifier and Type | Method and Description |
|---|---|
void |
addBTEItems(Context c,
List<Collection> mycollections,
String sourceDir,
String mapFile,
boolean template,
String inputType,
String workingDir)
In this method, the BTE is instantiated.
|
protected void |
addDCValue(Context c,
Item i,
String schema,
Node n) |
protected Item |
addItem(Context c,
List<Collection> mycollections,
String path,
String itemname,
PrintWriter mapOut,
boolean template)
item? try and add it to the archive.
|
void |
addItems(Context c,
List<Collection> mycollections,
String sourceDir,
String mapFile,
boolean template)
Add items
|
void |
addItemsAtomic(Context c,
List<Collection> mycollections,
String sourceDir,
String mapFile,
boolean template) |
void |
afterPropertiesSet() |
void |
cleanupZipTemp()
Cleanup
|
void |
deleteBatchUpload(Context c,
String uploadId)
Delete a batch by ID
|
protected boolean |
deleteDirectory(File path)
Delete a directory and its child files and directories
|
protected void |
deleteItem(Context c,
Item myitem) |
protected void |
deleteItem(Context c,
String myhandle) |
void |
deleteItems(Context c,
String mapFile)
Delete items via mapfile
|
void |
emailErrorMessage(EPerson eperson,
String error)
Since the BTE batch import is done in a new thread we are unable to communicate
with calling method about success or failure.
|
void |
emailSuccessMessage(Context context,
EPerson eperson,
String fileName)
Since the BTE batch import is done in a new thread we are unable to communicate
with calling method about success or failure.
|
protected String |
generateRandomFilename(boolean hidden)
Generate a random filename based on current time
|
List<BatchUpload> |
getImportsAvailable(EPerson eperson)
Get imports available for a person
|
String |
getImportUploadableDirectory(EPerson ePerson)
Get import upload directory
|
protected String |
getStringValue(Node node)
Return the String value of a Node.
|
String |
getTempWorkDir()
Get temporary work directory
|
File |
getTempWorkDirFile()
Get temporary work directory (as File)
|
protected void |
loadDublinCore(Context c,
Item myitem,
String filename) |
protected void |
loadMetadata(Context c,
Item myitem,
String path) |
protected Document |
loadXML(String filename)
Load in the XML from file.
|
protected List<Collection> |
processCollectionFile(Context c,
String path,
String filename)
Read the collections file inside the item directory.
|
protected void |
processContentFileEntry(Context c,
Item i,
String path,
String fileName,
String bundleName,
boolean primary)
each entry represents a bitstream....
|
protected List<String> |
processContentsFile(Context c,
Item i,
String path,
String filename)
Given a contents file and an item, stuffing it with bitstreams from the
contents file Returns a List of Strings with lines from the contents
file that request non-default bitstream permission
|
protected String |
processHandleFile(Context c,
Item i,
String path,
String filename)
Read in the handle file contents or return null if empty or doesn't exist
|
protected void |
processOptions(Context c,
Item myItem,
List<String> options)
Process the Options to apply to the Item.
|
void |
processUIImport(String filepath,
Collection owningCollection,
String[] otherCollections,
String resumeDir,
String inputType,
Context context,
boolean template)
Given a local file or public URL to a zip file that has the Simple Archive Format, this method imports the contents to DSpace
|
protected Map<String,String> |
readMapFile(String filename) |
protected void |
registerBitstream(Context c,
Item i,
int assetstore,
String bitstreamPath,
String bundleName,
String description)
Register the bitstream file into DSpace
|
void |
replaceItems(Context c,
List<Collection> mycollections,
String sourceDir,
String mapFile,
boolean template)
Replace items
|
protected void |
setPermission(Context c,
Group g,
int actionID,
Bitstream bs)
Set the Permission on a Bitstream.
|
void |
setQuiet(boolean isQuiet)
Set quiet flag
|
void |
setResume(boolean isResume)
Set resume flag
|
void |
setTest(boolean isTest)
Set test flag
|
void |
setUseWorkflow(boolean useWorkflow)
Set use workflow
|
void |
setUseWorkflowSendEmail(boolean useWorkflowSendEmail) |
String |
unzip(File zipfile)
Unzip a file
|
String |
unzip(File zipfile,
String destDir)
Unzip a file to a destination
|
String |
unzip(String sourcedir,
String zipfilename)
Unzip a file in a specific source directory
|
@Autowired(required=true) protected AuthorizeService authorizeService
@Autowired(required=true) protected BitstreamService bitstreamService
@Autowired(required=true) protected BitstreamFormatService bitstreamFormatService
@Autowired(required=true) protected BundleService bundleService
@Autowired(required=true) protected CollectionService collectionService
@Autowired(required=true) protected EPersonService ePersonService
@Autowired(required=true) protected HandleService handleService
@Autowired(required=true) protected ItemService itemService
@Autowired(required=true) protected InstallItemService installItemService
@Autowired(required=true) protected GroupService groupService
@Autowired(required=true) protected MetadataFieldService metadataFieldService
@Autowired(required=true) protected MetadataSchemaService metadataSchemaService
@Autowired(required=true) protected ResourcePolicyService resourcePolicyService
@Autowired(required=true) protected WorkspaceItemService workspaceItemService
@Autowired(required=true) protected WorkflowService workflowService
protected final String tempWorkDir
protected boolean isTest
protected boolean isResume
protected boolean useWorkflow
protected boolean useWorkflowSendEmail
protected boolean isQuiet
protected FilenameFilter metadataFileFilter
protected FilenameFilter directoryFilter
public void afterPropertiesSet()
throws Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanExceptionpublic void addBTEItems(Context c, List<Collection> mycollections, String sourceDir, String mapFile, boolean template, String inputType, String workingDir) throws Exception
addBTEItems in interface ItemImportServicec - The contectmycollections - The collections the items are inserted tosourceDir - The filepath to the file to read data frommapFile - The filepath to mapfile to be generatedtemplate - whether to use collection template item as starting pointinputType - The type of the input data (bibtex, csv, etc.)workingDir - The path to create temporary files (for command line or UI based)Exception - if error occurspublic void addItemsAtomic(Context c, List<Collection> mycollections, String sourceDir, String mapFile, boolean template) throws Exception
addItemsAtomic in interface ItemImportServicec - DSpace Contextmycollections - List of CollectionssourceDir - source locationmapFile - map filetemplate - whether to use template itemException - if errorpublic void addItems(Context c, List<Collection> mycollections, String sourceDir, String mapFile, boolean template) throws Exception
ItemImportServiceaddItems in interface ItemImportServicec - DSpace Contextmycollections - List of CollectionssourceDir - source locationmapFile - map filetemplate - whether to use template itemException - if errorpublic void replaceItems(Context c, List<Collection> mycollections, String sourceDir, String mapFile, boolean template) throws Exception
ItemImportServicereplaceItems in interface ItemImportServicec - DSpace Contextmycollections - List of CollectionssourceDir - source directorymapFile - map filetemplate - whether to use template itemException - if errorpublic void deleteItems(Context c, String mapFile) throws Exception
ItemImportServicedeleteItems in interface ItemImportServicec - DSpace ContextmapFile - map fileException - if errorprotected Item addItem(Context c, List<Collection> mycollections, String path, String itemname, PrintWriter mapOut, boolean template) throws Exception
c - current Contextmycollections - - add item to these Collections.path - - directory containing the item directories.itemname - handle - non-null means we have a pre-defined handle alreadymapOut - - mapfile we're writingtemplate - whether to use collection template item as starting pointException - if error occursprotected Map<String,String> readMapFile(String filename) throws Exception
Exceptionprotected void loadMetadata(Context c, Item myitem, String path) throws SQLException, IOException, ParserConfigurationException, SAXException, TransformerException, AuthorizeException
protected void loadDublinCore(Context c, Item myitem, String filename) throws SQLException, IOException, ParserConfigurationException, SAXException, TransformerException, AuthorizeException
protected void addDCValue(Context c, Item i, String schema, Node n) throws TransformerException, SQLException, AuthorizeException
protected List<Collection> processCollectionFile(Context c, String path, String filename) throws IOException, SQLException
c - The contextpath - The path to the data directory for this itemfilename - The collections file filename. Should be "collections"IOException - if IO errorSQLException - if database errorprotected String processHandleFile(Context c, Item i, String path, String filename)
c - DSpace contexti - DSpace itempath - path to handle filefilename - name of fileprotected List<String> processContentsFile(Context c, Item i, String path, String filename) throws SQLException, IOException, AuthorizeException
c - DSpace Contexti - DSpace itempath - path as stringfilename - file nameSQLException - if database errorIOException - if IO errorAuthorizeException - if authorization errorprotected void processContentFileEntry(Context c, Item i, String path, String fileName, String bundleName, boolean primary) throws SQLException, IOException, AuthorizeException
c - DSpace Contexti - Dspace Itempath - path to filefileName - file namebundleName - bundle nameprimary - if primary bitstreamSQLException - if database errorIOException - if IO errorAuthorizeException - if authorization errorprotected void registerBitstream(Context c, Item i, int assetstore, String bitstreamPath, String bundleName, String description) throws SQLException, IOException, AuthorizeException
c - DSpace Contexti - DSpace Itemassetstore - assetstore numberbitstreamPath - the full filepath expressed in the contents filebundleName - bundle namedescription - bitstream descriptionSQLException - if database errorIOException - if IO errorAuthorizeException - if authorization errorprotected void processOptions(Context c, Item myItem, List<String> options) throws SQLException, AuthorizeException
48217870-MIT.pdf permissions: -r 'MIT Users' description: Full printable version (MIT only)
permissions:[r|w]-['group name']
description: 'the description of the file'
where:
[r|w] (meaning: read|write)
['MIT Users'] (the group name)
c - DSpace ContextmyItem - DSpace Itemoptions - List of option stringsSQLException - if database errorAuthorizeException - if authorization errorprotected void setPermission(Context c, Group g, int actionID, Bitstream bs) throws SQLException, AuthorizeException
c - DSpace Contextg - Dspace GroupactionID - action identifierbs - BitstreamSQLException - if database errorAuthorizeException - if authorization errorConstantsprotected String getStringValue(Node node)
node - nodeprotected Document loadXML(String filename) throws IOException, ParserConfigurationException, SAXException
filename - the filename to load fromIOException - if IO errorParserConfigurationException - if config errorSAXException - if XML errorprotected boolean deleteDirectory(File path)
path - The directory to deletepublic String unzip(File zipfile) throws IOException
ItemImportServiceunzip in interface ItemImportServicezipfile - fileIOException - if errorpublic String unzip(File zipfile, String destDir) throws IOException
ItemImportServiceunzip in interface ItemImportServicezipfile - filedestDir - destination directoryIOException - if errorpublic String unzip(String sourcedir, String zipfilename) throws IOException
ItemImportServiceunzip in interface ItemImportServicesourcedir - source directoryzipfilename - file nameIOException - if errorprotected String generateRandomFilename(boolean hidden)
hidden - set to add . as a prefix to make the file hiddenpublic void processUIImport(String filepath, Collection owningCollection, String[] otherCollections, String resumeDir, String inputType, Context context, boolean template) throws Exception
processUIImport in interface ItemImportServicefilepath - The filepath to local file or the public URL of the zip fileowningCollection - The owning collection the items will belong tootherCollections - The collections the created items will be inserted to, apart from the owning oneresumeDir - In case of a resume request, the directory that containsthe old mapfile and datainputType - The input type of the data (bibtex, csv, etc.), in case of local filecontext - The contexttemplate - whether to use template itemException - if errorpublic void emailSuccessMessage(Context context, EPerson eperson, String fileName) throws javax.mail.MessagingException
ItemImportServiceemailSuccessMessage in interface ItemImportServicecontext - - the current Contexteperson - - eperson to send the email tofileName - - the filepath to the mapfile created by the batch importjavax.mail.MessagingException - if errorpublic void emailErrorMessage(EPerson eperson, String error) throws javax.mail.MessagingException
ItemImportServiceemailErrorMessage in interface ItemImportServiceeperson - - EPerson to send the error message toerror - - the error messagejavax.mail.MessagingException - if errorpublic List<BatchUpload> getImportsAvailable(EPerson eperson) throws Exception
ItemImportServicegetImportsAvailable in interface ItemImportServiceeperson - EPerson objectException - if errorpublic String getImportUploadableDirectory(EPerson ePerson) throws Exception
ItemImportServicegetImportUploadableDirectory in interface ItemImportServiceePerson - EPerson objectException - if errorpublic void deleteBatchUpload(Context c, String uploadId) throws Exception
ItemImportServicedeleteBatchUpload in interface ItemImportServicec - DSpace ContextuploadId - identifierException - if errorpublic String getTempWorkDir()
ItemImportServicegetTempWorkDir in interface ItemImportServicepublic File getTempWorkDirFile()
ItemImportServicegetTempWorkDirFile in interface ItemImportServicepublic void cleanupZipTemp()
ItemImportServicecleanupZipTemp in interface ItemImportServicepublic void setTest(boolean isTest)
ItemImportServicesetTest in interface ItemImportServiceisTest - true or falsepublic void setResume(boolean isResume)
ItemImportServicesetResume in interface ItemImportServiceisResume - true or falsepublic void setUseWorkflow(boolean useWorkflow)
ItemImportServicesetUseWorkflow in interface ItemImportServiceuseWorkflow - whether to enable workflowpublic void setUseWorkflowSendEmail(boolean useWorkflowSendEmail)
setUseWorkflowSendEmail in interface ItemImportServiceuseWorkflowSendEmail - whether to send mailpublic void setQuiet(boolean isQuiet)
ItemImportServicesetQuiet in interface ItemImportServiceisQuiet - true or falseCopyright © 2016 DuraSpace. All rights reserved.