当前位置: 首页>>代码示例>>Java>>正文


Java ContainerRequest.setUris方法代码示例

本文整理汇总了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;
}
 
开发者ID:cvent,项目名称:pangaea,代码行数:17,代码来源:EnvironmentModifierFilter.java

示例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());
            }
        }
    }
}
 
开发者ID:inbloom,项目名称:secure-data-service,代码行数:21,代码来源:URITranslator.java

示例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;
}
 
开发者ID:inbloom,项目名称:secure-data-service,代码行数:20,代码来源:VersionFilter.java

示例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;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:ParamFilter.java

示例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());
}
 
开发者ID:personium,项目名称:personium-core,代码行数:31,代码来源:PersoniumCoreContainerFilter.java

示例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);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:15,代码来源:UrlSuffixFilter.java

示例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;
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:12,代码来源:ParamFilter.java

示例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;
}
 
开发者ID:barnyard,项目名称:pi,代码行数:15,代码来源:HttpContentTypeFilter.java

示例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());
                }
            }
        }
    }
}
 
开发者ID:inbloom,项目名称:secure-data-service,代码行数:64,代码来源:EndpointMutator.java


注:本文中的com.sun.jersey.spi.container.ContainerRequest.setUris方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。