edu.uky.rch.ept.projectexplorer.model
Class Project

java.lang.Object
  extended byedu.uky.rch.ept.projectexplorer.model.Project
All Implemented Interfaces:
ICollectionAccessMethods, IConcurrentXMLAccessMethods, IDataAccessMethods, IDTDAccessMethods, IGenericResourceAccessMethods, IImageAccessMethods, org.eclipse.ui.views.properties.IPropertySource, ITextAccessMethods, IXMLAccessMethods

public class Project
extends Object
implements IDataAccessMethods, org.eclipse.ui.views.properties.IPropertySource

A Project is a grouping of related resources and collections. Every project belongs to a Repository but not every resource of a project needs to belong to the same repository.

Author:
sandeep

Field Summary
static String ATT_NAME
           
static String TAG_PROJECT
           
 
Fields inherited from interface edu.uky.rch.ept.data.IDataAccessMethods
EOF, RT_DOCUMENT, RT_NODELIST, RT_STRINGS
 
Constructor Summary
Project(String ID, Repository repository)
          Creates a new Project with the given ID and repository.
Project(String name, String path, Repository repository)
          Creates a new Project with the given name, path, and repository.
 
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 copyCollectionContents(String sourceCollectionAddress, String destinationCollectionAddress)
          Copies all resources from the source collection (should be accessed using the DataFactory) to the destination collection.
 boolean createCollection(String address)
          Creates a collection specified by the address.
 boolean deleteCollection(String address, boolean force)
          Deletes the collection specified by the address.
 boolean deleteCXML(String address, String dtdID, String xpath)
          Removes the node at the specified location in the resource.
 boolean deleteResource(String address)
          Delete a resource if it exists.
 boolean deleteXML(String address, String xpath)
          Deletes the node pointed to by the xpath, from the xml resource.
 boolean equals(Object object)
           
static String generateID(String projectName)
          Generate and returns an ID from the given projectname.
 String getAbsoluteAddress(String address)
          Returns the absolute address for the give address.
 Object[] getChildren()
          Returns the children of this project.
 ResourceList getCollectionContents(String collectionAddress)
          Returns a ResourceList containing resource descriptors for each of the resources and collections in the specified collection.
 String getCXML(String address, String[] dtdIDs)
          Combine the specified hierarchies of the CXML content and return the result as a pseudo-XML string.
 String getDescription()
          Returns the description of this project
 String getDTD(String ID)
          Retrieves the specified DTD
 Object getEditableValue()
           
 String getID()
          Returns the ID of this project
 org.eclipse.swt.graphics.ImageData getImage(String address)
          Retrieves the Image from the specified address
 BufferedInputStream getInputStream(String address)
          Create and return a BufferedInputStream for the resource.
 String getName()
          Returns the name of this project
 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.
 org.eclipse.ui.views.properties.IPropertyDescriptor[] getPropertyDescriptors()
           
 Object getPropertyValue(Object id)
           
protected  String getRelativeAddress(String address)
          Returns the Repository-relative address for the given address
protected  String[] getRelativeIDs(String[] IDs)
           
 Repository getRepository()
          Returns a reference to the parent repository.
 String getText(String address, int beginIndex, int endIndex)
          Retrieves the specified text data from the resource at the given address.
 String getTimestamp()
          Returns the timestamp of this project
 String getXML(String address)
          Retrieves the XML data from the specified address.
 org.dom4j.Document getXMLDocument(String address)
          Retrieves the XML data from the specified address.
 boolean hasChildren()
          Returns true (lazy approach)
 void insertCXML(String address, String dtdID, String xpath, org.dom4j.Node newContent)
          Inserts the given XML node into the CXML resource at the indicated location.
 void insertText(String address, int atIndex, String newContent)
          Inserts the new text content into the resource starting at the index specified.
 void insertXML(String address, String xpath, org.dom4j.Node newContent)
          Inserts the given xml node into the xml resource immediately after the node specified by the xpath.
 boolean isAbsoluteAddress(String address)
          Checks if the given address is absolute.
 boolean isCollection(String address)
          Returns true if the specified address points to a collection.
 boolean isPropertySet(Object id)
           
 Object queryCXML(String xmlResourceAddress, String[] dtdIDs, String query, short returnType)
          Executes the given query on the CXML resource and returns the results as a list of org.dom4j.Nodes.
 Object queryXML(String xmlResourceAddress, String query, short returnType)
          Executes the given query on the XML resource and returns the results in the format specified by the returnType parameter.
 boolean renameResource(String srcAddress, String destAddress, boolean force)
          Move or rename a resource from one address to another.
 void replaceCXML(String address, String dtdID, String xpath, org.dom4j.Node newContent)
          Replaces the node at the specified location in the resource with a new node at the same location.
 void replaceCXMLContent(String address, int beginIndex, int endIndex, String newContent)
          (unimplemented) Treats a CXML resource as text resource (all tags are treated as though they did not exist) and replaces the text from beginIndex to endIndex-1 with the new text content.
 void replaceText(String address, int beginIndex, int endIndex, String newContent)
          Replaces the specified text with the new content.
 void replaceXML(String address, String xpath, org.dom4j.Node newContent)
          Replaces the specified node in the resource with the new node.
 void replaceXMLContent(String address, int beginIndex, int endIndex, String newContent)
          Treats an xml resource as text resource (all tags are ignored as if they didnt exist) and replaces the text from beginIndex to endIndex-1 with the new text content.
 void resetPropertyValue(Object id)
           
 ResourceList scanCollection(String address, Pattern pattern, boolean includeCollections)
          Returns a ResourceList containing resource descriptors for each of the resources (and possibly collections) located within the specified collection which match the given pattern.
 void setDescription(String description)
          Updates the description for this project
 void setName(String name)
          Sets the name for this project
 void setPropertyValue(Object id, Object value)
           
 void setRepository(Repository source)
          Updates the parent repository for this project.
 void setTimestamp(String timestamp)
          Sets the timestamp for this project
 boolean storeCXML(String address, String[] dtdIDs, String content, boolean force)
          Creates a new CXML resource.
 boolean storeDTD(String ID, String content, boolean force)
          Creates a new DTD resource with the given content.
 boolean storeImage(String address, URL source, boolean force)
          Imports the image from the source & stores it at the given address.
 boolean storeResource(String address, BufferedInputStream source, boolean force)
          Create a new resource with the content from the source.
 boolean storeText(String address, String content, boolean force)
          Creates a new text resource and writes the given content into it.
 boolean storeXML(String address, org.dom4j.Document content, boolean force)
          Creates a new XML resource with the given content, reindented for readability.
 boolean storeXML(String address, org.dom4j.Document content, boolean force, boolean indent)
          Creates a new XML resource with the given content, possibly reindented.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TAG_PROJECT

public static String TAG_PROJECT

ATT_NAME

public static String ATT_NAME
Constructor Detail

Project

public Project(String name,
               String path,
               Repository repository)
Creates a new Project with the given name, path, and repository. The ID of the project is unspecified by this API, and may be obtained by the getID() method.

Parameters:
name - human-readable name of the project. If name is null, read the name from an existing project.xml,
path - path of the project, as a data layer path string. The path string may be either absolute (if it contains "://") or relative.
repository - the repository to which the project should belong

Project

public Project(String ID,
               Repository repository)
Creates a new Project with the given ID and repository. The ID is used as the name of the project; the project will be stored in a data layer path determined by the repository and ID, though the precise path created is not specified by this API. Use the three-argument constructor to create a project in a particular location.

Parameters:
ID - identifier for the project.
repository - the repository to which the project should belong
Method Detail

getChildren

public Object[] getChildren()
Returns the children of this project. The children of a project are gather from the extensions to the ProjectItemsContributor tag of the ProjectContributions extension point. These contributions can be made from any number of tools installed in the workbench.

Returns:
an array of children

hasChildren

public boolean hasChildren()
Returns true (lazy approach)

Returns:
true

getRepository

public Repository getRepository()
Returns a reference to the parent repository.

Returns:
parent repository

getDescription

public String getDescription()
Returns the description of this project

Returns:
description

getID

public String getID()
Returns the ID of this project

Returns:
ID

getName

public String getName()
Returns the name of this project

Returns:
name

getTimestamp

public String getTimestamp()
Returns the timestamp of this project

Returns:
timestamp

setRepository

public void setRepository(Repository source)
Updates the parent repository for this project.

Parameters:
source - parent repository

setDescription

public void setDescription(String description)
Updates the description for this project

Parameters:
description - new description

setName

public void setName(String name)
Sets the name for this project

Parameters:
name - new name

setTimestamp

public void setTimestamp(String timestamp)
Sets the timestamp for this project

Parameters:
timestamp - new timestamp

isAbsoluteAddress

public boolean isAbsoluteAddress(String address)
Checks if the given address is absolute.

Parameters:
address - address to check
Returns:
true if the given address is an absolute address, false otherwise

getRelativeAddress

protected String getRelativeAddress(String address)
Returns the Repository-relative address for the given address

Parameters:
address - the address
Returns:
repository-relative address

getAbsoluteAddress

public String getAbsoluteAddress(String address)
Returns the absolute address for the give address. The address is returned as-is if it is already absolute.

Parameters:
address - the address
Returns:
absolute address

getRelativeIDs

protected String[] getRelativeIDs(String[] IDs)
Parameters:
IDs -
Returns:

canRead

public boolean canRead(String address)
                throws MalformedAddressException,
                       IOException
Description copied from interface: IGenericResourceAccessMethods
Check if the resource specified by the address can be read.

Specified by:
canRead in interface IGenericResourceAccessMethods
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
Description copied from interface: IGenericResourceAccessMethods
Check if the resource specified by the address can be written to.

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

isCollection

public boolean isCollection(String address)
                     throws MalformedAddressException,
                            IOException
Description copied from interface: ICollectionAccessMethods
Returns true if the specified address points to a collection.

Specified by:
isCollection in interface ICollectionAccessMethods
Parameters:
address - the address to check
Returns:
true if the address points to an existing collection
Throws:
MalformedAddressException
IOException

createCollection

public boolean createCollection(String address)
                         throws MalformedAddressException,
                                IOException
Description copied from interface: ICollectionAccessMethods
Creates a collection specified by the address.

Specified by:
createCollection in interface ICollectionAccessMethods
Parameters:
address - address of the collection
Returns:
true if the collection did not exist and was succesfully created, false otherwise.
Throws:
MalformedAddressException
IOException

deleteCollection

public boolean deleteCollection(String address,
                                boolean force)
                         throws MalformedAddressException,
                                IOException
Description copied from interface: ICollectionAccessMethods
Deletes the collection specified by the address.

Specified by:
deleteCollection in interface ICollectionAccessMethods
Parameters:
address - address of the collection
force - if true, then the collection will be deleted even if it contains resources and other sub-collections. Use with caution, as all resources contained within the collection will be deleted
Returns:
true if the collection existed and was succesfully deleted, false otherwise.
Throws:
MalformedAddressException
IOException

deleteResource

public boolean deleteResource(String address)
                       throws MalformedAddressException,
                              IOException
Description copied from interface: IGenericResourceAccessMethods
Delete a resource if it exists.

Specified by:
deleteResource in interface IGenericResourceAccessMethods
Parameters:
address - address of the resource
Returns:
true if the resource existed and was succesfully deleted, false otherwise
Throws:
MalformedAddressException
IOException

getText

public String getText(String address,
                      int beginIndex,
                      int endIndex)
               throws MalformedAddressException,
                      ResourceNotFoundException,
                      IndexOutOfBoundsException,
                      IOException
Description copied from interface: ITextAccessMethods
Retrieves the specified text data from the resource at the given address. The text data is read starting from the beginIndex to the character at index endIndex-1. Thus the length of the substring returned is endIndex-beginIndex. If endIndex is EOF, then the contents will be read till the end of the resource.

Specified by:
getText in interface ITextAccessMethods
Parameters:
address - address of the resource
beginIndex - the beginning index, inclusive.
endIndex - the endIndex, exclusive.
Returns:
the specified text data from the resource
Throws:
IndexOutOfBoundsException - if the beginIndex is negative, or beginIndex is larger than endIndex and endIndex is not EOF.
ResourceNotFoundException - if the resource doesnt exist
MalformedAddressException
IOException

storeText

public boolean storeText(String address,
                         String content,
                         boolean force)
                  throws MalformedAddressException,
                         IOException
Description copied from interface: ITextAccessMethods
Creates a new text resource and writes the given content into it.

Specified by:
storeText in interface ITextAccessMethods
Parameters:
address - the address of the resource
content - the data to be written
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

insertText

public void insertText(String address,
                       int atIndex,
                       String newContent)
                throws MalformedAddressException,
                       ResourceNotFoundException,
                       IndexOutOfBoundsException,
                       IOException
Description copied from interface: ITextAccessMethods
Inserts the new text content into the resource starting at the index specified. If atIndex is greater than the length of the resource or is EOF, the new text will be appended to the resource

Specified by:
insertText in interface ITextAccessMethods
Parameters:
address - the address of the resource
atIndex - offset from the beginning of the resource
newContent - text to be inserted
Throws:
ResourceNotFoundException - if the resource doesnt exist
IndexOutOfBoundsException - if the atIndex is negative and not EOF
MalformedAddressException
IOException

replaceText

public void replaceText(String address,
                        int beginIndex,
                        int endIndex,
                        String newContent)
                 throws MalformedAddressException,
                        ResourceNotFoundException,
                        IndexOutOfBoundsException,
                        IOException
Description copied from interface: ITextAccessMethods
Replaces the specified text with the new content. The text that is replaced starts from beginIndex and ends at endIndex-1. If endIndex is EOF, then the text till the end of the resource will be replaced.

Specified by:
replaceText in interface ITextAccessMethods
Parameters:
address - address of the resource
beginIndex - beginning index, inclusive
endIndex - end index, exclusive
newContent - new content to replace the text
Throws:
IndexOutOfBoundsException - if the beginIndex is negative, or beginIndex is larger than endIndex and endIndex is not EOF.
ResourceNotFoundException - if the resource doesnt exist
MalformedAddressException
IOException

getXMLDocument

public org.dom4j.Document getXMLDocument(String address)
                                  throws MalformedAddressException,
                                         ResourceNotFoundException,
                                         IOException
Description copied from interface: IXMLAccessMethods
Retrieves the XML data from the specified address.

Specified by:
getXMLDocument in interface IXMLAccessMethods
Parameters:
address - address of the xml resource
Returns:
a Document object built from the data in the resource
Throws:
ResourceNotFoundException - if the resource doesnt exist
MalformedAddressException
IOException

getXML

public String getXML(String address)
              throws MalformedAddressException,
                     ResourceNotFoundException,
                     IOException
Description copied from interface: IXMLAccessMethods
Retrieves the XML data from the specified address.

Specified by:
getXML in interface IXMLAccessMethods
Parameters:
address - address of the xml resource
Returns:
a String object containing the data from the resource
Throws:
ResourceNotFoundException - if the resource doesnt exist
MalformedAddressException
IOException

storeXML

public boolean storeXML(String address,
                        org.dom4j.Document content,
                        boolean force,
                        boolean indent)
                 throws MalformedAddressException,
                        IOException
Description copied from interface: IXMLAccessMethods
Creates a new XML resource with the given content, possibly reindented. This method is to be used for xml resources that do not have concurrent hierarchies.

Specified by:
storeXML in interface IXMLAccessMethods
Parameters:
address - the address of the resource
content - the Document to be written
force - if true then the resource is overwritten if it already exists
indent - if true reindent the document, compressing contiguous sequences of whitespace characters in content.
Returns:
true if the resource did not exist and was created successfully, false otherwise
Throws:
MalformedAddressException
IOException

storeXML

public boolean storeXML(String address,
                        org.dom4j.Document content,
                        boolean force)
                 throws MalformedAddressException,
                        IOException
Description copied from interface: IXMLAccessMethods
Creates a new XML resource with the given content, reindented for readability. Use IXMLAccessMethods.storeXML(String, Document, boolean, boolean) instead to preserve whitespace. This method is to be used for XML resources that do not have concurrent hierarchies.

Specified by:
storeXML in interface IXMLAccessMethods
Parameters:
address - the address of the resource.
content - the Document to be written
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

insertXML

public void insertXML(String address,
                      String xpath,
                      org.dom4j.Node newContent)
               throws MalformedAddressException,
                      ResourceNotFoundException,
                      InvalidNodePathException,
                      IOException
Description copied from interface: IXMLAccessMethods
Inserts the given xml node into the xml resource immediately after the node specified by the xpath.

Specified by:
insertXML in interface IXMLAccessMethods
Parameters:
address - address of the resource
xpath - valid path to a node
newContent - new node
Throws:
ResourceNotFoundException - if the resource doesnt exist
InvalidNodePathException - if the given xpath does not point to a node (valid location)
MalformedAddressException
IOException

replaceXML

public void replaceXML(String address,
                       String xpath,
                       org.dom4j.Node newContent)
                throws MalformedAddressException,
                       ResourceNotFoundException,
                       InvalidNodePathException,
                       IOException
Description copied from interface: IXMLAccessMethods
Replaces the specified node in the resource with the new node.

Specified by:
replaceXML in interface IXMLAccessMethods
Parameters:
address - address of the resource
xpath - valid path to an existing node in the resource
newContent - new node
Throws:
InvalidNodePathException - if the given xpath does not point to a node (valid location) in the resource
ResourceNotFoundException - if the resource doesnt exist
MalformedAddressException
IOException

replaceXMLContent

public void replaceXMLContent(String address,
                              int beginIndex,
                              int endIndex,
                              String newContent)
                       throws MalformedAddressException,
                              ResourceNotFoundException,
                              IndexOutOfBoundsException,
                              IOException
Description copied from interface: IXMLAccessMethods
Treats an xml resource as text resource (all tags are ignored as if they didnt exist) and replaces the text from beginIndex to endIndex-1 with the new text content. If endIndex is EOF, the text till the end of the resource will be replaced.

Specified by:
replaceXMLContent in interface IXMLAccessMethods
Parameters:
address - address of the resource
beginIndex - beginIndex, inclusive
endIndex - endIndex, exclusive
newContent - new text content
Throws:
ResourceNotFoundException - if the resource doesnt exist
IndexOutOfBoundsException - if the beginIndex is negative, or beginIndex is larger than endIndex and endIndex is not EOF.
MalformedAddressException
IOException

deleteXML

public boolean deleteXML(String address,
                         String xpath)
                  throws MalformedAddressException,
                         ResourceNotFoundException,
                         InvalidNodePathException,
                         IOException
Description copied from interface: IXMLAccessMethods
Deletes the node pointed to by the xpath, from the xml resource.

Specified by:
deleteXML in interface IXMLAccessMethods
Parameters:
address - address of the resource
xpath - valid path to an existing node in the resource
Returns:
true if the node existed and was succesfully deleted, false otherwise
Throws:
ResourceNotFoundException - if the resource doesnt exist
InvalidNodePathException - if the given xpath does not point to a node (valid location) in the resource
MalformedAddressException
IOException

queryXML

public Object queryXML(String xmlResourceAddress,
                       String query,
                       short returnType)
                throws MalformedAddressException,
                       ResourceNotFoundException,
                       MalformedQueryException,
                       IOException,
                       InvalidTypeException
Description copied from interface: IXMLAccessMethods
Executes the given query on the XML resource and returns the results in the format specified by the returnType parameter.

Specified by:
queryXML in interface IXMLAccessMethods
Parameters:
xmlResourceAddress - address of the XML resource
query - the query
returnType - return type.

The following values are valid for the return type:

  • RT_DOCUMENT - Returns a Document object
  • RT_NODELIST - Returns a list of Nodes
  • RT_STRINGS - Returns a String array

Returns:
an object containing the result of the query. The type of object is decided by the returnType parameter.
Throws:
MalformedQueryException - if the query is malformed
ResourceNotFoundException - if the resource doesnt exist
InvalidTypeException - if the return type specified is unrecognized
MalformedAddressException
IOException

getCXML

public String getCXML(String address,
                      String[] dtdIDs)
               throws MalformedAddressException,
                      ResourceNotFoundException,
                      IOException
Description copied from interface: IConcurrentXMLAccessMethods
Combine the specified hierarchies of the CXML content and return the result as a pseudo-XML string. If dtdIDs[] is null or an empty array, combine all the hierarchies. If dtdIDs contains a single DTD and the document is well-formed with respect to that DTD, the result will be proper XML.

Specified by:
getCXML in interface IConcurrentXMLAccessMethods
Parameters:
address - address of the CXML resource.
dtdIDs - an array of DTD identifiers, specifying which hierarchies to combine. If this parameter is null or empty, all the hierarchies are combined.
Returns:
a String with the combined hierarchies.
Throws:
ResourceNotFoundException - if the resource doesn't exist
MalformedAddressException
IOException

storeCXML

public boolean storeCXML(String address,
                         String[] dtdIDs,
                         String content,
                         boolean force)
                  throws MalformedAddressException,
                         IOException
Description copied from interface: IConcurrentXMLAccessMethods
Creates a new CXML resource. This method parses the given content to handle the concurrent hierarchies and creates the required xml resource. The different hierarchies to be handled are specified by the identifiers referred to by the array of DTD identifiers. Note: currently, content should be the empty string; if not, that content will not be located properly with respect to other nodes. This will be fixed.

Specified by:
storeCXML in interface IConcurrentXMLAccessMethods
Parameters:
address - the address at which to store the CXML resource
dtdIDs - an array of DTD identifiers
content - the CXML data to be written (currently, the empty string)
force - flag indicating whether the resource should be overwritten if it already exists.
Returns:
true if the resource was created successfully, false otherwise.
Throws:
MalformedAddressException
IOException

insertCXML

public void insertCXML(String address,
                       String dtdID,
                       String xpath,
                       org.dom4j.Node newContent)
                throws MalformedAddressException,
                       ResourceNotFoundException,
                       InvalidNodePathException,
                       IOException
Description copied from interface: IConcurrentXMLAccessMethods
Inserts the given XML node into the CXML resource at the indicated location. The location takes the form "[[beg:end]]", where beg and end are the integer coordinates of the node, used to position it with respect to other nodes.

Specified by:
insertCXML in interface IConcurrentXMLAccessMethods
Parameters:
address - address of the resource.
dtdID - identifier of the corresponding DTD.
xpath - location for the new node, as specified above.
newContent - new node, which should be either an org.dom4j.Element or an org.dom4j.Text. The node's content is ignored; only the top-level node itself is used.
Throws:
InvalidNodePathException - if the given location is invalid.
ResourceNotFoundException - if the resource doesnt exist
MalformedAddressException
IOException

replaceCXML

public void replaceCXML(String address,
                        String dtdID,
                        String xpath,
                        org.dom4j.Node newContent)
                 throws MalformedAddressException,
                        ResourceNotFoundException,
                        InvalidNodePathException,
                        IOException
Description copied from interface: IConcurrentXMLAccessMethods
Replaces the node at the specified location in the resource with a new node at the same location. The location is of the same form as the similarly-named parameter to IConcurrentXMLAccessMethods.deleteCXML(java.lang.String, java.lang.String, java.lang.String).

Specified by:
replaceCXML in interface IConcurrentXMLAccessMethods
Parameters:
address - address of the resource.
dtdID - identifier of the corresponding DTD.
xpath - location and tag name of an existing node, as specified by IConcurrentXMLAccessMethods.deleteCXML(java.lang.String, java.lang.String, java.lang.String).
newContent - the node to replace the deleted node; this should be as the argument to IConcurrentXMLAccessMethods.insertCXML(java.lang.String, java.lang.String, java.lang.String, org.dom4j.Node).
Throws:
InvalidNodePathException - if the given location is invalid.
ResourceNotFoundException - if the resource doesnt exist.
MalformedAddressException
IOException

replaceCXMLContent

public void replaceCXMLContent(String address,
                               int beginIndex,
                               int endIndex,
                               String newContent)
                        throws MalformedAddressException,
                               ResourceNotFoundException,
                               IndexOutOfBoundsException,
                               IOException
Description copied from interface: IConcurrentXMLAccessMethods
(unimplemented) Treats a CXML resource as text resource (all tags are treated as though they did not exist) and replaces the text from beginIndex to endIndex-1 with the new text content. If endIndex is EOF, the text till the end of the resource will be replaced.

Specified by:
replaceCXMLContent in interface IConcurrentXMLAccessMethods
Parameters:
address - address of the resource
beginIndex - beginIndex, inclusive
endIndex - endIndex, exclusive
newContent - new text content
Throws:
ResourceNotFoundException - if the resource doesnt exist
IndexOutOfBoundsException - if the beginIndex is negative, or beginIndex is larger than endIndex and endIndex is not EOF.
MalformedAddressException
IOException

deleteCXML

public boolean deleteCXML(String address,
                          String dtdID,
                          String xpath)
                   throws MalformedAddressException,
                          ResourceNotFoundException,
                          InvalidNodePathException,
                          IOException
Description copied from interface: IConcurrentXMLAccessMethods
Removes the node at the specified location in the resource. The location takes the form "[[beg:end]]|tag", where beg and end are the integer coordinates of the node (the coordinates passed to IConcurrentXMLAccessMethods.insertCXML(java.lang.String, java.lang.String, java.lang.String, org.dom4j.Node) when the node was originally inserted) and tag is the tag name of the node to be removed (or "st:string" to remove text content).

Specified by:
deleteCXML in interface IConcurrentXMLAccessMethods
Parameters:
address - address of the resource
dtdID - identifier of the corresponding DTD.
xpath - location and tag name of an existing node, as specified above.
Returns:
true if the node existed and was succesfully deleted, false otherwise.
Throws:
InvalidNodePathException - if the location is invalid.
ResourceNotFoundException - if the resource doesnt exist
MalformedAddressException
IOException

queryCXML

public Object queryCXML(String xmlResourceAddress,
                        String[] dtdIDs,
                        String query,
                        short returnType)
                 throws MalformedAddressException,
                        ResourceNotFoundException,
                        MalformedQueryException,
                        IOException,
                        InvalidTypeException
Description copied from interface: IConcurrentXMLAccessMethods
Executes the given query on the CXML resource and returns the results as a list of org.dom4j.Nodes. Each such node is either an Element or a Text object. The query is of the form "op[[from:to]] where from and to are the coordinates of the context range (these are the same coordinates used by IConcurrentXMLAccessMethods.insertCXML(java.lang.String, java.lang.String, java.lang.String, org.dom4j.Node)). op indicates the type of query to perform, and may be one of:

Specified by:
queryCXML in interface IConcurrentXMLAccessMethods
Parameters:
xmlResourceAddress - address of the XML resource
dtdIDs - an array of DTD identifiers, specifying which of the hierarchies to consider for the query. If this parameter is null or empty, then all the hierarchies are considered.
query - the query, as specified above.
returnType - return type. This argument is currently ignored.
Returns:
an object containing the result of the query. The object is currently always a List of dom4j Element and Text nodes.
Throws:
InvalidTypeException - if the return type specified is unrecognized (should never happen)
MalformedQueryException - if the query is malformed
ResourceNotFoundException - if the resource doesnt exist
MalformedAddressException
IOException

getDTD

public String getDTD(String ID)
              throws MalformedAddressException,
                     ResourceNotFoundException,
                     IOException
Description copied from interface: IDTDAccessMethods
Retrieves the specified DTD

Specified by:
getDTD in interface IDTDAccessMethods
Parameters:
ID - identifier of the DTD
Returns:
a String object containing the DTD contents from the resource
Throws:
ResourceNotFoundException - if the resource doesnt exist
MalformedAddressException
IOException

storeDTD

public boolean storeDTD(String ID,
                        String content,
                        boolean force)
                 throws MalformedAddressException,
                        IOException
Description copied from interface: IDTDAccessMethods
Creates a new DTD resource with the given content. All DTDs are to be stored in a collection named 'DTDs' which should be in the root of the project structure. For example is the ID is 'cotlib.damage', then the corresponding resource should be created at and named as in "DTDs/cotlib.damage.dtd" from the project's root.

Specified by:
storeDTD in interface IDTDAccessMethods
Parameters:
ID - the identifier for the DTD
content - DTD 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

getImage

public org.eclipse.swt.graphics.ImageData getImage(String address)
                                            throws MalformedAddressException,
                                                   ResourceNotFoundException,
                                                   IOException
Description copied from interface: IImageAccessMethods
Retrieves the Image from the specified address

Specified by:
getImage in interface IImageAccessMethods
Parameters:
address - address of the Image
Returns:
an ImageData object corresponding to the image
Throws:
ResourceNotFoundException - if the resource doesnt exist
MalformedAddressException
IOException

storeImage

public boolean storeImage(String address,
                          URL source,
                          boolean force)
                   throws MalformedAddressException,
                          ResourceNotFoundException,
                          IOException
Description copied from interface: IImageAccessMethods
Imports the image from the source & stores it at the given address.

Specified by:
storeImage in interface IImageAccessMethods
Parameters:
address - the address of the resource
source - URL pointing to the image to be imported
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
ResourceNotFoundException
IOException

getCollectionContents

public ResourceList getCollectionContents(String collectionAddress)
                                   throws MalformedAddressException,
                                          ResourceNotFoundException,
                                          IOException
Description copied from interface: ICollectionAccessMethods
Returns a ResourceList containing resource descriptors for each of the resources and collections in the specified collection.

There is no guarantee that the resource descriptors in the resulting resourcelist will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order of resource names.

Specified by:
getCollectionContents in interface ICollectionAccessMethods
Parameters:
collectionAddress - path to the collection
Returns:
a ResourceList with ResourceDescriptors pointing to the resources and collections in the specified collection. The ResourceList will be empty if the collection is empty.
Throws:
ResourceNotFoundException - if the specified collection doesnt exist
MalformedAddressException
IOException

scanCollection

public ResourceList scanCollection(String address,
                                   Pattern pattern,
                                   boolean includeCollections)
                            throws MalformedAddressException,
                                   ResourceNotFoundException,
                                   IOException
Description copied from interface: ICollectionAccessMethods
Returns a ResourceList containing resource descriptors for each of the resources (and possibly collections) located within the specified collection which match the given pattern. Unlike ICollectionAccessMethods.getCollectionContents(java.lang.String), this method perfoms a recursive search.

There is no guarantee that the resource descriptors in the resulting resourcelist will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order of resource names.

Specified by:
scanCollection in interface ICollectionAccessMethods
Parameters:
address - path to the collection
pattern - pattern to match against
includeCollections -
Returns:
a ResourceList with ResourceDescriptors pointing to the resources with addresses matching the pattern which are located within the specified collection. The ResourceList will be empty if the collection is empty.
Throws:
ResourceNotFoundException - if the specified collection doesnt exist
MalformedAddressException
IOException

getInputStream

public BufferedInputStream getInputStream(String address)
                                   throws MalformedAddressException,
                                          ResourceNotFoundException,
                                          IOException
Description copied from interface: IGenericResourceAccessMethods
Create and return a BufferedInputStream for the resource.

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

getOutputStream

public BufferedOutputStream getOutputStream(String address)
                                     throws MalformedAddressException,
                                            ResourceNotFoundException,
                                            IOException
Description copied from interface: IGenericResourceAccessMethods
Create and return a BufferedOutputStream for the resource.

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

getOutputStream

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

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

storeResource

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

Specified by:
storeResource in interface IGenericResourceAccessMethods
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
Description copied from interface: IGenericResourceAccessMethods
Move or rename a resource from one address to another.

Specified by:
renameResource in interface IGenericResourceAccessMethods
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

generateID

public static String generateID(String projectName)
Generate and returns an ID from the given projectname.

Parameters:
projectName - project name
Returns:
generated ID

copyCollectionContents

public boolean copyCollectionContents(String sourceCollectionAddress,
                                      String destinationCollectionAddress)
                               throws MalformedAddressException,
                                      ResourceNotFoundException,
                                      IOException
Copies all resources from the source collection (should be accessed using the DataFactory) to the destination collection. For example copyCollection("db://eptserver/someProject/images", "file://home/eptprojects/someOtherProject/folioImages") would recursively copy all the resources in the "images" collection specified in the source collection to a collecection called "folioImages" at the destination.

Parameters:
sourceCollectionAddress - the source collection which is to be copied
destinationCollectionAddress - the destination collection which will be created.
Returns:
true if all the contents were succesfully copied.
Throws:
MalformedAddressException
ResourceNotFoundException
IOException

equals

public boolean equals(Object object)

getEditableValue

public Object getEditableValue()
Specified by:
getEditableValue in interface org.eclipse.ui.views.properties.IPropertySource

getPropertyDescriptors

public org.eclipse.ui.views.properties.IPropertyDescriptor[] getPropertyDescriptors()
Specified by:
getPropertyDescriptors in interface org.eclipse.ui.views.properties.IPropertySource

getPropertyValue

public Object getPropertyValue(Object id)
Specified by:
getPropertyValue in interface org.eclipse.ui.views.properties.IPropertySource

setPropertyValue

public void setPropertyValue(Object id,
                             Object value)
Specified by:
setPropertyValue in interface org.eclipse.ui.views.properties.IPropertySource

resetPropertyValue

public void resetPropertyValue(Object id)
Specified by:
resetPropertyValue in interface org.eclipse.ui.views.properties.IPropertySource

isPropertySet

public boolean isPropertySet(Object id)
Specified by:
isPropertySet in interface org.eclipse.ui.views.properties.IPropertySource