Search in sources :

Example 21 with UriComponentsBuilder

use of org.springframework.web.util.UriComponentsBuilder in project java-chassis by ServiceComb.

the class CseUriTemplateHandler method expandInternal.

@Override
protected URI expandInternal(String uriTemplate, Map<String, ?> uriVariables) {
    UriComponentsBuilder uriComponentsBuilder = initUriComponentsBuilder(uriTemplate);
    UriComponents uriComponents = expandAndEncode(uriComponentsBuilder, uriVariables);
    return createUri(uriTemplate, uriComponentsBuilder, uriComponents);
}
Also used : UriComponents(org.springframework.web.util.UriComponents) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder)

Example 22 with UriComponentsBuilder

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

the class BulkSmsGateway method sendBatch.

// -------------------------------------------------------------------------
// Implementation
// -------------------------------------------------------------------------
@Override
public List<OutboundMessageResponse> sendBatch(OutboundMessageBatch smsBatch, SmsGatewayConfig config) {
    BulkSmsGatewayConfig bulkSmsConfig = (BulkSmsGatewayConfig) config;
    UriComponentsBuilder uriBuilder = buildBaseUrl(bulkSmsConfig, SubmissionType.BATCH);
    uriBuilder.queryParam("batch_data", buildCsvUrl(smsBatch.getMessages()));
    return Lists.newArrayList(send(uriBuilder));
}
Also used : UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder)

Example 23 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 24 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 25 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)

Aggregations

UriComponentsBuilder (org.springframework.web.util.UriComponentsBuilder)25 UriComponents (org.springframework.web.util.UriComponents)10 Test (org.junit.Test)8 MvcUriComponentsBuilder (org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder)7 Map (java.util.Map)2 ServletUriComponentsBuilder (org.springframework.web.servlet.support.ServletUriComponentsBuilder)2 Claim (com.auth0.jwt.interfaces.Claim)1 DecodedJWT (com.auth0.jwt.interfaces.DecodedJWT)1 IOException (java.io.IOException)1 URI (java.net.URI)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Random (java.util.Random)1 Res (org.fourthline.cling.support.model.Res)1 OutboundMessageResponse (org.hisp.dhis.outboundmessage.OutboundMessageResponse)1 Player (org.libresonic.player.domain.Player)1 MimeType (org.seamless.util.MimeType)1 MockServletContext (org.springframework.mock.web.test.MockServletContext)1 AccessDeniedException (org.springframework.security.access.AccessDeniedException)1 InsufficientAuthenticationException (org.springframework.security.authentication.InsufficientAuthenticationException)1