public class TDBeaconsFTSRestClient extends FTSRestClient
implements StructureFTSRestClientI
{
- private static final String DEFAULT_THREEDBEACONS_DOMAIN = "https://wwwdev.ebi.ac.uk/pdbe/pdbe-kb/3dbeacons/api/uniprot/summary/";
-
- private static FTSRestClientI instance = null;
+ /**
+ * production server URI
+ */
+ private static String TDB_PROD_API="https://www.ebi.ac.uk/pdbe/pdbe-kb/3dbeacons/api/uniprot/summary/";
+ /**
+ * dev server URI
+ */
+ private static String TDB_DEV_API="https://wwwdev.ebi.ac.uk/pdbe/pdbe-kb/3dbeacons/api/uniprot/summary/";
+ private static String DEFAULT_THREEDBEACONS_DOMAIN = TDB_PROD_API;
+
+ public static FTSRestClientI instance = null;
protected TDBeaconsFTSRestClient()
{
}
-
@SuppressWarnings("unchecked")
@Override
public FTSRestResponse executeRequest(FTSRestRequest tdbRestRequest)
System.out.println(uri.toString());
// Execute the REST request
- ClientResponse clientResponse = webResource
- .accept(MediaType.APPLICATION_JSON).get(clientResponseClass);
+ ClientResponse clientResponse;
+ if (isMocked()) {
+ clientResponse = null;
+ }
+ else
+ {
+ clientResponse = webResource.accept(MediaType.APPLICATION_JSON)
+ .get(clientResponseClass);
+ }
// Get the JSON string from the response object or directly from the
// client (JavaScript)
String responseString = null;
// Check the response status and report exception if one occurs
- int responseStatus = clientResponse.getStatus();
+ int responseStatus = isMocked() ? (mockQuery.equals(query) ? 200 : 404) : clientResponse.getStatus();
switch (responseStatus)
{
// if success
}
else
{
- responseString = clientResponse.getEntity(String.class);
+ responseString = isMocked() ? mockResponse: clientResponse.getEntity(String.class);
}
break;
case 400:
throw new Exception(parseJsonExceptionString(responseString));
+ case 404:
+ return emptyTDBeaconsJsonResponse();
default:
throw new Exception(
getMessageByHTTPStatusCode(responseStatus, "3DBeacons"));
}
+ /**
+ * returns response for when the 3D-Beacons service doesn't have a record for
+ * the given query - in 2.11.2 this triggers a failover to the PDBe FTS
+ *
+ * @return null
+ */
+ private FTSRestResponse emptyTDBeaconsJsonResponse()
+ {
+ return null;
+ }
+
public String setSearchTerm(String term)
{
return term;