Ejemplo n.º 1
0
  @Override
  public boolean delete(final ObjectId id) {
    final byte[] rawKey = id.getRawValue();
    final DatabaseEntry key = new DatabaseEntry(rawKey);

    final OperationStatus status = objectDb.delete(txn.getTransaction(), key);

    return SUCCESS.equals(status);
  }
Ejemplo n.º 2
0
  /** @see org.geogit.storage.ObjectDatabase#exists(org.geogit.api.ObjectId) */
  @Override
  public boolean exists(final ObjectId id) {
    Preconditions.checkNotNull(id, "id");

    DatabaseEntry key = new DatabaseEntry(id.getRawValue());
    DatabaseEntry data = new DatabaseEntry();
    // tell db not to retrieve data
    data.setPartial(0, 0, true);

    final LockMode lockMode = LockMode.DEFAULT;
    CurrentTransaction.getInstance(env);
    OperationStatus status = objectDb.get(txn.getTransaction(), key, data, lockMode);
    return SUCCESS == status;
  }
Ejemplo n.º 3
0
  /** @see org.geogit.storage.ObjectDatabase#getRaw(org.geogit.api.ObjectId) */
  @Override
  protected InputStream getRawInternal(final ObjectId id) throws IOException {
    Preconditions.checkNotNull(id, "id");
    DatabaseEntry key = new DatabaseEntry(id.getRawValue());
    DatabaseEntry data = new DatabaseEntry();

    final LockMode lockMode = LockMode.READ_COMMITTED;
    Transaction transaction = txn.getTransaction();
    OperationStatus operationStatus = objectDb.get(transaction, key, data, lockMode);
    if (NOTFOUND.equals(operationStatus)) {
      throw new IllegalArgumentException("Object does not exist: " + id.toString());
    }
    final byte[] cData = data.getData();

    return new ByteArrayInputStream(cData);
  }
Ejemplo n.º 4
0
  /** @see org.geogit.storage.ObjectDatabase#put(org.geogit.storage.ObjectWriter) */
  @Override
  protected boolean putInternal(final ObjectId id, final byte[] rawData, final boolean override)
      throws IOException {
    final byte[] rawKey = id.getRawValue();
    DatabaseEntry key = new DatabaseEntry(rawKey);
    DatabaseEntry data = new DatabaseEntry(rawData);

    OperationStatus status;
    if (override) {
      status = objectDb.put(txn.getTransaction(), key, data);
    } else {
      status = objectDb.putNoOverwrite(txn.getTransaction(), key, data);
    }
    final boolean didntExist = SUCCESS.equals(status);

    if (LOGGER.isLoggable(Level.FINER)) {
      if (didntExist) {
        LOGGER.finer("Key already exists in blob store, blob reused for id: " + id);
      }
    }
    return didntExist;
  }