Search in sources :

Example 1 with CassandraResourceProvider

use of org.apache.sling.cassandra.resource.provider.CassandraResourceProvider in project sling by apache.

the class CassandraDataAddTest method testAddData.

@Test
public void testAddData() {
    String cf = "p1";
    try {
        String r1 = getrowID("/content/cassandra/" + cf + "/c1");
        String r2 = getrowID("/content/cassandra/" + cf + "/c1/c2");
        CassandraResourceProvider cassandraResourceProvider = new CassandraResourceProvider();
        createColumnFamily(cf, cassandraResourceProvider.getKeyspace(), new StringSerializer());
        cassandraResourceProvider.setColumnFamily(cf);
        addData(cassandraResourceProvider.getKeyspace(), cf, new StringSerializer(), new String[] { "'" + r1 + "','/content/cassandra/" + cf + "/c1','nt:cassandra1','nt:supercass1','resolutionPathInfo=json'", "'" + r2 + "','/content/cassandra/" + cf + "/c1/c2','nt:cassandra','nt:supercass2','resolutionPathInfo=json'" });
        Assert.assertTrue(true);
    } catch (Exception e) {
        LOGGER.info("Ignore err" + e.getMessage());
        Assert.fail("Failed to add data to cassandra");
    }
}
Also used : CassandraResourceProvider(org.apache.sling.cassandra.resource.provider.CassandraResourceProvider) StringSerializer(me.prettyprint.cassandra.serializers.StringSerializer) HInvalidRequestException(me.prettyprint.hector.api.exceptions.HInvalidRequestException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Test(org.junit.Test)

Example 2 with CassandraResourceProvider

use of org.apache.sling.cassandra.resource.provider.CassandraResourceProvider in project sling by apache.

the class CassandraDataParentNodeTest method testGetParentData.

@Test
public void testGetParentData() {
    String cf = "p1";
    try {
        String r1 = getrowID("/content/cassandra/" + cf + "/c1");
        String r2 = getrowID("/content/cassandra/" + cf + "/c1/c2");
        CassandraResourceProvider cassandraResourceProvider = new CassandraResourceProvider();
        createColumnFamily(cf, cassandraResourceProvider.getKeyspace(), new StringSerializer());
        cassandraResourceProvider.setColumnFamily(cf);
        addData(cassandraResourceProvider.getKeyspace(), cf, new StringSerializer(), new String[] { "'" + r1 + "','/content/cassandra/" + cf + "/c1','nt:cassandra1','nt:supercass1','resolutionPathInfo=json'", "'" + r2 + "','/content/cassandra/" + cf + "/c1/c2','nt:cassandra','nt:supercass2','resolutionPathInfo=json'" });
        getParentData(cassandraResourceProvider, cf);
    } catch (Exception e) {
        LOGGER.info("Ignore err" + e.getMessage());
    }
}
Also used : CassandraResourceProvider(org.apache.sling.cassandra.resource.provider.CassandraResourceProvider) StringSerializer(me.prettyprint.cassandra.serializers.StringSerializer) HInvalidRequestException(me.prettyprint.hector.api.exceptions.HInvalidRequestException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Test(org.junit.Test)

Example 3 with CassandraResourceProvider

use of org.apache.sling.cassandra.resource.provider.CassandraResourceProvider in project sling by apache.

the class CassandraModifyResourceProviderDeleteTest method testDeleteData.

@Test
public void testDeleteData() {
    String cf = "p3";
    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.commit(resolver);
        Assert.assertNotNull("Commited Resource cannot be null", cassandraResourceProvider.getResource(resolver, path1));
        cassandraResourceProvider.delete(resolver, path1);
        Assert.assertNotNull("Uncommited deleted resource cannot be null", cassandraResourceProvider.getResource(resolver, path1));
        cassandraResourceProvider.commit(resolver);
        Assert.assertNull("Deleted 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");
    }
}
Also used : HashMap(java.util.HashMap) CassandraResourceProvider(org.apache.sling.cassandra.resource.provider.CassandraResourceProvider) StringSerializer(me.prettyprint.cassandra.serializers.StringSerializer) HInvalidRequestException(me.prettyprint.hector.api.exceptions.HInvalidRequestException) CassandraResourceResolver(org.apache.sling.cassandra.resource.provider.CassandraResourceResolver) Test(org.junit.Test)

Example 4 with CassandraResourceProvider

use of org.apache.sling.cassandra.resource.provider.CassandraResourceProvider 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");
    }
}
Also used : HashMap(java.util.HashMap) CassandraResourceProvider(org.apache.sling.cassandra.resource.provider.CassandraResourceProvider) StringSerializer(me.prettyprint.cassandra.serializers.StringSerializer) HInvalidRequestException(me.prettyprint.hector.api.exceptions.HInvalidRequestException) CassandraResourceResolver(org.apache.sling.cassandra.resource.provider.CassandraResourceResolver) Test(org.junit.Test)

Example 5 with CassandraResourceProvider

use of org.apache.sling.cassandra.resource.provider.CassandraResourceProvider in project sling by apache.

the class AccessControlUtil method m.

private static void m() {
    AccessControlUtil accessControlUtil = new AccessControlUtil(new CassandraResourceProvider());
    String path = "/content/cassandra/p2/c2";
    String policy = "0_dishara_allow : " + READ;
    Set<String> set = new HashSet<String>();
    set.add("dishara");
    try {
        accessControlUtil.addACE(path, policy);
        int[] results = accessControlUtil.buildAtLevel(set, path);
        System.out.println("GRANT" + results[0]);
        System.out.println("DENY" + results[1]);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : CassandraResourceProvider(org.apache.sling.cassandra.resource.provider.CassandraResourceProvider) HInvalidRequestException(me.prettyprint.hector.api.exceptions.HInvalidRequestException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) HashSet(java.util.HashSet)

Aggregations

HInvalidRequestException (me.prettyprint.hector.api.exceptions.HInvalidRequestException)10 CassandraResourceProvider (org.apache.sling.cassandra.resource.provider.CassandraResourceProvider)10 StringSerializer (me.prettyprint.cassandra.serializers.StringSerializer)9 UnsupportedEncodingException (java.io.UnsupportedEncodingException)8 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)8 Test (org.junit.Test)8 HashMap (java.util.HashMap)4 CassandraResourceResolver (org.apache.sling.cassandra.resource.provider.CassandraResourceResolver)4 HashSet (java.util.HashSet)1