}
// for special handling of entryDN attribute, see DIRSERVER-1902
Entry originalEntry = ( ( ClonedServerEntry ) entry ).getOriginalEntry();
AttributeType entryDnType = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.ENTRY_DN_AT_OID );
// First, remove all the attributes if we have the NoAtribute flag set to true
if ( operationContext.isNoAttributes() )
{
for ( Attribute attribute : originalEntry )
{
AttributeType attributeType = attribute.getAttributeType();
entry.remove( entry.get( attributeType ) );
}
entry.removeAttributes( entryDnType );
return;
}
// If the user has requested all the User attributes ('*') only, we filter the entry's attribute to keep only
// the USER attributes, plus the Operational attributes in the returning list
if ( operationContext.isAllUserAttributes() )
{
for ( Attribute attribute : originalEntry )
{
AttributeType attributeType = attribute.getAttributeType();
if ( attributeType.isOperational() )
{
if ( !operationContext.contains( schemaManager, attributeType ) )
{
entry.removeAttributes( attributeType );
}
else if ( typesOnly )
{
entry.get( attributeType ).clear();
}
}
else if ( typesOnly )
{
entry.get( attributeType ).clear();
}
}
// DIRSERVER-1953
if ( !operationContext.contains( schemaManager, entryDnType ) )
{
entry.removeAttributes( entryDnType );
}
return;
}
// If the user has requested all the Operational attributes ('+') only, we filter the entry's attribute to keep only
// the OPERATIONAL attributes, plus the User attributes in the returning list
if ( operationContext.isAllOperationalAttributes() )
{
for ( Attribute attribute : originalEntry )
{
AttributeType attributeType = attribute.getAttributeType();
if ( attributeType.isUser() )
{
if ( !operationContext.contains( schemaManager, attributeType ) )
{
entry.removeAttributes( attributeType );
}
else if ( typesOnly )
{
entry.get( attributeType ).clear();
}
}
else if ( typesOnly )
{
entry.get( attributeType ).clear();
}
}
if ( !operationContext.contains( schemaManager, entryDnType ) )
{
entry.removeAttributes( entryDnType );
}
else if ( typesOnly )
{
entry.get( entryDnType ).clear();
}
return;
}
// Last, not least, check if the attributes are in the returning list
if ( operationContext.getReturningAttributes() != null )
{
for ( Attribute attribute : originalEntry )
{
if ( !operationContext.contains( schemaManager, attribute.getAttributeType() ) )
{
entry.removeAttributes( attribute.getAttributeType() );
continue;
}
AttributeType attributeType = attribute.getAttributeType();
boolean isNotRequested = true;
for ( AttributeTypeOptions attrOptions : operationContext.getReturningAttributes() )
{
if ( attrOptions.getAttributeType().equals( attributeType ) ||