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:
Robert Tansley
2004-05-20 15:42:50 +00:00
parent 055a825fa2
commit 7574ff8da0

View File

@@ -52,6 +52,7 @@ import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException; import java.io.IOException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.sql.SQLException; import java.sql.SQLException;
@@ -244,12 +245,10 @@ public class METSExport
throw new IOException("Couldn't create " + aipDir.toString()); throw new IOException("Couldn't create " + aipDir.toString());
} }
Mets mets = createMETS(context, item);
// Write the METS file // Write the METS file
FileOutputStream out = new FileOutputStream( FileOutputStream out = new FileOutputStream(
aipDir.toString() + java.io.File.separator + "mets.xml"); aipDir.toString() + java.io.File.separator + "mets.xml");
mets.write(new MetsWriter(out)); writeMETS(context, item, out);
out.close(); out.close();
// Write bitstreams // Write bitstreams
@@ -276,13 +275,16 @@ public class METSExport
/** /**
* Write METS metadata corresponding to the metadata for an item
* *
* @param context DSpace context * @param context DSpace context
* @param item DSpace item to create METS object for * @param item DSpace item to create METS object for
* @return METS object for DSpace item * @return METS object for DSpace item
*/ */
public static Mets createMETS(Context context, Item item) public static void writeMETS(Context context, Item item, OutputStream os)
throws SQLException, IOException, AuthorizeException, MetsException throws SQLException, IOException, AuthorizeException
{
try
{ {
init(context); init(context);
@@ -448,7 +450,15 @@ public class METSExport
mets.validate(new MetsValidator()); 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());
}
} }