}
private static SearchParameter getSearchParameter( ISearch search )
{
SearchParameter searchParameter = ( SearchParameter ) search.getSearchParameter().clone();
// add children detetion attributes
if ( search.isInitHasChildrenFlag() )
{
if ( search.getBrowserConnection().getSchema()
.hasAttributeTypeDescription( SchemaConstants.HAS_SUBORDINATES_AT )
&& !Utils.containsIgnoreCase( Arrays.asList( searchParameter.getReturningAttributes() ),
SchemaConstants.HAS_SUBORDINATES_AT ) )
{
String[] returningAttributes = new String[searchParameter.getReturningAttributes().length + 1];
System.arraycopy( searchParameter.getReturningAttributes(), 0, returningAttributes, 0,
searchParameter.getReturningAttributes().length );
returningAttributes[returningAttributes.length - 1] = SchemaConstants.HAS_SUBORDINATES_AT;
searchParameter.setReturningAttributes( returningAttributes );
}
else if ( search.getBrowserConnection().getSchema()
.hasAttributeTypeDescription( SchemaConstants.NUM_SUBORDINATES_AT )
&& !Utils.containsIgnoreCase( Arrays.asList( searchParameter.getReturningAttributes() ),
SchemaConstants.NUM_SUBORDINATES_AT ) )
{
String[] returningAttributes = new String[searchParameter.getReturningAttributes().length + 1];
System.arraycopy( searchParameter.getReturningAttributes(), 0, returningAttributes, 0,
searchParameter.getReturningAttributes().length );
returningAttributes[returningAttributes.length - 1] = SchemaConstants.NUM_SUBORDINATES_AT;
searchParameter.setReturningAttributes( returningAttributes );
}
else if ( search.getBrowserConnection().getSchema()
.hasAttributeTypeDescription( SchemaConstants.SUBORDINATE_COUNT_AT )
&& !Utils.containsIgnoreCase( Arrays.asList( searchParameter.getReturningAttributes() ),
SchemaConstants.SUBORDINATE_COUNT_AT ) )
{
String[] returningAttributes = new String[searchParameter.getReturningAttributes().length + 1];
System.arraycopy( searchParameter.getReturningAttributes(), 0, returningAttributes, 0,
searchParameter.getReturningAttributes().length );
returningAttributes[returningAttributes.length - 1] = SchemaConstants.SUBORDINATE_COUNT_AT;
searchParameter.setReturningAttributes( returningAttributes );
}
}
// always add the objectClass attribute, we need it
// - to detect alias and referral entries
// - to determine the entry's icon
// - to determine must and may attributes
if ( !Utils.containsIgnoreCase( Arrays.asList( searchParameter.getReturningAttributes() ),
SchemaConstants.OBJECT_CLASS_AT )
&& !Utils.containsIgnoreCase( Arrays.asList( searchParameter.getReturningAttributes() ),
SchemaConstants.ALL_USER_ATTRIBUTES ) )
{
String[] returningAttributes = new String[searchParameter.getReturningAttributes().length + 1];
System.arraycopy( searchParameter.getReturningAttributes(), 0, returningAttributes, 0,
searchParameter.getReturningAttributes().length );
returningAttributes[returningAttributes.length - 1] = SchemaConstants.OBJECT_CLASS_AT;
searchParameter.setReturningAttributes( returningAttributes );
}
// filter controls if not supported by server
if ( searchParameter.getControls() != null )
{
IBrowserConnection connection = search.getBrowserConnection();
Set<String> supportedConrolSet = new HashSet<String>();
if ( connection.getRootDSE() != null
&& connection.getRootDSE().getAttribute( SchemaConstants.SUPPORTED_CONTROL_AT ) != null )
{
IAttribute scAttribute = connection.getRootDSE().getAttribute( SchemaConstants.SUPPORTED_CONTROL_AT );
String[] supportedControls = scAttribute.getStringValues();
for ( int i = 0; i < supportedControls.length; i++ )
{
supportedConrolSet.add( Strings.toLowerCase( supportedControls[i] ) );
}
}
List<StudioControl> controls = searchParameter.getControls();
for ( Iterator<StudioControl> it = controls.iterator(); it.hasNext(); )
{
StudioControl control = it.next();
if ( !supportedConrolSet.contains( Strings.toLowerCase( control.getOid() ) ) )
{