org.dspace.content
Class Bundle

java.lang.Object
  extended by org.dspace.content.DSpaceObject
      extended by org.dspace.content.Bundle

public class Bundle
extends DSpaceObject

Class representing bundles of bitstreams stored in the DSpace system

The corresponding Bitstream objects are loaded into memory. At present, there is no metadata associated with bundles - they are simple containers. Thus, the update method doesn't do much yet. Creating, adding or removing bitstreams has instant effect in the database.

Version:
$Revision: 3036 $
Author:
Robert Tansley

Method Summary
 void addBitstream(Bitstream b)
          Add an existing bitstream to this bundle
 Bitstream createBitstream(InputStream is)
          Create a new bitstream in this bundle.
static Bundle find(Context context, int id)
          Get a bundle from the database.
 Bitstream getBitstreamByName(String name)
           
 Bitstream[] getBitstreams()
          Get the bitstreams in this bundle
 String getHandle()
          Get the Handle of the object.
 int getID()
          Get the internal identifier of this bundle
 Item[] getItems()
          Get the items this bundle appears in
 String getName()
          Get the name of the bundle
 int getPrimaryBitstreamID()
          Get the primary bitstream ID of the bundle
 int getType()
          return type found in Constants
 Bitstream registerBitstream(int assetstore, String bitstreamPath)
          Create a new bitstream in this bundle.
 void removeBitstream(Bitstream b)
          Remove a bitstream from this bundle - the bitstream is only deleted if this was the last reference to it
 void setName(String name)
          Set the name of the bundle
 void setPrimaryBitstreamID(int bitstreamID)
          Set the primary bitstream ID of the bundle
 void unsetPrimaryBitstreamID()
          Unset the primary bitstream ID of the bundle
 void update()
          Update the bundle metadata
 
Methods inherited from class org.dspace.content.DSpaceObject
addDetails, clearDetails, find, getDetails
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

find

public static Bundle find(Context context,
                          int id)
                   throws SQLException
Get a bundle from the database. The bundle and bitstream metadata are all loaded into memory.

Parameters:
context - DSpace context object
id - ID of the bundle
Returns:
the bundle, or null if the ID is invalid.
Throws:
SQLException

getID

public int getID()
Get the internal identifier of this bundle

Specified by:
getID in class DSpaceObject
Returns:
the internal identifier

getName

public String getName()
Get the name of the bundle

Specified by:
getName in class DSpaceObject
Returns:
name of the bundle (ORIGINAL, TEXT, THUMBNAIL) or NULL if not set

setName

public void setName(String name)
Set the name of the bundle

Parameters:
name - string name of the bundle (ORIGINAL, TEXT, THUMBNAIL) are the values currently used

getPrimaryBitstreamID

public int getPrimaryBitstreamID()
Get the primary bitstream ID of the bundle

Returns:
primary bitstream ID or -1 if not set

setPrimaryBitstreamID

public void setPrimaryBitstreamID(int bitstreamID)
Set the primary bitstream ID of the bundle

Parameters:
bitstreamID - int ID of primary bitstream (e.g. index html file)

unsetPrimaryBitstreamID

public void unsetPrimaryBitstreamID()
Unset the primary bitstream ID of the bundle


getHandle

public String getHandle()
Description copied from class: DSpaceObject
Get the Handle of the object. This may return null

Specified by:
getHandle in class DSpaceObject
Returns:
Handle of the object, or null if it doesn't have one

getBitstreamByName

public Bitstream getBitstreamByName(String name)
Parameters:
name - name of the bitstream you're looking for
Returns:
the bitstream or null if not found

getBitstreams

public Bitstream[] getBitstreams()
Get the bitstreams in this bundle

Returns:
the bitstreams

getItems

public Item[] getItems()
                throws SQLException
Get the items this bundle appears in

Returns:
array of Item s this bundle appears in
Throws:
SQLException

createBitstream

public Bitstream createBitstream(InputStream is)
                          throws AuthorizeException,
                                 IOException,
                                 SQLException
Create a new bitstream in this bundle.

Parameters:
is - the stream to read the new bitstream from
Returns:
the newly created bitstream
Throws:
AuthorizeException
IOException
SQLException

registerBitstream

public Bitstream registerBitstream(int assetstore,
                                   String bitstreamPath)
                            throws AuthorizeException,
                                   IOException,
                                   SQLException
Create a new bitstream in this bundle. This method is for registering bitstreams.

Parameters:
assetstore - corresponds to an assetstore in dspace.cfg
bitstreamPath - the path and filename relative to the assetstore
Returns:
the newly created bitstream
Throws:
IOException
SQLException
AuthorizeException

addBitstream

public void addBitstream(Bitstream b)
                  throws SQLException,
                         AuthorizeException
Add an existing bitstream to this bundle

Parameters:
b - the bitstream to add
Throws:
SQLException
AuthorizeException

removeBitstream

public void removeBitstream(Bitstream b)
                     throws AuthorizeException,
                            SQLException,
                            IOException
Remove a bitstream from this bundle - the bitstream is only deleted if this was the last reference to it

If the bitstream in question is the primary bitstream recorded for the bundle the primary bitstream field is unset in order to free the bitstream from the foreign key constraint so that the cleanup process can run normally.

Parameters:
b - the bitstream to remove
Throws:
AuthorizeException
SQLException
IOException

update

public void update()
            throws SQLException,
                   AuthorizeException
Update the bundle metadata

Throws:
SQLException
AuthorizeException

getType

public int getType()
return type found in Constants

Specified by:
getType in class DSpaceObject
Returns:
type of the object


Copyright © 2008 The DSpace Foundation. All Rights Reserved.