Search in sources :

Example 76 with UriComponentsBuilder

use of org.springframework.web.util.UriComponentsBuilder in project dhis2-core by dhis2.

the class BulkSmsGateway method createUri.

// -------------------------------------------------------------------------
// Supportive methods
// -------------------------------------------------------------------------
private UriComponentsBuilder createUri(BulkSmsGatewayConfig bulkSmsConfig, Set<String> recipients, SubmissionType type) {
    UriComponentsBuilder uriBuilder = buildBaseUrl(bulkSmsConfig, type);
    uriBuilder.queryParam("msisdn", getRecipients(recipients));
    return uriBuilder;
}
Also used : UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder)

Example 77 with UriComponentsBuilder

use of org.springframework.web.util.UriComponentsBuilder in project dhis2-core by dhis2.

the class BulkSmsGateway method send.

@Override
public OutboundMessageResponse send(String subject, String text, Set<String> recipients, SmsGatewayConfig config) {
    UriComponentsBuilder uriBuilder = createUri((BulkSmsGatewayConfig) config, recipients, SubmissionType.SINGLE);
    uriBuilder.queryParam("message", text);
    return send(uriBuilder);
}
Also used : UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder)

Example 78 with UriComponentsBuilder

use of org.springframework.web.util.UriComponentsBuilder in project dhis2-core by dhis2.

the class SimplisticHttpGetGateWay method buildUrl.

// -------------------------------------------------------------------------
// Supportive methods
// -------------------------------------------------------------------------
private UriComponentsBuilder buildUrl(GenericHttpGatewayConfig config, String text, Set<String> recipients) {
    UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromHttpUrl(config.getUrlTemplate());
    uriBuilder = getUrlParameters(config.getParameters(), uriBuilder);
    uriBuilder.queryParam(config.getMessageParameter(), text);
    uriBuilder.queryParam(config.getRecipientParameter(), !recipients.isEmpty() ? recipients.iterator().next() : "");
    return uriBuilder;
}
Also used : UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder)

Example 79 with UriComponentsBuilder

use of org.springframework.web.util.UriComponentsBuilder in project spring-data-commons by spring-projects.

the class PagedResourcesAssembler method createLink.

/**
 * Creates a {@link Link} with the given rel that will be based on the given {@link UriTemplate} but enriched with the
 * values of the given {@link Pageable} (if not {@literal null}).
 *
 * @param base must not be {@literal null}.
 * @param pageable can be {@literal null}
 * @param rel must not be {@literal null} or empty.
 * @return
 */
private Link createLink(UriTemplate base, Pageable pageable, String rel) {
    UriComponentsBuilder builder = fromUri(base.expand());
    pageableResolver.enhance(builder, getMethodParameter(), pageable);
    return new Link(new UriTemplate(builder.build().toString()), rel);
}
Also used : UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) ServletUriComponentsBuilder(org.springframework.web.servlet.support.ServletUriComponentsBuilder) UriTemplate(org.springframework.hateoas.UriTemplate) Link(org.springframework.hateoas.Link)

Example 80 with UriComponentsBuilder

use of org.springframework.web.util.UriComponentsBuilder in project spring-data-commons by spring-projects.

the class EnableSpringDataWebSupportIntegrationTests method createsProxyForInterfaceBasedControllerMethodParameter.

// DATACMNS-630
@Test
public void createsProxyForInterfaceBasedControllerMethodParameter() throws Exception {
    WebApplicationContext applicationContext = WebTestUtils.createApplicationContext(SampleConfig.class);
    MockMvc mvc = MockMvcBuilders.webAppContextSetup(applicationContext).build();
    UriComponentsBuilder builder = UriComponentsBuilder.fromUriString("/proxy");
    builder.queryParam("name", "Foo");
    builder.queryParam("shippingAddresses[0].zipCode", "ZIP");
    builder.queryParam("shippingAddresses[0].city", "City");
    builder.queryParam("billingAddress.zipCode", "ZIP");
    builder.queryParam("billingAddress.city", "City");
    builder.queryParam("date", "2014-01-11");
    // 
    mvc.perform(post(builder.build().toString())).andExpect(status().isOk());
}
Also used : UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) MockMvc(org.springframework.test.web.servlet.MockMvc) WebApplicationContext(org.springframework.web.context.WebApplicationContext) Test(org.junit.Test)

Aggregations

UriComponentsBuilder (org.springframework.web.util.UriComponentsBuilder)131 Test (org.junit.Test)34 UriComponents (org.springframework.web.util.UriComponents)23 ServletUriComponentsBuilder (org.springframework.web.servlet.support.ServletUriComponentsBuilder)12 URI (java.net.URI)9 Test (org.junit.jupiter.api.Test)9 SearchRequest (org.nzbhydra.searching.searchrequests.SearchRequest)8 MvcUriComponentsBuilder (org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder)8 ArrayList (java.util.ArrayList)7 LinkedMultiValueMap (org.springframework.util.LinkedMultiValueMap)7 List (java.util.List)6 User (com.serotonin.m2m2.vo.User)5 RestProcessResult (com.serotonin.m2m2.web.mvc.rest.v1.message.RestProcessResult)5 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)5 HashMap (java.util.HashMap)5 HttpEntity (org.springframework.http.HttpEntity)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 HttpClientErrorException (org.springframework.web.client.HttpClientErrorException)5 IOException (java.io.IOException)4 Map (java.util.Map)4