|
void | setServer (String server) throws IllegalArgumentException |
|
String | getServerURL () |
|
String | latlongFormatter (String text) |
|
String | trimmLast (String text) |
|
JSONObject | asJSONObject (String text) throws IOException |
|
JSONArray | asJSONArray (String text) throws IOException |
|
Object | safeJSONTraverse (String sequence, Object original, Class<?> target) throws IOException |
| Traverse JSON in a type-safe manner. More...
|
|
String | executeHTTPRequest (Request request) throws ClientProtocolException, IOException, RateLimitException |
|
String | get (String url) throws RateLimitException, IOException |
|
String | getUSGS (String url) throws RateLimitException, IOException |
|
String | post (String url, Map< String, String > arguments) throws IOException, RateLimitException |
|
String | post (String url, String data) throws IOException, RateLimitException |
|
String | delete (String url) throws IOException, RateLimitException |
|
String | prepare (String url) |
|
String | prepareUSGS (String url) |
|
◆ Connector()
bridges.connect.Connector.Connector |
( |
| ) |
|
|
protected |
◆ asJSONArray()
JSONArray bridges.connect.Connector.asJSONArray |
( |
String |
text | ) |
throws IOException |
Decode a String containing JSON into a JSON Array, or throw an error.
- Parameters
-
text | The JSON Array as a string |
- Returns
- a non-null JSONArray
◆ asJSONObject()
JSONObject bridges.connect.Connector.asJSONObject |
( |
String |
text | ) |
throws IOException |
Decode a String containing JSON into a JSON Object, or throw an error.
- Parameters
-
- Returns
- A non-null JSON object
◆ delete()
String bridges.connect.Connector.delete |
( |
String |
url | ) |
throws IOException, RateLimitException |
Send a delete request to the server for the given user and assignment
- Parameters
-
url | send a delete request using this url |
◆ executeHTTPRequest()
String bridges.connect.Connector.executeHTTPRequest |
( |
Request |
request | ) |
throws ClientProtocolException, IOException, RateLimitException |
Execute an Apache Fluent Request. Decorates HTTP error tracebacks with urls and server {"error": "..."} responses. Throws an IOException with URL if the server returns an empty response. Returns server response if the status code is >= 400 but can still throw other exceptions if JSON parsing fails when formatting server JSON response
- Parameters
-
- Returns
- the requested string from the server
- Exceptions
-
ClientProtocolException | |
IOException | |
RateLimitException | |
◆ get()
◆ getServerURL()
String bridges.connect.Connector.getServerURL |
( |
| ) |
|
Get the current base URL for the server (with no ending/)
- Returns
- url of the server
◆ getUSGS()
String bridges.connect.Connector.getUSGS |
( |
String |
url | ) |
throws RateLimitException, IOException |
Execute a request of earthquakes to Earthquake server
- Parameters
-
- Returns
- JSON string
- Exceptions
-
RateLimitException | |
IOException | |
◆ latlongFormatter()
String bridges.connect.Connector.latlongFormatter |
( |
String |
text | ) |
|
This reformats the coordinates in Earthwuake tweet such that there will be no arrays present when casting to the JSONObject. for the reasons described below
- Parameters
-
- Returns
◆ post() [1/2]
String bridges.connect.Connector.post |
( |
String |
url, |
|
|
Map< String, String > |
arguments |
|
) |
| throws IOException, RateLimitException |
Execute a simple POST request with relative paths, taking a Scala Map() of request parameters.
◆ post() [2/2]
String bridges.connect.Connector.post |
( |
String |
url, |
|
|
String |
data |
|
) |
| throws IOException, RateLimitException |
◆ prepare()
String bridges.connect.Connector.prepare |
( |
String |
url | ) |
|
Escape the URL and prepend the base URL.
- Parameters
-
url | prepare the request to be sent using this url |
- Returns
- the new url as a String
◆ prepareUSGS()
String bridges.connect.Connector.prepareUSGS |
( |
String |
url | ) |
|
- Parameters
-
url | prepare the request to be sent using this url for earthquake data |
- Returns
- the new url as a String
◆ safeJSONTraverse()
Object bridges.connect.Connector.safeJSONTraverse |
( |
String |
sequence, |
|
|
Object |
original, |
|
|
Class<?> |
target |
|
) |
| throws IOException |
Traverse JSON in a type-safe manner.
This is somewhat complicated, but comes with the advantage that the debugging reports are far clearer when you know the whole path you are searching for.
Use this syntax: [ number ] to access an array element, ["quoted string"] to get an object attribute
- Parameters
-
◆ setServer()
void bridges.connect.Connector.setServer |
( |
String |
server | ) |
throws IllegalArgumentException |
Set the current server to 'live', 'clone', or 'local', or throw an error; live is the default, clone is used for development/testing and local for use by developers on their local machines
- Parameters
-
◆ setServerURL()
void bridges.connect.Connector.setServerURL |
( |
String |
server_url | ) |
|
|
protected |
Set the current base URL for the server (with no ending /)
- Parameters
-
server_url | server url to be set |
◆ trimmLast()
String bridges.connect.Connector.trimmLast |
( |
String |
text | ) |
|
Trimm the end of the earthquake data: ,"products":{"String":[]}
Important: future implementations could combine the above in one single method with a hash table for different patters Mihai
- Parameters
-
- Returns
◆ airline_url
String bridges.connect.Connector.airline_url = "https://earthquakes-uncc.herokuapp.com/airline" |
|
package |
◆ http_connection
Executor bridges.connect.Connector.http_connection |
|
package |
◆ pattern_found
int bridges.connect.Connector.pattern_found = 0 |
|
package |
◆ server_clone
String bridges.connect.Connector.server_clone = "http://bridges-clone.herokuapp.com" |
|
package |
◆ server_games
String bridges.connect.Connector.server_games = "http://bridges-games.herokuapp.com" |
|
package |
◆ server_live
String bridges.connect.Connector.server_live = "http://bridges-cs.herokuapp.com" |
|
package |
◆ server_local
String bridges.connect.Connector.server_local = "http://127.0.0.1:3000" |
|
package |
◆ server_sockets
String bridges.connect.Connector.server_sockets = "http://bridges-sockets.herokuapp.com" |
|
package |
◆ server_type
String bridges.connect.Connector.server_type = "application" |
|
package |
◆ server_url
String bridges.connect.Connector.server_url = "http://bridges-cs.herokuapp.com" |
|
package |
◆ usgs_url
String bridges.connect.Connector.usgs_url = "https://earthquakes-uncc.herokuapp.com/eq" |
|
package |
The documentation for this class was generated from the following file:
- /home/erik/work/bridges/bridges-java/src/main/java/bridges/connect/Connector.java