mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-10 03:23:13 +00:00
Slightly refactored code again -- callers don't need METS.jar
git-svn-id: http://scm.dspace.org/svn/repo/trunk@931 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -52,6 +52,7 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.sql.SQLException;
|
||||
@@ -244,12 +245,10 @@ public class METSExport
|
||||
throw new IOException("Couldn't create " + aipDir.toString());
|
||||
}
|
||||
|
||||
Mets mets = createMETS(context, item);
|
||||
|
||||
// Write the METS file
|
||||
FileOutputStream out = new FileOutputStream(
|
||||
aipDir.toString() + java.io.File.separator + "mets.xml");
|
||||
mets.write(new MetsWriter(out));
|
||||
writeMETS(context, item, out);
|
||||
out.close();
|
||||
|
||||
// Write bitstreams
|
||||
@@ -276,13 +275,16 @@ public class METSExport
|
||||
|
||||
|
||||
/**
|
||||
* Write METS metadata corresponding to the metadata for an item
|
||||
*
|
||||
* @param context DSpace context
|
||||
* @param item DSpace item to create METS object for
|
||||
* @return METS object for DSpace item
|
||||
*/
|
||||
public static Mets createMETS(Context context, Item item)
|
||||
throws SQLException, IOException, AuthorizeException, MetsException
|
||||
public static void writeMETS(Context context, Item item, OutputStream os)
|
||||
throws SQLException, IOException, AuthorizeException
|
||||
{
|
||||
try
|
||||
{
|
||||
init(context);
|
||||
|
||||
@@ -448,7 +450,15 @@ public class METSExport
|
||||
|
||||
mets.validate(new MetsValidator());
|
||||
|
||||
return mets;
|
||||
mets.write(new MetsWriter(os));
|
||||
}
|
||||
catch (MetsException e)
|
||||
{
|
||||
// We don't pass up a MetsException, so callers don't need to
|
||||
// know the details of the METS toolkit
|
||||
e.printStackTrace();
|
||||
throw new IOException (e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user