Package org.springframework.web.util

Examples of org.springframework.web.util.UriComponentsBuilder$PathSegmentComponentBuilder


    if (authorizationRequest == null || authorizationRequest.getRedirectUri() == null) {
      // we have no redirect for the user. very sad.
      throw new UnapprovedClientAuthenticationException("Authorization failure, and no redirect URI.", failure);
    }

    UriComponentsBuilder template = UriComponentsBuilder.fromUriString(authorizationRequest.getRedirectUri());
    Map<String, String> query = new LinkedHashMap<String, String>();
    StringBuilder values = new StringBuilder();

    values.append("error={error}");
    query.put("error", failure.getOAuth2ErrorCode());

    values.append("&error_description={error_description}");
    query.put("error_description", failure.getMessage());

    if (authorizationRequest.getState() != null) {
      values.append("&state={state}");
      query.put("state", authorizationRequest.getState());
    }

    if (failure.getAdditionalInformation() != null) {
      for (Map.Entry<String, String> additionalInfo : failure.getAdditionalInformation().entrySet()) {
        values.append("&" + additionalInfo.getKey() + "={" + additionalInfo.getKey() + "}");
        query.put(additionalInfo.getKey(), additionalInfo.getValue());
      }
    }

    if (fragment) {
      template.fragment(values.toString());
    }
    else {
      template.query(values.toString());
    }

    return template.build().expand(query).encode().toUriString();

  }
View Full Code Here


    if (authorizationCode == null) {
      throw new IllegalStateException("No authorization code found in the current request scope.");
    }

    UriComponentsBuilder template = UriComponentsBuilder.fromUriString(authorizationRequest.getRedirectUri());
    template.queryParam("code", authorizationCode);

    String state = authorizationRequest.getState();
    if (state != null) {
      template.queryParam("state", state);
    }

    return template.build().encode().toUriString();
  }
View Full Code Here

     * @param argumentValues argument values matching to method parameters
     * @return a UriComponentsBuilder instance
     */
    public static UriComponentsBuilder fromMethod(Method method, Object... argumentValues) {

        UriComponentsBuilder builder = ServletUriComponentsBuilder.newInstance().path(getMethodRequestMapping(method));
        UriComponents uriComponents = applyContributors(builder, method, argumentValues);

        String typePath = getTypeRequestMapping(method.getDeclaringClass());
        String methodPath = uriComponents.getPath();
        String path = pathMatcher.combine(typePath, methodPath);
View Full Code Here

        MethodInvocationInfo info = (MethodInvocationInfo) methodInvocationInfo;

        Method method = info.getControllerMethod();
        Object[] argumentValues = info.getArgumentValues();

        UriComponentsBuilder builder = ServletUriComponentsBuilder.newInstance().path(getMethodRequestMapping(method));
        UriComponents uriComponents = applyContributors(builder, method, argumentValues);

        String typeMapping = getTypeRequestMapping(method.getDeclaringClass());
        String methodMapping = uriComponents.getPath();
        String path = pathMatcher.combine(typeMapping, methodMapping);
View Full Code Here

  public void assetConsidersPaginationCustomization() {

    HateoasPageableHandlerMethodArgumentResolver resolver = context
        .getBean(HateoasPageableHandlerMethodArgumentResolver.class);

    UriComponentsBuilder builder = UriComponentsBuilder.newInstance();
    resolver.enhance(builder, null, new PageRequest(0, 9000, Direction.ASC, "firstname"));

    MultiValueMap<String, String> params = builder.build().getQueryParams();

    assertThat(params.containsKey("myPage"), is(true));
    assertThat(params.containsKey("mySort"), is(true));

    assertThat(params.get("mySize"), hasSize(1));
View Full Code Here

    TemplateVariables variables = new TemplateVariables();
    String href = linkFor(type).withSelfRel().getHref();

    if (metadata.isPagingResource()) {

      UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(href);

      if (pageable != null) {
        resolver.enhance(builder, null, pageable);
      }

      href = builder.build().toString();

      variables = variables.concat(resolver.getPaginationTemplateVariables(null, builder.build()));
    }

    ProjectionDefinitionConfiguration projectionConfiguration = config.projectionConfiguration();

    if (projectionConfiguration.hasProjectionFor(type)) {
View Full Code Here

      ResourceMetadata mapping = mappings.getMappingFor(domainType);

      if (mapping.isExported()) {

        BaseUri baseUri = new BaseUri(configuration.getBaseUri());
        UriComponentsBuilder builder = baseUri.getUriComponentsBuilder().path(ALPS_ROOT_MAPPING);
        String href = builder.path(mapping.getPath().toString()).build().toUriString();
        descriptors.add(Alps.descriptor().name(mapping.getRel()).href(href).build());
      }
    }

    Alps alps = Alps.alps().//
View Full Code Here

    Link orders = discoverUnique("orders");

    MockHttpServletResponse response = request(orders);
    Link orderLink = assertContentLinkWithRel("self", response, true).expand();

    UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(orderLink.getHref());
    String uri = builder.queryParam("projection", "summary").build().toUriString();

    response = mvc.perform(get(uri)). //
        andExpect(status().isOk()). //
        andExpect(jsonPath("$.price", is(2.5))).//
        andReturn().getResponse();
View Full Code Here

    /**
     * Search for questions that have one or more of the given tags.
     * See https://api.stackexchange.com/docs/search
     */
    public List<Question> searchForQuestionsTagged(String... tags) {
        UriComponentsBuilder builder = getBuilderFor(baseUrl + SEARCH_TEMPLATE);

        if (tags.length > 0) {
            String tagsString = StringUtils.arrayToDelimitedString(tags, ";");
            builder = builder.queryParam(TAGGED_PARAM, tagsString);
        }

        UriComponents uriComponents = builder.build();

        Questions result = restClient.get(restOperations, uriComponents.toUriString(), Questions.class);

        return result.items;
    }
View Full Code Here

        return result.items;
    }

    private UriComponentsBuilder getBuilderFor(String uri) {
        UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(uri);

        for (Entry<String, String> entry : PARAMETERS.entrySet()) {
            builder.queryParam(entry.getKey(), entry.getValue());
        }

        return builder;
    }
View Full Code Here

TOP

Related Classes of org.springframework.web.util.UriComponentsBuilder$PathSegmentComponentBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.