Package org.openrdf.http.server.helpers

Examples of org.openrdf.http.server.helpers.ServerConnection


    // Currently, we don't use method annotations in Sesame
    setAnnotated(false);
  }

  protected CacheInfo getCacheInfo() {
    ServerConnection connection = getConnection();
    if (connection != null) {
      return connection.getCacheInfo();
    }

    ServerRepository repository = getRepository();
    if (repository != null) {
      return repository.getCacheInfo();
View Full Code Here


  @Override
  protected int beforeHandle(Request request, Response response) {
    ServerRepository repository = RequestAtt.getRepository(request);

    try {
      ServerConnection connection = repository.getConnection();
      connection.addRequest(request);
      RequestAtt.setConnection(request, connection);
      return Filter.CONTINUE;
    }
    catch (StoreException e) {
      logger.error("Failed to open a connection on the repository", e);
View Full Code Here

    }
  }

  private void closeConnection(Request request) {
    try {
      ServerConnection connection = RequestAtt.getConnection(request);
      connection.removeRequest(request);
      connection.close();
    }
    catch (StoreException e) {
      logger.error("Failed to close repository connection", e);
    }
  }
View Full Code Here

  @Override
  protected int beforeHandle(Request request, Response response) {
    String connectionID = getConnectionID(request);
    logger.debug("{}={}", CONNECTION_ID_PARAM, connectionID);

    ServerConnection connection = RequestAtt.getRepository(request).getConnection(connectionID);

    if (connection != null) {
      connection.addRequest(request);
      RequestAtt.setConnection(request, connection);
      return Filter.CONTINUE;
    }
    else {
      response.setStatus(Status.CLIENT_ERROR_NOT_FOUND);
View Full Code Here

      releaseConnection(request);
    }
  }

  private void releaseConnection(Request request) {
    ServerConnection connection = RequestAtt.getConnection(request);
    connection.removeRequest(request);
  }
View Full Code Here

  @Override
  protected int beforeHandle(Request request, Response response) {
    String queryID = getQueryID(request);
    logger.debug("{}={}", QUERY_ID_PARAM, queryID);

    ServerConnection connection = RequestAtt.getConnection(request);
    Query query = connection.getQuery(queryID);

    if (query == null) {
      response.setStatus(Status.CLIENT_ERROR_NOT_FOUND);
      return Filter.STOP;
    }

    try {
      // Parse request-specific parameters
      Form params = ServerUtil.getParameters(request);
      if (params != null) {
        QueryParser.parseQueryParameters(query, params, connection.getValueFactory());
      }

      RequestAtt.setQuery(request, query);
      return Filter.CONTINUE;
    }
View Full Code Here

  private final Logger logger = LoggerFactory.getLogger(this.getClass());

  protected final Representation getRepresentation(RDFWriterFactory factory, MediaType mediaType)
    throws ResourceException
  {
    ServerConnection con = getConnection();
    StatementPatternParams p = new StatementPatternParams(getRequest(), con.getValueFactory());

    try {
      ModelResult modelResult = getConnection().match(p.getSubject(), p.getPredicate(), p.getObject(),
          p.isIncludeInferred(), p.getContext());
View Full Code Here

  @Override
  protected Representation delete(Variant variant)
    throws ResourceException
  {
    ServerConnection con = getConnection();
    StatementPatternParams p = new StatementPatternParams(getRequest(), con.getValueFactory());

    try {
      con.removeMatch(p.getSubject(), p.getPredicate(), p.getObject(), p.getContext());
      con.getCacheInfo().processUpdate();
      return null;
    }
    catch (StoreException e) {
      throw new ResourceException(SERVER_ERROR_INTERNAL, "Repository update error", e);
    }
View Full Code Here

      logger.debug("Processing transaction...");

      TransactionReader reader = new TransactionReader();
      Iterable<? extends TransactionOperation> txn = reader.parse(in);

      ServerConnection connection = getConnection();

      boolean autoCommit = connection.isAutoCommit();
      if (autoCommit) {
        connection.begin();
      }

      try {
        for (TransactionOperation op : txn) {
          op.execute(connection);
        }

        if (autoCommit) {
          connection.commit();
        }

        connection.getCacheInfo().processUpdate();

        logger.debug("Transaction processed ");
      }
      finally {
        if (autoCommit && !connection.isAutoCommit()) {
          // restore auto-commit by rolling back
          logger.error("Rolling back transaction");
          connection.rollback();
        }
      }
    }
    catch (SAXParseException e) {
      throw new ErrorInfoException(MALFORMED_DATA, e.getMessage());
View Full Code Here

    if (rdfFormat == null) {
      throw new ResourceException(CLIENT_ERROR_UNSUPPORTED_MEDIA_TYPE, "Unsupported MIME type: "
          + mimeType);
    }

    ServerConnection connection = getConnection();
    ValueFactory vf = connection.getValueFactory();

    Form params = getQuery();
    Resource[] contexts = ServerUtil.parseContextParam(params, CONTEXT_PARAM_NAME, vf);
    URI baseURI = ServerUtil.parseURIParam(params, BASEURI_PARAM_NAME, vf);

    if (baseURI == null) {
      baseURI = vf.createURI("foo:bar");
      logger.info("no base URI specified, using dummy '{}'", baseURI);
    }

    try {
      InputStream in = entity.getStream();

      boolean autoCommit = connection.isAutoCommit();
      if (autoCommit) {
        connection.begin();
      }

      try {
        if (replaceCurrent) {
          connection.clear(contexts);
        }
        connection.add(in, baseURI.toString(), rdfFormat, contexts);

        if (autoCommit) {
          connection.commit();
        }

        connection.getCacheInfo().processUpdate();
      }
      finally {
        if (autoCommit && !connection.isAutoCommit()) {
          // restore auto-commit by rolling back'
          connection.rollback();
        }
      }
    }
    catch (UnsupportedRDFormatException e) {
      throw new ResourceException(CLIENT_ERROR_UNSUPPORTED_MEDIA_TYPE,
View Full Code Here

TOP

Related Classes of org.openrdf.http.server.helpers.ServerConnection

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.