org.dspace.content.packager
Class PackageUtils

java.lang.Object
  extended by org.dspace.content.packager.PackageUtils

public class PackageUtils
extends Object

Container class for code that is useful to many packagers.

Version:
$Revision: 3761 $
Author:
Larry Stone

Nested Class Summary
static class PackageUtils.UnclosableInputStream
          Stream wrapper that does not allow its wrapped stream to be closed.
 
Constructor Summary
PackageUtils()
           
 
Method Summary
static void addDepositLicense(Context context, String license, Item item, Collection collection)
          Add DSpace Deposit License to an Item.
static void checkMetadata(Item item)
          Test that item has adequate metadata.
static BitstreamFormat findOrCreateBitstreamFormat(Context context, String shortDesc, String MIMEType, String desc)
          Find or create a bitstream format to match the given short description.
static Bitstream getBitstreamByFormat(Item item, BitstreamFormat bsf, String bnName)
          Find bitstream by its format, looking in a specific bundle.
static Bitstream getBitstreamByName(Item item, String name)
          Find bitstream by its Name, looking in all bundles.
static Bitstream getBitstreamByName(Item item, String bsName, String bnName)
          Find bitstream by its Name, looking in specific named bundle.
static boolean isMetaInfoBundle(Bundle bn)
          Predicate, does this bundle container meta-information.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PackageUtils

public PackageUtils()
Method Detail

checkMetadata

public static void checkMetadata(Item item)
                          throws PackageValidationException
Test that item has adequate metadata. Check item for the minimal DC metadata required to ingest a new item, and throw a PackageValidationException if test fails. Used by all SIP processors as a common sanity test.

Parameters:
item - - item to test.
Throws:
PackageValidationException

addDepositLicense

public static void addDepositLicense(Context context,
                                     String license,
                                     Item item,
                                     Collection collection)
                              throws SQLException,
                                     IOException,
                                     AuthorizeException
Add DSpace Deposit License to an Item. Utility function to add the a user-supplied deposit license or a default one if none was given; creates new bitstream in the "LICENSE" bundle and gives it the special license bitstream format.

Parameters:
context - - dspace context
license - - license string to add, may be null to invoke default.
item - - the item.
collection - - get the default license from here.
Throws:
SQLException
IOException
AuthorizeException

getBitstreamByName

public static Bitstream getBitstreamByName(Item item,
                                           String name)
                                    throws SQLException
Find bitstream by its Name, looking in all bundles.

Parameters:
item - Item whose bitstreams to search.
name - Bitstream's name to match.
Returns:
first bitstream found or null.
Throws:
SQLException

getBitstreamByName

public static Bitstream getBitstreamByName(Item item,
                                           String bsName,
                                           String bnName)
                                    throws SQLException
Find bitstream by its Name, looking in specific named bundle.

Parameters:
item - - dspace item whose bundles to search.
bsName - - name of bitstream to match.
bnName - - bundle name to match, or null for all.
Returns:
the format found or null if none found.
Throws:
SQLException

getBitstreamByFormat

public static Bitstream getBitstreamByFormat(Item item,
                                             BitstreamFormat bsf,
                                             String bnName)
                                      throws SQLException
Find bitstream by its format, looking in a specific bundle. Used to look for particularly-typed Package Manifest bitstreams.

Parameters:
item - - dspace item whose bundles to search.
bsf - - BitstreamFormat object to match.
bnName - - bundle name to match, or null for all.
Returns:
the format found or null if none found.
Throws:
SQLException

isMetaInfoBundle

public static boolean isMetaInfoBundle(Bundle bn)
Predicate, does this bundle container meta-information. I.e. does this bundle contain descriptive metadata or other metadata such as license bitstreams? If so we probablly don't want to put it into the "content" section of a package; hence this predicate.

Parameters:
bn - -- the bundle
Returns:
true if this bundle name indicates it is a meta-info bundle.

findOrCreateBitstreamFormat

public static BitstreamFormat findOrCreateBitstreamFormat(Context context,
                                                          String shortDesc,
                                                          String MIMEType,
                                                          String desc)
                                                   throws SQLException,
                                                          AuthorizeException
Find or create a bitstream format to match the given short description. Used by packager ingesters to obtain a special bitstream format for the manifest (and/or metadata) file.

NOTE: When creating a new format, do NOT set any extensions, since we don't want any file with the same extension, which may be something generic like ".xml", to accidentally get set to this format.

Parameters:
context - - the context.
shortDesc - - short descriptive name, used to locate existing format.
MIMEtype - - mime content-type
desc - - long description
Returns:
BitstreamFormat object that was found or created. Never null.
Throws:
SQLException
AuthorizeException


Copyright © 2010 DuraSpace. All Rights Reserved.