public class Examples extends ForwardResource implements VOSIResource
Additional TAP endpoint: /examples
. Then, this TAPResource
writes
a list of TAP examples.
The returned document MUST be a RDFa document as requested by the IVOA documents: TAPNote 1.0 or DALI 1.0. The syntax used in the returned document is thus expected to be one of those described by the two IVOA documents ; for now no particular syntax has been fixed by the IVOA community.
This TAP endpoint is also a VOSI resource. A capability is then provided thanks to the function
getCapability()
. The returned capability is the following:
<capability standardID="ivo://ivoa.net/std/DALI#examples> <interface xsi:type="vr:WebBrowser" role="std"> <accessURL use="full"> <-- Full URL of the TAP service suffixed by "/examples" --> </accessURL> </interface> </capability>
The home page URI is expected to be either relative/absolute path (both related to the Web Application
directory, NOT the local file system), a file:
URI (pointing toward a local file system file)
or a URL (basically any URI whose the scheme is not file:
).
To read/write the specified file, this class extends ForwardResource
in order to use its function
ForwardResource.forward(String, String, HttpServletRequest, HttpServletResponse)
.
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
accessURL
URL toward this TAP resource.
|
java.lang.String |
examplesFile
File containing the
/examples endpoint content. |
static java.lang.String |
MIME_TYPE
MIME type of this resource.
|
static java.lang.String |
RESOURCE_NAME
Name of this TAP resource.
|
static java.lang.String |
STANDARD_ID
Standard ID of this VOSI resource.
|
logger
Constructor and Description |
---|
Examples(TAP tap,
java.lang.String file)
Build an
/examples endpoint whose the content is provided by the specified file. |
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Let free properly all system/file/DB resources kept opened by this TAP resource.
|
boolean |
executeResource(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Interpret the given request, execute the appropriate action and finally return a result or display information to the user.
|
java.lang.String |
getAccessURL()
Get the URL which lets access this resource.
|
java.lang.String |
getCapability()
Get the capabilities of this resource.
|
java.lang.String |
getName()
Get the name of this TAP resource.
|
java.lang.String |
getStandardID()
Get the standardID of this endpoint of the VOSI interface.
|
void |
init(javax.servlet.ServletConfig config)
Let initialize this TAP resource.
|
void |
setTAPBaseURL(java.lang.String baseURL)
Let diffuse the base URL of the TAP service to all its TAP resources.
|
forward, logError
public static final java.lang.String RESOURCE_NAME
public static final java.lang.String STANDARD_ID
public static final java.lang.String MIME_TYPE
public final java.lang.String examplesFile
/examples
endpoint content.protected java.lang.String accessURL
URL toward this TAP resource. This URL is particularly important for its declaration in the capabilities of the TAP service.
Note: By default, it is just the name of this resource. It is updated after initialization of the service when the TAP service base URL is communicated to its resources. Then, it is: baseTAPURL + "/" + RESOURCE_NAME.
public Examples(TAP tap, java.lang.String file) throws java.lang.NullPointerException
/examples
endpoint whose the content is provided by the specified file.tap
- The TAP service whose the logger must be used.file
- The file containing the content of this endpoint.
It must be a URI with no scheme to reference a file inside the Web Application directory,
with the scheme file:
to reference a local system file
or with another scheme to make an explicit redirection toward the specified URL.java.lang.NullPointerException
- If at least one of the parameters is missing.public void init(javax.servlet.ServletConfig config) throws javax.servlet.ServletException
TAPResource
init
in interface TAPResource
config
- Servlet configuration. (may be useful for the configuration of this resource)javax.servlet.ServletException
- If any error prevent the initialization of this TAP resource. In case a such exception is thrown, the service should stop immediately.public void destroy()
TAPResource
destroy
in interface TAPResource
public final void setTAPBaseURL(java.lang.String baseURL)
TAPResource
Let diffuse the base URL of the TAP service to all its TAP resources.
Important note: This function should be called just once: either at the creation of the service or when the first request is sent to the TAP service (in this case, the request is also used to finish the initialization of the TAP service, and of all its resources).
setTAPBaseURL
in interface TAPResource
baseURL
- Common URL/URI used in all requests sent by any user to the TAP service.public java.lang.String getName()
TAPResource
Get the name of this TAP resource.
Important note: This name MUST NOT be NULL and SHOULD NEVER change.
getName
in interface TAPResource
public java.lang.String getCapability()
VOSIResource
getCapability
in interface VOSIResource
public java.lang.String getAccessURL()
VOSIResource
getAccessURL
in interface VOSIResource
public final java.lang.String getStandardID()
VOSIResource
Get the standardID of this endpoint of the VOSI interface.
The standard IDs of the VOSI endpoints are the following:
getStandardID
in interface VOSIResource
public boolean executeResource(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, TAPException
TAPResource
Interpret the given request, execute the appropriate action and finally return a result or display information to the user.
IMPORTANT:
"TAP resources can not take the law in their own hands!" :-)
Errors that could occur inside this function should not be written directly in the given HttpServletResponse
.
They should be thrown to the resources executor: an instance of TAP
, which
will fill the HttpServletResponse
with the error in the format described by the IVOA standard - VOTable. Besides, TAP
may also
add more information and may log the error (in function of this type).
executeResource
in interface TAPResource
request
- Request sent by the user and which should be interpreted/executed here.response
- Response in which the result of the request must be written.java.io.IOException
- If any error occurs while writing the result of the given request.TAPException
- If any other error occurs while interpreting and executing the request or by formating and writing its result.