/** * @return A Jersey WebResource setup to target http://<galaxy_url>/api and with the key query parameter set to * desired Galaxy key. */ public WebResource get() { final String apiKey = getApiKey(); WebResource resource = getRawWebResource(); if(apiKey != null) { resource = resource.queryParam("key", apiKey); } return resource; }
/** * Build Jersey client, and get {@link WebResource} targeting Galaxy API. * Use public method get() to get higher level WebResource with key populated * for instance. * * @return Web resource corresponding to target Galaxy API. */ protected WebResource getRawWebResource() { final com.sun.jersey.api.client.Client client = getJerseyClient(); return client.resource(getUrl()).path(API_PATH); } }
public static GalaxyInstance get(final String url, final String apiKey, final boolean debug) { return get(new DefaultWebResourceFactoryImpl(url, apiKey, debug)); }
@Deprecated public String getGalaxyUrl() { return getUrl(); }
@Override public synchronized String getApiKey() { if(key == null) { final String unencodedCredentials = email + ":" + password; final String encodedCredentials = javax.xml.bind.DatatypeConverter.printBase64Binary(unencodedCredentials.getBytes()); final WebResource resource = super.getRawWebResource(); final ClientResponse response = resource.path("authenticate") .path("baseauth") .header("Authorization", encodedCredentials) .get(ClientResponse.class); if(response.getStatus() != 200) { throw new RuntimeException("Failed to build Galaxy API key for supplied user e-mail and password."); } final Map<String, Object> responseObjects = response.getEntity(Map.class); key = responseObjects.get("api_key").toString(); } return key; }
public static GalaxyInstance get(final String url, final String apiKey) { return get(new DefaultWebResourceFactoryImpl(url, apiKey)); }
public static ToolShedInstance get(final String url, final String apiKey) { return get(new DefaultWebResourceFactoryImpl(url, apiKey)); }