Search in sources :

Example 1 with CqlQuery

use of me.prettyprint.cassandra.model.CqlQuery in project sling by apache.

the class CassandraResourceProvider method deleteResource.

private boolean deleteResource(ResourceResolver resourceResolver, String path) throws PersistenceException {
    try {
        String key = getrowID(path);
        if (key == null) {
            return false;
        }
        String _cf = CassandraResourceProviderUtil.getColumnFamilySector(path);
        createColumnFamily(_cf, this.getKeyspace(), new StringSerializer());
        StringSerializer se = new StringSerializer();
        CqlQuery<String, String, String> cqlQuery = new CqlQuery<String, String, String>(keyspace, se, se, se);
        String query = "delete FROM " + _cf + " where KEY = '" + key + "';";
        cqlQuery.setQuery(query);
        QueryResult<CqlRows<String, String, String>> result = cqlQuery.execute();
    } catch (NoSuchAlgorithmException e) {
        throw new PersistenceException(e.getMessage());
    } catch (UnsupportedEncodingException e) {
        throw new PersistenceException(e.getMessage());
    }
    return true;
}
Also used : CqlRows(me.prettyprint.cassandra.model.CqlRows) UnsupportedEncodingException(java.io.UnsupportedEncodingException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) CqlQuery(me.prettyprint.cassandra.model.CqlQuery) StringSerializer(me.prettyprint.cassandra.serializers.StringSerializer)

Aggregations

UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 CqlQuery (me.prettyprint.cassandra.model.CqlQuery)1 CqlRows (me.prettyprint.cassandra.model.CqlRows)1 StringSerializer (me.prettyprint.cassandra.serializers.StringSerializer)1