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: 4309 $
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.
 DSpaceObject getAdminObject(int action)
          Return the dspace object where an ADMIN action right is sufficient to grant the initial authorize check.
 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
 DSpaceObject getParentObject()
          Return the dspace object that "own" the current object in the hierarchy.
 int getPrimaryBitstreamID()
          Get the primary bitstream ID of the bundle
 int getType()
          return type found in Constants
 void inheritCollectionDefaultPolicies(Collection c)
          remove all policies on the bundle and its contents, and replace them with the DEFAULT_BITSTREAM_READ policies belonging to the collection.
 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 replaceAllBitstreamPolicies(List<ResourcePolicy> newpolicies)
          remove all of the policies for the bundle and bitstream contents and replace them with a new list of policies
 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

inheritCollectionDefaultPolicies

public void inheritCollectionDefaultPolicies(Collection c)
                                      throws SQLException,
                                             AuthorizeException
remove all policies on the bundle and its contents, and replace them with the DEFAULT_BITSTREAM_READ policies belonging to the collection.

Parameters:
c - Collection
Throws:
SQLException - if an SQL error or if no default policies found. It's a bit draconian, but default policies must be enforced.
AuthorizeException

replaceAllBitstreamPolicies

public void replaceAllBitstreamPolicies(List<ResourcePolicy> newpolicies)
                                 throws SQLException,
                                        AuthorizeException
remove all of the policies for the bundle and bitstream contents and replace them with a new list of policies

Parameters:
newpolicies - - this will be all of the new policies for the bundle and bitstream contents
Throws:
SQLException
AuthorizeException

getAdminObject

public DSpaceObject getAdminObject(int action)
                            throws SQLException
Description copied from class: DSpaceObject
Return the dspace object where an ADMIN action right is sufficient to grant the initial authorize check.

Default behaviour is ADMIN right on the object grant right on all other action on the object itself. Subclass should override this method as need.

Overrides:
getAdminObject in class DSpaceObject
Parameters:
action - ID of action being attempted, from org.dspace.core.Constants. The ADMIN action is not a valid parameter for this method, an IllegalArgumentException should be thrown
Returns:
the dspace object, if any, where an ADMIN action is sufficient to grant the original action
Throws:
SQLException

getParentObject

public DSpaceObject getParentObject()
                             throws SQLException
Description copied from class: DSpaceObject
Return the dspace object that "own" the current object in the hierarchy. Note that this method has a meaning slightly different from the getAdminObject because it is independent of the action but it is in a way related to it. It defines the "first" dspace object OTHER then the current one, where allowed ADMIN actions imply allowed ADMIN actions on the object self.

Overrides:
getParentObject in class DSpaceObject
Returns:
the dspace object that "own" the current object in the hierarchy
Throws:
SQLException


Copyright © 2010 DuraSpace. All Rights Reserved.