public class ItemExportServiceImpl extends Object implements ItemExportService
ItemExport creates the simple AIP package that the importer also uses. It consists of:
/exportdir/42/ (one directory per item) / dublin_core.xml - qualified dublin core in RDF schema / contents - text file, listing one file per line / file1 - files contained in the item / file2 / ...
issues -doesn't handle special characters in metadata (needs to turn &'s into &, etc.)
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 BitstreamService |
bitstreamService |
protected CommunityService |
communityService |
protected EPersonService |
ePersonService |
protected HandleService |
handleService |
protected ItemService |
itemService |
protected int |
SUBDIR_LIMIT |
COMPRESSED_EXPORT_MIME_TYPE| Modifier | Constructor and Description |
|---|---|
protected |
ItemExportServiceImpl() |
| Modifier and Type | Method and Description |
|---|---|
String |
assembleFileName(String type,
EPerson eperson,
Date date)
Create a file name based on the date and eperson
|
boolean |
canDownload(Context context,
String fileName)
The file name of the export archive contains the eperson id of the person
who created it When requested for download this method can check if the
person requesting it is the same one that created it
|
void |
createDownloadableExport(DSpaceObject dso,
Context context,
boolean migrate)
Convenience methot to create export a single Community, Collection, or
Item
|
void |
createDownloadableExport(DSpaceObject dso,
Context context,
String additionalEmail,
boolean migrate)
Convenience methot to create export a single Community, Collection, or
Item
|
void |
createDownloadableExport(List<DSpaceObject> dsObjects,
Context context,
boolean migrate)
Convenience method to export a List of dspace objects (Community,
Collection or Item)
|
void |
createDownloadableExport(List<DSpaceObject> dsObjects,
Context context,
String additionalEmail,
boolean migrate)
Convenience method to export a List of dspace objects (Community,
Collection or Item)
|
protected boolean |
deleteDirectory(File path) |
void |
deleteOldExportArchives()
A clean up method that is ran before a new export archive is created.
|
void |
deleteOldExportArchives(EPerson eperson)
A clean up method that is ran before a new export archive is created.
|
void |
emailErrorMessage(EPerson eperson,
String error)
Since the archive is created 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 archive is created in a new thread we are unable to communicate
with calling method about success or failure.
|
void |
exportAsZip(Context context,
Iterator<Item> items,
String destDirName,
String zipFileName,
int seqStart,
boolean migrate,
boolean excludeBitstreams)
Method to perform an export and save it as a zip file.
|
protected void |
exportItem(Context c,
Item myItem,
String destDirName,
int seqStart,
boolean migrate,
boolean excludeBitstreams) |
void |
exportItem(Context c,
Iterator<Item> i,
String destDirName,
int seqStart,
boolean migrate,
boolean excludeBitstreams) |
protected EPerson |
getEPersonFromString(Context context,
String strID) |
String |
getExportDownloadDirectory(EPerson ePerson)
Use config file entry for org.dspace.app.itemexport.download.dir and id
of the eperson to create a download directory name
|
InputStream |
getExportDownloadInputStream(String fileName,
EPerson eperson)
Used to read the export archived.
|
long |
getExportFileLastModified(Context context,
String fileName) |
long |
getExportFileSize(Context context,
String fileName)
Get the file size of the export archive represented by the file name.
|
List<String> |
getExportsAvailable(EPerson eperson)
Reads the download directory for the eperson to see if any export
archives are available
|
String |
getExportWorkDirectory()
Returns config file entry for org.dspace.app.itemexport.work.dir
|
protected void |
processDownloadableExport(List<DSpaceObject> dsObjects,
Context context,
String additionalEmail,
boolean toMigrate)
Does the work creating a List with all the Items in the Community or
Collection It then kicks off a new Thread to export the items, zip the
export directory and send confirmation email
|
protected void |
writeBitstreams(Context c,
Item i,
File destDir,
boolean excludeBitstreams)
Create both the bitstreams and the contents file.
|
protected void |
writeHandle(Context c,
Item i,
File destDir) |
protected void |
writeMetadata(Context c,
Item i,
File destDir,
boolean migrate)
Discover the different schemas in use and output a separate metadata XML
file for each schema.
|
protected void |
writeMetadata(Context c,
String schema,
Item i,
File destDir,
boolean migrate) |
void |
zip(String strSource,
String target) |
protected void |
zipFiles(File cpFile,
String strSource,
String strTarget,
ZipOutputStream cpZipOutputStream) |
protected final int SUBDIR_LIMIT
@Autowired(required=true) protected BitstreamService bitstreamService
@Autowired(required=true) protected CommunityService communityService
@Autowired(required=true) protected EPersonService ePersonService
@Autowired(required=true) protected ItemService itemService
@Autowired(required=true) protected HandleService handleService
public void exportItem(Context c, Iterator<Item> i, String destDirName, int seqStart, boolean migrate, boolean excludeBitstreams) throws Exception
exportItem in interface ItemExportServiceExceptionprotected void exportItem(Context c, Item myItem, String destDirName, int seqStart, boolean migrate, boolean excludeBitstreams) throws Exception
Exceptionprotected void writeMetadata(Context c, Item i, File destDir, boolean migrate) throws Exception
c - i - destDir - Exceptionprotected void writeMetadata(Context c, String schema, Item i, File destDir, boolean migrate) throws Exception
Exceptionprotected void writeHandle(Context c, Item i, File destDir) throws Exception
Exceptionprotected void writeBitstreams(Context c, Item i, File destDir, boolean excludeBitstreams) throws Exception
c - the DSpace contexti - the item being exporteddestDir - the item's export directoryException - if there is any problem writing to the export directorypublic void exportAsZip(Context context, Iterator<Item> items, String destDirName, String zipFileName, int seqStart, boolean migrate, boolean excludeBitstreams) throws Exception
ItemExportServiceexportAsZip in interface ItemExportServicecontext - The DSpace Contextitems - The items to exportdestDirName - The directory to save the export inzipFileName - The name to save the zip file asseqStart - The first number in the sequencemigrate - Whether to use the migrate option or notExceptionpublic void createDownloadableExport(DSpaceObject dso, Context context, boolean migrate) throws Exception
ItemExportServicecreateDownloadableExport in interface ItemExportServicedso - - the dspace object to exportcontext - - the dspace contextExceptionpublic void createDownloadableExport(List<DSpaceObject> dsObjects, Context context, boolean migrate) throws Exception
ItemExportServicecreateDownloadableExport in interface ItemExportServicedsObjects - - List containing dspace objectscontext - - the dspace contextExceptionpublic void createDownloadableExport(DSpaceObject dso, Context context, String additionalEmail, boolean migrate) throws Exception
ItemExportServicecreateDownloadableExport in interface ItemExportServicedso - - the dspace object to exportcontext - - the dspace contextadditionalEmail - - cc email to useExceptionpublic void createDownloadableExport(List<DSpaceObject> dsObjects, Context context, String additionalEmail, boolean migrate) throws Exception
ItemExportServicecreateDownloadableExport in interface ItemExportServicedsObjects - - List containing dspace objectscontext - - the dspace contextadditionalEmail - - cc email to useExceptionprotected void processDownloadableExport(List<DSpaceObject> dsObjects, Context context, String additionalEmail, boolean toMigrate) throws Exception
dsObjects - - List of dspace objects to processcontext - - the dspace contextadditionalEmail - - email address to cc in addition the the current user emailExceptionpublic String assembleFileName(String type, EPerson eperson, Date date) throws Exception
ItemExportServiceassembleFileName in interface ItemExportServiceeperson - - eperson who requested export and will be able to download itdate - - the date the export process was createdExceptionpublic String getExportDownloadDirectory(EPerson ePerson) throws Exception
ItemExportServicegetExportDownloadDirectory in interface ItemExportServiceePerson - - the eperson who requested export archiveExceptionpublic String getExportWorkDirectory() throws Exception
ItemExportServicegetExportWorkDirectory in interface ItemExportServiceExceptionpublic InputStream getExportDownloadInputStream(String fileName, EPerson eperson) throws Exception
ItemExportServicegetExportDownloadInputStream in interface ItemExportServicefileName - the name of the file to downloadeperson - the eperson requesting the downloadExceptionpublic long getExportFileSize(Context context, String fileName) throws Exception
ItemExportServicegetExportFileSize in interface ItemExportServicefileName - name of the file to get the size.Exceptionprotected EPerson getEPersonFromString(Context context, String strID) throws SQLException
SQLExceptionpublic long getExportFileLastModified(Context context, String fileName) throws Exception
getExportFileLastModified in interface ItemExportServiceExceptionpublic boolean canDownload(Context context, String fileName)
ItemExportServicecanDownload in interface ItemExportServicecontext - dspace contextfileName - the file name to check auths forpublic List<String> getExportsAvailable(EPerson eperson) throws Exception
ItemExportServicegetExportsAvailable in interface ItemExportServiceExceptionpublic void deleteOldExportArchives(EPerson eperson) throws Exception
ItemExportServicedeleteOldExportArchives in interface ItemExportServiceeperson - - the eperson to clean upExceptionpublic void deleteOldExportArchives()
throws Exception
ItemExportServicedeleteOldExportArchives in interface ItemExportServiceExceptionpublic void emailSuccessMessage(Context context, EPerson eperson, String fileName) throws javax.mail.MessagingException
ItemExportServiceemailSuccessMessage in interface ItemExportServicecontext - - the current Contexteperson - - eperson to send the email tofileName - - the file name to be downloaded. It is added to the url in
the emailjavax.mail.MessagingExceptionpublic void emailErrorMessage(EPerson eperson, String error) throws javax.mail.MessagingException
ItemExportServiceemailErrorMessage in interface ItemExportServiceeperson - - EPerson to send the error message toerror - - the error messagejavax.mail.MessagingExceptionpublic void zip(String strSource, String target) throws Exception
zip in interface ItemExportServiceExceptionprotected void zipFiles(File cpFile, String strSource, String strTarget, ZipOutputStream cpZipOutputStream) throws Exception
Exceptionprotected boolean deleteDirectory(File path)
Copyright © 2016 DuraSpace. All Rights Reserved.