/** * Gets the connection params. * * @param key the key * @return the connection params */ public List<String> getConnectionParams(String key) { WebTarget target = getSessionWebTarget(); StringList value = target.path("params").queryParam("sessionid", this.sessionHandle).queryParam("key", key) .request().get(StringList.class); return value.getElements(); }
public List<String> getConnectionParams() { WebTarget target = getSessionWebTarget(); StringList list = target.path("params").queryParam("sessionid", this.sessionHandle).queryParam("verbose", true) .request().get(StringList.class); return list.getElements(); }
/** * Gets the connection params. * * @param key the key * @return the connection params */ public List<String> getConnectionParams(String key) { WebTarget target = getSessionWebTarget(); StringList value = target.path("params").queryParam("sessionid", this.sessionHandle).queryParam("key", key) .request().get(StringList.class); return value.getElements(); }
/** * List resources from session * * @param type type of resource * @return List of resources */ public List<String> listResourcesFromConnection(String type) { WebTarget target = getSessionWebTarget(); StringList result = target.path("resources/list").queryParam("sessionid", this.sessionHandle) .queryParam("type", type).request().get(StringList.class); return result.getElements(); }
public List<String> getConnectionParams() { WebTarget target = getSessionWebTarget(); StringList list = target.path("params").queryParam("sessionid", this.sessionHandle).queryParam("verbose", true) .request().get(StringList.class); return list.getElements(); }
/** * List resources from session * * @param type type of resource * @return List of resources */ public List<String> listResourcesFromConnection(String type) { WebTarget target = getSessionWebTarget(); StringList result = target.path("resources/list").queryParam("sessionid", this.sessionHandle) .queryParam("type", type).request().get(StringList.class); return result.getElements(); }
private WebTarget getSessionWebTarget() { return getSessionWebTarget(buildClient()); }
private WebTarget getSessionWebTarget() { return getSessionWebTarget(buildClient()); }
/** * Close the connection. */ @Override public synchronized void close() { if (closed) { log.warn("Session already closed. Ignoring the attempt to close again."); return; } WebTarget target = getSessionWebTarget(); Response response = target.queryParam("sessionid", this.sessionHandle).request().delete(); if (response == null) { // Should never come here, just fool-proofing throw new LensClientException("Null response from server while closing connection."); } switch(response.getStatus()){ case 410: log.warn("Session is already gone. Ignoring the attempt to close again."); break; case 200: APIResult apiResult = response.readEntity(APIResult.class); if (apiResult.getStatus() != APIResult.Status.SUCCEEDED) { throw new LensClientException("Error closing lens connection: " + apiResult.getMessage()); } break; default: throw new LensClientException("Couldn't close session, error code: " + response.getStatus()); } closed = true; }
/** * Close the connection. */ @Override public synchronized void close() { if (closed) { log.warn("Session already closed. Ignoring the attempt to close again."); return; } WebTarget target = getSessionWebTarget(); Response response = target.queryParam("sessionid", this.sessionHandle).request().delete(); if (response == null) { // Should never come here, just fool-proofing throw new LensClientException("Null response from server while closing connection."); } switch(response.getStatus()){ case 410: log.warn("Session is already gone. Ignoring the attempt to close again."); break; case 200: APIResult apiResult = response.readEntity(APIResult.class); if (apiResult.getStatus() != APIResult.Status.SUCCEEDED) { throw new LensClientException("Error closing lens connection: " + apiResult.getMessage()); } break; default: throw new LensClientException("Couldn't close session, error code: " + response.getStatus()); } closed = true; }
/** * Sets the connection params. * * @param key the key * @param value the value * @return the API result */ public APIResult setConnectionParams(String key, String value) { WebTarget target = getSessionWebTarget(); FormDataMultiPart mp = new FormDataMultiPart(); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), this.sessionHandle, MediaType.APPLICATION_XML_TYPE)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("key").build(), key)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("value").build(), value)); log.debug("Setting connection params {}={}", key, value); return target.path("params").request() .put(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE), APIResult.class); }
/** * Sets the connection params. * * @param key the key * @param value the value * @return the API result */ public APIResult setConnectionParams(String key, String value) { WebTarget target = getSessionWebTarget(); FormDataMultiPart mp = new FormDataMultiPart(); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), this.sessionHandle, MediaType.APPLICATION_XML_TYPE)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("key").build(), key)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("value").build(), value)); log.debug("Setting connection params {}={}", key, value); return target.path("params").request() .put(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE), APIResult.class); }
/** * Adds the resource to connection. * * @param type the type * @param resourcePath the resource path * @return the API result */ public APIResult addResourceToConnection(String type, String resourcePath) { WebTarget target = getSessionWebTarget(); FormDataMultiPart mp = new FormDataMultiPart(); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), this.sessionHandle, MediaType.APPLICATION_XML_TYPE)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("type").build(), type)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("path").build(), resourcePath)); return target.path("resources/add").request() .put(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE), APIResult.class); }
/** * Removes the resource from connection. * * @param type the type * @param resourcePath the resource path * @return the API result */ public APIResult removeResourceFromConnection(String type, String resourcePath) { WebTarget target = getSessionWebTarget(); FormDataMultiPart mp = new FormDataMultiPart(); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), this.sessionHandle, MediaType.APPLICATION_XML_TYPE)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("type").build(), type)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("path").build(), resourcePath)); return target.path("resources/delete").request() .put(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE), APIResult.class); }
/** * Removes the resource from connection. * * @param type the type * @param resourcePath the resource path * @return the API result */ public APIResult removeResourceFromConnection(String type, String resourcePath) { WebTarget target = getSessionWebTarget(); FormDataMultiPart mp = new FormDataMultiPart(); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), this.sessionHandle, MediaType.APPLICATION_XML_TYPE)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("type").build(), type)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("path").build(), resourcePath)); return target.path("resources/delete").request() .put(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE), APIResult.class); }
/** * Adds the resource to connection. * * @param type the type * @param resourcePath the resource path * @return the API result */ public APIResult addResourceToConnection(String type, String resourcePath) { WebTarget target = getSessionWebTarget(); FormDataMultiPart mp = new FormDataMultiPart(); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), this.sessionHandle, MediaType.APPLICATION_XML_TYPE)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("type").build(), type)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("path").build(), resourcePath)); return target.path("resources/add").request() .put(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE), APIResult.class); }
WebTarget target = getSessionWebTarget(); FormDataMultiPart mp = new FormDataMultiPart(); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("username").build(), params.getUser()));
WebTarget target = getSessionWebTarget(); FormDataMultiPart mp = new FormDataMultiPart(); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("username").build(), params.getUser()));