Search in sources :

Example 1 with SearchDefaultScope

use of org.teiid.translator.ldap.LDAPExecutionFactory.SearchDefaultScope in project teiid by teiid.

the class IQueryToLdapSearchParser method getSearchScopeFromFromItem.

private int getSearchScopeFromFromItem(NamedTable fromItem) {
    // $NON-NLS-1$
    String searchScopeString = "";
    int searchScope = LDAPConnectorConstants.ldapDefaultSearchScope;
    // TODO: Re-use the getExpressionString method if possible, rather than
    // rewriting the same code twice.
    Table group = fromItem.getMetadataObject();
    String nameInSource = group.getNameInSource();
    // string instead so we can safely call split on it
    if (nameInSource == null) {
        // $NON-NLS-1$
        nameInSource = "";
    }
    // now split it on ? to find the part of it that specifies search scope
    // $NON-NLS-1$
    String[] nameInSourceArray = nameInSource.split("\\?");
    if (nameInSourceArray.length >= 2) {
        searchScopeString = nameInSourceArray[1];
    }
    // try the default in the connector properties
    if (searchScopeString.equals("")) {
        // $NON-NLS-1$
        SearchDefaultScope searchDefaultScope = this.executionFactory.getSearchDefaultScope();
        if (searchDefaultScope != null) {
            searchScopeString = searchDefaultScope.name();
        }
        // protect against getting null back from the property
        if (searchScopeString == null) {
            // $NON-NLS-1$
            searchScopeString = "";
        }
    }
    if (searchScopeString.equals("SUBTREE_SCOPE")) {
        // $NON-NLS-1$
        searchScope = SearchControls.SUBTREE_SCOPE;
    } else if (searchScopeString.equals("ONELEVEL_SCOPE")) {
        // $NON-NLS-1$
        searchScope = SearchControls.ONELEVEL_SCOPE;
    } else if (searchScopeString.equals("OBJECT_SCOPE")) {
        // $NON-NLS-1$
        searchScope = SearchControls.OBJECT_SCOPE;
    }
    return searchScope;
}
Also used : Table(org.teiid.metadata.Table) SearchDefaultScope(org.teiid.translator.ldap.LDAPExecutionFactory.SearchDefaultScope)

Aggregations

Table (org.teiid.metadata.Table)1 SearchDefaultScope (org.teiid.translator.ldap.LDAPExecutionFactory.SearchDefaultScope)1