use of me.prettyprint.cassandra.serializers.StringSerializer in project sling by apache.
the class CassandraModifyResourceProviderRevertTest method testRevertData.
@Test
public void testRevertData() {
String cf = "p4";
try {
String path1 = "/content/cassandra/" + cf + "/c1";
CassandraResourceProvider cassandraResourceProvider = new CassandraResourceProvider();
createColumnFamily(cf, cassandraResourceProvider.getKeyspace(), new StringSerializer());
cassandraResourceProvider.setColumnFamily(cf);
Map<String, Object> map1 = new HashMap<String, Object>();
map1.put("metadata", "resolutionPathInfo=json");
map1.put("resourceType", "nt:cassandra0");
map1.put("resourceSuperType", "nt:supercass1");
CassandraResourceResolver resolver = new CassandraResourceResolver();
cassandraResourceProvider.create(resolver, path1, map1);
Assert.assertNull("Before Commiting resource should be null", cassandraResourceProvider.getResource(resolver, path1));
cassandraResourceProvider.revert(resolver);
Assert.assertNull("Reverted resource should be null", cassandraResourceProvider.getResource(resolver, path1));
} catch (Exception e) {
LOGGER.info("Ignore err" + e.getMessage());
Assert.fail("Failed to add data to cassandra");
}
}
use of me.prettyprint.cassandra.serializers.StringSerializer in project sling by apache.
the class AccessControlUtil method addACE.
private void addACE(String path, String policy) throws Exception {
String rid = getrowID(path);
createColumnFamily(ACL_CF, provider.getKeyspace(), new StringSerializer());
String getAllACEs = "select * from " + ACL_CF + " where KEY = '" + rid + "'";
QueryResult<CqlRows<String, String, String>> results = CassandraResourceProviderUtil.executeQuery(getAllACEs, provider.getKeyspace(), new StringSerializer());
if (CassandraResourceProviderUtil.recordExists(results, "policy")) {
updateACL(rid, policy, new StringSerializer(), results);
} else {
addACL(rid, policy, new StringSerializer());
}
}
use of me.prettyprint.cassandra.serializers.StringSerializer in project archiva by apache.
the class CassandraMetadataRepository method removeNamespace.
@Override
public void removeNamespace(String repositoryId, String namespaceId) throws MetadataRepositoryException {
try {
String key = //
new Namespace.KeyBuilder().withNamespace(//
namespaceId).withRepositoryId(//
repositoryId).build();
//
HFactory.createMutator(cassandraArchivaManager.getKeyspace(), new StringSerializer()).addDeletion(key, //
cassandraArchivaManager.getNamespaceFamilyName()).execute();
QueryResult<OrderedRows<String, String, String>> result = //
HFactory.createRangeSlicesQuery(keyspace, ss, ss, //
ss).setColumnFamily(//
cassandraArchivaManager.getProjectFamilyName()).setColumnNames(//
REPOSITORY_NAME.toString()).addEqualsExpression(REPOSITORY_NAME.toString(), //
repositoryId).addEqualsExpression(NAMESPACE_ID.toString(), //
namespaceId).execute();
for (Row<String, String, String> row : result.get()) {
this.projectTemplate.deleteRow(row.getKey());
}
result = //
HFactory.createRangeSlicesQuery(keyspace, ss, ss, //
ss).setColumnFamily(//
cassandraArchivaManager.getProjectVersionMetadataFamilyName()).setColumnNames(//
REPOSITORY_NAME.toString()).addEqualsExpression(REPOSITORY_NAME.toString(), //
repositoryId).addEqualsExpression(NAMESPACE_ID.toString(), //
namespaceId).execute();
for (Row<String, String, String> row : result.get()) {
this.projectVersionMetadataTemplate.deleteRow(row.getKey());
removeMailingList(row.getKey());
}
result = //
HFactory.createRangeSlicesQuery(keyspace, ss, ss, //
ss).setColumnFamily(//
cassandraArchivaManager.getArtifactMetadataFamilyName()).setColumnNames(//
REPOSITORY_NAME.toString()).addEqualsExpression(REPOSITORY_NAME.toString(), //
repositoryId).addEqualsExpression(NAMESPACE_ID.toString(), //
namespaceId).execute();
for (Row<String, String, String> row : result.get()) {
this.artifactMetadataTemplate.deleteRow(row.getKey());
}
result = //
HFactory.createRangeSlicesQuery(keyspace, ss, ss, //
ss).setColumnFamily(//
cassandraArchivaManager.getMetadataFacetFamilyName()).setColumnNames(//
REPOSITORY_NAME.toString()).addEqualsExpression(REPOSITORY_NAME.toString(), //
repositoryId).addEqualsExpression(NAMESPACE_ID.toString(), //
namespaceId).execute();
for (Row<String, String, String> row : result.get()) {
this.metadataFacetTemplate.deleteRow(row.getKey());
}
} catch (HInvalidRequestException e) {
logger.error(e.getMessage(), e);
throw new MetadataRepositoryException(e.getMessage(), e);
}
}
use of me.prettyprint.cassandra.serializers.StringSerializer in project archiva by apache.
the class CassandraUtils method getAsStringValue.
public static <T> String getAsStringValue(ColumnSlice<String, T> columnSlice, String columnName) {
StringSerializer ss = StringSerializer.get();
if (StringUtils.isEmpty(columnName)) {
return null;
}
HColumn<String, T> hColumn = columnSlice.getColumnByName(columnName);
return hColumn == null ? null : ss.fromByteBuffer(hColumn.getValueBytes());
}
use of me.prettyprint.cassandra.serializers.StringSerializer in project cassandra-indexing by hmsonline.
the class AbstractIndexingTest method select.
protected Map<String, Map<String, String>> select(Keyspace keyspace, String columnFamily) {
logger.debug("selecting from [" + columnFamily + "] @ [" + keyspace.getKeyspaceName() + "]");
StringSerializer ss = new StringSerializer();
RangeSlicesQuery<String, String, String> query = HFactory.createRangeSlicesQuery(keyspace, ss, ss, ss);
query.setColumnFamily(columnFamily);
query.setRange("", "", true, 100);
query.setRowCount(100);
query.setKeys("", "");
List<Row<String, String, String>> rows = query.execute().get().getList();
Map<String, Map<String, String>> result = new HashMap<String, Map<String, String>>();
for (Row<String, String, String> row : rows) {
Map<String, String> cols = new LinkedHashMap<String, String>();
for (HColumn<String, String> col : row.getColumnSlice().getColumns()) {
cols.put(col.getName(), col.getValue());
}
result.put(row.getKey(), cols);
}
return result;
}
Aggregations