use of com.cinchapi.concourse.server.aop.VerifyWritePermission in project concourse by cinchapi.
the class ConcourseServer method findOrInsertCclJson.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyWritePermission
public long findOrInsertCclJson(String ccl, String json, AccessToken creds, TransactionToken transaction, String environment) throws TException {
List<Multimap<String, Object>> objects = Lists.newArrayList(Convert.jsonToJava(json));
AtomicSupport store = getStore(transaction, environment);
Set<Long> records = Sets.newLinkedHashSet();
AtomicOperations.executeWithRetry(store, (atomic) -> {
records.clear();
AbstractSyntaxTree ast;
if (objects.size() == 1) {
// CON-321: Support local resolution when the data blob is a
// single object
ast = compiler.parse(ccl, objects.get(0));
} else {
ast = compiler.parse(ccl);
}
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", ccl));
}
}
use of com.cinchapi.concourse.server.aop.VerifyWritePermission in project concourse by cinchapi.
the class ConcourseServer method clearKeysRecords.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyWritePermission
public void clearKeysRecords(List<String> keys, List<Long> records, AccessToken creds, TransactionToken transaction, String environment) throws TException {
AtomicSupport store = getStore(transaction, environment);
AtomicOperations.executeWithRetry(store, (atomic) -> {
for (long record : records) {
for (String key : keys) {
Operations.clearKeyRecordAtomic(key, record, atomic);
}
}
});
}
use of com.cinchapi.concourse.server.aop.VerifyWritePermission in project concourse by cinchapi.
the class ConcourseServer method insertJsonRecords.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyWritePermission
public Map<Long, Boolean> insertJsonRecords(String json, List<Long> records, AccessToken creds, TransactionToken transaction, String environment) throws TException {
AtomicSupport store = getStore(transaction, environment);
Multimap<String, Object> data = Convert.jsonToJava(json);
Map<Long, Boolean> result = Maps.newLinkedHashMap();
AtomicOperations.executeWithRetry(store, (atomic) -> {
List<DeferredWrite> deferred = Lists.newArrayList();
for (long record : records) {
result.put(record, Operations.insertAtomic(data, record, atomic, deferred));
}
Operations.insertDeferredAtomic(deferred, atomic);
});
return result;
}
use of com.cinchapi.concourse.server.aop.VerifyWritePermission in project concourse by cinchapi.
the class ConcourseServer method verifyOrSet.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyWritePermission
public void verifyOrSet(String key, TObject value, long record, AccessToken creds, TransactionToken transaction, String env) throws TException {
AtomicSupport store = getStore(transaction, env);
AtomicOperations.executeWithRetry(store, (atomic) -> {
Set<TObject> values = atomic.select(key, record);
for (TObject val : values) {
if (!val.equals(value)) {
atomic.remove(key, val, record);
}
}
if (!atomic.verify(key, value, record)) {
atomic.add(key, value, record);
}
});
}
use of com.cinchapi.concourse.server.aop.VerifyWritePermission in project concourse by cinchapi.
the class ConcourseServer method clearRecords.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyWritePermission
public void clearRecords(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.clearRecordAtomic(record, atomic);
}
});
}
Aggregations