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