當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。