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) |
void |
addItemsAtomic(Context c,
List<Collection> mycollections,
String sourceDir,
String mapFile,
boolean template) |
void |
afterPropertiesSet() |
void |
cleanupZipTemp() |
void |
deleteBatchUpload(Context c,
String uploadId) |
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) |
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) |
String |
getImportUploadableDirectory(EPerson ePerson) |
protected String |
getStringValue(Node node)
Return the String value of a Node.
|
String |
getTempWorkDir() |
File |
getTempWorkDirFile() |
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 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) |
protected void |
setPermission(Context c,
Group g,
int actionID,
Bitstream bs)
Set the Permission on a Bitstream.
|
void |
setQuiet(boolean isQuiet) |
void |
setResume(boolean isResume) |
void |
setTest(boolean isTest) |
void |
setUseWorkflow(boolean useWorkflow) |
void |
setUseWorkflowSendEmail(boolean useWorkflowSendEmail) |
String |
unzip(File zipfile) |
String |
unzip(File zipfile,
String destDir) |
String |
unzip(String sourcedir,
String zipfilename) |
@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 - inputType - The type of the input data (bibtex, csv, etc.)workingDir - The path to create temporary files (for command line or UI based)Exceptionpublic void addItemsAtomic(Context c, List<Collection> mycollections, String sourceDir, String mapFile, boolean template) throws Exception
addItemsAtomic in interface ItemImportServiceExceptionpublic void addItems(Context c, List<Collection> mycollections, String sourceDir, String mapFile, boolean template) throws Exception
addItems in interface ItemImportServiceExceptionpublic void replaceItems(Context c, List<Collection> mycollections, String sourceDir, String mapFile, boolean template) throws Exception
replaceItems in interface ItemImportServiceExceptionpublic void deleteItems(Context c, String mapFile) throws Exception
deleteItems in interface ItemImportServiceExceptionprotected Item addItem(Context c, List<Collection> mycollections, String path, String itemname, PrintWriter mapOut, boolean template) throws Exception
mycollections - - 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 writingExceptionprotected 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"IOExceptionSQLExceptionprotected String processHandleFile(Context c, Item i, String path, String filename)
protected List<String> processContentsFile(Context c, Item i, String path, String filename) throws SQLException, IOException, AuthorizeException
protected void processContentFileEntry(Context c, Item i, String path, String fileName, String bundleName, boolean primary) throws SQLException, IOException, AuthorizeException
c - i - path - fileName - bundleName - SQLExceptionIOExceptionAuthorizeExceptionprotected void registerBitstream(Context c, Item i, int assetstore, String bitstreamPath, String bundleName, String description) throws SQLException, IOException, AuthorizeException
c - i - assetstore - bitstreamPath - the full filepath expressed in the contents filebundleName - SQLExceptionIOExceptionAuthorizeExceptionprotected void processOptions(Context c, Item myItem, List<String> options) throws SQLException, AuthorizeException
c - myItem - options - SQLExceptionAuthorizeExceptionprotected void setPermission(Context c, Group g, int actionID, Bitstream bs) throws SQLException, AuthorizeException
c - g - actionID - bs - SQLExceptionAuthorizeExceptionprotected String getStringValue(Node node)
node - protected Document loadXML(String filename) throws IOException, ParserConfigurationException, SAXException
filename - the filename to load fromIOExceptionParserConfigurationExceptionSAXExceptionprotected boolean deleteDirectory(File path)
path - The directory to deletepublic String unzip(File zipfile) throws IOException
unzip in interface ItemImportServiceIOExceptionpublic String unzip(File zipfile, String destDir) throws IOException
unzip in interface ItemImportServiceIOExceptionpublic String unzip(String sourcedir, String zipfilename) throws IOException
unzip in interface ItemImportServiceIOExceptionprotected String generateRandomFilename(boolean hidden)
hidden: - 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 contextExceptionpublic 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.MessagingExceptionpublic 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.MessagingExceptionpublic List<BatchUpload> getImportsAvailable(EPerson eperson) throws Exception
getImportsAvailable in interface ItemImportServiceExceptionpublic String getImportUploadableDirectory(EPerson ePerson) throws Exception
getImportUploadableDirectory in interface ItemImportServiceExceptionpublic void deleteBatchUpload(Context c, String uploadId) throws Exception
deleteBatchUpload in interface ItemImportServiceExceptionpublic String getTempWorkDir()
getTempWorkDir in interface ItemImportServicepublic File getTempWorkDirFile()
getTempWorkDirFile in interface ItemImportServicepublic void cleanupZipTemp()
cleanupZipTemp in interface ItemImportServicepublic void setTest(boolean isTest)
setTest in interface ItemImportServicepublic void setResume(boolean isResume)
setResume in interface ItemImportServicepublic void setUseWorkflow(boolean useWorkflow)
setUseWorkflow in interface ItemImportServicepublic void setUseWorkflowSendEmail(boolean useWorkflowSendEmail)
setUseWorkflowSendEmail in interface ItemImportServicepublic void setQuiet(boolean isQuiet)
setQuiet in interface ItemImportServiceCopyright © 2016 DuraSpace. All Rights Reserved.