Package org.openrdf.http.protocol.error

Examples of org.openrdf.http.protocol.error.ErrorInfo


public class MalformedQuery extends BadRequest {

  private static final long serialVersionUID = -6836412684686503188L;

  public MalformedQuery(String msg) {
    super(new ErrorInfo(ErrorType.MALFORMED_QUERY, msg).toString());
  }
View Full Code Here


public class UnsupportedQueryLanguage extends BadRequest {

  private static final long serialVersionUID = -4486188821642629533L;

  public UnsupportedQueryLanguage(String msg) {
    super(new ErrorInfo(ErrorType.UNSUPPORTED_QUERY_LANGUAGE, msg).toString());
  }
View Full Code Here

  private static final long serialVersionUID = 8540515029592553577L;

  static final int STATUS_CODE = HttpURLConnection.HTTP_BAD_REQUEST;

  public static BadRequest create(String msg) {
    ErrorInfo errInfo = ErrorInfo.parse(msg);
    ErrorType type = errInfo.getErrorType();
    if (type == ErrorType.UNSUPPORTED_FILE_FORMAT) {
      return new UnsupportedFileFormat(errInfo.getErrorMessage());
    }
    else if (type == ErrorType.UNSUPPORTED_QUERY_LANGUAGE) {
      return new UnsupportedQueryLanguage(errInfo.getErrorMessage());
    }
    else if (type == ErrorType.MALFORMED_DATA) {
      return new MalformedData(errInfo.getErrorMessage());
    }
    else if (type == ErrorType.MALFORMED_QUERY) {
      return new MalformedQuery(errInfo.getErrorMessage());
    }
    else {
      return new BadRequest(errInfo.toString());
    }
  }
View Full Code Here

public class UnsupportedFileFormat extends BadRequest {

  private static final long serialVersionUID = 2224008763380338386L;

  public UnsupportedFileFormat(String msg) {
    super(new ErrorInfo(ErrorType.UNSUPPORTED_FILE_FORMAT, msg).toString());
  }
View Full Code Here

public class MalformedData extends BadRequest {

  private static final long serialVersionUID = -6138770791457273654L;

  public MalformedData(String msg) {
    super(new ErrorInfo(ErrorType.MALFORMED_DATA, msg).toString());
  }
View Full Code Here

  private static final long serialVersionUID = 8056400029162650973L;

  private final ErrorInfo errInfo;

  public ErrorInfoException(ErrorType errType, String errMsg) {
    this(new ErrorInfo(errType, errMsg));
  }
View Full Code Here

  }

  @Override
  public Status getStatus(Throwable throwable, Request request, Response response) {
    if (throwable instanceof ErrorInfoException) {
      ErrorInfo errInfo = ((ErrorInfoException)throwable).getErrorInfo();
      response.setEntity(new StringRepresentation(errInfo.toString(), TEXT_PLAIN, Language.ALL, UTF_8));
      return new Status(CLIENT_ERROR_BAD_REQUEST, errInfo.getErrorType().getLabel());
    }
    else {
      return super.getStatus(throwable, request, response);
    }
  }
View Full Code Here

        return serviceRegistry.get(format);
      }
    }

    if (hasAcceptParam) {
      ErrorInfo errInfo = new ErrorInfo(ErrorType.UNSUPPORTED_FILE_FORMAT, mimeType);
      throw new ClientHTTPException(SC_BAD_REQUEST, errInfo.toString());
    }
    else {
      // No acceptable format was found, send 406 as required by RFC 2616
      throw new ClientHTTPException(SC_NOT_ACCEPTABLE, "No acceptable file format found.");
    }
View Full Code Here

    }
    else if (httpCode == HttpURLConnection.HTTP_UNAUTHORIZED) {
      throw new UnauthorizedException();
    }
    else {
      ErrorInfo errInfo = getErrorInfo(method);

      // Throw appropriate exception
      if (errInfo.getErrorType() == ErrorType.MALFORMED_QUERY) {
        throw new MalformedQueryException(errInfo.getErrorMessage());
      }
      else if (errInfo.getErrorType() == ErrorType.UNSUPPORTED_QUERY_LANGUAGE) {
        throw new UnsupportedQueryLanguageException(errInfo.getErrorMessage());
      }
      else {
        throw new RepositoryException(method.getStatusText());
      }
    }
View Full Code Here

  protected ErrorInfo getErrorInfo(HttpMethod method)
    throws RepositoryException
  {
    try {
      ErrorInfo errInfo = ErrorInfo.parse(method.getResponseBodyAsString());
      logger.warn("Server reports problem: {}", errInfo.getErrorMessage());
      return errInfo;
    }
    catch (IOException e) {
      logger.warn("Unable to retrieve error info from server");
      throw new RepositoryException("Unable to retrieve error info from server", e);
View Full Code Here

TOP

Related Classes of org.openrdf.http.protocol.error.ErrorInfo

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.