Пример #1
0
    private TermList getTermlist() {
      // TODO Auto-generated method stub
      MultiValueMap<String, String> body = new LinkedMultiValueMap<String, String>();
      ResponseEntity<TermList> responseEntity = null;

      HttpHeaders requestHeaders = new HttpHeaders();
      requestHeaders.setAccept(Collections.singletonList(new MediaType("application", "xml")));
      HttpEntity<?> requestEntity = new HttpEntity<Object>(body, requestHeaders);

      String newurl = "http://www.dcapp.org/export/category.xml";

      try {
        RestTemplate restTemplate = new DCAppRestTemplate(10000);
        SimpleXmlHttpMessageConverter converter = new SimpleXmlHttpMessageConverter();
        HttpMessageConverter<?> formHttpMessageConverter = new FormHttpMessageConverter();
        HttpMessageConverter<?> stringHttpMessageConverternew = new StringHttpMessageConverter();

        restTemplate.getMessageConverters().add(converter);
        restTemplate.getMessageConverters().add(formHttpMessageConverter);
        restTemplate.getMessageConverters().add(stringHttpMessageConverternew);
        // responseEntity = restTemplate.exchange(this.url, HttpMethod.POST, requestEntity,
        // TermList.class);
        responseEntity =
            restTemplate.exchange(newurl, HttpMethod.GET, requestEntity, TermList.class);
      } catch (RestClientException e) {
        Log.e("DirectoryFragment", "Exception while retrieving terms listing.", e.getCause());
      }

      TermList terms = responseEntity.getBody();

      terms.setIsParent();

      return terms;
    }
Пример #2
0
    private void getDCAppTerms() {
      final String url = "http://www.dcapp.org/rest/taxonomy_vocabulary/getTree";
      MultiValueMap<String, String> body = new LinkedMultiValueMap<String, String>();
      body.add("vid", "12");
      ResponseEntity<TermList> responseEntity = null;

      HttpHeaders requestHeaders = new HttpHeaders();
      requestHeaders.setAccept(Collections.singletonList(new MediaType("application", "xml")));
      HttpEntity<?> requestEntity = new HttpEntity<Object>(body, requestHeaders);
      TermList termlist = null;

      try {
        RestTemplate restTemplate = new DCAppRestTemplate(10 * 1000);
        SimpleXmlHttpMessageConverter converter = new SimpleXmlHttpMessageConverter();
        HttpMessageConverter formHttpMessageConverter = new FormHttpMessageConverter();
        HttpMessageConverter stringHttpMessageConverternew = new StringHttpMessageConverter();

        restTemplate.getMessageConverters().add(converter);
        restTemplate.getMessageConverters().add(formHttpMessageConverter);
        restTemplate.getMessageConverters().add(stringHttpMessageConverternew);
        responseEntity = restTemplate.exchange(url, HttpMethod.POST, requestEntity, TermList.class);
        termlist = responseEntity.getBody();
      } catch (RestClientException e) {
        Log.e("DirectoryFragment", "Exception while retrieving terms listing.", e.getCause());
      }

      if (termlist != null) {
        termlist.setIsParent();
        DCAppApplication app = (DCAppApplication) getApplication();
        app.setTermList(termlist);
      }
    }
    /*
     * (non-Javadoc)
     * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization(java.lang.Object, java.lang.String)
     */
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName)
        throws BeansException {

      if (bean instanceof RequestMappingHandlerAdapter) {

        RequestMappingHandlerAdapter adapter = (RequestMappingHandlerAdapter) bean;
        adapter.setMessageConverters(potentiallyRegisterModule(adapter.getMessageConverters()));
      }

      if (bean instanceof AnnotationMethodHandlerAdapter) {

        AnnotationMethodHandlerAdapter adapter = (AnnotationMethodHandlerAdapter) bean;
        List<HttpMessageConverter<?>> augmentedConverters =
            potentiallyRegisterModule(Arrays.asList(adapter.getMessageConverters()));
        adapter.setMessageConverters(
            augmentedConverters.toArray(new HttpMessageConverter<?>[augmentedConverters.size()]));
      }

      if (bean instanceof RestTemplate) {

        RestTemplate template = (RestTemplate) bean;
        template.setMessageConverters(potentiallyRegisterModule(template.getMessageConverters()));
      }

      return bean;
    }
 @Override
 protected Void doInBackground(Void... params) {
   try {
     EditText nombre = (EditText) findViewById(R.id.editText14);
     EditText descripcion = (EditText) findViewById(R.id.editText15);
     MyApp userURL = ((MyApp) getApplication());
     String email = userURL.getUsuarioLogeado().getEmail();
     final String url =
         userURL.getUrlServicio()
             + "/ServiceDiscoteca/Ingresar/"
             + nombre.getText().toString()
             + "/"
             + email
             + "/"
             + descripcion.getText().toString()
             + "/Image";
     RestTemplate restTemplate = new RestTemplate();
     restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
     restTemplate.getForObject(url, Void.class);
     Toast.makeText(
             getApplicationContext(),
             "Se ha registrado la discoteca " + nombre.getText().toString(),
             Toast.LENGTH_SHORT)
         .show();
   } catch (Exception e) {
     Log.e("Cliente Rest", e.getMessage(), e);
   }
   return null;
 }
Пример #5
0
  @Override
  protected Integer doInBackground(String... params) {
    try {
      try {
        username = params[0];
        password = params[1];
        String url =
            "http://"
                + WS_IP
                + "/myresource/registermobile?username="******"&password="******"Myapp", "username = "******"  password= "******" response text=" + s);

        return code;
      } catch (Exception e) {
        errordetails = e.getMessage();
        return 500;
      }
    } catch (Exception e) {
      Log.e("HttpRequestTask", e.getMessage(), e);
      return 500;
    }
  }
Пример #6
0
    @Override
    protected ItemGridModel[] doInBackground(Integer... args) {

      try {

        RestTemplate restTemplate = new RestTemplate();

        HttpComponentsClientHttpRequestFactory httpRequestFactory =
            new HttpComponentsClientHttpRequestFactory();
        httpRequestFactory.setConnectTimeout(10 * 1000);
        httpRequestFactory.setReadTimeout(10 * 1000);
        restTemplate.setRequestFactory(httpRequestFactory);

        String url = Constant.URL_SERVICE;

        restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());

        return restTemplate.getForObject(url, ItemGridModel[].class);
      } catch (ResourceAccessException e) {
        Log.e(Constant.TAG, "Error update grid", e);
      } catch (Exception e) {
        Log.e(Constant.TAG, "Error update grid", e);
      }
      return null;
    }
Пример #7
0
  /**
   * Orders the job given by its jobid. Pay is per assigment, which is by default 5 units.
   *
   * @param job as CrowdJob
   * @param channels : a vector of channels, in which the job should be made available
   * @param units : number of units to order
   * @param payPerAssigment : pay in (dollar) cents for each assignments
   * @return JsonNode that Crowdflower returns
   */
  JsonNode orderJob(CrowdJob job, Vector<String> channels, int units, int payPerAssigment) {
    Log LOG = LogFactory.getLog(getClass());

    RestTemplate restTemplate = new RestTemplate();
    restTemplate.getMessageConverters().add(new MappingJacksonHttpMessageConverter());
    restTemplate.getMessageConverters().add(new FormHttpMessageConverter());

    MultiValueMap<String, String> argumentMap = new LinkedMultiValueMap<String, String>();

    argumentMap.add(debitKey, String.valueOf(units));
    for (String channel : channels) {
      argumentMap.add(channelKey + "[]", channel);
    }

    updateVariable(job, jobPaymentKey, String.valueOf(payPerAssigment));

    LOG.info(
        "Order Job: #"
            + job.getId()
            + " with "
            + units
            + " judgments for "
            + payPerAssigment
            + " cents (dollar) per assigment.");
    JsonNode result =
        restTemplate.postForObject(orderJobURL, argumentMap, JsonNode.class, job.getId(), apiKey);

    return result;
  }
    @Override
    protected Message doInBackground(Void... params) {
      final String url = getString(R.string.base_uri) + "/getmessage";

      // Populate the HTTP Basic Authentitcation header with the username and password
      HttpAuthentication authHeader = new HttpBasicAuthentication(username, password);
      HttpHeaders requestHeaders = new HttpHeaders();
      requestHeaders.setAuthorization(authHeader);
      requestHeaders.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));

      // Create a new RestTemplate instance
      RestTemplate restTemplate = new RestTemplate();
      restTemplate.getMessageConverters().add(new MappingJacksonHttpMessageConverter());

      try {
        // Make the network request
        Log.d(TAG, url);
        ResponseEntity<Message> response =
            restTemplate.exchange(
                url, HttpMethod.GET, new HttpEntity<Object>(requestHeaders), Message.class);
        return response.getBody();
      } catch (HttpClientErrorException e) {
        Log.e(TAG, e.getLocalizedMessage(), e);
        return new Message(0, e.getStatusText(), e.getLocalizedMessage());
      } catch (ResourceAccessException e) {
        Log.e(TAG, e.getLocalizedMessage(), e);
        return new Message(0, e.getClass().getSimpleName(), e.getLocalizedMessage());
      }
    }
Пример #9
0
    @Override
    protected Boolean doInBackground(HelpPost... arg0) {
      try {
        final String url =
            getMainApplication().getRestBaseUrl()
                + "/sendacceptnotification?"
                + "facebookId="
                + arg0[0].getUserId()
                + "&"
                + "firstName="
                + getMainApplication().getData("firstName")
                + "&"
                + "lastName="
                + getMainApplication().getData("lastName")
                + "&"
                + "postId="
                + arg0[0].getUserId()
                + "_"
                + arg0[0].getTime();

        RestTemplate restTemplate = new RestTemplate();
        restTemplate.getMessageConverters().add(new MappingJacksonHttpMessageConverter());
        return restTemplate.getForObject(new URI(url), Boolean.class);
      } catch (Exception e) {
        Log.e(TAG, e.getMessage(), e);
      }
      return false;
    }
Пример #10
0
  @Override
  protected Object doInBackground(Object[] params) {
    try {
      RestTemplate restTemplate = new RestTemplate();
      restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());

      HttpHeaders requestHeaders = new HttpHeaders();

      String restUrl = ServerConstants.SERVER_API_URL + "user/login";

      User user = new User(username, password);
      SingleUser singleUser = new SingleUser();
      singleUser.setUser(user);

      HttpEntity<SingleUser> requestEntity = new HttpEntity<>(singleUser, requestHeaders);

      ResponseEntity<Boolean> responseEntity =
          restTemplate.exchange(restUrl, HttpMethod.POST, requestEntity, Boolean.class);

      boolean loginSuccessful = responseEntity.getBody();

      Log.d("Login", Boolean.toString(loginSuccessful));

      return loginSuccessful;
    } catch (Exception ex) {
      ex.printStackTrace();

      return false;
    }
  }
Пример #11
0
    @Override
    protected String doInBackground(String... params) {
      ConnectivityManager connectivityManager =
          (ConnectivityManager) MainActivity.this.getSystemService(Context.CONNECTIVITY_SERVICE);
      NetworkInfo activeNetworkInfo;
      activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
      if (activeNetworkInfo == null || !activeNetworkInfo.isConnected()) {
        MainActivity.this.runOnUiThread(
            new Runnable() {
              public void run() {
                Toast.makeText(
                        MainActivity.this,
                        "Connect to the internet to view tests.",
                        Toast.LENGTH_SHORT)
                    .show();
              }
            });

        String cs = prefs.getString("children", "[]");
        children = new JsonParser().parse(cs).getAsJsonArray();
      } else {
        try {
          RestTemplate restTemplate = new RestTemplate();
          restTemplate.getMessageConverters().add(new StringHttpMessageConverter());
          String rawJson =
              restTemplate.getForObject(
                  "https://www.localresearch.com/api/profile/ucla-test-bank/", String.class);
          JsonElement object = new JsonParser().parse(rawJson);
          children =
              object
                  .getAsJsonObject()
                  .get("sections")
                  .getAsJsonArray()
                  .get(0)
                  .getAsJsonObject()
                  .get("highlights")
                  .getAsJsonArray();
          prefs.edit().putString("children", children.toString()).apply();
        } catch (Exception e) {
          children = new JsonParser().parse(prefs.getString("children", "[]")).getAsJsonArray();
          MainActivity.this.runOnUiThread(
              new Runnable() {
                public void run() {
                  Toast.makeText(
                          MainActivity.this,
                          "An error occurred while updating tests. This may be caused by poor internet connection.",
                          Toast.LENGTH_SHORT)
                      .show();
                }
              });
        }
      }
      values.clear();
      for (JsonElement child : children) {
        Log.d("LOG", child.getAsJsonObject().get("name").getAsString());
        values.add(child.getAsJsonObject().get("name").getAsString());
      }
      return null;
    }
Пример #12
0
  /**
   * Retrieve the job by the supplied job ID and represent in the CrowdJob class.
   *
   * @param jobid
   * @return job class which represents the job @ ID
   * @throws HttpServerErrorException
   */
  CrowdJob retrieveJob(String jobid) throws HttpServerErrorException {
    RestTemplate restTemplate = new RestTemplate();
    // restTemplate.getMessageConverters().add(new StringHttpMessageConverter());
    restTemplate.getMessageConverters().add(new MappingJacksonHttpMessageConverter());
    JsonNode result = restTemplate.getForObject(baseJobURL, JsonNode.class, jobid, apiKey);

    return new CrowdJob(result);
  }
Пример #13
0
  /**
   * Get the status of a job id. The returned JSON will look like: {"all_judgments": 50,
   * "golden_judgments": 5, "tainted_judgments": 15, "needed_judgments": 20}
   *
   * @param jobId
   * @return JsonNode containing the status as supplied by Crowdflower
   */
  JsonNode getStatus(String jobId) {
    RestTemplate restTemplate = new RestTemplate();
    restTemplate.getMessageConverters().add(new MappingJacksonHttpMessageConverter());

    JsonNode result = restTemplate.getForObject(pingURL, JsonNode.class, jobId, apiKey);

    return result;
  }
Пример #14
0
 @SuppressWarnings("unchecked")
 public TestAllServerAdapter() {
   converters = Mockito.mock(ArrayList.class);
   converters.add(new StringHttpMessageConverter());
   converters.add(new StringHttpMessageConverter());
   syncTemplate = Mockito.mock(RestTemplate.class);
   when(syncTemplate.getMessageConverters()).thenReturn(converters);
 }
Пример #15
0
  @Bean(name = "restTemplate")
  public RestTemplate getRestTemplate() {
    RestTemplate restTemplate = new RestTemplate();
    restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
    restTemplate.getMessageConverters().add(new StringHttpMessageConverter());

    return restTemplate;
  }
Пример #16
0
  /**
   * Sets a single key in Crowdflowers job with a given value
   *
   * @param job
   * @param key
   * @param value
   */
  void updateVariable(CrowdJob job, String Url, String key, String value) {
    MultiValueMap<String, String> argumentMap = new LinkedMultiValueMap<String, String>();
    argumentMap.add(key, value);

    RestTemplate restTemplate = new RestTemplate();
    restTemplate.getMessageConverters().add(new FormHttpMessageConverter());

    restTemplate.put(Url, argumentMap, job.getId(), apiKey);
  }
Пример #17
0
  /**
   * Create a new job on Crowdflower using supplied job class. If this class had been retrieved with
   * retrieveJob(String jobid), then you copied the job without its data. Can be used to copy jobs
   * across different accounts if API key is changed between the call to retrieveJob
   *
   * @param job - job class that should be replicated as new job on Crowdflower
   * @return job class which represents the new job
   * @throws HttpServerErrorException
   */
  CrowdJob createNewJob(CrowdJob job) throws HttpServerErrorException {
    RestTemplate restTemplate = new RestTemplate();
    restTemplate.getMessageConverters().add(new MappingJacksonHttpMessageConverter());
    restTemplate.getMessageConverters().add(new FormHttpMessageConverter());

    JsonNode result =
        restTemplate.postForObject(newJobURL, job.getArgumentMap(), JsonNode.class, apiKey);

    return new CrowdJob(result);
  }
Пример #18
0
  @SuppressWarnings("rawtypes")
  private static RestTemplate getTemplate() {

    RestTemplate restTemplate = new RestTemplate();

    Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
    Class[] vetor = {Resultado.class};
    marshaller.setClassesToBeBound(vetor);
    // conversor de objetos
    MarshallingHttpMessageConverter marshallingHttpConverter =
        new MarshallingHttpMessageConverter(marshaller);
    marshallingHttpConverter.setSupportedMediaTypes(Arrays.asList(MediaType.APPLICATION_XML));
    restTemplate.getMessageConverters().add(marshallingHttpConverter);

    // conversor de string
    StringHttpMessageConverter sCOnverter = new StringHttpMessageConverter();
    sCOnverter.setSupportedMediaTypes(Arrays.asList(MediaType.TEXT_PLAIN));
    restTemplate.getMessageConverters().add(sCOnverter);

    return restTemplate;
  }
Пример #19
0
  public void testRequestResponse1() {

    String url = "http://" + serverIp + ":8080/nonstop/welcome?name=x:1;y:2";

    RestTemplate restTemplate = new RestTemplate();
    restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
    Dto response = restTemplate.getForObject(url, Dto.class);

    String string = response.getString();
    System.out.println(string);
    assertEquals("hello, x:1;y:2", string);
  }
Пример #20
0
  /**
   * Update the list of allowed countries for this job to Crowdflower (the list is set in the job)
   *
   * @param job
   * @throws HttpServerErrorException
   */
  void updateAllowedCountries(CrowdJob job) throws HttpServerErrorException {
    RestTemplate restTemplate = new RestTemplate();
    restTemplate.getMessageConverters().add(new FormHttpMessageConverter());

    if (job.getExcludedCountries().size() > 0) {
      restTemplate.put(baseJobURL, job.getExcludedCountriesMap(), job.getId(), apiKey);
    }

    if (job.getIncludedCountries().size() > 0) {
      restTemplate.put(baseJobURL, job.getIncludedCountriesMap(), job.getId(), apiKey);
    }
  }
Пример #21
0
  @Override
  public RestTemplate createRestTemplate() {
    RestTemplate restTemplate = new RestTemplate();

    // web services support json responses
    MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter();
    final List<HttpMessageConverter<?>> listHttpMessageConverters =
        restTemplate.getMessageConverters();

    listHttpMessageConverters.add(jsonConverter);
    restTemplate.setMessageConverters(listHttpMessageConverters);
    return restTemplate;
  }
Пример #22
0
 public static String addVisit(VisitMobile visit) {
   HttpHeaders requestHeaders = new HttpHeaders();
   HttpEntity<VisitMobile> entity = new HttpEntity<VisitMobile>(visit, requestHeaders);
   RestTemplate template = new RestTemplate();
   template.getMessageConverters().add(new StringHttpMessageConverter());
   template.getMessageConverters().add(new MappingJacksonHttpMessageConverter());
   String finalUri = Global.server + uri + "addvisit" + extension;
   Log.d(TAG, "Hitting the " + finalUri);
   ResponseEntity<String> response =
       template.exchange(finalUri, HttpMethod.POST, entity, String.class);
   String responseString = response.getBody();
   return responseString;
 }
Пример #23
0
 public static String login() {
   String input = Global.username + ":" + Global.password;
   HttpHeaders requestHeaders = new HttpHeaders();
   HttpEntity<String> entity = new HttpEntity<String>(input, requestHeaders);
   RestTemplate template = new RestTemplate();
   template.getMessageConverters().add(new StringHttpMessageConverter());
   String finalUri = Global.server + uri + "login" + extension;
   Log.d(TAG, "Hitting the " + finalUri);
   ResponseEntity<String> response =
       template.exchange(finalUri, HttpMethod.POST, entity, String.class);
   String responseString = response.getBody();
   return responseString;
 }
Пример #24
0
    @Override
    protected String doInBackground(Void... params) {
      try {
        final String url = "http://localhost:8080/protaxi/client/callTest";
        RestTemplate restTemplate = new RestTemplate();
        restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
        String greeting = restTemplate.getForObject(url, String.class);
        return greeting;
      } catch (Exception e) {
        Log.e("MainActivity", e.getMessage(), e);
      }

      return null;
    }
 @Override
 protected Meal[] doInBackground(Void... params) {
   //      try {
   final String url = getString(R.string.url) + "/meals";
   RestTemplate restTemplate = new RestTemplate();
   restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
   Meal[] meals = restTemplate.getForObject(url, Meal[].class);
   return meals;
   //          }catch (Exception e){
   //                Toast.makeText(getApplicationContext(), "No meals Found",
   // Toast.LENGTH_LONG).show();
   //             return null;
   //        }
 }
  public ServerConnection() {
    Properties properties = new Properties();
    try {
      properties.load(ServerConnection.class.getClassLoader().getResourceAsStream(CONFIG_FILE));
    } catch (IOException e) {
      e.printStackTrace();
    }

    baseUri = (String) properties.get(Constants.BASE_URI_PROPERTY);
    System.setProperty("http.keepAlive", "false");

    connection = new RestTemplate();
    connection.getMessageConverters().add(new MappingJacksonHttpMessageConverter());
  }
Пример #27
0
  /**
   * Upload the data vector as JSON to the specified Crowdflower job
   *
   * @param job
   * @param data - Generic vector of data, containing ordinary java classes. They should be
   *     annotated so that Jackson understands how to map them to JSON.
   */
  void uploadData(CrowdJob job, List<?> data) {
    Log LOG = LogFactory.getLog(getClass());

    // Crowdflower wants a Multi-line JSON, with each line having a new JSON object
    // Thus we have to map each (raw) object in data individually to a JSON string

    ObjectMapper mapper = new ObjectMapper();
    String jsonObjectCollection = "";

    StringBuilder jsonStringBuilder = new StringBuilder();
    int count = 0;
    for (Object obj : data) {
      count++;
      JsonNode jsonData = mapper.convertValue(obj, JsonNode.class);
      jsonStringBuilder.append(jsonData.toString());
      jsonStringBuilder.append("\n");
    }

    jsonObjectCollection = jsonStringBuilder.toString();

    RestTemplate restTemplate = new RestTemplate();
    restTemplate.getMessageConverters().add(new StringHttpMessageConverter());

    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_JSON);
    HttpEntity<String> request = new HttpEntity<String>(jsonObjectCollection, headers);

    String result = "";

    if (job == null) {
      LOG.info("Upload new data and create new job: " + String.valueOf(count) + " data items");
      result = restTemplate.postForObject(uploadDataURL, request, String.class, apiKey);
    } else {
      LOG.info(
          "Uploading new data to job: "
              + job.getId()
              + ": "
              + String.valueOf(count)
              + " data items");
      result =
          restTemplate.postForObject(
              uploadDataWithJobURL, request, String.class, job.getId(), apiKey);
    }
    LOG.info("Upload response:" + result);

    // set gold? this is what i would like to do...
    // updateVariable(job, "https://api.crowdflower.com/v1/jobs/{jobid}/gold?key={apiKey}",
    // "set_standard_gold", "TRUE");
  }
Пример #28
0
 public DzieckoMDTOResponse postByRestTemplate(DzieckoMDTORequest dzieckoMDTORequest) {
   // The connection URL
   String url = Constant.HOST_ADDRES + REGISTER;
   // Create a new RestTemplate instance
   RestTemplate restTemplate = new RestTemplate();
   // Add the String message converter
   //        restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
   restTemplate.getMessageConverters().add(new StringHttpMessageConverter());
   // Make the HTTP GET request, marshaling the response to a String
   Log.d(LOG_CHILD_REGISTER, "SENDS : " + dzieckoMDTORequest);
   DzieckoMDTOResponse response =
       restTemplate.postForObject(url, dzieckoMDTORequest, DzieckoMDTOResponse.class);
   Log.d(LOG_CHILD_REGISTER, "RESULT : " + response);
   return response;
 }
  public OperationResult execute(Long customerId, CustomerAddress newAddress) throws Exception {

    OperationResult result = null;
    logger.trace("CustomerAddressService.execute");

    Long start = System.currentTimeMillis();

    try {
      RestTemplate restTemplate = new RestTemplate();
      restTemplate
          .getMessageConverters()
          .add(0, new StringHttpMessageConverter(Charset.forName("UTF-8")));

      HttpHeaders headers = new HttpHeaders();
      headers.setContentType(MediaType.APPLICATION_JSON);

      StringBuilder sBuilder =
          new StringBuilder(inventoryServiceURL)
              .append(InventoryServiceActions.ADDRESS)
              .append("/")
              .append(customerId.toString());

      UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(sBuilder.toString());

      String requestJson = new ObjectMapper().writeValueAsString(newAddress);
      HttpEntity<String> entity = new HttpEntity<String>(requestJson, headers);

      result =
          restTemplate
              .exchange(
                  builder.build().encode().toString(),
                  HttpMethod.PUT,
                  entity,
                  OperationResult.class)
              .getBody();
      if (result == null) {
        throw new Exception("Unable to get responce from inventory service");
      }
    } catch (Exception ex) {
      logger.warn(ex.getMessage());
      throw ex;
    } finally {
      logger.info(
          "Execution time: " + TimeUnit.MILLISECONDS.toMillis(System.currentTimeMillis() - start));
    }

    return result;
  }
  @Override
  protected List<PlayersPitchersViewModel.Pitcher> doInBackground(Void... params) {

    List<PlayersPitchersViewModel.Pitcher> list = null;

    try {
      // http://clutchwin.com/api/v1/opponents/pitchers.json?
      final String baseUrl = Config.OpponentsForBatter;
      StringBuilder finalUrl;
      finalUrl = new StringBuilder(baseUrl);
      finalUrl
          .append(Config.AccessTokenKey)
          .append(Config.AccessTokenValue)
          .append(Config.BatterIdKey)
          .append(ClutchWinApplication.getPlayersContextViewModel().getBatterId())
          .append(Config.SeasonIdKey)
          .append(ClutchWinApplication.getPlayersContextViewModel().getYearId())
          .append(Config.FieldSetBasicKeyValue);

      RestTemplate restTemplate = new RestTemplate();
      restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
      list =
          Arrays.asList(
              restTemplate.getForObject(
                  finalUrl.toString(), PlayersPitchersViewModel.Pitcher[].class));

      /*
      try {
          if(list != null && list.size() > 0) {
              Helpers.writeListToInternalStorage(list, Config.PP_CacheFileKey);
          } else {
              Helpers.deleteCacheFile(Config.PP_CacheFileKey);
          }
      } catch (IOException e) {
          Log.e("PlayersPitchersAsyncTask::writeListToInternalStorage", e.getMessage(), e);
      }
      */

    } catch (Exception e) {
      Log.e("PlayersPitchersCache", e.getMessage(), e);
      if (onCompleteListener != null) {
        onCompleteListener.onPlayersPitcherServiceFailure(e);
      }

      Crittercism.logHandledException(e);
    }
    return list;
  }