use of com.cinchapi.concourse.server.aop.VerifyWritePermission in project concourse by cinchapi.
the class ConcourseServer method setKeyValueRecords.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyWritePermission
public void setKeyValueRecords(String key, TObject value, List<Long> records, AccessToken creds, TransactionToken transaction, String environment) throws TException {
AtomicSupport store = getStore(transaction, environment);
AtomicOperations.executeWithRetry(store, (atomic) -> {
for (long record : records) {
atomic.set(key, value, record);
}
});
}
use of com.cinchapi.concourse.server.aop.VerifyWritePermission in project concourse by cinchapi.
the class ConcourseServer method findOrInsertCriteriaJson.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyWritePermission
public long findOrInsertCriteriaJson(TCriteria criteria, String json, AccessToken creds, TransactionToken transaction, String environment) throws TException {
List<Multimap<String, Object>> objects = Lists.newArrayList(Convert.jsonToJava(json));
AbstractSyntaxTree ast = compiler.parse(criteria);
AtomicSupport store = getStore(transaction, environment);
Set<Long> records = Sets.newLinkedHashSet();
AtomicOperations.executeWithRetry(store, (atomic) -> {
records.clear();
Operations.findOrInsertAtomic(records, objects, ast, atomic);
});
if (records.size() == 1) {
return Iterables.getOnlyElement(records);
} else {
throw new DuplicateEntryException(AnyStrings.joinWithSpace("Found", records.size(), "records that match", Language.translateFromThriftCriteria(criteria).ccl()));
}
}
use of com.cinchapi.concourse.server.aop.VerifyWritePermission in project concourse by cinchapi.
the class ConcourseServer method clearKeyRecords.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyWritePermission
public void clearKeyRecords(String key, List<Long> records, AccessToken creds, TransactionToken transaction, String environment) throws TException {
AtomicSupport store = getStore(transaction, environment);
AtomicOperations.executeWithRetry(store, (atomic) -> {
for (long record : records) {
Operations.clearKeyRecordAtomic(key, record, atomic);
}
});
}
use of com.cinchapi.concourse.server.aop.VerifyWritePermission in project concourse by cinchapi.
the class ConcourseServer method insertJson.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyWritePermission
public Set<Long> insertJson(String json, AccessToken creds, TransactionToken transaction, String environment) throws TException {
List<Multimap<String, Object>> objects = Convert.anyJsonToJava(json);
AtomicSupport store = getStore(transaction, environment);
Set<Long> records = Sets.newLinkedHashSet();
AtomicOperations.executeWithRetry(store, (atomic) -> {
records.clear();
List<DeferredWrite> deferred = Lists.newArrayList();
for (Multimap<String, Object> object : objects) {
long record;
if (object.containsKey(Constants.JSON_RESERVED_IDENTIFIER_NAME)) {
// If the $id$ is specified in the JSON blob, insert the
// data into that record since no record(s) are provided
// as method parameters.
// WARNING: This means that doing the equivalent of
// `insert(jsonify(records))` will cause an infinite
// loop because this method will attempt to insert the
// data into the same records from which it was
// exported. Therefore, advise users to not export data
// with the $id and import that same data in the same
// environment.
record = ((Number) Iterables.getOnlyElement(object.get(Constants.JSON_RESERVED_IDENTIFIER_NAME))).longValue();
} else {
record = Time.now();
}
atomic.touch(record);
if (Operations.insertAtomic(object, record, atomic, deferred)) {
records.add(record);
} else {
throw AtomicStateException.RETRY;
}
}
Operations.insertDeferredAtomic(deferred, atomic);
});
return records;
}
use of com.cinchapi.concourse.server.aop.VerifyWritePermission in project concourse by cinchapi.
the class ConcourseServer method revertKeyRecordsTime.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyWritePermission
public void revertKeyRecordsTime(String key, List<Long> records, long timestamp, AccessToken creds, TransactionToken transaction, String environment) throws TException {
AtomicSupport store = getStore(transaction, environment);
AtomicOperations.executeWithRetry(store, (atomic) -> {
for (long record : records) {
Operations.revertAtomic(key, record, timestamp, atomic);
}
});
}
Aggregations