Package org.jboss.resteasy.spi

Examples of org.jboss.resteasy.spi.BadRequestException


   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


            String contentType = servletRequest.getContentType();
            MediaType mediaType = MediaType.valueOf(contentType);
            MessageBodyReader reader = factory.getMessageBodyReader(type,
                    genericType, annotations, mediaType);
            if (reader == null)
               throw new BadRequestException(
                       "Could not find message body reader for type: "
                               + genericType + " of content type: " + mediaType);
            return reader.readFrom(type, genericType, annotations, mediaType,
                    request.getHttpHeaders().getRequestHeaders(), request
                            .getInputStream());
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

                  declaringClass, target);
      this.readerUtility = new ReaderUtility(factory, interceptors)
      {
         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

            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

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

    public Role updateRole(@PathParam("role_id") String roleId, Role role) {
        //Only operate here if you only have 1 ID to pull,
        //but if the user passes in an ID in the body of the JSON
        //and that ID is NOT equal to what the ID in the URL is, then throw an error
        if (role.getId() != null && !roleId.equals(role.getId())) {
            throw new BadRequestException(i18n.tr("Role ID does not match path."));
        }
        Role existingRole = lookupRole(roleId);
        existingRole.setName(role.getName());
        return this.userService.updateRole(existingRole);
    }
View Full Code Here

        Role existingRole = lookupRole(roleId);

        // Don't allow NONE permissions to be created, this is currently just for
        // internal use:
        if (permission.getAccess().equals(Access.NONE)) {
            throw new BadRequestException(i18n.tr("Access type NONE not supported."));
        }

        // Attach actual owner objects to each incoming permission:
        Owner temp = permission.getOwner();
        Owner real = ownerCurator.lookupByKey(temp.getKey());
View Full Code Here

        if (client.isPublicClient()) {
            Map<String, String> error = new HashMap<String, String>();
            error.put(OAuth2Constants.ERROR, "invalid_client");
            error.put(OAuth2Constants.ERROR_DESCRIPTION, "Public clients not allowed");
            event.error(Errors.INVALID_CLIENT);
            throw new BadRequestException("Public clients not allowed", javax.ws.rs.core.Response.status(javax.ws.rs.core.Response.Status.BAD_REQUEST).entity(error).type("application/json").build());
        }

        if (!(client instanceof ApplicationModel)) {
            Map<String, String> error = new HashMap<String, String>();
            error.put(OAuth2Constants.ERROR, "invalid_client");
            error.put(OAuth2Constants.ERROR_DESCRIPTION, "Just applications are allowed");
            event.error(Errors.INVALID_CLIENT);
            throw new BadRequestException("ust applications are allowed", javax.ws.rs.core.Response.status(javax.ws.rs.core.Response.Status.BAD_REQUEST).entity(error).type("application/json").build());
        }

        return (ApplicationModel)client;
    }
View Full Code Here

        if (applicationClusterHost == null || applicationClusterHost.length() == 0) {
            Map<String, String> error = new HashMap<String, String>();
            error.put(OAuth2Constants.ERROR, "invalid_request");
            error.put(OAuth2Constants.ERROR_DESCRIPTION, "application cluster host not specified");
            event.error(Errors.INVALID_CODE);
            throw new BadRequestException("Cluster host not specified", javax.ws.rs.core.Response.status(javax.ws.rs.core.Response.Status.BAD_REQUEST).entity(error).type("application/json").build());
        }

        return applicationClusterHost;
    }
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.