Package org.jboss.resteasy.spi

Examples of org.jboss.resteasy.spi.BadRequestException


      {
         throw f;
      }
      catch (Exception e)
      {
         BadRequestException badRequest = new BadRequestException("Failed processing arguments of " + method.toString(), e);
         badRequest.setLoggable(true);
         throw badRequest;
      }
   }
View Full Code Here


         {
            return constructor.newInstance(strVal);
         }
         catch (InstantiationException e)
         {
            throw new BadRequestException("Unable to extract parameter from http request for " + getParamSignature() + " value is '" + strVal + "'" + " for " + target, e);
         }
         catch (IllegalAccessException e)
         {
            throw new BadRequestException("Unable to extract parameter from http request: " + getParamSignature() + " value is '" + strVal + "'" + " for " + target, e);
         }
         catch (InvocationTargetException e)
         {
            throw new BadRequestException("Unable to extract parameter from http request: " + getParamSignature() + " value is '" + strVal + "'" + " for " + target, e);
         }
      }
      else if (valueOf != null)
      {
         try
         {
            return valueOf.invoke(null, strVal);
         }
         catch (IllegalAccessException e)
         {
            throw new BadRequestException("Unable to extract parameter from http request: " + getParamSignature() + " value is '" + strVal + "'" + " for " + target, e);
         }
         catch (InvocationTargetException e)
         {
            throw new BadRequestException("Unable to extract parameter from http request: " + getParamSignature() + " value is '" + strVal + "'" + " for " + target, e.getTargetException());
         }
      }
      return null;
   }
View Full Code Here

            return o;
         }
         final MediaType mediaType = request.getHttpHeaders().getMediaType();
         if (mediaType == null)
         {
            throw new BadRequestException("content-type was null and expecting to extract a body");
         }

         // We have to do this hack because of servlets and servlet filters
         // A filter that does getParameter() will screw up the input stream which will screw up the
         // provider.  We do it here rather than hack the provider as the provider is reused for client side
         // and also, the server may be using the client framework to make another remote call.
         if (isFormData(type, genericType, annotations, mediaType))
         {
            boolean encoded = FindAnnotation.findAnnotation(annotations, Encoded.class) != null;
            if (encoded) return request.getFormParameters();
            else return request.getDecodedFormParameters();
         }
         else
         {
            return readerUtility.doRead(request, type, genericType, annotations, mediaType);
         }
      }
      catch (IOException e)
      {
         throw new BadRequestException("Failure extracting body", e);
      }
   }
View Full Code Here

      }


      public RuntimeException createReaderNotFound(Type genericType, MediaType mediaType)
      {
         return new BadRequestException(
                 "Could not find message body reader for type: "
                         + genericType + " of content type: " + mediaType);
      }
View Full Code Here

      {
         this.encodedName = URLDecoder.decode(paramName, "UTF-8");
      }
      catch (UnsupportedEncodingException e)
      {
         throw new BadRequestException("Unable to decode query string", e);
      }
   }
View Full Code Here

        String parameter = content.substring(qualityIndex + 1);
        content = content.substring(0, qualityIndex);

        int equalsIndex = parameter.indexOf('=');
        if (equalsIndex < 0)
          throw new BadRequestException("Malformed parameter: " + parameter);
        String name = parameter.substring(0, equalsIndex).trim();
        if (! "q".equals(name))
          throw new BadRequestException("Unsupported parameter: " + name);
        String value = parameter.substring(equalsIndex + 1).trim();
        qualityValue = QualityValue.valueOf(value);
      }

      content = content.trim();
      if (content.length() == 0)
        throw new BadRequestException("Empty field in: " + header + ".");
      if (content.equals("*"))
        result.put(null, qualityValue);
      else
        result.put(content, qualityValue);

View Full Code Here

    int offset = 0;
    while (offset >= 0) {
      int slashIndex = header.indexOf('/', offset);
      if (slashIndex < 0)
        throw new BadRequestException("Malformed media type: " + header);
      String type = header.substring(offset, slashIndex);
      String subtype;
      Map<String,String> parameters = null;
      QualityValue qualityValue = QualityValue.DEFAULT;
View Full Code Here

  private static int parseParameters(Map<String,String> parameters, String header, int offset) {
    while (true) {
      int equalsIndex = header.indexOf('=', offset);
      if (equalsIndex < 0)
        throw new BadRequestException("Malformed parameters: " + header);
      String name = header.substring(offset, equalsIndex).trim();
      offset = equalsIndex + 1;
      if (header.charAt(offset) == '"') {
        int end = offset;
        ++offset;
        do {
          end = header.indexOf('"', ++end);
          if (end < 0)
            throw new BadRequestException("Quoted string is not closed: " + header);
        } while (header.charAt(end - 1) == '\\');
        String value = header.substring(offset, end);
        parameters.put(name, value);
        offset = end + 1;

        int parameterEndIndex = header.indexOf(';', offset);
        int itemEndIndex = header.indexOf(',', offset);
        if (parameterEndIndex == itemEndIndex) {
          assert itemEndIndex == -1;
          if (header.substring(offset).trim().length() != 0)
            throw new BadRequestException("Tailing garbage: " + header);
          return -1;
        } else if (parameterEndIndex < 0 || (itemEndIndex >= 0 && itemEndIndex < parameterEndIndex)) {
          if (header.substring(offset, itemEndIndex).trim().length() != 0)
            throw new BadRequestException("Garbage after quoted string: " + header);
          return itemEndIndex + 1;
        } else {
          if (header.substring(offset, parameterEndIndex).trim().length() != 0)
            throw new BadRequestException("Garbage after quoted string: " + header);
          offset = parameterEndIndex + 1;
        }
      } else {
        int parameterEndIndex = header.indexOf(';', offset);
        int itemEndIndex = header.indexOf(',', offset);
View Full Code Here


  private static int parseAsInteger(String value) {
    int length = value.length();
    if (length == 0 || length > 5)
      throw new BadRequestException(MALFORMED_VALUE_MESSAGE);
    if (length > 1 && value.charAt(1) != '.')
      throw new BadRequestException(MALFORMED_VALUE_MESSAGE);
    int firstCharacter = value.codePointAt(0);
    if (firstCharacter == '1') {
      for (int i = 2; i < length; ++i)
        if (value.charAt(i) != '0')
          throw new BadRequestException(MALFORMED_VALUE_MESSAGE);
      return 1000;
    } else if (firstCharacter == '0') {
      int weight = 0;
      for (int i = 2; i < 5; ++i) {
        weight *= 10;
        if (i < length) {
          int digit = value.codePointAt(i) - '0';
          if (digit < 0 || digit > 9)
            throw new BadRequestException(MALFORMED_VALUE_MESSAGE);
          weight += digit;
        }
      }
      return weight;
    } else
      throw new BadRequestException(MALFORMED_VALUE_MESSAGE);
  }
View Full Code Here

         }

         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++)
         {
View Full Code Here

TOP

Related Classes of org.jboss.resteasy.spi.BadRequestException

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.