in src/main/java/org/apache/directory/fortress/core/impl/SdDAO.java [360:438]
List<SDSet> search( SDSet sdset ) throws FinderException
{
List<SDSet> sdList = new ArrayList<>();
LdapConnection ld = null;
String ssdRoot = getSdRoot( sdset.getContextId() );
String objectClass = SSD_OBJECT_CLASS_NM;
if ( sdset.getType() == SDSet.SDType.DYNAMIC )
{
objectClass = DSD_OBJECT_CLASS_NM;
}
try
{
String searchVal = encodeSafeText( sdset.getName(), GlobalIds.ROLE_LEN );
String filter = GlobalIds.FILTER_PREFIX + objectClass + ")(" + SD_SET_NM + "=" + searchVal + "*))";
ld = getAdminConnection();
try ( SearchCursor searchResults = search( ld, ssdRoot,
SearchScope.SUBTREE, filter, SD_SET_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
{
long sequence = 0;
while ( searchResults.next() )
{
sdList.add( unloadLdapEntry( searchResults.getEntry(), sequence++ ) );
}
}
catch ( IOException e )
{
String error = "search sdset name [" + sdset.getName() + "] type [" + sdset.getType()
+ "] caught IOException=" + e.getMessage();
int errCode;
if ( sdset.getType() == SDSet.SDType.DYNAMIC )
{
errCode = GlobalErrIds.DSD_SEARCH_FAILED;
}
else
{
errCode = GlobalErrIds.SSD_SEARCH_FAILED;
}
throw new FinderException( errCode, error, e );
}
catch ( CursorException e )
{
String error = "search sdset name [" + sdset.getName() + "] type [" + sdset.getType()
+ "] caught CursorException=" + e.getMessage();
int errCode;
if ( sdset.getType() == SDSet.SDType.DYNAMIC )
{
errCode = GlobalErrIds.DSD_SEARCH_FAILED;
}
else
{
errCode = GlobalErrIds.SSD_SEARCH_FAILED;
}
throw new FinderException( errCode, error, e );
}
}
catch ( LdapException e )
{
String error = "search sdset name [" + sdset.getName() + "] type [" + sdset.getType()
+ "] caught LdapException=" + e;
int errCode;
if ( sdset.getType() == SDSet.SDType.DYNAMIC )
{
errCode = GlobalErrIds.DSD_SEARCH_FAILED;
}
else
{
errCode = GlobalErrIds.SSD_SEARCH_FAILED;
}
throw new FinderException( errCode, error, e );
}
finally
{
closeAdminConnection( ld );
}
return sdList;
}