Package org.jboss.resteasy.spi

Examples of org.jboss.resteasy.spi.BadRequestException


         {
            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


         {
            formParameters = FormUrlEncodedProvider.parseForm(getInputStream());
         }
         catch (IOException e)
         {
            throw new BadRequestException(e);
         }
      }
      else
      {
         throw new IllegalArgumentException("Request media type is not application/x-www-form-urlencoded");
View Full Code Here

      {
         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

    @Test
    public void extractIllegalValue() {
        rem = injector.getInstance(BadRequestExceptionMapper.class);
        String foo = "javax.ws.rs.SomeThing(\"paramName\") value is 'strVal' for";
        BadRequestException bre = new BadRequestException(foo);
        Response r = rem.toResponse(bre);

        assertEquals(Status.BAD_REQUEST.getStatusCode(), r.getStatus());
        verifyMessage(r, "strVal is not a valid value for paramName");
    }
View Full Code Here

    }

    @Test
    public void emptyMessage() {
        rem = injector.getInstance(BadRequestExceptionMapper.class);
        BadRequestException bre = new BadRequestException("");
        Response r = rem.toResponse(bre);

        assertEquals(Status.BAD_REQUEST.getStatusCode(), r.getStatus());
        assertNull(r.getEntity());
    }
View Full Code Here

    }

    @Test
    public void jbossBadRequestException() {
        String foo = "foo";
        BadRequestException bre = new BadRequestException(foo);
        Response r = rem.toResponse(bre);

        assertEquals(Status.INTERNAL_SERVER_ERROR.getStatusCode(), r.getStatus());
        verifyMessage(r, "Runtime Error");
    }
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

   {
      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
         {
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.