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


Java ContainerRequest.getPath方法代码示例

本文整理汇总了Java中com.sun.jersey.spi.container.ContainerRequest.getPath方法的典型用法代码示例。如果您正苦于以下问题:Java ContainerRequest.getPath方法的具体用法?Java ContainerRequest.getPath怎么用?Java ContainerRequest.getPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.jersey.spi.container.ContainerRequest的用法示例。


在下文中一共展示了ContainerRequest.getPath方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: filter

import com.sun.jersey.spi.container.ContainerRequest; //导入方法依赖的package包/类
@Override
public ContainerRequest filter(final ContainerRequest req) {
	
	if (log.isTraceEnabled()) {
		String baseUri = req.getBaseUri().getPath();
		String method = req.getMethod();
		String path = req.getPath();
		MediaType mediaType = req.getMediaType();
		
		String dbg = Strings.of("\r\nRESTEndPoint: {}"  +														
				  				"\r\n---------------------------------------------------------------------"  +				
				  				"\r\n       Method: {}"  +
				  				"\r\n        Path: {}" + 
				  				"\r\nContent-Type: {}" +
				  				"\r\n---------------------------------------------------------------------")
				  			.customizeWith(baseUri,
				  					       method,
				  					       path,
				  					       mediaType != null ? mediaType
				  					    		   			 : "not specified")
				  			.asString();
		log.trace(dbg);
	}
	return req;
}
 
开发者ID:opendata-euskadi,项目名称:r01fb,代码行数:26,代码来源:RESTLogRequestFilter.java

示例2: filter

import com.sun.jersey.spi.container.ContainerRequest; //导入方法依赖的package包/类
@Override
public ContainerRequest filter(final ContainerRequest request) {
	if (logger.isInfoEnabled()) {
		String requestInfo = request.getPath() + " (" + request.getMethod() +
				(request.getMediaType() == null ? "" : " " + request.getMediaType()) + ")";
		logger.info(requestInfo);

		StringBuilder parameters = new StringBuilder("Params: ");
		Set<Entry<String, List<String>>> entrySet = request.getFormParameters().entrySet();
		for (Entry<String, List<String>> parameter : entrySet) {
			parameters.append(parameter.getKey()).append(":").append(parameter.getValue()).append(", ");
		}
		if (!entrySet.isEmpty()) {
			parameters.setLength(parameters.length() - ", ".length());
			logger.info(parameters.toString());
		}

	}
	return request;
}
 
开发者ID:LemoProject,项目名称:lemo2,代码行数:21,代码来源:RequestLoggingFilter.java

示例3: filter

import com.sun.jersey.spi.container.ContainerRequest; //导入方法依赖的package包/类
@Override
public ContainerRequest filter(ContainerRequest containerRequest) {
    // Filter out all events in case that the trial license expired
    AddonsManager addonsManager = ContextHelper.get().beanForType(AddonsManager.class);
    ArtifactoryResponse artifactoryResponse = new HttpArtifactoryResponse(response);
    try {
        String path = containerRequest.getPath();
        addonsManager.interceptRestResponse(artifactoryResponse, path);
        if (artifactoryResponse.isError()) {
            // throw the exception to make sure to return
            throw new AuthorizationRestException("License expired or not installed");
        }
    } catch (IOException e) {
        log.error("Fail to intercept license REST validation", e);
        throw new RuntimeException("Fail to intercept license validation during rest request", e);
    }
    return containerRequest;
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:19,代码来源:LicenseRestFilter.java

示例4: filter

import com.sun.jersey.spi.container.ContainerRequest; //导入方法依赖的package包/类
@Override
public ContainerRequest filter(ContainerRequest request) {

    String requestPath = request.getPath();
    // Don't process if we are listing all buckets or creating a new bucket
    if (StringUtils.isEmpty(requestPath) || (requestPath.matches(REGEX_ONLY_BUCKET) && request.getMethod().equals("PUT")))
        return request;
    String bucketName = requestPath.indexOf('/') > 0 ? requestPath.substring(0, requestPath.indexOf('/')) : requestPath;
    LOG.debug(String.format("Validating Region for bucket: %s", bucketName));
    String bucketRegionName = bucketMetaDataHelper.getLocationForBucket(bucketName);
    LOG.debug("bucketRegionName: " + bucketRegionName);
    Region bucketRegion = getRegionForRegionName(bucketRegionName);
    LOG.debug("bucketRegion: " + bucketRegion);
    int thisNodeRegionCode = pisssApplicationManager.getKoalaIdFactory().getRegion();

    if (thisNodeRegionCode == bucketRegion.getRegionCode()) {
        return request;
    }
    // Permanent Redirect. Location set
    return permanentRedirect(request, bucketRegion, bucketName);
}
 
开发者ID:barnyard,项目名称:pi,代码行数:22,代码来源:ValidRegionFilter.java

示例5: filter

import com.sun.jersey.spi.container.ContainerRequest; //导入方法依赖的package包/类
@Override
public ContainerRequest filter(final ContainerRequest request) {
	if (logger.isInfoEnabled()) {
		String requestInfo = request.getPath() + " (" + request.getMethod() +
				(request.getMediaType() == null ? "" : " " + request.getMediaType()) + ")";
		logger.debug(requestInfo);

		StringBuilder parameters = new StringBuilder("Params: ");
		Set<Entry<String, List<String>>> entrySet = request.getFormParameters().entrySet();
		for (Entry<String, List<String>> parameter : entrySet) {
			parameters.append(parameter.getKey()).append(":").append(parameter.getValue()).append(", ");
		}
		if (!entrySet.isEmpty()) {
			parameters.setLength(parameters.length() - ", ".length());
			logger.debug(parameters.toString());
		}

	}
	return request;
}
 
开发者ID:LemoProject,项目名称:Lemo-Data-Management-Server,代码行数:21,代码来源:RequestLoggingFilter.java

示例6: 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

示例7: validateDateSearchUri

import com.sun.jersey.spi.container.ContainerRequest; //导入方法依赖的package包/类
/**
 * Verifies that if a date range is specified that the request URI
 * is allowed to be searched via date ranges
 * @param request
 */
private void validateDateSearchUri(ContainerRequest request) {

    String requestPath = request.getPath();

    Matcher m = ID_REPLACEMENT_PATTERN.matcher(requestPath);

    if (m.matches()){
        // transform requestPath from "v1.x/foo/2344,3453,5345/bar" to "v1.x/foo/{id}/bar"
        requestPath = m.group(1) + PathConstants.ID_PLACEHOLDER + m.group(2);
    }

    if (this.resourceEndPoint.getDateRangeDisallowedEndPoints().contains(requestPath)) {

        List<String> schoolYears = request.getQueryParameters().get(ParameterConstants.SCHOOL_YEARS);
        if (schoolYears != null && schoolYears.size() > 0){
            throw new QueryParseException("Date range filtering not allowed", request.getPath());
        }
    }
}
 
开发者ID:inbloom,项目名称:secure-data-service,代码行数:25,代码来源:DateSearchFilter.java

示例8: validateNotBlockGetRequest

import com.sun.jersey.spi.container.ContainerRequest; //导入方法依赖的package包/类
/**
 * Validate the request URL is not blocked
 *
 * @param request
 */
private void validateNotBlockGetRequest(ContainerRequest request) {
    if (!request.getMethod().equals(RequestMethod.GET.name())) {
        return;
    }

    String requestPath = request.getPath();
    Matcher m = ID_REPLACEMENT_PATTERN.matcher(requestPath);

    if (m.matches()) {
        // transform requestPath from "v1.x/foo/2344,3453,5345/bar" to
        // "v1.x/foo/{id}/bar"
        requestPath = m.group(1) + PathConstants.ID_PLACEHOLDER + m.group(2);
    }

    if (this.resourceEndPoint.getBlockGetRequestEndPoints().contains(requestPath)) {
        throw new RequestBlockedException(request.getPath());
    }
}
 
开发者ID:inbloom,项目名称:secure-data-service,代码行数:24,代码来源:PreProcessFilter.java

示例9: filter

import com.sun.jersey.spi.container.ContainerRequest; //导入方法依赖的package包/类
@Override
public ContainerRequest filter(final ContainerRequest request) {
    String accessKey = request.getQueryParameters().getFirst("accessKey");
    String url = request.getPath();
    this.log.info(accessKey + " accesses " + url);
    return request;
}
 
开发者ID:dobrakmato,项目名称:pexel-platform,代码行数:8,代码来源:ApiLoggingFilter.java

示例10: 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

示例11: validateNonTwoPartUri

import com.sun.jersey.spi.container.ContainerRequest; //导入方法依赖的package包/类
private void validateNonTwoPartUri(ContainerRequest request) {
    String requestPath = request.getPath();

    Matcher m = TWO_PART_URI_PATTERN.matcher(requestPath);

    if (m.find()){
        throw new QueryParseException("Date range filtering not allowed", request.getPath());
    }
}
 
开发者ID:inbloom,项目名称:secure-data-service,代码行数:10,代码来源:DateSearchFilter.java

示例12: validateNotVersionOneZero

import com.sun.jersey.spi.container.ContainerRequest; //导入方法依赖的package包/类
/**
 * Dissallows any date range searches for v1.0 URIs
 * @param request
 */
private void validateNotVersionOneZero(ContainerRequest request) {
    List<PathSegment> segments = request.getPathSegments();
    if (segments.size() > 0) {
        String version = segments.get(0).getPath();
        if (PathConstants.V1_0.equals(version)) {

            List<String> schoolYears = request.getQueryParameters().get(ParameterConstants.SCHOOL_YEARS);
            if (schoolYears != null && schoolYears.size() > 0){
                throw new QueryParseException("Date range filtering not allowed", request.getPath());
            }
        }
    }
}
 
开发者ID:inbloom,项目名称:secure-data-service,代码行数:18,代码来源:DateSearchFilter.java

示例13: filter

import com.sun.jersey.spi.container.ContainerRequest; //导入方法依赖的package包/类
/**
 * Apply the authentication filter to the incoming ContainerRequest
 * @param request is the incoming ContainerRequest
 * @return
 */
@Override
public ContainerRequest filter(ContainerRequest containerRequest) {

    System.out.println("AuthFilterController: Filtering request for Basic authorization....");

    /// Store the request method (e.g. GET, POST, PUT, or DELETE)
    String method = containerRequest.getMethod();

    /// Store the request path (e.g. "/vert/song/upload")
    String path = containerRequest.getPath(true);

    System.out.println("AuthFilterController: Method=" + method + " Path=" + path);

    /// Allow access to the WADL (Web Application Description Language) which
    /// describes the structure of the web application's resources.
    if (method.equals("GET") && (path.equals("application.wadl") || path.equals("application.wadl/xsd0.xsd"))) {
        System.out.println("AuthFilterController: Access granted to WADL");
        return containerRequest;
    } else if (method.equals("POST") && path.endsWith("data/users")) {
        System.out.println("AuthFilterController: Access granted to registering User");
        return containerRequest;
    } else if (method.equals("POST") && path.endsWith("data/session")) {
        System.out.println("AuthFilterController: Access granted to login for user");
        return containerRequest;
    } else if (method.equals("GET") && path.contains("data/activates")) {
        System.out.println("AuthFilterController: Access granted to user account activation");
        return containerRequest;
    } else if (method.equals("GET") && path.contains("file/song")) {
        System.out.println("AuthFilterController: Access granted to file download/streaming");
        return containerRequest;
    }

    /// Get the authentication passed in the HTTP headers, if it does not
    /// exist then throw an unauthorized exception
    String auth = containerRequest.getHeaderValue("authorization");
    String[] loginInfo = BasicAuth.decode(auth);
    if (loginInfo == null || loginInfo.length != 2) {
        System.out.println("AuthFilterController: Unauthorized access - no login info found");
        throw new WebApplicationException(Status.UNAUTHORIZED);
    }

    /// Retrieve user from the database, and check if one exists under the provided auth info
    User user = userService.authenticate(loginInfo[0], loginInfo[1]);
    if (user == null) {
        System.out.println("AuthFilterController: Unauthorized access - no match for user/password");
        throw new WebApplicationException(Status.UNAUTHORIZED);
    }

    /// Set user context in HttpServletRequest
    servletRequest.setAttribute(User.LOGGED_USER, user);
    System.out.println("AuthFilterController: Authorized access - " + user);
    return containerRequest;
}
 
开发者ID:VertMusic,项目名称:vert_backend,代码行数:59,代码来源:AuthFilterController.java

示例14: filter

import com.sun.jersey.spi.container.ContainerRequest; //导入方法依赖的package包/类
@Override
public ContainerResponse filter(ContainerRequest request, ContainerResponse response) {
    if (isRead(request.getMethod()) && isSuccessfulRead(response.getStatus())) {
        if (contextValidator.isUrlBlocked(request)) {
            throw new APIAccessDeniedException(String.format("url %s is not accessible.", request.getAbsolutePath().toString()));
        }

        SLIPrincipal principal = (SLIPrincipal) SecurityContextHolder.getContext().getAuthentication()
                .getPrincipal();
        principal.setSubEdOrgHierarchy(edOrgHelper.getStaffEdOrgsAndChildren());
        contextValidator.validateContextToUri(request, principal);
    }

    SecurityContextHolder.clearContext();

    if ("true".equals(apiPerformanceTracking)) {
        logApiDataToDb(request, response);
    }
    TenantContext.cleanup();
    printElapsed(request);
    expireCache();

    String queryString = "";
    if (null != request.getRequestUri().getQuery()) {
        queryString = "?" + request.getRequestUri().getQuery();
    }
    String executedPath = request.getPath() + queryString;

    // Truncate the executed path to avoid issues with response header length being too long for the servlet container
    if (executedPath != null && executedPath.length() > maxResponseHeaderXexecutedPath) {
        executedPath = executedPath.substring(0, Math.min(executedPath.length(), maxResponseHeaderXexecutedPath));
    }

    response.getHttpHeaders().add("X-RequestedPath", request.getProperties().get("requestedPath"));
    response.getHttpHeaders().add("X-ExecutedPath", executedPath);

    //        Map<String,Object> body = (Map<String, Object>) response.getEntity();
    //        body.put("requestedPath", request.getProperties().get("requestedPath"));
    //        body.put("executedPath", request.getPath());

    return response;
}
 
开发者ID:inbloom,项目名称:secure-data-service,代码行数:43,代码来源:PostProcessFilter.java


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