mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 18:14:26 +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.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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user