org.opentox.toxotis.core
Class OTOnlineResource<T extends OTOnlineResource>

java.lang.Object
  extended by org.opentox.toxotis.core.OTComponent<T>
      extended by org.opentox.toxotis.core.OTOnlineResource<T>
All Implemented Interfaces:
Serializable, IOnlineResource, IOTComponent, IStAXWritable
Direct Known Subclasses:
Algorithm, Model, OTPublishable, Task, User

public abstract class OTOnlineResource<T extends OTOnlineResource>
extends OTComponent<T>
implements IOnlineResource

Any OTComponent that can be available online and has a URL.

Author:
Pantelis Sopasakis, Charalampos Chomenides
See Also:
Serialized Form

Field Summary
protected static Map<String,String> XSD_DATATYPE_LINKS
          Assigns a documentation link to each XSDDataType element.
 
Fields inherited from class org.opentox.toxotis.core.OTComponent
meta, RDF_ABOUT, RDF_RDF, RDF_RESOURCE, RDF_TYPE
 
Constructor Summary
protected OTOnlineResource()
          Construct a new instance of OTOnlineResource.
protected OTOnlineResource(VRI uri)
          Construct an OpenTox online resource providing its URI.
 
Method Summary
 void download(File destination, Media media, AuthenticationToken token)
          Downloads a certain representation of the compound in a specified MIME type.
 void download(OutputStream destination, Media media, AuthenticationToken token)
          Downloads a certain representation of the compound in a specified MIME type.
 void download(String destination, Media media, AuthenticationToken token)
          Downloads a certain representation of the compound in a specified MIME type.
 void download(Writer destination, Media media, AuthenticationToken token)
          Downloads a certain representation of the compound in a specified MIME type.
 BufferedImage downloadImage(Media imageMedia, AuthenticationToken token)
           
 T loadFromRemote()
          Update the current component according to some remote resource.
 T loadFromRemote(AuthenticationToken authentication)
          Downloads and parses a component that is hosted on a remote location identified by the URI of the underlying component as returned by the method OTComponent.getUri().
protected abstract  T loadFromRemote(VRI vri, AuthenticationToken token)
          Loads an OpenTox component from a remote location identified by its uri and parses it into an instance of T.
 
Methods inherited from class org.opentox.toxotis.core.OTComponent
addOntologicalClasses, asOntModel, endRdfWriter, equals, getMeta, getOntologicalClasses, getUri, hashCode, initRdfWriter, isEnabled, setEnabled, setMeta, setOntologicalClasses, setUri, writeAnnotationProperty, writeClass, writeDatatypeProperty, writeMetaDataProperties, writeObjectProperty, writeRdf, writeRdf, writeSuperClassRelationships
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.opentox.toxotis.core.IOTComponent
addOntologicalClasses, asIndividual, asOntModel, getMeta, getOntologicalClasses, getUri, isEnabled, setEnabled, setMeta, setOntologicalClasses
 
Methods inherited from interface org.opentox.toxotis.core.IStAXWritable
writeRdf
 

Field Detail

XSD_DATATYPE_LINKS

protected static final Map<String,String> XSD_DATATYPE_LINKS
Assigns a documentation link to each XSDDataType element.

Constructor Detail

OTOnlineResource

protected OTOnlineResource(VRI uri)
Construct an OpenTox online resource providing its URI. This constructor is supposed to be invoked only be subclasses of OTOnlineResource, that is why it is protected.

Parameters:
uri - URI of the resource.

OTOnlineResource

protected OTOnlineResource()
Construct a new instance of OTOnlineResource. This constructor is intended to be invoked by subclasses of OTOnlineResource and also invoked the dummy constructor in OTComponent.

Method Detail

loadFromRemote

public T loadFromRemote()
                                          throws ServiceInvocationException
Update the current component according to some remote resource. Load information from the remote location as is identified by the uri of the resource. This method assuemes that no Authentication or Authorization is required to access the remote resource.

Returns:
An OpenTox component as an instance of T, i.e. of the same type with the object performing the request.
Throws:
ServiceInvocationException - In case the Ontological Model cannot be downloaded from the specified online resource.
See Also:
OTComponent.getUri(), OTComponent.setUri(org.opentox.toxotis.client.VRI)

loadFromRemote

public T loadFromRemote(AuthenticationToken authentication)
                                          throws ServiceInvocationException
Downloads and parses a component that is hosted on a remote location identified by the URI of the underlying component as returned by the method OTComponent.getUri(). The resource is downloaded as application/rdf+xml and subsequently is parsed into an instance of T.

Parameters:
authentication - Token used to authenticate the user against the SSO server and acquire permission to download the resource.
Returns:
Parsed instance of the component.
Throws:
ServiceInvocationException - A ServiceInvocationException is thrown in case the remote resource is unreachable, the service responds with an unexpected or error status code (500, 503, 400 etc) or other potent communication error occur during the connection or the transaction of data. A ToxOtis exception is also thrown in case of insufficient priviledges to access the resource or if the submitted token is stale or in general invalid.

loadFromRemote

protected abstract T loadFromRemote(VRI vri,
                                    AuthenticationToken token)
                                                      throws ServiceInvocationException
Loads an OpenTox component from a remote location identified by its uri and parses it into an instance of T. This method is protected and should be implemented by all subclasses of OTOnlineResource. The method is invoked by its public counterpart loadFromRemote(org.opentox.toxotis.util.aa.AuthenticationToken) which accesses the remote location providing an authentication token.

Parameters:
vri - Identifier of the location from where the component should be downloaded and parsed
token - Token provided
Returns:
Parsed instance of the component.
Throws:
ToxOtisException - A ToxOtisException is thrown in case the remote resource is unreachable, the service responds with an unexpected or error status code (500, 503, 400 etc) or other potent communication error occur during the connection or the transaction of data.
ServiceInvocationException

download

public void download(String destination,
                     Media media,
                     AuthenticationToken token)
              throws ServiceInvocationException
Downloads a certain representation of the compound in a specified MIME type.

Parameters:
destination - String where the data should be stored.
media - Content type of the downloaded representation
token - Token used for authenticating the client against the remote compound service (You can set it to null).
Throws:
ServiceInvocationException - In case an authentication error occurs or the remote service responds with an error code like 500 or 503 or the submitted representation is syntactically or semantically wrong (status 400).
See Also:
Collection of MIMEs

download

public void download(OutputStream destination,
                     Media media,
                     AuthenticationToken token)
              throws ServiceInvocationException
Downloads a certain representation of the compound in a specified MIME type.

Parameters:
destination - Stream where the data should be streamed.
media - Content type of the downloaded representation
token - Token used for authenticating the client against the remote compound service (You can set it to null).
Throws:
ToxOtisException - In case an authentication error occurs or the remote service responds with an error code like 500 or 503 or the submitted representation is syntactically or semantically wrong (status 400).
ServiceInvocationException
See Also:
Collection of MIMEs

download

public void download(File destination,
                     Media media,
                     AuthenticationToken token)
              throws ServiceInvocationException
Downloads a certain representation of the compound in a specified MIME type.

Parameters:
destination - File where the data should be stored.
media - Content type of the downloaded representation
token - Token used for authenticating the client against the remote compound service (You can set it to null).
Throws:
ToxOtisException - In case an authentication error occurs or the remote service responds with an error code like 500 or 503 or the submitted representation is syntactically or semantically wrong (status 400).
ServiceInvocationException
See Also:
Collection of MIMEs

downloadImage

public BufferedImage downloadImage(Media imageMedia,
                                   AuthenticationToken token)
                            throws ServiceInvocationException
Parameters:
imageMedia -
token -
Returns:
A depiction downloaded from the remote compound service (as specified by OTComponent.getUri() as a BufferedImage.
Throws:
ToxOtisException
ServiceInvocationException

download

public void download(Writer destination,
                     Media media,
                     AuthenticationToken token)
              throws ServiceInvocationException
Downloads a certain representation of the compound in a specified MIME type.

Parameters:
destination - Writer where the data should be written.
media - Content type of the downloaded representation
token - Token used for authenticating the client against the remote compound service (You can set it to null).
Throws:
ToxOtisException - In case an authentication error occurs or the remote service responds with an error code like 500 or 503 or the submitted representation is syntactically or semantically wrong (status 400).
ServiceInvocationException
See Also:
Collection of MIMEs


Copyright © 2011-2012 OpenTox. All Rights Reserved.