edu.uky.rch.ept.data
Interface IGenericResourceAccessMethods

All Known Subinterfaces:
IDataAccessMethods, IDataSourceDriver
All Known Implementing Classes:
DataFactory, DataSourceDriver, Project, Repository

public interface IGenericResourceAccessMethods

This interface defines generic data access methods for resources. Wherever addresses are involved in creating new resources, all non-existing collections in the specified path to the resource will be created automatically.

Each of the methods throws a subset of the following exceptions:

Author:
Sandeep Bodapati

Method Summary
 boolean canRead(String address)
          Check if the resource specified by the address can be read.
 boolean canWrite(String address)
          Check if the resource specified by the address can be written to.
 boolean deleteResource(String address)
          Delete a resource if it exists.
 BufferedInputStream getInputStream(String address)
          Create and return a BufferedInputStream for the resource.
 BufferedOutputStream getOutputStream(String address)
          Create and return a BufferedOutputStream for the resource.
 BufferedOutputStream getOutputStream(String address, boolean append)
          Create and return a (possibly append-only) BufferedOutputStream for the resource.
 boolean renameResource(String srcAddress, String destAddress, boolean force)
          Move or rename a resource from one address to another.
 boolean storeResource(String address, BufferedInputStream source, boolean force)
          Create a new resource with the content from the source.
 

Method Detail

canRead

public boolean canRead(String address)
                throws MalformedAddressException,
                       IOException
Check if the resource specified by the address can be read.

Parameters:
address - address of the resource
Returns:
true if the resource exists and can be read, false otherwise.
Throws:
MalformedAddressException
IOException

canWrite

public boolean canWrite(String address)
                 throws MalformedAddressException,
                        IOException
Check if the resource specified by the address can be written to.

Returns:
true if the resource can be created if it doesnt already exist or written to if it exists; false otherwise.
Throws:
MalformedAddressException
IOException

deleteResource

public boolean deleteResource(String address)
                       throws MalformedAddressException,
                              IOException
Delete a resource if it exists.

Parameters:
address - address of the resource
Returns:
true if the resource existed and was succesfully deleted, false otherwise
Throws:
MalformedAddressException
IOException

getInputStream

public BufferedInputStream getInputStream(String address)
                                   throws MalformedAddressException,
                                          ResourceNotFoundException,
                                          IOException
Create and return a BufferedInputStream for the resource.

Parameters:
address - address of the resource
Returns:
the BufferedInputStream
Throws:
MalformedAddressException - if the specified address is invalid
ResourceNotFoundException - if the resource did not exist
IOException - if there was an error opening the stream

getOutputStream

public BufferedOutputStream getOutputStream(String address)
                                     throws MalformedAddressException,
                                            ResourceNotFoundException,
                                            IOException
Create and return a BufferedOutputStream for the resource.

Parameters:
address - address of the resource
Returns:
the BufferedOutputStream
Throws:
MalformedAddressException - if the specified address is invalid
ResourceNotFoundException - if the resource did not exist and cannot be created
IOException - if there was an error opening the stream

getOutputStream

public BufferedOutputStream getOutputStream(String address,
                                            boolean append)
                                     throws MalformedAddressException,
                                            ResourceNotFoundException,
                                            IOException
Create and return a (possibly append-only) BufferedOutputStream for the resource.

Parameters:
address - address of the resource
Returns:
the BufferedOutputStream
Throws:
MalformedAddressException - if the specified address is invalid
ResourceNotFoundException - if the resource did not exist and cannot be created
IOException - if there was an error opening the stream.

storeResource

public boolean storeResource(String address,
                             BufferedInputStream source,
                             boolean force)
                      throws MalformedAddressException,
                             IOException
Create a new resource with the content from the source.

Parameters:
address - address of the new resource
source - a BufferedInputStream from which to read the content
force - if true then the resource is overwritten if it already exists
Returns:
true if the resource did not exist and was created successfully, false otherwise
Throws:
MalformedAddressException
IOException

renameResource

public boolean renameResource(String srcAddress,
                              String destAddress,
                              boolean force)
                       throws ResourceNotFoundException,
                              MalformedAddressException,
                              IOException
Move or rename a resource from one address to another.

Parameters:
srcAddress - the current address of the resource
destAddress - the new address of the resource
force - if true, the resource at destAddress is overwritten if it already exists
Returns:
true if the resource was successfully renamed, false otherwise. Renaming always fails if the source and destination addresses have different protocols. If they have the same protocol but belong to different projects, the data source driver for that protocol may or may not permit the renaming.
Throws:
ResourceNotFoundException
MalformedAddressException
IOException