Package org.openrdf.repository

Examples of org.openrdf.repository.RepositoryException


    throws IOException, RepositoryException, MalformedQueryException, UnauthorizedException
  {
    // Specify which formats we support using Accept headers
    Set<BooleanQueryResultFormat> booleanFormats = BooleanQueryResultParserRegistry.getInstance().getKeys();
    if (booleanFormats.isEmpty()) {
      throw new RepositoryException("No boolean query result parsers have been registered");
    }

    for (BooleanQueryResultFormat format : booleanFormats) {
      // Determine a q-value that reflects the user specified preference
      int qValue = 10;

      if (preferredBQRFormat != null && !preferredBQRFormat.equals(format)) {
        // Prefer specified format over other formats
        qValue -= 2;
      }

      for (String mimeType : format.getMIMETypes()) {
        String acceptParam = mimeType;

        if (qValue < 10) {
          acceptParam += ";q=0." + qValue;
        }

        method.addRequestHeader(ACCEPT_PARAM_NAME, acceptParam);
      }
    }

    int httpCode = httpClient.executeMethod(method);

    if (httpCode == HttpURLConnection.HTTP_OK) {
      String mimeType = getResponseMIMEType(method);
      try {
        BooleanQueryResultFormat format = BooleanQueryResultFormat.matchMIMEType(mimeType, booleanFormats);
        BooleanQueryResultParser parser = QueryResultIO.createParser(format);
        return parser.parse(method.getResponseBodyAsStream());
      }
      catch (UnsupportedQueryResultFormatException e) {
        throw new RepositoryException("Server responded with an unsupported file format: " + mimeType);
      }
      catch (QueryResultParseException e) {
        throw new RepositoryException("Malformed query result from server", e);
      }
    }
    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


      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

      }

      return createRepositoryResult(contextList);
    }
    catch (QueryEvaluationException e) {
      throw new RepositoryException(e);
    }
    catch (IOException e) {
      throw new RepositoryException(e);
    }
  }
View Full Code Here

  {
    try {
      getRepository().getHTTPClient().getStatements(subj, pred, obj, includeInferred, handler, contexts);
    }
    catch (IOException e) {
      throw new RepositoryException(e);
    }
  }
View Full Code Here

  {
    try {
      return getRepository().getHTTPClient().size(contexts);
    }
    catch (IOException e) {
      throw new RepositoryException(e);
    }
  }
View Full Code Here

        try {
          getRepository().getHTTPClient().sendTransaction(txn);
          txn.clear();
        }
        catch (IOException e) {
          throw new RepositoryException(e);
        }
      }
    }
  }
View Full Code Here

      }

      return createRepositoryResult(namespaceList);
    }
    catch (QueryEvaluationException e) {
      throw new RepositoryException(e);
    }
    catch (IOException e) {
      throw new RepositoryException(e);
    }
  }
View Full Code Here

  {
    try {
      return getRepository().getHTTPClient().getNamespace(prefix);
    }
    catch (IOException e) {
      throw new RepositoryException(e);
    }
  }
View Full Code Here

            break;
          }
        }
      }
      catch (QueryEvaluationException e) {
        throw new RepositoryException(e);
      }
      finally {
        try {
          repositoryList.close();
        }
        catch (QueryEvaluationException e) {
          throw new RepositoryException(e);
        }
      }
    }
    catch (IOException e) {
      throw new RepositoryException(e);
    }

    return isWritable;
  }
View Full Code Here

                    @Override
                    protected Iteration<? extends Statement, ? extends RepositoryException> createIteration() throws RepositoryException {
                        try {
                            return databaseConnection.listTriples(rsubj, rpred, robj, context, includeInferred, false);
                        } catch (ResultInterruptedException e) {
                            throw new RepositoryException("listing triples interrupted",e);
                        } catch (SQLException e) {
                            throw new RepositoryException("database error while listing triples",e);
                        }
                    }
                });
            }
        } else {
            iterations.add(new DelayedIteration<Statement, RepositoryException>() {
                @Override
                protected Iteration<? extends Statement, ? extends RepositoryException> createIteration() throws RepositoryException {
                    try {
                        return databaseConnection.listTriples(rsubj, rpred, robj, null, includeInferred, true);
                    } catch (ResultInterruptedException e) {
                        throw new RepositoryException("listing triples interrupted",e);
                    } catch (SQLException e) {
                        throw new RepositoryException("database error while listing triples",e);
                    }
                }
            });
        }
View Full Code Here

TOP

Related Classes of org.openrdf.repository.RepositoryException

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.