org.gcube.opensearch.opensearchoperator.resource
Class LocalOpenSearchResource

java.lang.Object
  extended by org.gcube.opensearch.opensearchoperator.resource.LocalOpenSearchResource
All Implemented Interfaces:
OpenSearchResource

public class LocalOpenSearchResource
extends java.lang.Object
implements OpenSearchResource

Class implementing the OpenSearchResource interface that processes OpenSearch resources in the absence of an InformationSystem

Author:
gerasimos.farantatos

Constructor Summary
LocalOpenSearchResource(java.io.File file, java.io.File schemaFile)
          Creates a new LocalOpenSearchResource whose XML representation is stored in a file
LocalOpenSearchResource(java.lang.String xml, java.io.File schemaFile)
          Creates a new LocalOpenSearchResouce whose XML representation is stored in a String
LocalOpenSearchResource(java.lang.String name, java.net.URL DDUrl, boolean brokered)
          Creates a new LocalOpenSearchResource by directly providing its attributes
LocalOpenSearchResource(java.net.URL url, java.io.File schemaFile)
          Creates a new LocalOpenSearchResource whose XML representation can be retrieved through a URL
 
Method Summary
 void addTransformation(java.lang.String MIMEType, java.lang.String recordSplitXPath, java.lang.String recordIdXPath, java.net.URL XSLTUrl, java.util.Map<java.lang.String,java.lang.String> presentationInfo)
          Adds a transformation specification to the OpenSearch resource
 org.w3c.dom.Document getDescriptionDocument()
          Retrieves the description document of the OpenSearch provider described by this resource
 java.lang.String getDescriptionDocURL()
          Retrieves the URL of the description document of the OpenSearch provider described by this resource
 java.lang.String getName()
          Returns the name of the OpenSearch provider
 java.lang.String getParameterQName(java.lang.String fieldName)
          Retrieves the fully qualified name of an OpenSearch parameter which corresponds to a field
 java.util.Map<java.lang.String,java.lang.String> getParameters()
          Retrieved the full mapping from field names to fully ns-qualified OpenSearch parameters as contained in the OpenSearch Resource
 java.util.Map<java.lang.String,java.lang.String> getPresentationInformation(java.lang.String MIMEType)
          Retrieves the presentation information, that is, a mapping from field names to XPath expressions
 javax.xml.xpath.XPathExpression getRecordIdXPath(java.lang.String MIMEType)
          Retrieves an XPathExpression that can be used to extract a record id a from a search result record
 javax.xml.xpath.XPathExpression getRecordSplitXPath(java.lang.String MIMEType)
          Retrieves an XPathExpression that can be used to split a search result page of a given MIME type to individual records
 java.lang.String getSecuritySpecs()
          Retrieves the security specifications of this OpenSearch provider
 java.util.List<java.lang.String> getTransformationTypes()
          Retrieves a list of all MIME types for which there exists a transformation specification
 javax.xml.transform.Transformer getTransformer()
          Retrieves a transformer that can be used to transform the results of the first MIME type appearing in this OpenSearch resource that are returned by the provider described by this resource
 javax.xml.transform.Transformer getTransformer(java.lang.String MIMEType)
          Retrieves a transformer that can be used to transform the results of a given MIME type that are returned by the provider described by this resource
 boolean isBrokered()
          Determines whether the provider described by this resource returns brokered results, i.e the results it returns describe other OpenSearch providers
 boolean isSecure()
          Determines if the provider described by this resource uses a security scheme
static void main(java.lang.String[] args)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalOpenSearchResource

public LocalOpenSearchResource(java.lang.String name,
                               java.net.URL DDUrl,
                               boolean brokered)
                        throws java.io.IOException,
                               javax.xml.parsers.ParserConfigurationException,
                               org.xml.sax.SAXException
Creates a new LocalOpenSearchResource by directly providing its attributes

Parameters:
name - The name of the OpenSearch resource to be created
DDUrl - The URL of the description document of the OpenSearch provider that will be associated with the OpenSearch resource to be created
brokered - true if the OpenSearch resource to be created provides brokered results, false otherwise
Throws:
java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException

LocalOpenSearchResource

public LocalOpenSearchResource(java.io.File file,
                               java.io.File schemaFile)
                        throws java.lang.Exception
Creates a new LocalOpenSearchResource whose XML representation is stored in a file

Parameters:
file - The file where the XML representation of the OpenSearch resource is stored
schemaFile - The schema file describing the schema of the OpenSearch resource to be used for validation. This is an optional parameter. If null, no validation will be performed
Throws:
java.lang.Exception - If the resource is malformed or in case of other error

LocalOpenSearchResource

public LocalOpenSearchResource(java.lang.String xml,
                               java.io.File schemaFile)
                        throws java.lang.Exception
Creates a new LocalOpenSearchResouce whose XML representation is stored in a String

Parameters:
xml - The XML representation of the OpenSearch resource to be created
schemaFile - The schema file describing the schema of the OpenSearch resource to be used for validation. This is an optional parameter. If null, no validation will be performed
Throws:
java.lang.Exception - If the resource is malformed or in case of other error

LocalOpenSearchResource

public LocalOpenSearchResource(java.net.URL url,
                               java.io.File schemaFile)
                        throws java.lang.Exception
Creates a new LocalOpenSearchResource whose XML representation can be retrieved through a URL

Parameters:
url - The URL that will be used to retrieve the XML representation of the OpenSearch resource to be created
schemaFile - The schema file describing the schema of the OpenSearch resource to be used for validation. This is an optional parameter. If null, no validation will be performed
Throws:
java.lang.Exception - If the resource is malformed or in case of other error
Method Detail

addTransformation

public void addTransformation(java.lang.String MIMEType,
                              java.lang.String recordSplitXPath,
                              java.lang.String recordIdXPath,
                              java.net.URL XSLTUrl,
                              java.util.Map<java.lang.String,java.lang.String> presentationInfo)
                       throws java.lang.Exception
Adds a transformation specification to the OpenSearch resource

Parameters:
MIMEType - The MIME type of the results that will be associated with the transformation specifications
recordSplitXPath - The Xpath expression to be used to split the results contained in a search result page to individual records
recordIdXPath - The Xpath expression to be used to extract a record id from a record of the search results
XSLTUrl - The URL of the XSLT to be used to transform the search result records to the desired form
presentationInfo - A mapping from presentable field names to XPath expressions that will be used to extract result fields from the results returned by the provider
Throws:
java.lang.Exception - In case of error

getName

public java.lang.String getName()
Returns the name of the OpenSearch provider

Specified by:
getName in interface OpenSearchResource
Returns:
The name of the OpenSearch provider
See Also:
OpenSearchResource.getName()

isBrokered

public boolean isBrokered()
Determines whether the provider described by this resource returns brokered results, i.e the results it returns describe other OpenSearch providers

Specified by:
isBrokered in interface OpenSearchResource
Returns:
true if the provider returns brokered results, false otherwise
See Also:
OpenSearchResource.isBrokered()

isSecure

public boolean isSecure()
Determines if the provider described by this resource uses a security scheme

Specified by:
isSecure in interface OpenSearchResource
Returns:
true if the provider uses a security scheme, false otherwise
See Also:
OpenSearchResource.isSecure()

getSecuritySpecs

public java.lang.String getSecuritySpecs()
Retrieves the security specifications of this OpenSearch provider

Specified by:
getSecuritySpecs in interface OpenSearchResource
Returns:
The security specifications of the provider
See Also:
OpenSearchResource.getSecuritySpecs()

getDescriptionDocument

public org.w3c.dom.Document getDescriptionDocument()
Retrieves the description document of the OpenSearch provider described by this resource

Specified by:
getDescriptionDocument in interface OpenSearchResource
Returns:
A Document representing the description document of the provider
See Also:
OpenSearchResource.getDescriptionDocument()

getDescriptionDocURL

public java.lang.String getDescriptionDocURL()
Retrieves the URL of the description document of the OpenSearch provider described by this resource

Specified by:
getDescriptionDocURL in interface OpenSearchResource
Returns:
A String containing the URL of the description document of the provider
See Also:
OpenSearchResource.getDescriptionDocURL()

getTransformer

public javax.xml.transform.Transformer getTransformer(java.lang.String MIMEType)
                                               throws java.lang.Exception
Retrieves a transformer that can be used to transform the results of a given MIME type that are returned by the provider described by this resource

Specified by:
getTransformer in interface OpenSearchResource
Parameters:
MIMEType - The MIME type of the results that will be transformed
Returns:
The transformer that can be used to transform the results of the given MIME type
Throws:
java.lang.Exception - In case of error
See Also:
OpenSearchResource.getTransformer(String)

getRecordSplitXPath

public javax.xml.xpath.XPathExpression getRecordSplitXPath(java.lang.String MIMEType)
                                                    throws java.lang.Exception
Retrieves an XPathExpression that can be used to split a search result page of a given MIME type to individual records

Specified by:
getRecordSplitXPath in interface OpenSearchResource
Parameters:
MIMEType - The MIME type of the results returned by the provider described by this resource
Returns:
The Xpath expression that can be used to split search result pages to individual records
Throws:
java.lang.Exception - In case of error
See Also:
OpenSearchResource.getRecordSplitXPath(String)

getRecordIdXPath

public javax.xml.xpath.XPathExpression getRecordIdXPath(java.lang.String MIMEType)
                                                 throws java.lang.Exception
Retrieves an XPathExpression that can be used to extract a record id a from a search result record

Specified by:
getRecordIdXPath in interface OpenSearchResource
Parameters:
MIMEType - The MIME type of the results returned by the provider described by this resource
Returns:
The Xpath expression that can be used extract a record id from a search result record
Throws:
java.lang.Exception - In case of error
See Also:
OpenSearchResource.getRecordIdXPath(String)

getTransformer

public javax.xml.transform.Transformer getTransformer()
                                               throws java.lang.Exception
Retrieves a transformer that can be used to transform the results of the first MIME type appearing in this OpenSearch resource that are returned by the provider described by this resource

Specified by:
getTransformer in interface OpenSearchResource
Returns:
The transformer that can be used to transform the results of the first MIME type appearing in this OpenSearch resource
Throws:
java.lang.Exception - In case of error
See Also:
org.gcube.opensearch.opensearchoperator.resource.OpenSearchResource#getTransformer())

getPresentationInformation

public java.util.Map<java.lang.String,java.lang.String> getPresentationInformation(java.lang.String MIMEType)
Retrieves the presentation information, that is, a mapping from field names to XPath expressions

Specified by:
getPresentationInformation in interface OpenSearchResource
Returns:
See Also:
OpenSearchResource.getPresentationInformation(String)

getTransformationTypes

public java.util.List<java.lang.String> getTransformationTypes()
Retrieves a list of all MIME types for which there exists a transformation specification

Specified by:
getTransformationTypes in interface OpenSearchResource
Returns:
All MIME types for which there exists a transformation specification
See Also:
OpenSearchResource.getTransformationTypes()

getParameterQName

public java.lang.String getParameterQName(java.lang.String fieldName)
Description copied from interface: OpenSearchResource
Retrieves the fully qualified name of an OpenSearch parameter which corresponds to a field

Specified by:
getParameterQName in interface OpenSearchResource
Parameters:
fieldName - The name of the field corresponding to the requested OpenSearch parameter
Returns:
The fully qualified name of the OpenSearch parameter

getParameters

public java.util.Map<java.lang.String,java.lang.String> getParameters()
Description copied from interface: OpenSearchResource
Retrieved the full mapping from field names to fully ns-qualified OpenSearch parameters as contained in the OpenSearch Resource

Specified by:
getParameters in interface OpenSearchResource
Returns:
All field name to fully ns-qualified mappings

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception