Examples of BadRequestException


Examples of org.exist.http.BadRequestException

          }

          final DocumentImpl feedDoc = collection.getDocument(broker,
              FEED_DOCUMENT_URI);
          if (feedDoc == null) {
            throw new BadRequestException("Collection "
                + request.getPath() + " is not an Atom feed.");
          }

          // Return the collection feed
          // String charset = getContext().getDefaultCharset();
          if (returnContent) {
            if (id == null) {
              response.setStatusCode(200);
              getFeed(broker, request.getPath(), response);
            } else {
              response.setStatusCode(200);
              getEntryById(broker, request.getPath(), id,
                  response);
            }
          } else {
            response.setStatusCode(204);
          }

        } else {
          throw new NotFoundException("Resource " + request.getPath()
              + " not found");
        }

      } else {
        // Do we have permission to read the resource
        if (!resource.getPermissions().validate(broker.getSubject(),
            Permission.READ)) {
          throw new PermissionDeniedException(
              "Not allowed to read resource");
        }

        if (returnContent) {
          response.setStatusCode(200);
          if (resource.getResourceType() == DocumentImpl.BINARY_FILE) {
            response.setContentType(resource.getMetadata()
                .getMimeType());
            try {
              final OutputStream os = response.getOutputStream();
              broker.readBinaryResource(
                  (BinaryDocument) resource, os);
              os.flush();
            } catch (final IOException ex) {
              LOG.fatal(
                  "Cannot read resource " + request.getPath(),
                  ex);
              throw new EXistException(
                  "I/O error on read of resource "
                      + request.getPath(), ex);
            }
          } else {
            // xml resource
            final Serializer serializer = broker.getSerializer();
            serializer.reset();

            final String charset = getContext().getDefaultCharset();
            // Serialize the document
            try {
              response.setContentType(resource.getMetadata()
                  .getMimeType() + "; charset=" + charset);
              final Writer w = new OutputStreamWriter(
                  response.getOutputStream(), charset);
              serializer.serialize(resource, w);
              w.flush();
              w.close();
            } catch (final IOException ex) {
              LOG.fatal(
                  "Cannot read resource " + request.getPath(),
                  ex);
              throw new EXistException(
                  "I/O error on read of resource "
                      + request.getPath(), ex);
            } catch (final SAXException saxe) {
              LOG.warn(saxe);
              throw new BadRequestException(
                  "Error while serializing XML: "
                      + saxe.getMessage());
            }
          }
View Full Code Here

Examples of org.jboss.resteasy.spi.BadRequestException

         }

         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

Examples of org.jboss.resteasy.spi.BadRequestException

         {
            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

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

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

Examples of org.jboss.resteasy.spi.BadRequestException

      {
         MessageBodyReader reader = factory.getMessageBodyReader(type,
                 genericType, annotations, mediaType);
         if (reader == null)
         {
            return new BadRequestException(
                    "Could not find message body reader for type: "
                            + genericType + " of content type: " + mediaType);
         }

         try
View Full Code Here

Examples of org.jboss.resteasy.spi.BadRequestException

            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

Examples of org.jboss.resteasy.spi.BadRequestException

                parameter.getDefaultValue(), parameter.getAccessibleObject(), parameter.getAnnotations(), factory);
        this.encode = parameter.isEncoded();
        try {
            this.encodedName = URLDecoder.decode(paramName, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            throw new BadRequestException("Unable to decode query string", e);
        }
    }
View Full Code Here

Examples of org.sonar.server.exceptions.BadRequestException

  @Override
  public void validate(String value, @Nullable List<String> options) {
    if (options != null && !options.contains(value)) {
      String optionsAsString = StringUtils.join(options, ", ");
      throw new BadRequestException("errors.type.notInOptions", value, optionsAsString);
    }
  }
View Full Code Here

Examples of org.wymiwyg.rwcf.BadRequestException

      relation.addProperty(KNOBOT.effectiveDate, effectiveDateLiteral);
      relation.addProperty(KNOBOT.strengthReduction, model.createTypedLiteral(DefaultValuesHandler
          .getDefaultStrengthReduction(model)));
      Statement titleStatement = comment.getProperty(RSS.title);
      if (titleStatement == null) {
        throw new BadRequestException("Title is required");
      }
      Resource namedItem = (Resource) NamedResourceGenerator
          .createNewResource(model, ehRequest.getRootURL(),
              titleStatement.getString()).inModel(importing);
      JenaUtil.replace(importing, comment, namedItem);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.