Package org.jboss.resteasy.specimpl

Examples of org.jboss.resteasy.specimpl.UriInfoImpl


            public void process() throws ServletException, IOException
            {
               try
               {
                  HttpHeaders headers = ServletUtil.extractHttpHeaders(request);
                  UriInfoImpl uriInfo = extractUriInfo(request, application.getResourcePathPrefix());

                  HttpResponse theResponse = new HttpServletResponseWrapper(
                        response,
                        dispatcher.getProviderFactory()
                  );
View Full Code Here


   public ResourceInvoker matchPattern(HttpRequest
           request, String
           path, int start)
   {
      UriInfoImpl uriInfo = (UriInfoImpl) request.getUri();
      Matcher matcher = pattern.matcher(path);
      matcher.region(start, path.length());

      if (matcher.matches())
      {
         // we consumed entire path string
         ResourceInvoker invoker = match(request.getHttpMethod(), request.getHttpHeaders().getMediaType(), request.getHttpHeaders().getAcceptableMediaTypes());
         if (invoker == null)
            throw new NotFoundException("Could not find resource for relative : " + path + " of full path: " + request.getUri().getRequestUri());
         uriInfo.pushMatchedURI(path, Encode.decode(path));
         populatePathParams(request, matcher, path);
         return invoker;
      }
      if (locator == null)
      {
         throw new NotFoundException("Could not find resource for relative : " + path + " of full path: " + request.getUri().getRequestUri());
      }
      if (matcher.find(start) && matcher.start() == start)
      {
         // a non-matched locator path must have a '/' immediately after.  A locator cannot match a partial segment
         String group0 = matcher.group(0);
         int charAt = start + group0.length();

         char c = path.charAt(charAt);
         if (c == '/')
         {
            String matched = path.substring(0, start + matcher.group(0).length());
            uriInfo.pushMatchedURI(matched, Encode.decode(matched));
            populatePathParams(request, matcher, path);
            return locator;
         }
      }
      throw new NotFoundException("Could not find resource for relative : " + path + " of full path: " + request.getUri().getRequestUri());
View Full Code Here

      return segment;
   }

   public ResourceInvoker matchSimple(HttpRequest request, String path, int start)
   {
      UriInfoImpl uriInfo = (UriInfoImpl) request.getUri();
      if (start + segment.length() == path.length()) // we've reached end of string
      {
         ResourceInvoker invoker = match(request.getHttpMethod(), request.getHttpHeaders().getMediaType(), request.getHttpHeaders().getAcceptableMediaTypes());
         if (invoker == null)
            throw new NotFoundException("Could not find resource for relative : " + path + " of full path: " + request.getUri().getRequestUri());

         uriInfo.pushMatchedURI(path, Encode.decode(path));
         return invoker;
      }
      else
      {
         try
         {
            return matchChildren(request, path, start + segment.length() + 1); // + 1 to ignore '/'
         }
         catch (Failure e)
         {
            if (locator != null)
            {
               String matched = path.substring(0, start + segment.length());
               uriInfo.pushMatchedURI(matched, Encode.decode(matched));
               return locator;
            }
            else throw e;
         }
      }
View Full Code Here

      request.httpHeaders = new HttpHeadersImpl();
      request.httpHeaders.setAcceptableLanguages(new ArrayList<String>());
      request.httpHeaders.setAcceptableMediaTypes(new ArrayList<MediaType>());
      request.httpHeaders.setCookies(new HashMap<String, Cookie>());
      request.httpHeaders.setRequestHeaders(new Headers<String>());
      request.uri = new UriInfoImpl(absoluteUri, absoluteUri, absoluteUri.getPath(), absoluteUri.getQuery(), PathSegmentImpl.parseSegments(absoluteUri.getPath()));
      request.preprocessedPath = request.uri.getPath(false);
      return request;

   }
View Full Code Here

   }

   public ServerResponse invoke(HttpRequest request, HttpResponse response, Object target)
   {
      incrementMethodCount(request.getHttpMethod());
      UriInfoImpl uriInfo = (UriInfoImpl) request.getUri();
      uriInfo.pushCurrentResource(target);
      try
      {
         ServerResponse jaxrsResponse = invokeOnTarget(request, response, target);

         if (jaxrsResponse != null && jaxrsResponse.getEntity() != null)
         {
            // if the content type isn't set, then set it to be either most desired type from the Accept header
            // or the first media type in the @Produces annotation
            // See RESTEASY-144
            Object type = jaxrsResponse.getMetadata().getFirst(
                    HttpHeaderNames.CONTENT_TYPE);
            if (type == null)
               jaxrsResponse.getMetadata().putSingle(HttpHeaderNames.CONTENT_TYPE, resolveContentType(request));
         }
         return jaxrsResponse;

      }
      finally
      {
         uriInfo.popCurrentResource();
      }
   }
View Full Code Here

   public Object inject(HttpRequest request, HttpResponse response)
   {
      if (extractor == null) // we are a PathSegment
      {
         UriInfoImpl uriInfo = (UriInfoImpl) request.getUri();
         List<PathSegment[]> list = null;
         if (encode)
         {
            list = uriInfo.getEncodedPathParameterPathSegments().get(paramName);
         }
         else
         {
            list = uriInfo.getPathParameterPathSegments().get(paramName);
         }
         PathSegment[] segments = list.get(list.size() - 1);
         if (isPathSegmentArray(type))
         {
            return segments;
View Full Code Here

         if (defaultInstance instanceof ThreadLocalResteasyProviderFactory)
         {
            ThreadLocalResteasyProviderFactory.push(providerFactory);
         }
         HttpHeaders headers = ServletUtil.extractHttpHeaders(request);
         UriInfoImpl uriInfo = ServletUtil.extractUriInfo(request, servletMappingPrefix);

         HttpResponse theResponse = createServletResponse(response);
         HttpRequest in = createHttpRequest(httpMethod, request, headers, uriInfo, theResponse);

         try
View Full Code Here

         String tmpContextPath = contextPath;
         if (!tmpContextPath.endsWith("/")) tmpContextPath += "/";
         baseURI = UriBuilder.fromUri(absolutePath).replacePath(tmpContextPath).build();
      }

      UriInfoImpl uriInfo = new UriInfoImpl(absolutePath, baseURI, path, request.getQueryString(), pathSegments);
      return uriInfo;
   }
View Full Code Here

      return pathExpression;
   }

   protected void populatePathParams(HttpRequest request, Matcher matcher, String path)
   {
      UriInfoImpl uriInfo = (UriInfoImpl) request.getUri();
      for (Group group : groups)
      {
         String value = matcher.group(group.group);
         uriInfo.addEncodedPathParameter(group.name, value);
         int index = matcher.start(group.group);

         int start = 0;
         if (path.charAt(0) == '/') start++;
         int segmentIndex = 0;

         if (start < path.length())
         {
            int count = 0;
            for (int i = start; i < index && i < path.length(); i++)
            {
               if (path.charAt(i) == '/') count++;
            }
            segmentIndex = count;
         }

         int numSegments = 1;
         for (int i = 0; i < value.length(); i++)
         {
            if (value.charAt(i) == '/') numSegments++;
         }

         if (segmentIndex + numSegments > request.getUri().getPathSegments().size())
         {

            throw new BadRequestException("Number of matched segments greater than actual");
         }
         PathSegment[] encodedSegments = new PathSegment[numSegments];
         PathSegment[] decodedSegments = new PathSegment[numSegments];
         for (int i = 0; i < numSegments; i++)
         {
            encodedSegments[i] = request.getUri().getPathSegments().get(segmentIndex + i);
            decodedSegments[i] = request.getUri().getPathSegments(false).get(segmentIndex + i);
         }
         uriInfo.getEncodedPathParameterPathSegments().add(group.name, encodedSegments);
         uriInfo.getPathParameterPathSegments().add(group.name, decodedSegments);
      }
   }
View Full Code Here

    private final InstallationManagementEndpoint endpoint = new InstallationManagementEndpoint();

    @Test
    public void shouldGenerateHeaderLinksFirstPage() throws URISyntaxException {
        //given
        final UriInfoImpl uriInfo = getUriInfo();

        //when
        final LinkHeader linkHeader = endpoint.getLinkHeader(0, 3, uriInfo);

        //then
View Full Code Here

TOP

Related Classes of org.jboss.resteasy.specimpl.UriInfoImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.