return attrToAdd;
}
private ObjectClass getObjectClassToAdd(ObjectClass ocToDelete)
{
ObjectClass ocToAdd;
boolean containsAttribute = false;
for (AttributeType attr : providedAttrsToDelete)
{
if(ocToDelete.getRequiredAttributeChain().contains(attr) ||
ocToDelete.getOptionalAttributeChain().contains(attr))
{
containsAttribute = true;
break;
}
}
boolean hasSuperior = false;
Set<ObjectClass> newSuperiors = new LinkedHashSet<ObjectClass>();
for (ObjectClass sup : ocToDelete.getSuperiorClasses())
{
boolean isFound = false;
for (ObjectClass oc: providedOcsToDelete)
{
if(sup.equals(oc))
{
hasSuperior = true;
isFound = true;
newSuperiors.addAll(getNewSuperiors(oc));
break;
}
}
if (!isFound)
{
//Use the same super if not found in the list.
newSuperiors.add(sup);
}
}
if (containsAttribute || hasSuperior)
{
ArrayList<String> allNames = new ArrayList<String>();
for (String str : ocToDelete.getNormalizedNames())
{
allNames.add(str);
}
Map<String, List<String>> extraProperties =
cloneExtraProperties(ocToDelete);
Set<AttributeType> required;
Set<AttributeType> optional;
if (containsAttribute)
{
required = new HashSet<AttributeType>(
ocToDelete.getRequiredAttributes());
optional = new HashSet<AttributeType>(
ocToDelete.getOptionalAttributes());
required.removeAll(providedAttrsToDelete);
optional.removeAll(providedAttrsToDelete);
}
else
{
required = ocToDelete.getRequiredAttributes();
optional = ocToDelete.getOptionalAttributes();
}
ocToAdd = new ObjectClass("",
ocToDelete.getPrimaryName(),
allNames,
ocToDelete.getOID(),
ocToDelete.getDescription(),
newSuperiors,