info.sswap.http.rest
Class RESTBase

java.lang.Object
  extended by info.sswap.http.rest.RESTBase
Direct Known Subclasses:
JSONSyntax, MakeEntity, MakePDG, MakeProperty, MakeRDG, MakeRIG, MakeRQG, MakeRRG, MakeType, RootResource

public abstract class RESTBase
extends java.lang.Object

An abstract class that is the base of all RESTful services in SSWAP HTTP/JSON API. Currently, this class provides the functionality of responding to GET requests which return human-readable message about how to access this particular resource.

Author:
Blazej Bulka

Field Summary
private static java.net.URL lastForwardInTesting
           
private static org.apache.log4j.Logger LOGGER
          Logger used by this abstract class.
 
Constructor Summary
RESTBase()
           
 
Method Summary
protected  void checkForUndefinedNS(info.sswap.api.model.SSWAPModel model)
           
static void clearLastForwardInTesting()
           
 javax.ws.rs.core.Response displayDescription()
          Serves the human-readable message about how to access this particular resource in response to an HTTP GET request
 javax.ws.rs.core.Response displayJSONSchema()
          Serves the human-readable message about how to access this particular resource in response to an HTTP GET request
protected  java.util.Map<java.lang.String,java.lang.String> extractPrefixOverride(javax.servlet.http.HttpServletRequest request)
           
protected  javax.ws.rs.core.Response forward(java.lang.String uploadedJson, java.lang.String subPath, java.util.Map<java.lang.String,java.lang.String> prefixOverride)
           
protected abstract  java.lang.String getDescriptionResource()
          Returns the name of the resource (in the classpath) that contains the human-readable description about this RESTful interface
protected abstract  java.lang.String getJSONSchemaResource()
          Returns the name of the resource (in the classpath) that contains the JSON schema for the document acceptable by this resource
static java.net.URL getLastForwardInTesting()
           
private  java.lang.String getMIMEType(com.clarkparsia.utils.web.Response response)
           
private  java.lang.String getOtherAPIBaseURL()
           
protected  boolean needsForwarding(java.lang.String uploadedJson)
           
protected  java.lang.String rebuildPrefixOverrideQueryString(java.util.Map<java.lang.String,java.lang.String> prefixOverride)
           
private static void recordForwardInTesting(java.net.URL url)
           
private  java.lang.String stripErrorPrefix(java.lang.String errorMessage)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

private static final org.apache.log4j.Logger LOGGER
Logger used by this abstract class.


lastForwardInTesting

private static java.net.URL lastForwardInTesting
Constructor Detail

RESTBase

public RESTBase()
Method Detail

getDescriptionResource

protected abstract java.lang.String getDescriptionResource()
Returns the name of the resource (in the classpath) that contains the human-readable description about this RESTful interface

Returns:
the name of the resource (in the class path) that is a plain text file with the description

getJSONSchemaResource

protected abstract java.lang.String getJSONSchemaResource()
Returns the name of the resource (in the classpath) that contains the JSON schema for the document acceptable by this resource

Returns:
the name of the resource (in the classpath) that is a JSON schema file

displayDescription

public javax.ws.rs.core.Response displayDescription()
Serves the human-readable message about how to access this particular resource in response to an HTTP GET request

Returns:
a response object

displayJSONSchema

public javax.ws.rs.core.Response displayJSONSchema()
Serves the human-readable message about how to access this particular resource in response to an HTTP GET request

Returns:
a response object

extractPrefixOverride

protected java.util.Map<java.lang.String,java.lang.String> extractPrefixOverride(javax.servlet.http.HttpServletRequest request)

rebuildPrefixOverrideQueryString

protected java.lang.String rebuildPrefixOverrideQueryString(java.util.Map<java.lang.String,java.lang.String> prefixOverride)

checkForUndefinedNS

protected void checkForUndefinedNS(info.sswap.api.model.SSWAPModel model)
                            throws info.sswap.api.model.ValidationException
Throws:
info.sswap.api.model.ValidationException

needsForwarding

protected boolean needsForwarding(java.lang.String uploadedJson)

getOtherAPIBaseURL

private java.lang.String getOtherAPIBaseURL()

getMIMEType

private java.lang.String getMIMEType(com.clarkparsia.utils.web.Response response)

stripErrorPrefix

private java.lang.String stripErrorPrefix(java.lang.String errorMessage)

forward

protected javax.ws.rs.core.Response forward(java.lang.String uploadedJson,
                                            java.lang.String subPath,
                                            java.util.Map<java.lang.String,java.lang.String> prefixOverride)
                                     throws java.net.MalformedURLException,
                                            java.io.IOException
Throws:
java.net.MalformedURLException
java.io.IOException

recordForwardInTesting

private static void recordForwardInTesting(java.net.URL url)

getLastForwardInTesting

public static java.net.URL getLastForwardInTesting()

clearLastForwardInTesting

public static void clearLastForwardInTesting()


Copyright (c) 2010, iPlant Collaborative, University of Arizona, Cold Spring Harbor Laboratories, University of Texas at Austin.