ServletContext servletContext = this.getServletContext();
JSONObject config = ConfigFetcher.getJsonObjectFromPath(servletContext.getRealPath("/"));
String bitlyApiKey = config.getString(SettingKeys.BITLY_API_KEY);
String bitlyUsername = config.getString(SettingKeys.BITLY_USERNAME);
LOGGER.info("issuing bitly call for url " + longUrlString);
Url url = as(bitlyUsername, bitlyApiKey).call(shorten(longUrlString));
LOGGER.info("bitly call done");
shortUrl = url.getShortUrl();
LOGGER.info("retrieved short url: " + shortUrl);
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "exception", e);
throw new FetchException("Unable to create short url", e);
}