use of org.springframework.web.util.UriComponentsBuilder in project libresonic by Libresonic.
the class LibresonicContentDirectory method createResourceForSong.
protected Res createResourceForSong(MediaFile song) {
Player player = playerService.getGuestPlayer(null);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(getBaseUrl() + "/ext/stream").queryParam("id", song.getId()).queryParam("player", player.getId());
if (song.isVideo()) {
builder.queryParam("format", TranscodingService.FORMAT_RAW);
}
jwtSecurityService.addJWTToken(builder);
String url = builder.toUriString();
String suffix = song.isVideo() ? FilenameUtils.getExtension(song.getPath()) : transcodingService.getSuffix(player, song, null);
String mimeTypeString = StringUtil.getMimeType(suffix);
MimeType mimeType = mimeTypeString == null ? null : MimeType.valueOf(mimeTypeString);
Res res = new Res(mimeType, null, url);
res.setDuration(formatDuration(song.getDurationSeconds()));
return res;
}
use of org.springframework.web.util.UriComponentsBuilder in project geode by apache.
the class ClientHttpRequest method getURL.
/**
* Gets the URL for the client's HTTP request.
* <p/>
*
* @param uriVariables a Map of URI path variables to values in order to expand the URI template
* into a URI.
* @return a URL as a URI referring to the location of the resource requested by the client via
* HTTP.
* @see #getURI()
* @see java.net.URI
* @see org.springframework.web.util.UriComponents
* @see org.springframework.web.util.UriComponentsBuilder
*/
public URI getURL(final Map<String, ?> uriVariables) {
final UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromUriString(UriUtils.decode(getURI().toString()));
if (isGet() || isDelete()) {
final List<String> pathVariables = getPathVariables();
// get query parameters to append to the URI/URL based on the request parameters that are not
// path variables...
final Map<String, List<Object>> queryParameters = CollectionUtils.removeKeys(new LinkedMultiValueMap<String, Object>(getParameters()), new Filter<Map.Entry<String, List<Object>>>() {
@Override
public boolean accept(final Map.Entry<String, List<Object>> entry) {
// so that it won't interfere with the expand() call afterwards
if (entry.getKey().contains(CLIMultiStepHelper.STEP_ARGS)) {
List<Object> stepArgsList = entry.getValue();
if (stepArgsList != null) {
String stepArgs = (String) stepArgsList.remove(0);
stepArgsList.add(UriUtils.encode(stepArgs));
}
}
return !pathVariables.contains(entry.getKey());
}
});
for (final String queryParameterName : queryParameters.keySet()) {
uriBuilder.queryParam(queryParameterName, getParameters().get(queryParameterName).toArray());
}
}
return uriBuilder.build().expand(UriUtils.encode(new HashMap<String, Object>(uriVariables))).encode().toUri();
}
use of org.springframework.web.util.UriComponentsBuilder in project java-chassis by ServiceComb.
the class CseUriTemplateHandler method expandInternal.
@Override
protected URI expandInternal(String uriTemplate, Object... uriVariables) {
UriComponentsBuilder uriComponentsBuilder = initUriComponentsBuilder(uriTemplate);
UriComponents uriComponents = expandAndEncode(uriComponentsBuilder, uriVariables);
return createUri(uriTemplate, uriComponentsBuilder, uriComponents);
}
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);
}
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));
}
Aggregations