Ejemplo n.º 1
0
 /**
  * Test the encodeParams method.
  *
  * @since 1.0
  */
 @Test
 public void testEncodeParams() {
   final LinkedDataServerSetup ldsSetup = new LinkedDataServerSetup();
   final JobConfiguration jobConf = newJobConfiguration();
   final boolean result = ldsSetup.encodeParams(jobConf);
   if (result) {
     LOGGER.info("OK");
   } else {
     LOGGER.info("NOK");
   }
 }
Ejemplo n.º 2
0
  /**
   * Implementation of a Links Discovery REST service client application. GET
   * /links-discovery/jobs/<jobid>
   *
   * @param jobid the job identifier.
   * @since 2.0
   */
  public void getJob(final Integer jobid) {
    // Convert integer to string
    final String s_jobid = "" + jobid;
    final Client client = ClientBuilder.newClient();
    final WebTarget webTarget = client.target(ALIADA_CKANCREATION_URL);

    // GET (Response in XML format)
    String acceptType = MediaType.APPLICATION_XML; // If we want the response in XML format
    Response getResponse = webTarget.path("/jobs").path(s_jobid).request(acceptType).get();
    LOGGER.info("status =" + getResponse.getStatus());
    LOGGER.info("response data=" + getResponse.readEntity(String.class));

    // GET (Response in JSON format)
    acceptType = MediaType.APPLICATION_JSON; // If we want the response in JSON format
    getResponse = webTarget.path("/jobs").path(s_jobid).request(acceptType).get();
    LOGGER.info("status =" + getResponse.getStatus());
    LOGGER.info("response data=" + getResponse.readEntity(String.class));
  }
Ejemplo n.º 3
0
  /**
   * Implementation of a CKAN Datahub Page Creation REST service client application. POST
   * /ckan-datahub/jobs/
   *
   * @param jobid the job identifier.
   * @since 2.0
   */
  public void newJob(final int jobid) {
    // Convert integer to string
    final String s_jobid = "" + jobid;
    final Client client = ClientBuilder.newClient();
    final WebTarget webTarget = client.target(ALIADA_CKANCREATION_URL);

    // Data to be sent via HTTP POST
    final Form form = new Form();
    form.param("jobid", s_jobid);

    // POST (Response in XML format)
    final String acceptType = MediaType.APPLICATION_XML; // If we want the response in XML format
    final Response postResponse =
        webTarget
            .path("/jobs")
            .request(acceptType)
            .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE));
    LOGGER.info("status =" + postResponse.getStatus());
    LOGGER.info("response data=" + postResponse.readEntity(String.class));
  }