Java Code Examples for me.prettyprint.hector.api.factory.HFactory#createColumnQuery()

The following examples show how to use me.prettyprint.hector.api.factory.HFactory#createColumnQuery() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CassandraUserStoreManager.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
/**
 * Checks if the role is existing the role store.
 */
@Override
protected boolean doCheckExistingRole(String roleNameWithTenantDomain) throws UserStoreException {

    RoleContext roleContext = createRoleContext(roleNameWithTenantDomain);
    boolean isExisting = false;

    String roleName = roleContext.getRoleName();

    Composite key = new Composite();
    key.addComponent(roleName, stringSerializer);
    key.addComponent(tenantIdString, stringSerializer);

    ColumnQuery<Composite, String, String> getCredentialQuery = HFactory.createColumnQuery(keyspace,
            CompositeSerializer.get(), stringSerializer, stringSerializer);

    getCredentialQuery.setColumnFamily(CFConstants.UM_ROLES).setKey(key).setName(CFConstants.UM_ROLE_NAME);

    HColumn<String, String> result = getCredentialQuery.execute().get();
    if (result != null && result.getValue() != null) {
        isExisting = true;
    }

    return isExisting;
}
 
Example 2
Source File: CassandraUserStoreManager.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
/**
 * Checks if the user is existing in the user store.
 */
@Override
protected boolean doCheckExistingUser(String userName) throws UserStoreException {

    Boolean isExist = false;

    Composite key = new Composite();
    key.addComponent(userName, stringSerializer);
    key.addComponent(tenantIdString, stringSerializer);

    ColumnQuery<Composite, String, String> getCredentialQuery = HFactory.createColumnQuery(keyspace,
            CompositeSerializer.get(), stringSerializer, stringSerializer);

    getCredentialQuery.setColumnFamily(CFConstants.UM_USER).setKey(key).setName(CFConstants.UM_USER_NAME);

    HColumn<String, String> result = getCredentialQuery.execute().get();
    if (result != null && result.getValue() != null) {
        isExist = true;
    }

    return isExist;

}
 
Example 3
Source File: CassandraService.java    From usergrid with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the column.
 *
 * @param ko the keyspace
 * @param columnFamily the column family
 * @param key the key
 * @param column the column
 *
 * @return column
 *
 * @throws Exception the exception
 */
public <N, V> HColumn<N, V> getColumn( Keyspace ko, Object columnFamily, Object key, N column,
                                       Serializer<N> nameSerializer, Serializer<V> valueSerializer )
        throws Exception {

    if ( db_logger.isTraceEnabled() ) {
        db_logger.trace( "getColumn cf={} key={} column={}", columnFamily, key, column );
    }

/*
 * ByteBuffer column_bytes = null; if (column instanceof List) {
 * column_bytes = Composite.serializeToByteBuffer((List<?>) column); } else
 * { column_bytes = bytebuffer(column); }
 */

    ColumnQuery<ByteBuffer, N, V> q = HFactory.createColumnQuery( ko, be, nameSerializer, valueSerializer );
    QueryResult<HColumn<N, V>> r =
            q.setKey( bytebuffer( key ) ).setName( column ).setColumnFamily( columnFamily.toString() ).execute();
    HColumn<N, V> result = r.get();

    if ( db_logger.isTraceEnabled() ) {
        if ( result == null ) {
            db_logger.trace( "getColumn returned null" );
        }
    }

    return result;
}
 
Example 4
Source File: Util.java    From carbon-identity-framework with Apache License 2.0 4 votes vote down vote up
public static String getExistingUserId(String credentialTypeName, String identifier, Keyspace keyspace) {

        identifier = createRowKeyForReverseLookup(identifier, credentialTypeName);
        ColumnQuery<String, String, String> usernameIndexQuery = HFactory.createColumnQuery(keyspace, stringSerializer,
                stringSerializer, stringSerializer);

        usernameIndexQuery.setColumnFamily(CFConstants.USERNAME_INDEX).setKey(identifier).setName(CFConstants.USER_ID);

        QueryResult<HColumn<String, String>> result = usernameIndexQuery.execute();

        HColumn<String, String> userIdCol = result.get();

        if (userIdCol == null) {
            return null;
        }

        return userIdCol.getValue();
    }
 
Example 5
Source File: Util.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
public static String getExistingUserId(String credentialTypeName, String identifier, Keyspace keyspace) {

        identifier = createRowKeyForReverseLookup(identifier, credentialTypeName);
        ColumnQuery<String, String, String> usernameIndexQuery = HFactory.createColumnQuery(keyspace, stringSerializer,
                stringSerializer, stringSerializer);

        usernameIndexQuery.setColumnFamily(CFConstants.USERNAME_INDEX).setKey(identifier).setName(CFConstants.USER_ID);

        QueryResult<HColumn<String, String>> result = usernameIndexQuery.execute();

        HColumn<String, String> userIdCol = result.get();

        if (userIdCol == null) {
            return null;
        }

        return userIdCol.getValue();
    }