Code example for String

Methods: trim

0
                                                                           String cfName)
            throws CassandraAdminClientException { 
        validateKeyspace(keyspaceName);
        validateCF(cfName);
        try { 
            return cassandraAdminStub.getColumnFamilyOfCurrentUser(keyspaceName, cfName);
        } catch (Exception e) {
            throw new CassandraAdminClientException("Error retrieving the CF for the name " + cfName, e, log);
        } 
    } 
 
    /** 
     * Authorize the given role to access the given resource 
     * 
     * @param role The name of the role 
     * @param path The resource path 
     * @return true if the operation was successful. 
     * @throws CassandraAdminClientException For errors during sharing the resource 
     */ 
    public boolean shareResource(String role, String path) throws CassandraAdminClientException {
        try { 
            return cassandraAdminStub.shareResource(role, path);
        } catch (Throwable e) {
            throw new CassandraAdminClientException("Error sharing a resource !", e, log);
        } 
    } 
 
    public boolean shareResourceRead(String role, String path) throws CassandraAdminClientException {
        try { 
            return cassandraAdminStub.shareResourceRead(role, path);
        } catch (Throwable e) {
            throw new CassandraAdminClientException("Error sharing a resource !", e, log);
        } 
    } 
 
    public boolean shareResourceWrite(String role, String path) throws CassandraAdminClientException {
        try { 
            return cassandraAdminStub.shareResourceWrite(role, path);
        } catch (Throwable e) {
            throw new CassandraAdminClientException("Error sharing a resource !", e, log);
        } 
    } 
 
    /** 
     * Clear the authorization of the given role to access the given resource 
     * 
     * @param role The name of the role 
     * @param path The resource path 
     * @return true if the operation was successful. 
     * @throws CassandraAdminClientException For errors during sharing the resource 
     */ 
    public boolean clearResource(String role, String path) throws CassandraAdminClientException {
        try { 
            return cassandraAdminStub.clearResource(role, path);
        } catch (Exception e) {
            throw new CassandraAdminClientException("Error clear authorization for a resource !", e, log);
        } 
    } 
 
    /** 
     * Get all the meta-data belong to the currently singed up user for a given keyspace 
     * 
     * @param keyspaceName the name of the keyspace 
     * @return A <code>KeyspaceInformation</code> representing the meta-data of a keyspace 
     * @throws CassandraAdminClientException For errors during locating keyspace 
     */ 
    public KeyspaceInformation getKeyspaceOfCurrentUser(String keyspaceName)
            throws CassandraAdminClientException { 
        validateKeyspace(keyspaceName);
        try { 
            return cassandraAdminStub.getKeyspaceofCurrentUser(keyspaceName);
        } catch (Exception e) {
            throw new CassandraAdminClientException("Error retrieving keyspace !", e, log);
        } 
    } 
 
    /** 
     * Create a new keyspace 
     * 
     * @param keyspaceInformation keyspace information 
     * @throws CassandraAdminClientException For errors during adding a keyspace 
     */ 
    public void addKeyspace(KeyspaceInformation keyspaceInformation, HttpSession session)
            throws CassandraAdminClientException { 
        validateKeyspaceInformation(keyspaceInformation);
        try { 
            cassandraAdminStub.addKeyspace(keyspaceInformation);
        } catch (Exception e) {
            session.setAttribute(CassandraAdminClientConstants.CURRENT_KEYSPACE, null);
            throw new CassandraAdminClientException("Error adding the keyspace !", e, log);
        } 
    } 
 
    /** 
     * Updates an existing keyspace 
     * 
     * @param keyspaceInformation keyspace information 
     * @throws CassandraAdminClientException For errors during adding a keyspace 
     */ 
    public void updateKeyspace(KeyspaceInformation keyspaceInformation, HttpSession session)
            throws CassandraAdminClientException { 
        validateKeyspaceInformation(keyspaceInformation);
        try { 
            cassandraAdminStub.updatedKeyspace(keyspaceInformation);
        } catch (Exception e) {
            session.setAttribute(CassandraAdminClientConstants.CURRENT_KEYSPACE, null);
            throw new CassandraAdminClientException("Error updating the keyspace !", e, log);
        } 
    } 
 
    /** 
     * Get all users 
     * 
     * @return A <code>String</code> array representing the names of all the users 
     * @throws CassandraAdminClientException For errors during looking up users 
     */ 
    public String[] getAllRoles() throws CassandraAdminClientException {
        try { 
            return cassandraAdminStub.getAllRoles();
        } catch (Exception e) {
            throw new CassandraAdminClientException("Error retrieving user names !", e, log);
        } 
    } 
 
    /** 
     * Remove a keyspace 
     * 
     * @param keyspaceName the name of the keyspace 
     * @return true for success 
     * @throws CassandraAdminClientException For errors during removing a keyspace 
     */ 
    public boolean deleteKeyspace(String keyspaceName) throws CassandraAdminClientException {
        validateKeyspace(keyspaceName);
        try { 
            return cassandraAdminStub.deleteKeyspace(keyspaceName);
        } catch (Exception e) {
            throw new CassandraAdminClientException("Error removing the keyspace !", e, log);
        } 
 
    } 
 
    /** 
     * Deletes a CF 
     * 
     * @param keyspaceName     the name of the keyspace 
     * @param columnFamilyName CF's name 
     * @return true for success 
     * @throws CassandraAdminClientException for errors during removing a CF 
     */ 
    public boolean deleteColumnFamily(String keyspaceName, String columnFamilyName)
            throws CassandraAdminClientException { 
        validateKeyspace(keyspaceName);
        validateCF(columnFamilyName);
        try { 
            return cassandraAdminStub.deleteColumnFamily(keyspaceName, columnFamilyName);
        } catch (Exception e) {
            throw new CassandraAdminClientException("Error removing the CF !", e, log);
        } 
    } 
 
    /** 
     * Add a CF under a given keyspace 
     * 
     * @param columnFamilyInformation information about a CF 
     * @throws CassandraAdminClientException for errors during adding a CF 
     */ 
    public void addColumnFamily(ColumnFamilyInformation columnFamilyInformation, HttpSession session)
            throws CassandraAdminClientException { 
        validateColumnFamilyInformation(columnFamilyInformation);
        try { 
            cassandraAdminStub.addColumnFamily(columnFamilyInformation);
        } catch (Exception e) {
            session.setAttribute(CassandraAdminClientConstants.CURRENT_KEYSPACE, null);
            throw new CassandraAdminClientException("Error adding the CF !", e, log);
        } 
    } 
 
    /** 
     * Update an existing CF under a given keyspace 
     * 
     * @param columnFamilyInformation CF information 
     * @throws CassandraAdminClientException for errors during adding a CF 
     */ 
    public void updateColumnFamily(ColumnFamilyInformation columnFamilyInformation, HttpSession session)
            throws CassandraAdminClientException { 
        validateColumnFamilyInformation(columnFamilyInformation);
        try { 
            cassandraAdminStub.updateColumnFamily(columnFamilyInformation);
        } catch (Exception e) {
            session.setAttribute(CassandraAdminClientConstants.CURRENT_KEYSPACE, null);
            throw new CassandraAdminClientException("Error updating the CF !", e, log);
        } 
    } 
 
    /** 
     * Get the token range of a given key space 
     * 
     * @param keyspace keyspace name 
     * @return Token range as a list 
     * @throws CassandraAdminClientException for errors during calling backend service 
     */ 
    public TokenRangeInformation[] getTokenRange(String keyspace)
            throws CassandraAdminClientException { 
        validateKeyspace(keyspace);
        try { 
            return cassandraAdminStub.getTokenRange(keyspace);
        } catch (Exception e) {
            log.error("Error getting the token range of the keyspace : " + keyspace, e);
        } 
        return null; 
    } 
 
    /** 
     * Get Keyspace shared roles list for Write 
     * @param path 
     * @return 
     */ 
 
    public String [] getKeyspaceSharedRolesWrite(String path){
        try{ 
            return cassandraAdminStub.getKeyspaceSharedRolesWrite(path);
        } catch (Exception e){
            log.error("Error retrieving role list" + path,e);
        } 
        return null; 
    } 
 
    /** 
     * Get Keyspace shared role list for Read 
     * @param path 
     * @return 
     */ 
    public String [] getKeyspaceSharedRolesRead(String path){
        try{ 
            return cassandraAdminStub.getKeyspaceSharedRolesRead(path);
        } catch (Exception e){
            log.error("Error retrieving role list" + path,e);
        } 
        return null; 
    } 
 
    /** 
     * validate Keyspace Name 
     * @param keyspaceName 
     * @throws CassandraAdminClientException 
     */ 
    private void validateKeyspace(String keyspaceName) throws CassandraAdminClientException {
        if (keyspaceName == null || "".equals(keyspaceName.trim())) {
            throw new CassandraAdminClientException("The keyspace name is empty or null", log);
        } 
    } 
 
    private void validateKeyspaceInformation(KeyspaceInformation keyspaceInformation)
            throws CassandraAdminClientException { 
        if (keyspaceInformation == null) {
            throw new CassandraAdminClientException("The keyspace information is empty or null", log);
        } 
        validateKeyspace(keyspaceInformation.getName());
    } 
 
    private void validateColumnFamilyInformation(ColumnFamilyInformation columnFamilyInformation)
            throws CassandraAdminClientException { 
        if (columnFamilyInformation == null) {
            throw new CassandraAdminClientException("The column family information is empty or null", log);
        } 
        validateKeyspace(columnFamilyInformation.getKeyspace());
        validateCF(columnFamilyInformation.getName());
    } 
 
    private void validateCF(String columnFamilyName) throws CassandraAdminClientException {
        if (columnFamilyName == null || "".equals(columnFamilyName.trim())) {
            throw new CassandraAdminClientException("The column family name name is empty or null", log);
        } 
    } 
} 
Stop searching for code, let great code find you!  Add Codota to your java IDE