Search in sources :

Example 11 with VerifyWritePermission

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));
    }
}
Also used : Multimap(com.google.common.collect.Multimap) AbstractSyntaxTree(com.cinchapi.ccl.syntax.AbstractSyntaxTree) AtomicSupport(com.cinchapi.concourse.server.storage.AtomicSupport) DuplicateEntryException(com.cinchapi.concourse.thrift.DuplicateEntryException) VerifyWritePermission(com.cinchapi.concourse.server.aop.VerifyWritePermission) VerifyAccessToken(com.cinchapi.concourse.server.aop.VerifyAccessToken) TranslateClientExceptions(com.cinchapi.concourse.server.aop.TranslateClientExceptions)

Example 12 with VerifyWritePermission

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);
            }
        }
    });
}
Also used : AtomicSupport(com.cinchapi.concourse.server.storage.AtomicSupport) VerifyWritePermission(com.cinchapi.concourse.server.aop.VerifyWritePermission) VerifyAccessToken(com.cinchapi.concourse.server.aop.VerifyAccessToken) TranslateClientExceptions(com.cinchapi.concourse.server.aop.TranslateClientExceptions)

Example 13 with VerifyWritePermission

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;
}
Also used : AtomicSupport(com.cinchapi.concourse.server.storage.AtomicSupport) ComplexTObject(com.cinchapi.concourse.thrift.ComplexTObject) TObject(com.cinchapi.concourse.thrift.TObject) VerifyWritePermission(com.cinchapi.concourse.server.aop.VerifyWritePermission) VerifyAccessToken(com.cinchapi.concourse.server.aop.VerifyAccessToken) TranslateClientExceptions(com.cinchapi.concourse.server.aop.TranslateClientExceptions)

Example 14 with VerifyWritePermission

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);
        }
    });
}
Also used : ComplexTObject(com.cinchapi.concourse.thrift.ComplexTObject) TObject(com.cinchapi.concourse.thrift.TObject) AtomicSupport(com.cinchapi.concourse.server.storage.AtomicSupport) VerifyWritePermission(com.cinchapi.concourse.server.aop.VerifyWritePermission) VerifyAccessToken(com.cinchapi.concourse.server.aop.VerifyAccessToken) TranslateClientExceptions(com.cinchapi.concourse.server.aop.TranslateClientExceptions)

Example 15 with VerifyWritePermission

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);
        }
    });
}
Also used : AtomicSupport(com.cinchapi.concourse.server.storage.AtomicSupport) VerifyWritePermission(com.cinchapi.concourse.server.aop.VerifyWritePermission) VerifyAccessToken(com.cinchapi.concourse.server.aop.VerifyAccessToken) TranslateClientExceptions(com.cinchapi.concourse.server.aop.TranslateClientExceptions)

Aggregations

TranslateClientExceptions (com.cinchapi.concourse.server.aop.TranslateClientExceptions)22 VerifyAccessToken (com.cinchapi.concourse.server.aop.VerifyAccessToken)22 VerifyWritePermission (com.cinchapi.concourse.server.aop.VerifyWritePermission)22 AtomicSupport (com.cinchapi.concourse.server.storage.AtomicSupport)22 ComplexTObject (com.cinchapi.concourse.thrift.ComplexTObject)6 TObject (com.cinchapi.concourse.thrift.TObject)6 Multimap (com.google.common.collect.Multimap)3 AbstractSyntaxTree (com.cinchapi.ccl.syntax.AbstractSyntaxTree)2 AtomicOperation (com.cinchapi.concourse.server.storage.AtomicOperation)2 AtomicStateException (com.cinchapi.concourse.server.storage.AtomicStateException)2 TransactionStateException (com.cinchapi.concourse.server.storage.TransactionStateException)2 DuplicateEntryException (com.cinchapi.concourse.thrift.DuplicateEntryException)2 TransactionException (com.cinchapi.concourse.thrift.TransactionException)2 SortableSet (com.cinchapi.concourse.data.sort.SortableSet)1 Set (java.util.Set)1