|
Version: 1.1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.biomoby.client.CentralImpl
public class CentralImpl
A default implementation of the
interface Central
allowing access to a Moby registry.
This class is supposed to be used by all other clients that wish to communicate with the Moby Registry, but do not want to know about all XML details that are necessary for talking with the Moby Central directly. This is an example of a client program:
import org.biomoby.shared.Central; import org.biomoby.shared.MobyException; import org.biomoby.client.CentralImpl; import java.util.Map; import java.util.Iterator; public class Test { public static void main (String[] args) throws MobyException { Central worker = new CentralImpl(); Map authorities = worker.getServiceNamesByAuthority(); for (Iterator it = authorities.entrySet().iterator(); it.hasNext(); ) { Map.Entry entry = (Map.Entry)it.next(); System.out.println (entry.getKey()); String[] names = (String[])entry.getValue(); for (int i = 0; i < names.length; i++) System.out.println ("\t" + names[i]); } } }
Field Summary | |
---|---|
static String |
CENTRAL_IMPL_RESOURCE_NAME
The META-INF resource file that will be checked to determine what default class should be instantiated in order to create a Central Implementation when getDefaultCentral() is called. |
static String |
DEFAULT_CENTRAL_IMPL_CLASSNAME
The class to use for getDefaultCentral if all else fails |
static String |
DEFAULT_ENDPOINT
Default location (endpoint) of a Moby registry. |
static String |
DEFAULT_NAMESPACE
Default namespace used by the contacted Moby registry. |
static ThreadLocal |
DOCUMENT_BUILDER_FACTORIES
Thread local that gives each thread its own DocumentBuilderFactory (since it is not thread-safe). |
Fields inherited from interface org.biomoby.shared.Central |
---|
DATA_TYPES_RESOURCE_NAME, FULL_RESOURCE_NAME, HAS, HASA, iHAS, iHASA, iISA, ISA, NAMESPACES_RESOURCE_NAME, SERVICE_INSTANCES_RESOURCE_NAME, SERVICE_TYPES_RESOURCE_NAME |
Constructor Summary | |
---|---|
CentralImpl()
Default constructor. |
|
CentralImpl(String endpoint)
Constructor allowing to specify which Moby Registry to use. |
|
CentralImpl(String endpoint,
String namespace)
Constructor allowing to specify which Moby Registry and what namespace to use. |
Method Summary | |
---|---|
String |
call(String methodName,
String inputXML)
Call Moby registry's method with given XML as input and return whatever you get back. |
String |
createId(String rootName,
String semanticType,
String syntaxType,
long lastModified,
Properties props)
Create a unique ID from the given parameters. |
String |
escapeXML(String str)
Convert non-suitable characters in a XML string into their entity references. |
boolean |
existsInCache(String id)
Is the object identified by its 'id' already cached? |
MobyService[] |
extractServices(String xml)
Extract one or more MobyService objects from the given XML piece. |
MobyService[] |
findService(MobyService pattern)
Find services matching whatever is non-empty in the given 'pattern'. |
MobyService[] |
findService(MobyService pattern,
String[] keywords)
Find service matching both all non-empty fields in the 'pattern' and the 'keywords'. |
MobyService[] |
findService(MobyService pattern,
String[] keywords,
boolean includeChildrenServiceTypes,
boolean includeParentDataTypes)
All 'findService' methods end up here. |
MobyService[] |
findService(String serviceType)
Find services of the given type and its sub-types. |
MobyService[] |
findService(String[] keywords)
Find services by given keywords. |
static void |
formatFault(org.apache.axis.AxisFault e,
PrintStream out,
String endpoint,
QName method)
Format an exception. |
static String |
formatFault(org.apache.axis.AxisFault e,
String endpoint,
QName method)
Format an exception. |
boolean |
getCacheMode()
Find if caching is currently enabled. |
Object |
getContents(String id)
Return 'data' identified by 'id'. |
MobyDataType |
getDataType(String dataTypeName)
Parses and imports the following XML. |
Map |
getDataTypeNames()
Parses and imports the following XML. |
Map |
getDataTypeRelationships(String dataTypeName)
Parses and imports the following XML. |
String[] |
getDataTypeRelationships(String dataTypeName,
String relationshipType)
Parses and imports the following XML. |
MobyDataType[] |
getDataTypes()
|
static CentralImpl |
getDefaultCentral()
Using this method to get a Central object will ensure that other parts of the org.biomoby.shared class hierarchy that implicitly check the registry will use the same cache. |
static CentralImpl |
getDefaultCentral(Registry reg)
|
static String |
getDefaultURI()
|
static String |
getDefaultURL()
|
MobyNamespace[] |
getFullNamespaces()
Parses and imports the following XML. |
Map |
getNamespaces()
Deprecated. Replaced by getFullNamespaces() that gives
more information for the same price. |
String[] |
getProviders()
Parses and imports the following XML. |
String |
getRegisterDataTypeXML(MobyDataType dataType)
|
String |
getRegisterNamespaceXML(MobyNamespace namespace)
|
String |
getRegisterServiceTypeXML(MobyServiceType serviceType)
|
String |
getRegisterServiceXML(MobyService service)
|
String |
getRegistryEndpoint()
Return an endpoint (a stringified URL) representing a Moby registry that an instance of this implementation is connected to. |
String |
getRegistryNamespace()
Return a namespace (a URI) used by a Moby registry that an instance of this implementation is connected to. |
InputStream |
getResource(String resourceName)
First get (from a BioMoby registry) a URL for the given 'resourceName' and then retrieve a document from this URL. |
MobyResourceRef[] |
getResourceRefs()
Parses and imports the following XML. |
Map<String,String> |
getServiceNames()
Deprecated. Replaced by getServiceNamesByAuthority() . The reason is that this method
returns a random result if there are more services with the
same name but belonging to different authorities. |
Map |
getServiceNamesByAuthority()
Parses and imports the following XML. |
Map |
getServicesByAuthority()
Similar to getServiceNamesByAuthority() but the
resulting Map contains slightly more. |
String[] |
getServiceTypeRelationships(String serviceTypeName,
boolean expand)
Parses and imports the following XML. |
Map<String,String> |
getServiceTypes()
Parses and imports the following XML. |
String |
getServiceWSDL(String serviceName)
Get WSDL defining a service given by its name. |
String |
getServiceWSDL(String serviceName,
String authority)
Get WSDL defining a service given by its name and its authority. |
static Document |
loadDocument(InputStream input)
Loads a DOM Document from an InputStream. |
void |
registerDataType(MobyDataType dataType)
Register new data type. |
void |
registerNamespace(MobyNamespace namespace)
Register new namespace. |
void |
registerService(MobyService service)
Register a new service. |
void |
registerServiceType(MobyServiceType serviceType)
Register new service type. |
void |
removeFromCache(String id)
Remove cached object identified by its 'id' from the cache. |
void |
setCacheMode(boolean shouldCache)
By default, caching is enabled to reduce network traffic. |
void |
setContents(String id,
Object data)
Store/cache 'data' identified by 'id'. |
boolean |
setDebug(boolean enabled)
Ask the implementation to create more verbose logs or messages about what is going on. |
void |
unregisterDataType(MobyDataType dataType)
B |
void |
unregisterNamespace(MobyNamespace namespace)
Unregister given Moby namespace. |
void |
unregisterService(MobyService service)
Unregister given Moby service. |
void |
unregisterServiceType(MobyServiceType serviceType)
Unregister given Moby service type. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String DEFAULT_ENDPOINT
public static final String DEFAULT_NAMESPACE
public static final String CENTRAL_IMPL_RESOURCE_NAME
public static final String DEFAULT_CENTRAL_IMPL_CLASSNAME
public static ThreadLocal DOCUMENT_BUILDER_FACTORIES
Constructor Detail |
---|
public CentralImpl() throws MobyException
DEFAULT_ENDPOINT
) using a default namespace
(as defined int DEFAULT_NAMESPACE
).
MobyException
public CentralImpl(String endpoint) throws MobyException
MobyException
- if 'endpoint' is not a valid URL, or if no
DOM parser is availablepublic CentralImpl(String endpoint, String namespace) throws MobyException
MobyException
- if 'endpoint' is not a valid URL, or if no
DOM parser was foundMethod Detail |
---|
public static Document loadDocument(InputStream input) throws MobyException
MobyException
public MobyService[] extractServices(String xml) throws MobyException
<Services> <Service authURI="authority.URI.here" lsid="..." serviceName="MyService"> <serviceType>Service_Ontology_Term</serviceType> <Category>moby</Category> <!-- or 'cgi' or 'soap' --> <contactEmail>your@email.addy.here</contactEmail> <signatureURL>http://service.RDF.here</signatureURL> <URL>http://service.endpoint.here/scriptname</URL> <authoritative>1</authoritative> <Input> <!-- one or more Simple and/or Complex Primary articles --> </Input> <Output> <!-- one or more Simple and/or Complex Primary articles --> </Output> <secondaryArticles> <!-- one or more Secondary articles --> </secondaryArticles> <Description><![CDATA[free text description here]]></Description> </Service> ... <!-- one or more Service blocks may be returned --> ... ... </Services>
MobyException
- if the XML document is invalidpublic String createId(String rootName, String semanticType, String syntaxType, long lastModified, Properties props)
SimpleCache
createId
in interface SimpleCache
rootName
- is some high level name of the cached objectsemanticType
- is yet another feature of the cached objectsyntaxType
- is another property of the cached object
(e.i. it may be used as the file name suffix if the cache is
implemented as a filesystem)lastModified
- is time in millis indicating when the
cached object was created or modifiedprops
- are all remaining properties identifying the
cached object
public boolean existsInCache(String id)
SimpleCache
existsInCache
in interface SimpleCache
id
- a unique ID of the cached (or possibly cached) object
public Object getContents(String id)
SimpleCache
getContents
in interface SimpleCache
id
- a unique ID of the object being returned
public void setContents(String id, Object data)
SimpleCache
setContents
in interface SimpleCache
id
- a unique ID of the object being storeddata
- are being storedpublic void removeFromCache(String id)
SimpleCache
removeFromCache
in interface SimpleCache
id
- a unique IDpublic void setCacheMode(boolean shouldCache)
setCacheMode
in interface Central
shouldCache
- whether retrieveXXX call results should be
cached in case they are called again (i.e. don't request
MobyCentral every time)public boolean getCacheMode()
getCacheMode
in interface Central
public Map<String,String> getServiceNames() throws MobyException
getServiceNamesByAuthority()
. The reason is that this method
returns a random result if there are more services with the
same name but belonging to different authorities.
<serviceNames> <serviceName name="serviceName" authURI='authority.info.here'/> ... ... </serviceNames>
getServiceNames
in interface Central
MobyException
- if communication with the Moby Registry failspublic Map getServiceNamesByAuthority() throws MobyException
<serviceNames> <serviceName name="serviceName" lsid="..." authURI='authority.info.here'/> ... ... </serviceNames>
getServiceNamesByAuthority
in interface Central
MobyException
- if communication with the Moby Registry failspublic Map getServicesByAuthority() throws MobyException
getServiceNamesByAuthority()
but the
resulting Map contains slightly more.
MobyException
public String[] getProviders() throws MobyException
<serviceProviders> <serviceProvider name="authority.URI.here"/> ... ... </serviceProviders>
getProviders
in interface Central
MobyException
- if communication with the Moby Registry failspublic Map<String,String> getServiceTypes() throws MobyException
<serviceTypes> <serviceType name="serviceName" lsid="..."> <Description><![CDATA[free text description here]]></Description> <contactEmail>...</contactEmail> <authURI>...</authURI> </serviceType> ... ... </serviceTypes>
getServiceTypes
in interface Central
MobyException
- if communication with the Moby Registry failspublic MobyNamespace[] getFullNamespaces() throws MobyException
<Namespaces> <Namespace name="namespace" lsid="..."> <Description><![CDATA[free text description here]]></Description> <contactEmail>...</contactEmail> <authURI>...</authURI> </Namespace> ... ... </Namespaces>
getFullNamespaces
in interface Central
MobyException
- if communication with the Moby Registry failspublic Map getNamespaces() throws MobyException
getFullNamespaces()
that gives
more information for the same price.
Central
getNamespaces
in interface Central
MobyException
- if communication with the Moby Registry failspublic Map getDataTypeNames() throws MobyException
<objectNames> <Object name="objectName" lsid="..."> <Description><![CDATA[free text description here]]></Description> </Object> ... ... </objectNames>
getDataTypeNames
in interface Central
MobyException
- if communication with the Moby Registry failspublic MobyDataType getDataType(String dataTypeName) throws MobyException, NoSuccessException
<retrieveObjectDefinition> <objectType lsid="...">go_term</objectType> <Description><![CDATA[A very lightweight object holding a GO term name and its definition]]></Description> <authURI>http://www.illuminae.com</authURI> <contactEmail>markw@illuminae.com</contactEmail> <Relationship relationshipType='urn:lsid:biomoby.org:objectrelation:isa'> <objectType articleName=''>urn:lsid:biomoby.org:objectclass:object</objectType> </Relationship> <Relationship relationshipType='urn:lsid:biomoby.org:objectrelation:hasa'> <objectType articleName='Term'>urn:lsid:biomoby.org:objectclass:string</objectType> <objectType articleName='Definition'>urn:lsid:biomoby.org:objectclass:string</objectType> </Relationship> <Relationship relationshipType='urn:lsid:biomoby.org:objectrelation:has'> <objectType articleName='Problems'>urn:lsid:biomoby.org:objectclass:string</objectType> <objectType articleName='Issues'>urn:lsid:biomoby.org:objectclass:string</objectType> </Relationship> </retrieveObjectDefinition>
getDataType
in interface Central
MobyException
- if communication with the Moby Registry fails
NoSuccessException
- if 'dataTypeName' was not foundpublic MobyDataType[] getDataTypes() throws MobyException, NoSuccessException
getDataTypes
in interface Central
MobyException
NoSuccessException
public String getServiceWSDL(String serviceName) throws MobyException, NoSuccessException
Central
getServiceWSDL
in interface Central
MobyException
- if communication with the Moby Registry fails
NoSuccessException
- if such service was not foundCentral.getServiceWSDL(String,String)
public String getServiceWSDL(String serviceName, String authority) throws MobyException, NoSuccessException
Central
getServiceWSDL
in interface Central
MobyException
- if communication with the Moby Registry fails
NoSuccessException
- if such service was not foundpublic String getRegisterDataTypeXML(MobyDataType dataType)
public void registerDataType(MobyDataType dataType) throws MobyException, NoSuccessException, PendingCurationException
Central
If the same data type is already registered, it is overwritten.
registerDataType
in interface Central
MobyException
- if communication with the Moby Registry fails
NoSuccessException
- if registration failed
PendingCurationException
public void unregisterDataType(MobyDataType dataType) throws MobyException, NoSuccessException, PendingCurationException
unregisterDataType
in interface Central
MobyException
- if communication with the Moby Registry fails
NoSuccessException
- if unregistration failed
PendingCurationException
public String getRegisterServiceTypeXML(MobyServiceType serviceType)
public void registerServiceType(MobyServiceType serviceType) throws MobyException, NoSuccessException, PendingCurationException
Central
If the same service type is already registered, it is not overwritten but an exception is raised.
registerServiceType
in interface Central
MobyException
- if communication with the Moby Registry fails
NoSuccessException
- if registration failed
PendingCurationException
public void unregisterServiceType(MobyServiceType serviceType) throws MobyException, NoSuccessException, PendingCurationException
Central
unregisterServiceType
in interface Central
MobyException
- if communication with the Moby Registry fails
NoSuccessException
- if unregistration failed
PendingCurationException
public String getRegisterNamespaceXML(MobyNamespace namespace)
public void registerNamespace(MobyNamespace namespace) throws MobyException, NoSuccessException, PendingCurationException
Central
If the same namespace is already registered, it is overwritten.
registerNamespace
in interface Central
MobyException
- if communication with the Moby Registry fails
NoSuccessException
- if registration failed
PendingCurationException
public void unregisterNamespace(MobyNamespace namespace) throws MobyException, NoSuccessException, PendingCurationException
Central
unregisterNamespace
in interface Central
MobyException
- if communication with the Moby Registry fails
NoSuccessException
- if unregistration failed
PendingCurationException
public String getRegisterServiceXML(MobyService service)
public void registerService(MobyService service) throws MobyException, NoSuccessException, PendingCurationException
Central
If the same service type is already registered, it is not overwritten but an exception is raised.
registerService
in interface Central
MobyException
- if communication with the Moby Registry fails
NoSuccessException
- if registration failed
PendingCurationException
public void unregisterService(MobyService service) throws MobyException, NoSuccessException, PendingCurationException
Central
unregisterService
in interface Central
MobyException
- if communication with the Moby Registry fails
NoSuccessException
- if unregistration failed
PendingCurationException
public MobyService[] findService(String serviceType) throws MobyException
Central
findService
in interface Central
MobyException
- if communication with the Moby Registry failspublic MobyService[] findService(String[] keywords) throws MobyException
Central
findService
in interface Central
MobyException
- if communication with the Moby Registry failspublic MobyService[] findService(MobyService pattern) throws MobyException
Central
findService
in interface Central
MobyException
- if communication with the Moby Registry failspublic MobyService[] findService(MobyService pattern, String[] keywords) throws MobyException
Central
findService
in interface Central
MobyException
public MobyService[] findService(MobyService pattern, String[] keywords, boolean includeChildrenServiceTypes, boolean includeParentDataTypes) throws MobyException
findService
in interface Central
includeChildrenServiceTypes
- - if true (which is default)
then it discovers also services that are child types (more
specific) than the service type in 'pattern'includeParentDataTypes
- - if true (which is default) then
it finds services that operate not only on the input/output
data types defined in 'pattern', but also any ontolological
parent types of that data types
MobyException
public String call(String methodName, String inputXML) throws MobyException
Central
Meant for debugging and may be deprecated anytime...
call
in interface Central
MobyException
public boolean setDebug(boolean enabled)
Central
setDebug
in interface Central
enabled
- true if debug mode should be enabled, false otherwise
public String[] getServiceTypeRelationships(String serviceTypeName, boolean expand) throws MobyException
<Relationships> <Relationship relationshipType='urn:lsid:biomoby.org:servicerelation:isa'> <serviceType>urn:lsid:biomoby.org:servicetype:analysis</serviceType> <serviceType>urn:lsid:biomoby.org:servicetype:service</serviceType> </Relationship> </Relationships>
getServiceTypeRelationships
in interface Central
serviceTypeName
- is a service type name whose
relationships should be looked atexpand
- 'true' causes that all related type names are
returned, 'false' means that only first-level neighbour is returned
MobyException
- if communication with the Moby Registry failspublic Map getDataTypeRelationships(String dataTypeName) throws MobyException
<Relationships> <Relationship relationshipType='urn:lsid:biomoby.org:objectrelation:isa'> <objectType>urn:lsid:biomoby.org:objectclass:virtualsequence</objectType> <objectType>urn:lsid:biomoby.org:objectclass:object</objectType> </Relationship> <Relationship relationshipType='urn:lsid:biomoby.org:objectrelation:hasa'> <objectType>urn:lsid:biomoby.org:objectclass:string</objectType> <objectType>urn:lsid:biomoby.org:objectclass:integer</objectType> </Relationship> </Relationships>Added at Sun Feb 19 19:32:31 PHT 2006: it recognizes also an attributes 'lsid' and 'articleName' in <objectType> element.
getDataTypeRelationships
in interface Central
dataTypeName
- is an ontology term specifying whose
relationships should be looked at
Central.ISA
, Central.HASA
, and Central.HAS
. The
values (of type String) are data type names.
MobyException
- if communication with the Moby Registry failspublic String[] getDataTypeRelationships(String dataTypeName, String relationshipType) throws MobyException
<Relationships> <Relationship relationshipType='urn:lsid:biomoby.org:objectrelation:isa'> <objectType>urn:lsid:biomoby.org:objectclass:virtualsequence</objectType> <objectType>urn:lsid:biomoby.org:objectclass:object</objectType> </Relationship> </Relationships>
getDataTypeRelationships
in interface Central
dataTypeName
- is an ontology term specifying whose
relationships should be looked atrelationshipType
- is one from the set Central.ISA
,
Central.HASA
, and Central.HAS
.
MobyException
- if communication with the Moby Registry failspublic String getRegistryEndpoint()
Central
getRegistryEndpoint
in interface Central
public String getRegistryNamespace()
Central
getRegistryNamespace
in interface Central
public MobyResourceRef[] getResourceRefs() throws MobyException
<resourceURLs> <Resource name="Service" url="..." /> <Resource name="Object" url="..." /> <Resource name="Namespace" url="..." /> <Resource name="ServiceInstance" url="..." /> <Resource name="Full" url="..." /> </resourceURLs>
getResourceRefs
in interface Central
MobyException
- if communication with the Moby Registry failspublic InputStream getResource(String resourceName) throws MobyException
Central
The document is in RDF and represents some (or all) entities registered in the BioMoby registry.
getResource
in interface Central
resourceName
- is an ontology name (must be one of these:
Central.SERVICE_TYPES_RESOURCE_NAME
, Central.DATA_TYPES_RESOURCE_NAME
, Central.NAMESPACES_RESOURCE_NAME
,
Central.SERVICE_INSTANCES_RESOURCE_NAME
, Central.FULL_RESOURCE_NAME
)
MobyException
- if communication with the Moby Registry
fails, or if communication with the resource URL failspublic static CentralImpl getDefaultCentral() throws MobyException
MobyException
public static CentralImpl getDefaultCentral(Registry reg) throws MobyException
MobyException
public static String getDefaultURL()
public static String getDefaultURI()
public String escapeXML(String str)
Adapted from jDom.
str
- input to be converted
public static String formatFault(org.apache.axis.AxisFault e, String endpoint, QName method)
public static void formatFault(org.apache.axis.AxisFault e, PrintStream out, String endpoint, QName method)
|
Version: 1.1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |