use of org.springframework.web.util.UriComponentsBuilder in project nakadi by zalando.
the class SubscriptionsUriHelper method createSubscriptionListUri.
public static String createSubscriptionListUri(final Optional<String> owningApplication, final Set<String> eventTypes, final int offset, final int limit) {
final UriComponentsBuilder urlBuilder = UriComponentsBuilder.fromPath("/subscriptions");
if (!eventTypes.isEmpty()) {
urlBuilder.queryParam("event_type", eventTypes.toArray());
}
owningApplication.ifPresent(owningApp -> urlBuilder.queryParam("owning_application", owningApp));
return urlBuilder.queryParam("offset", offset).queryParam("limit", limit).build().toString();
}
use of org.springframework.web.util.UriComponentsBuilder in project taskana by Taskana.
the class AbstractRessourcesAssembler method getBuilderForOriginalUri.
protected UriComponentsBuilder getBuilderForOriginalUri() {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
UriComponentsBuilder baseUri = ServletUriComponentsBuilder.fromServletMapping(request).path(request.getRequestURI());
for (Map.Entry<String, String[]> entry : request.getParameterMap().entrySet()) {
for (String value : entry.getValue()) {
baseUri.queryParam(entry.getKey(), value);
}
}
UriComponentsBuilder original = baseUri;
return original;
}
use of org.springframework.web.util.UriComponentsBuilder in project taskana by Taskana.
the class WorkbasketSummaryResourcesAssembler method getBuilderForOriginalUri.
private UriComponentsBuilder getBuilderForOriginalUri() {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
UriComponentsBuilder baseUri = ServletUriComponentsBuilder.fromServletMapping(request).path(request.getRequestURI());
for (Map.Entry<String, String[]> entry : request.getParameterMap().entrySet()) {
for (String value : entry.getValue()) {
baseUri.queryParam(entry.getKey(), value);
}
}
UriComponentsBuilder original = baseUri;
return original;
}
use of org.springframework.web.util.UriComponentsBuilder in project spring-cloud-netflix by spring-cloud.
the class LocationRewriteFilter method run.
@Override
public Object run() {
RequestContext ctx = RequestContext.getCurrentContext();
Route route = routeLocator.getMatchingRoute(urlPathHelper.getPathWithinApplication(ctx.getRequest()));
if (route != null) {
Pair<String, String> lh = locationHeader(ctx);
if (lh != null) {
String location = lh.second();
URI originalRequestUri = UriComponentsBuilder.fromHttpRequest(new ServletServerHttpRequest(ctx.getRequest())).build().toUri();
UriComponentsBuilder redirectedUriBuilder = UriComponentsBuilder.fromUriString(location);
UriComponents redirectedUriComps = redirectedUriBuilder.build();
String newPath = getRestoredPath(this.zuulProperties, route, redirectedUriComps);
String modifiedLocation = redirectedUriBuilder.scheme(originalRequestUri.getScheme()).host(originalRequestUri.getHost()).port(originalRequestUri.getPort()).replacePath(newPath).build().toUriString();
lh.setSecond(modifiedLocation);
}
}
return null;
}
use of org.springframework.web.util.UriComponentsBuilder in project ma-core-public by infiniteautomation.
the class PasswordResetService method generateResetUrl.
public URI generateResetUrl(String token) throws UnknownHostException {
UriComponentsBuilder builder;
String baseUrl = SystemSettingsDao.getValue(SystemSettingsDao.PUBLICLY_RESOLVABLE_BASE_URL);
if (baseUrl != null) {
builder = UriComponentsBuilder.fromPath(baseUrl);
} else {
boolean sslOn = Common.envProps.getBoolean("ssl.on", false);
int port = sslOn ? Common.envProps.getInt("ssl.port", 443) : Common.envProps.getInt("web.port", 8080);
builder = UriComponentsBuilder.newInstance().scheme(sslOn ? "https" : "http").host(InetAddress.getLocalHost().getHostName()).port(port);
}
String resetPage = DefaultPagesDefinition.getPasswordResetUri();
return builder.path(resetPage).queryParam(PASSWORD_RESET_PAGE_TOKEN_PARAMETER, token).build().toUri();
}
Aggregations