in src/main/java/org/apache/directory/fortress/core/impl/OrgUnitDAO.java [489:565]
Set<String> getOrgs( OrgUnit orgUnit ) throws FinderException
{
Set<String> ouSet = new TreeSet<String>( String.CASE_INSENSITIVE_ORDER );
LdapConnection ld = null;
String orgUnitRoot = getOrgRoot( orgUnit );
try
{
String filter = "(objectclass=" + ORGUNIT_OBJECT_CLASS_NM + ")";
ld = getAdminConnection();
try ( SearchCursor searchResults = search( ld, orgUnitRoot,
SearchScope.ONELEVEL, filter, ORGUNIT_ATR, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
{
while ( searchResults.next() )
{
ouSet.add( getAttribute( searchResults.getEntry(), SchemaConstants.OU_AT ) );
}
}
catch ( CursorException e )
{
String error = "getOrgs type [" + orgUnit.getType() + "] root [" + orgUnitRoot
+ "] caught CursorException=" + e;
int errCode;
if ( orgUnit.getType() == OrgUnit.Type.PERM )
{
errCode = GlobalErrIds.ORG_GET_FAILED_PERM;
}
else
{
errCode = GlobalErrIds.ORG_GET_FAILED_USER;
}
throw new FinderException( errCode, error, e );
}
catch ( IOException e )
{
String error = "getOrgs type [" + orgUnit.getType() + "] root [" + orgUnitRoot
+ "] caught IOException=" + e;
int errCode;
if ( orgUnit.getType() == OrgUnit.Type.PERM )
{
errCode = GlobalErrIds.ORG_GET_FAILED_PERM;
}
else
{
errCode = GlobalErrIds.ORG_GET_FAILED_USER;
}
throw new FinderException( errCode, error, e );
}
}
catch ( LdapException e )
{
String error = "getOrgs type [" + orgUnit.getType() + "] root [" + orgUnitRoot
+ "] caught LdapException=" + e;
int errCode;
if ( orgUnit.getType() == OrgUnit.Type.PERM )
{
errCode = GlobalErrIds.ORG_GET_FAILED_PERM;
}
else
{
errCode = GlobalErrIds.ORG_GET_FAILED_USER;
}
throw new FinderException( errCode, error, e );
}
finally
{
closeAdminConnection( ld );
}
return ouSet;
}