/**
  * If the "value" entry contains both "DerivedTxConfig" AND "TxConfig", then the algorithm is
  * accidentally picking up shadowed annotations of the same type within the class hierarchy. Such
  * undesirable behavior would cause the logic in {@link
  * org.springframework.context.annotation.ProfileCondition} to fail.
  *
  * @see
  *     org.springframework.core.env.EnvironmentSystemIntegrationTests#mostSpecificDerivedClassDrivesEnvironment_withDevEnvAndDerivedDevConfigClass
  */
 @Test
 public void
     getAllAnnotationAttributesOnClassWithLocalAnnotationThatShadowsAnnotationFromSuperclass() {
   MultiValueMap<String, Object> attributes =
       getAllAnnotationAttributes(DerivedTxConfig.class, TX_NAME);
   assertNotNull("Annotation attributes map for @Transactional on DerivedTxConfig", attributes);
   assertEquals("value for DerivedTxConfig.", asList("DerivedTxConfig"), attributes.get("value"));
 }
 @Override
 public Methods getMethods(String apiKey) {
   MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
   if (apiKey != null) parameters.set("api_key", apiKey);
   return restTemplate.getForObject(
       buildUri("flickr.reflection.getMethods", parameters), Methods.class);
 }
Exemplo n.º 3
0
  @Override
  public boolean login(String username, String password) throws ServiceException {
    RestTemplate restTemplate = this.restClient.getRestTemplate();
    String url = this.restClient.createServiceUrl("/login");
    HttpHeaders headers = this.restClient.getHttpHeaders();
    headers.add("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE);

    MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>();
    form.add("user", username);
    form.add("password", password);

    HttpEntity<MultiValueMap<String, String>> entity =
        new HttpEntity<MultiValueMap<String, String>>(form, headers);

    LOG.info("Login " + username + " at " + url);

    UserStatusDto status = null;
    try {
      status = restTemplate.postForObject(url, entity, UserStatusDto.class);
    } catch (RestClientException e) {
      throw new ServiceException("Login failed: " + e.getMessage(), e);
    }

    if (status.getEvent() == UserEvent.AUTH_FAILURE) {
      return false;
    }

    LOG.debug("Login " + username + " successful");

    this.user = status;

    return true;
  }
Exemplo n.º 4
0
 public URI build() {
   StringBuilder builder = new StringBuilder(url);
   try {
     if (!params.isEmpty()) {
       builder.append("?");
       boolean first = true;
       for (String key : params.keySet()) {
         if (!first) {
           builder.append("&");
         } else {
           first = false;
         }
         for (String value : params.get(key)) {
           builder.append(key + "=" + UriUtils.encodeQueryParam(value, "UTF-8"));
         }
       }
     }
     return new URI(builder.toString());
   } catch (UnsupportedEncodingException ex) {
     // should not happen, UTF-8 is always supported
     throw new IllegalStateException(ex);
   } catch (URISyntaxException ex) {
     throw new IllegalArgumentException(
         "Could not create URI from [" + builder + "]: " + ex, ex);
   }
 }
Exemplo n.º 5
0
 /**
  * Builds the authorization header. The elements in additionalParameters are expected to not be
  * encoded.
  */
 public String buildAuthorizationHeaderValue(
     HttpMethod method,
     URI targetUrl,
     Map<String, String> oauthParameters,
     MultiValueMap<String, String> additionalParameters,
     String consumerSecret,
     String tokenSecret) {
   StringBuilder header = new StringBuilder();
   header.append("OAuth ");
   for (Entry<String, String> entry : oauthParameters.entrySet()) {
     header
         .append(oauthEncode(entry.getKey()))
         .append("=\"")
         .append(oauthEncode(entry.getValue()))
         .append("\", ");
   }
   MultiValueMap<String, String> collectedParameters =
       new LinkedMultiValueMap<String, String>(
           (int) ((oauthParameters.size() + additionalParameters.size()) / .75 + 1));
   collectedParameters.setAll(oauthParameters);
   collectedParameters.putAll(additionalParameters);
   String baseString = buildBaseString(method, getBaseStringUri(targetUrl), collectedParameters);
   String signature = calculateSignature(baseString, consumerSecret, tokenSecret);
   header
       .append(oauthEncode("oauth_signature"))
       .append("=\"")
       .append(oauthEncode(signature))
       .append("\"");
   return header.toString();
 }
 @Test
 public void simpleStringKeyStringValueFormData() throws Exception {
   HttpRequestExecutingMessageHandler handler =
       new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration");
   MockRestTemplate template = new MockRestTemplate();
   new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template);
   handler.setHttpMethod(HttpMethod.POST);
   setBeanFactory(handler);
   handler.afterPropertiesSet();
   Map<String, String> form = new LinkedHashMap<String, String>();
   form.put("a", "1");
   form.put("b", "2");
   form.put("c", "3");
   Message<?> message = MessageBuilder.withPayload(form).build();
   QueueChannel replyChannel = new QueueChannel();
   handler.setOutputChannel(replyChannel);
   Exception exception = null;
   try {
     handler.handleMessage(message);
   } catch (Exception e) {
     exception = e;
   }
   assertEquals("intentional", exception.getCause().getMessage());
   HttpEntity<?> request = template.lastRequestEntity.get();
   Object body = request.getBody();
   assertNotNull(request.getHeaders().getContentType());
   assertTrue(body instanceof MultiValueMap<?, ?>);
   MultiValueMap<?, ?> map = (MultiValueMap<?, ?>) body;
   assertEquals("1", map.get("a").iterator().next());
   assertEquals("2", map.get("b").iterator().next());
   assertEquals("3", map.get("c").iterator().next());
   assertEquals(MediaType.APPLICATION_FORM_URLENCODED, request.getHeaders().getContentType());
 }
  /** tests that an error occurs if you attempt to use bad client credentials. */
  @Test
  @Ignore
  // Need a custom auth entry point to get the correct JSON response here.
  public void testInvalidClient() throws Exception {

    MultiValueMap<String, String> formData = new LinkedMultiValueMap<String, String>();
    formData.add("grant_type", "password");
    formData.add("username", resource.getUsername());
    formData.add("password", resource.getPassword());
    formData.add("scope", "cloud_controller.read");
    HttpHeaders headers = new HttpHeaders();
    headers.set(
        "Authorization", "Basic " + new String(Base64.encode("no-such-client:".getBytes("UTF-8"))));
    headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
    @SuppressWarnings("rawtypes")
    ResponseEntity<Map> response = serverRunning.postForMap("/oauth/token", formData, headers);
    assertEquals(HttpStatus.UNAUTHORIZED, response.getStatusCode());
    List<String> newCookies = response.getHeaders().get("Set-Cookie");
    if (newCookies != null && !newCookies.isEmpty()) {
      fail("No cookies should be set. Found: " + newCookies.get(0) + ".");
    }
    assertEquals(
        "no-cache, no-store, max-age=0, must-revalidate",
        response.getHeaders().getFirst("Cache-Control"));

    assertEquals(401, response.getStatusCode().value());

    @SuppressWarnings("unchecked")
    OAuth2Exception error = OAuth2Exception.valueOf(response.getBody());
    assertEquals("Bad credentials", error.getMessage());
    assertEquals("invalid_request", error.getOAuth2ErrorCode());
  }
  @Test
  @OAuth2ContextConfiguration(
      resource = OAuth2ContextConfiguration.Implicit.class,
      initialize = false)
  public void testUserMustSupplyOldPassword() throws Exception {

    MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
    parameters.set("source", "credentials");
    parameters.set("username", joe.getUserName());
    parameters.set("password", "pas5Word");
    context.getAccessTokenRequest().putAll(parameters);

    PasswordChangeRequest change = new PasswordChangeRequest();
    change.setPassword("Newpasswo3d");

    HttpHeaders headers = new HttpHeaders();
    ResponseEntity<Void> result =
        client.exchange(
            serverRunning.getUrl(userEndpoint) + "/{id}/password",
            HttpMethod.PUT,
            new HttpEntity<>(change, headers),
            Void.class,
            joe.getId());
    assertEquals(HttpStatus.BAD_REQUEST, result.getStatusCode());
  }
  @Test
  public void testStatusUpdatingMessageHandler() {
    TimelineOperations timelineOperations = Mockito.mock(TimelineOperations.class);
    Mockito.when(this.twitter.timelineOperations()).thenReturn(timelineOperations);

    ArgumentCaptor<TweetData> argument = ArgumentCaptor.forClass(TweetData.class);

    this.in1.send(new GenericMessage<String>("foo"));

    Mockito.verify(timelineOperations).updateStatus(argument.capture());
    assertEquals("foo", argument.getValue().toRequestParameters().getFirst("status"));

    Mockito.reset(timelineOperations);

    ClassPathResource media = new ClassPathResource("log4j.properties");
    this.in2.send(
        MessageBuilder.withPayload(Collections.singletonMap("foo", "bar"))
            .setHeader("media", media)
            .build());

    Mockito.verify(timelineOperations).updateStatus(argument.capture());
    TweetData tweetData = argument.getValue();
    MultiValueMap<String, Object> requestParameters = tweetData.toRequestParameters();
    assertEquals("bar", requestParameters.getFirst("status"));
    assertNull(requestParameters.getFirst("media"));
    MultiValueMap<String, Object> uploadMediaParameters = tweetData.toUploadMediaParameters();
    assertEquals(media, uploadMediaParameters.getFirst("media"));
  }
 /**
  * Obtain a new access token for the specified resource using the refresh token.
  *
  * @param resource The resource.
  * @param refreshToken The refresh token.
  * @return The access token, or null if failed.
  */
 protected OAuth2AccessToken obtainAccessToken(
     OAuth2ProtectedResourceDetails resource, OAuth2RefreshToken refreshToken) {
   MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>();
   form.add("grant_type", "refresh_token");
   form.add("refresh_token", refreshToken.getValue());
   return retrieveToken(form, resource);
 }
  @Override
  public Object resolveArgument(
      MethodParameter parameter,
      ModelAndViewContainer mavContainer,
      NativeWebRequest webRequest,
      WebDataBinderFactory binderFactory)
      throws Exception {

    Class<?> paramType = parameter.getParameterType();

    if (MultiValueMap.class.isAssignableFrom(paramType)) {
      MultiValueMap<String, String> result;
      if (HttpHeaders.class.isAssignableFrom(paramType)) {
        result = new HttpHeaders();
      } else {
        result = new LinkedMultiValueMap<String, String>();
      }
      for (Iterator<String> iterator = webRequest.getHeaderNames(); iterator.hasNext(); ) {
        String headerName = iterator.next();
        for (String headerValue : webRequest.getHeaderValues(headerName)) {
          result.add(headerName, headerValue);
        }
      }
      return result;
    } else {
      Map<String, String> result = new LinkedHashMap<String, String>();
      for (Iterator<String> iterator = webRequest.getHeaderNames(); iterator.hasNext(); ) {
        String headerName = iterator.next();
        String headerValue = webRequest.getHeader(headerName);
        result.put(headerName, headerValue);
      }
      return result;
    }
  }
 /**
  * @name createProduct
  * @description Method is used in provisioning of service to create the product for bugzilla by
  *     taking the service_instance as a name whenever the product is created at the same time with
  *     same name the group for that product is created by bugzilla internally
  * @param productName
  * @return Product
  * @throws IOException
  */
 public Product createProduct(String productName) throws IOException {
   if (getBugzillaProduct(productName).getProducts() != null
       && getBugzillaProduct(productName).getProducts().size() != 0) {
     updateProductGroup(productName);
     return getBugzillaProduct(productName).getProducts().get(0);
   }
   Product bugzillaProduct = new Product();
   setProperties();
   try {
     logger.info(
         "Bugzilla getBugzillaResource().getBugzillaServer()  "
             + getBugzillaResource().getBugzillaServer());
     url = new URI(REST_PRODUCT_URL);
     MultiValueMap<String, String> productData = new LinkedMultiValueMap<String, String>();
     productData.add("name", productName);
     productData.add("description", productName + " as description");
     productData.add("version", "1.0");
     HttpEntity<?> requestEntity = new HttpEntity<Object>(productData, createHeaders());
     ResponseEntity<String> responseEntity =
         getRestTemplate().exchange(url, HttpMethod.POST, requestEntity, String.class);
     ObjectMapper mapper = new ObjectMapper();
     bugzillaProduct = mapper.readValue(responseEntity.getBody(), Product.class);
     logger.info("Bugzilla Product Created  " + bugzillaProduct.getId());
     if (bugzillaProduct.getId() != null) {
       bugzillaProduct = getBugzillaProduct(productName).getProducts().get(0);
       updateProductGroup(productName);
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
   return bugzillaProduct;
 }
Exemplo n.º 13
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;
  }
  private Map<String, Object> makeCall(String json, String method) throws PluggableTaskException {

    LOG.debug("Calling method: '%s', with JSON: %s", method, json);

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

    postParameters.add("rest_data", json);
    postParameters.add("input_type", "JSON");
    postParameters.add("method", method);
    postParameters.add("response_type", "JSON");

    RestTemplate restTemplate = new RestTemplate();

    String resultString =
        restTemplate.postForObject(
            ENTRY_POINT,
            postParameters,
            String.class,
            getParameter(PARAM_SERVER.getName()),
            getParameter(PARAM_SUGARINSTANCE.getName()));

    LOG.debug("Result contents: %s", resultString);

    // Tried to use Spring MappingJacksonHttpMessageConverter, but
    // server sends text/html mime type. Using Jackson directly:
    ObjectMapper mapper = new ObjectMapper();
    Map<String, Object> result = null;
    try {
      result = mapper.readValue(resultString, Map.class);
    } catch (IOException ioe) {
      throw new PluggableTaskException(ioe);
    }

    return result;
  }
Exemplo n.º 15
0
  /** 把数据先保存到keyvalue里. */
  public FormParameter doSaveRecord(Map<String, Object> map, String userId, String tenantId)
      throws Exception {
    FormParameter formParameter = new FormParameter();
    MultiValueMap multiValueMap = new LinkedMultiValueMap();

    for (Map.Entry<String, Object> entry : map.entrySet()) {
      multiValueMap.add(entry.getKey(), entry.getValue());
    }

    formParameter.setMultiValueMap(multiValueMap);
    formParameter.setHumanTaskId((String) map.get("taskId"));

    String businessKey = operationService.saveDraft(userId, tenantId, formParameter);

    if ((formParameter.getBusinessKey() == null)
        || "".equals(formParameter.getBusinessKey().trim())) {
      formParameter.setBusinessKey(businessKey);
    }

    Record record = keyValueConnector.findByCode(businessKey);

    record = new RecordBuilder().build(record, multiValueMap, tenantId);

    keyValueConnector.save(record);

    return formParameter;
  }
  private static void loginAndSaveXAuthToken(
      final String user, final String password, final HttpHeaders headersToUpdate) {

    log.info("Authenticating user before subscribing to web socket");

    String url = "http://dev.bearchoke.com:" + port + "/api/authenticate";

    try {
      new RestTemplate()
          .execute(
              url,
              HttpMethod.POST,
              request -> {
                MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
                map.add("username", user);
                map.add("password", password);
                new FormHttpMessageConverter()
                    .write(map, MediaType.APPLICATION_FORM_URLENCODED, request);
              },
              response -> {
                String xAuthToken = response.getHeaders().getFirst(ServerConstants.X_AUTH_TOKEN);
                log.info("Retrieved x-auth-token: " + xAuthToken);
                headersToUpdate.add(ServerConstants.X_AUTH_TOKEN, xAuthToken);
                return null;
              });
    } catch (Exception ex) {
      log.error(ex.getMessage(), ex);
    }
  }
Exemplo n.º 17
0
  public static MultiValueMap<String, String> plain_text() {

    MultiValueMap<String, String> header = new HttpHeaders();
    header.put("Content-Type", Arrays.asList("plain/text"));

    return header;
  }
Exemplo n.º 18
0
 public MultiValueMap<String, String> getExcludedCountriesMap() {
   MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
   for (String country : getExcludedCountries()) {
     map.add(jobKey + "[" + excludedCountriesKey + "][]", country);
   }
   return map;
 }
 /**
  * @name createBugzillaUser
  * @description this method is used to create user for bugzilla at the time of binding as the name
  *     as [email protected] as the service id is used to create the product and group so by
  *     default this user will associate that group and product
  * @param serviceInstance
  * @return
  */
 public BugzillaUser createBugzillaUser(ServiceInstance serviceInstance) {
   String userMailId = "admin@" + serviceInstance.getId() + ".com";
   final String password = generatePassword();
   BugzillaUser bugzillaUser = new BugzillaUser();
   setProperties();
   try {
     url = new URI(REST_CREATE_USER_URL);
     MultiValueMap<String, String> userData = new LinkedMultiValueMap<String, String>();
     userData.add("email", userMailId); // a valid email required
     userData.add("full_name", userMailId);
     userData.add("password", password);
     HttpEntity<?> requestEntity = new HttpEntity<Object>(userData, createHeaders());
     ResponseEntity<String> responseEntity =
         getRestTemplate().exchange(url, HttpMethod.POST, requestEntity, String.class);
     ObjectMapper mapper = new ObjectMapper();
     bugzillaUser = mapper.readValue(responseEntity.getBody(), BugzillaUser.class);
     if (bugzillaUser.getId() != null) {
       bugzillaUser.setEmail(userMailId);
       bugzillaUser.setPassword(password);
     }
     logger.info("Bugzilla User Created  " + bugzillaUser.getId());
     updateBugzillaUserAsAdmin(bugzillaUser);
     createComponent(serviceInstance.getId());
   } catch (Exception e) {
     e.printStackTrace();
   }
   return bugzillaUser;
 }
Exemplo n.º 20
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);
      }
    }
 private String generateForm(MultiValueMap<String, String> form) {
   StringBuilder builder = new StringBuilder();
   try {
     for (Iterator<String> names = form.keySet().iterator(); names.hasNext(); ) {
       String name = names.next();
       for (Iterator<String> values = form.get(name).iterator(); values.hasNext(); ) {
         String value = values.next();
         builder.append(URLEncoder.encode(name, "UTF-8"));
         if (value != null) {
           builder.append('=');
           builder.append(URLEncoder.encode(value, "UTF-8"));
           if (values.hasNext()) {
             builder.append('&');
           }
         }
       }
       if (names.hasNext()) {
         builder.append('&');
       }
     }
   } catch (UnsupportedEncodingException ex) {
     throw new IllegalStateException(ex);
   }
   return builder.toString();
 }
  private MultiValueMap<String, String> getParametersForTokenRequest(
      AuthorizationCodeResourceDetails resource, OAuth2SecurityContext context) {

    MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>();
    form.add("grant_type", "authorization_code");
    form.add("code", context.getAuthorizationCode());

    String redirectUri = resource.getPreEstablishedRedirectUri();
    if (context != null && redirectUri == null) {
      // no pre-established redirect uri: use the preserved state
      // TODO: treat redirect URI as a special kind of state (this is a historical mini hack)
      redirectUri = String.valueOf(context.getPreservedState());
    } else {
      // TODO: the state key is what should be sent, not the value
      form.add("state", String.valueOf(context.getPreservedState()));
    }

    if (redirectUri == null) {
      // still no redirect uri? just try the one for the current context...
      redirectUri = context == null ? null : context.getUserAuthorizationRedirectUri();
    }

    form.add("redirect_uri", redirectUri);

    return form;
  }
Exemplo n.º 23
0
 /**
  * This method logs into a service by doing an standard http using the configuration in this
  * class.
  *
  * @param username the username to log into the application with
  * @param password the password to log into the application with
  * @return the url that the login redirects to
  */
 public String login(String username, String password) {
   MultiValueMap<String, String> form = new LinkedMultiValueMap<>();
   form.add(usernameInputFieldName, username);
   form.add(passwordInputFieldName, password);
   URI location = this.template.postForLocation(loginUrl(), form);
   return location.toString();
 }
Exemplo n.º 24
0
 private Map resolveRequestHeaderMap(Class<? extends Map> mapType, NativeWebRequest webRequest) {
   if (MultiValueMap.class.isAssignableFrom(mapType)) {
     MultiValueMap<String, String> result;
     if (HttpHeaders.class.isAssignableFrom(mapType)) {
       result = new HttpHeaders();
     } else {
       result = new LinkedMultiValueMap<String, String>();
     }
     for (Iterator<String> iterator = webRequest.getHeaderNames(); iterator.hasNext(); ) {
       String headerName = iterator.next();
       for (String headerValue : webRequest.getHeaderValues(headerName)) {
         result.add(headerName, headerValue);
       }
     }
     return result;
   } else {
     Map<String, String> result = new LinkedHashMap<String, String>();
     for (Iterator<String> iterator = webRequest.getHeaderNames(); iterator.hasNext(); ) {
       String headerName = iterator.next();
       String headerValue = webRequest.getHeader(headerName);
       result.put(headerName, headerValue);
     }
     return result;
   }
 }
 public void proposeEdit(
     String venueId,
     String name,
     String address,
     String crossStreet,
     String city,
     String state,
     String zip,
     String phone,
     double latitude,
     double longitude,
     String primaryCategoryId) {
   requireUserAuthorization();
   MultiValueMap<String, Object> params = new LinkedMultiValueMap<String, Object>();
   params.add("name", name);
   params.add("address", address);
   params.add("crossStreet", crossStreet);
   params.add("city", city);
   params.add("state", state);
   params.add("zip", zip);
   params.add("phone", phone);
   params.add("ll", Double.toString(latitude) + "," + Double.toString(longitude));
   params.add("primaryCategoryId", primaryCategoryId);
   post(buildUri(VENUES_ENDPOINT + venueId + "/proposeedit"), params, Map.class);
 }
Exemplo n.º 26
0
  public BaseTest addDynamic(String paid, String photoname, List<String> msgs) {
    cnpClient.configureRequest();
    StringBuffer fstr = new StringBuffer("");
    for (int i = 0; i < msgs.size(); i++) {
      fstr.append(msgs.get(i));
      fstr.append("**");
    }
    String fstr2 = fstr.toString();
    fstr2 = fstr2.substring(0, fstr2.length() - 2);
    Log.i("tag", "fstr2:" + fstr2);
    MultiValueMap<String, Object> params = cnpClient.getParams();
    params.set("paid", paid);
    params.set("photoname", photoname);
    //        try {
    //            String fstr3 = URLEncoder.encode(fstr2, "UTF-8");
    //            params.set("fstr", fstr3);
    //        }catch (UnsupportedEncodingException e) {
    params.set("fstr", fstr2);
    //        }

    return getRestTemplate()
        .postForObject(
            AppContext.getInstance().getString(R.string.path_api) + "home/photo_dynamic/",
            cnpClient.getParams(),
            BaseTest.class);
  }
Exemplo n.º 27
0
    @Override
    protected void onPostExecute(Bitmap result) {
      MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
      map.add("foto", util.BitMapToString(result));

      Webservice ws = new Webservice();
      new HttpAtualizaUsuarioFB(ws.atualizarUsuario(id_usuario), map, Usuario.class, "").execute();
    }
 @Override
 public Method getMethodInfo(String apiKey, String methodName) {
   MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
   if (apiKey != null) parameters.set("api_key", apiKey);
   if (methodName != null) parameters.set("method_name", methodName);
   return restTemplate.getForObject(
       buildUri("flickr.reflection.getMethodInfo", parameters), Method.class);
 }
 private MultiValueMap<String, Object> getBody() {
   MultiValueMap<String, Object> body = new LinkedMultiValueMap<String, Object>();
   body.set("grant_type", "password");
   body.set("username", "foo");
   body.set("password", "bar");
   body.set("scope", "read");
   return body;
 }
Exemplo n.º 30
0
 @Override
 public SlackMessageResponse meMessage(String message, String channelNameOrId) {
   MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
   map.add("channel", channelNameOrId);
   map.add("text", message);
   SlackMessageResponse slackResponse = post("/chat.meMessage", map, SlackMessageResponse.class);
   return slackResponse;
 }