in src/main/java/org/apache/directory/fortress/core/impl/OrgUnitDAO.java [407:480]
List<OrgUnit> findOrgs( OrgUnit orgUnit ) throws FinderException
{
List<OrgUnit> orgUnitList = new ArrayList<>();
LdapConnection ld = null;
String orgUnitRoot = getOrgRoot( orgUnit );
try
{
String searchVal = encodeSafeText( orgUnit.getName(), GlobalIds.ROLE_LEN );
String filter = GlobalIds.FILTER_PREFIX + ORGUNIT_OBJECT_CLASS_NM + ")("
+ SchemaConstants.OU_AT + "=" + searchVal + "*))";
ld = getAdminConnection();
try ( SearchCursor searchResults = search( ld, orgUnitRoot,
SearchScope.ONELEVEL, filter, ORGUNIT_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
{
long sequence = 0;
while ( searchResults.next() )
{
orgUnitList
.add( getEntityFromLdapEntry( searchResults.getEntry(), sequence++, orgUnit.getContextId() ) );
}
}
catch ( IOException i )
{
String error = "findOrgs search val [" + orgUnit.getName() + "] type [" + orgUnit.getType()
+ "] root [" + orgUnitRoot + "] caught IOException=" + i;
int errCode;
if ( orgUnit.getType() == OrgUnit.Type.PERM )
{
errCode = GlobalErrIds.ORG_SEARCH_FAILED_PERM;
}
else
{
errCode = GlobalErrIds.ORG_SEARCH_FAILED_USER;
}
throw new FinderException( errCode, error, i );
}
catch ( CursorException e )
{
String error = "findOrgs search val [" + orgUnit.getName() + "] type [" + orgUnit.getType()
+ "] root [" + orgUnitRoot + "] caught CursorException=" + e;
int errCode;
if ( orgUnit.getType() == OrgUnit.Type.PERM )
{
errCode = GlobalErrIds.ORG_SEARCH_FAILED_PERM;
}
else
{
errCode = GlobalErrIds.ORG_SEARCH_FAILED_USER;
}
throw new FinderException( errCode, error, e );
}
}
catch ( LdapException e )
{
String error = "findOrgs search val [" + orgUnit.getName() + "] type [" + orgUnit.getType()
+ "] root [" + orgUnitRoot + "] caught LdapException=" + e;
int errCode;
if ( orgUnit.getType() == OrgUnit.Type.PERM )
{
errCode = GlobalErrIds.ORG_SEARCH_FAILED_PERM;
}
else
{
errCode = GlobalErrIds.ORG_SEARCH_FAILED_USER;
}
throw new FinderException( errCode, error, e );
}
finally
{
closeAdminConnection( ld );
}
return orgUnitList;
}