本文整理匯總了Java中com.sun.jersey.spi.container.ContainerRequest.setUris方法的典型用法代碼示例。如果您正苦於以下問題:Java ContainerRequest.setUris方法的具體用法?Java ContainerRequest.setUris怎麽用?Java ContainerRequest.setUris使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.sun.jersey.spi.container.ContainerRequest
的用法示例。
在下文中一共展示了ContainerRequest.setUris方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: filter
import com.sun.jersey.spi.container.ContainerRequest; //導入方法依賴的package包/類
@Override
public ContainerRequest filter(ContainerRequest request) {
// only if the query parameters contain the configured name
// and one of the values from "fromValues"
if (request.getQueryParameters() != null
&& !request.getQueryParameters().isEmpty()
&& request.getQueryParameters().containsKey(queryParamToModify)
&& ArrayUtils.contains(fromValues,
request.getQueryParameters().getFirst(queryParamToModify))) {
URI modifiedUri = getModifiedUri(request.getRequestUri());
request.setUris(request.getBaseUri(), modifiedUri);
}
return request;
}
示例2: translate
import com.sun.jersey.spi.container.ContainerRequest; //導入方法依賴的package包/類
public void translate(ContainerRequest request) {
String uri = request.getPath();
List<PathSegment> segments = request.getPathSegments();
String version = PathConstants.V1;
if (!segments.isEmpty()) {
version = segments.get(0).getPath();
}
for (Map.Entry<String, URITranslation> entry : uriTranslationMap.entrySet()) {
String key = entry.getKey();
if (uri.contains(key)) {
String newPath = uriTranslationMap.get(key).translate(request.getPath());
if (!newPath.equals(uri)) {
request.setUris(request.getBaseUri(),
request.getBaseUriBuilder().path(version).path(newPath).build());
}
}
}
}
示例3: updateContainerRequest
import com.sun.jersey.spi.container.ContainerRequest; //導入方法依賴的package包/類
private ContainerRequest updateContainerRequest(ContainerRequest containerRequest, List<PathSegment> segments, String newVersion) {
//add the new version
UriBuilder builder = containerRequest.getBaseUriBuilder().path(newVersion);
//add the rest of the request
for (PathSegment segment : segments) {
builder.path(segment.getPath());
}
if (containerRequest.getRequestUri().getQuery() != null &&
!containerRequest.getRequestUri().getQuery().isEmpty()) {
builder.replaceQuery(containerRequest.getRequestUri().getQuery());
}
containerRequest.getProperties().put(REQUESTED_PATH, containerRequest.getPath());
containerRequest.setUris(containerRequest.getBaseUri(), builder.build());
return containerRequest;
}
示例4: filter
import com.sun.jersey.spi.container.ContainerRequest; //導入方法依賴的package包/類
@Override
public ContainerRequest filter(final ContainerRequest request) {
final MultivaluedMap<String, String> parameters = request.getQueryParameters();
if (containsUpperCase(parameters.keySet())) {
//rebuild URI
final URI lower = rebuildQuery(request.getRequestUri(), parameters);
request.setUris(request.getBaseUri(), lower);
}
return request;
}
示例5: uriOverride
import com.sun.jersey.spi.container.ContainerRequest; //導入方法依賴的package包/類
/**
* Uriのオーバーライド処理.
* @param request 加工するリクエスト
*/
private void uriOverride(final ContainerRequest request) {
String xForwardedProto = request.getHeaderValue(PersoniumCoreUtils.HttpHeaders.X_FORWARDED_PROTO);
String xForwardedHost = request.getHeaderValue(PersoniumCoreUtils.HttpHeaders.X_FORWARDED_HOST);
String xForwardedPath = request.getHeaderValue(PersoniumCoreUtils.HttpHeaders.X_FORWARDED_PATH);
UriBuilder bub = request.getBaseUriBuilder();
UriBuilder rub = request.getRequestUriBuilder();
if (xForwardedProto != null) {
bub.scheme(xForwardedProto);
rub.scheme(xForwardedProto);
}
if (xForwardedHost != null) {
bub.host(xForwardedHost);
rub.host(xForwardedHost);
}
if (xForwardedPath != null) {
bub.replacePath("/");
// クエリを含んでいる場合は、クエリを削除してリクエストパスに設定する
if (xForwardedPath.contains("?")) {
xForwardedPath = xForwardedPath.substring(0, xForwardedPath.indexOf("?"));
}
rub.replacePath(xForwardedPath);
}
request.setUris(bub.build(), rub.build());
}
示例6: adjustHeader
import com.sun.jersey.spi.container.ContainerRequest; //導入方法依賴的package包/類
private void adjustHeader(ContainerRequest request, String path, String suffix) {
String mime = SUFFIXES.get(suffix);
// change accept header
InBoundHeaders headers = (InBoundHeaders) request.getRequestHeaders();
headers.put(HttpHeaders.ACCEPT, Collections.singletonList(mime));
request.setHeaders(headers);
// remove suffix from the URL
String newPath = path.substring(0, path.length() - suffix.length());
URI requestUri = request.getRequestUri();
URI newURI = UriBuilder.fromUri(requestUri).replacePath(newPath).build();
request.setUris(request.getBaseUri(), newURI);
}
示例7: filter
import com.sun.jersey.spi.container.ContainerRequest; //導入方法依賴的package包/類
@Override
public ContainerRequest filter(final ContainerRequest request) {
final MultivaluedMap<String, String> parameters =
request.getQueryParameters();
if (containsUpperCase(parameters.keySet())) {
//rebuild URI
final URI lower = rebuildQuery(request.getRequestUri(), parameters);
request.setUris(request.getBaseUri(), lower);
}
return request;
}
示例8: filter
import com.sun.jersey.spi.container.ContainerRequest; //導入方法依賴的package包/類
@Override
public ContainerRequest filter(ContainerRequest request) {
String path = request.getPath();
String extension = path.substring(path.lastIndexOf(DOT)+1);
if(MAP.containsKey(extension)){
LOG.debug("overriding Accept type to " + MAP.get(extension));
List<String> acceptType = Arrays.asList(new String[] {MAP.get(extension)});
request.getRequestHeaders().put("accept", acceptType);
String newPath = path.replaceFirst(DOT+extension+"$", "");
request.setUris(request.getBaseUri(), UriBuilder.fromUri(request.getRequestUri()).replacePath(newPath).build());
}
return request;
}
示例9: mutateURI
import com.sun.jersey.spi.container.ContainerRequest; //導入方法依賴的package包/類
/**
* Mutates the URI based on who the user is (provided in Authentication object) and what they're
* requesting (provided in Container Request object).
*
* @param auth
* OAuth2Authentication object (contains principal for user).
* @param request
* Container Request (contains path and query parameters).
*/
public void mutateURI(Authentication auth, ContainerRequest request) {
/*
* Don't mutate POSTs.
*/
if (request.getMethod().equals(POST)) {
return;
}
SLIPrincipal user = (SLIPrincipal) auth.getPrincipal();
String clientId = ((OAuth2Authentication) auth).getClientAuthentication().getClientId();
List<PathSegment> segments = sanitizePathSegments(request);
String parameters = request.getRequestUri().getQuery();
if (segments.size() == 0) {
throw new NotFoundException();
}
if (usingVersionedApi(segments)) {
if (!request.getProperties().containsKey(REQUESTED_PATH)) {
request.getProperties().put(REQUESTED_PATH, request.getPath());
}
MutatedContainer mutated = uriMutator.mutate(segments, parameters, user, clientId);
if (mutated != null && mutated.isModified()) {
String version = getResourceVersion(segments, mutated);
if (mutated.getHeaders() != null) {
InBoundHeaders headers = new InBoundHeaders();
headers.putAll(request.getRequestHeaders());
for (String key : mutated.getHeaders().keySet()) {
headers.putSingle(key, mutated.getHeaders().get(key));
}
request.setHeaders(headers);
}
if (mutated.getPath() != null) {
if (mutated.getQueryParameters() != null && !mutated.getQueryParameters().isEmpty()) {
LOG.info("URI Rewrite: {}?{} --> {}?{}", new Object[] { request.getPath(), parameters, mutated.getPath(),
mutated.getQueryParameters() });
request.setUris(request.getBaseUri(),
request.getBaseUriBuilder().path(version).path(mutated.getPath())
.replaceQuery(mutated.getQueryParameters()).build());
} else {
LOG.info("URI Rewrite: {} --> {}", new Object[] { request.getPath(), mutated.getPath() });
request.setUris(request.getBaseUri(),
request.getBaseUriBuilder().path(version).path(mutated.getPath()).build());
}
}
}
}
}