* @return
* the associated {@link SearchControls} object
*/
private SearchControls getSearchControls( SearchRequestCodec request )
{
SearchControls controls = new SearchControls();
// Scope
switch ( request.getScope() )
{
case OBJECT:
controls.setSearchScope( SearchControls.OBJECT_SCOPE );
break;
case ONELEVEL:
controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
break;
case SUBTREE:
controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
break;
default:
controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
}
// Returning attributes
List<String> returningAttributes = new ArrayList<String>();
for ( EntryAttribute entryAttribute : request.getAttributes() )
{
returningAttributes.add( entryAttribute.getId() );
}
// If the returning attributes are empty, we need to return the user attributes
// [Cf. RFC 2251 - "There are two special values which may be used: an empty
// list with no attributes, and the attribute description string '*'. Both of
// these signify that all user attributes are to be returned."]
if ( returningAttributes.size() == 0 )
{
returningAttributes.add( "*" );
}
controls.setReturningAttributes( returningAttributes.toArray( new String[0] ) );
// Size Limit
controls.setCountLimit( request.getSizeLimit() );
// Time Limit
controls.setTimeLimit( request.getTimeLimit() );
return controls;
}