com.googlecode.fascinator.common.storage
Class StorageUtils

java.lang.Object
  extended by com.googlecode.fascinator.common.storage.StorageUtils

public class StorageUtils
extends java.lang.Object

Storage API utility methods.

Author:
Oliver Lucido

Field Summary
static java.lang.String DEFAULT_HOSTNAME
          Default host name
 
Constructor Summary
StorageUtils()
           
 
Method Summary
static DigitalObject checkHarvestFile(Storage storage, java.io.File file)
          Ensure the provided harvest file is up-to-date in storage.
static Payload createLinkedPayload(DigitalObject object, java.lang.String pid, java.lang.String path)
          Creates a linked Payload in the specified DigitalObject
static Payload createOrUpdatePayload(DigitalObject object, java.lang.String pid, java.io.InputStream in)
          Create or update a stored Payload in the specified DigitalObject
static Payload createOrUpdatePayload(DigitalObject object, java.lang.String pid, java.io.InputStream in, java.lang.String filePath)
           
static java.lang.String generateOid(java.io.File file)
          Generates a Object identifier for a given file
static java.lang.String generatePid(java.io.File file)
          Generates a Payload identifier for a given file
static DigitalObject getDigitalObject(Storage storage, java.lang.String oid)
          Gets a DigitalObject from the specified Storage instance.
static DigitalObject linkFile(Storage storage, java.io.File file)
          This method stores a link to a File as a DigitalObject into the specified Storage
static DigitalObject storeFile(Storage storage, java.io.File file)
          This method stores a copy of a File as a DigitalObject into the specified Storage
static DigitalObject storeFile(Storage storage, java.io.File file, boolean linked)
          This method stores a File as a DigitalObject into the specified Storage.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_HOSTNAME

public static final java.lang.String DEFAULT_HOSTNAME
Default host name

See Also:
Constant Field Values
Constructor Detail

StorageUtils

public StorageUtils()
Method Detail

generateOid

public static java.lang.String generateOid(java.io.File file)
Generates a Object identifier for a given file

Parameters:
file - the File to store
Returns:
a String object id

generatePid

public static java.lang.String generatePid(java.io.File file)
Generates a Payload identifier for a given file

Parameters:
file - the File to store
Returns:
a String payload id

storeFile

public static DigitalObject storeFile(Storage storage,
                                      java.io.File file)
                               throws StorageException
This method stores a copy of a File as a DigitalObject into the specified Storage

Parameters:
storage - a Storage instance
file - the File to store
Returns:
a DigitalObject
Throws:
StorageException - if there was an error storing the file

linkFile

public static DigitalObject linkFile(Storage storage,
                                     java.io.File file)
                              throws StorageException
This method stores a link to a File as a DigitalObject into the specified Storage

Parameters:
storage - a Storage instance
file - the File to store
Returns:
a DigitalObject
Throws:
StorageException - if there was an error storing the file

storeFile

public static DigitalObject storeFile(Storage storage,
                                      java.io.File file,
                                      boolean linked)
                               throws StorageException
This method stores a File as a DigitalObject into the specified Storage. The File can be stored as a linked Payload if specified.

Parameters:
storage - a Storage instance
file - the File to store
linked - set true to link to the original file, false to copy
Returns:
a DigitalObject
Throws:
StorageException - if there was an error storing the file

getDigitalObject

public static DigitalObject getDigitalObject(Storage storage,
                                             java.lang.String oid)
                                      throws StorageException
Gets a DigitalObject from the specified Storage instance. If the object does not exist, this method will attempt to create it.

Parameters:
storage - a Storage instance
oid - the object identifier to get (or create)
Returns:
a DigitalObject
Throws:
StorageException - if the object could not be retrieved or created

checkHarvestFile

public static DigitalObject checkHarvestFile(Storage storage,
                                             java.io.File file)
                                      throws StorageException
Ensure the provided harvest file is up-to-date in storage.

Parameters:
storage - a Storage instance
file - to check in storage
Returns:
a DigitalObject
Throws:
StorageException - if the object could not be retrieved or created

createOrUpdatePayload

public static Payload createOrUpdatePayload(DigitalObject object,
                                            java.lang.String pid,
                                            java.io.InputStream in)
                                     throws StorageException
Create or update a stored Payload in the specified DigitalObject

Parameters:
object - the DigitalObject to create the Payload in
pid - the Payload ID
in - the InputStream for the Payload's data
Returns:
a Payload
Throws:
StorageException - if the Payload could not be created

createOrUpdatePayload

public static Payload createOrUpdatePayload(DigitalObject object,
                                            java.lang.String pid,
                                            java.io.InputStream in,
                                            java.lang.String filePath)
                                     throws StorageException
Throws:
StorageException

createLinkedPayload

public static Payload createLinkedPayload(DigitalObject object,
                                          java.lang.String pid,
                                          java.lang.String path)
                                   throws StorageException
Creates a linked Payload in the specified DigitalObject

Parameters:
object - the DigitalObject to create the Payload in
pid - the Payload ID
path - the absolute path to the file the Payload links to
Returns:
a Payload
Throws:
StorageException - if the Payload could not be created


Copyright © 2009-2013. All Rights Reserved.