/** * Build the ObjectClasses references */ private void buildObjectClassReferences() { // Remember the OC we have already processed Set<String> done = new HashSet<>(); // The ObjectClass for ( ObjectClass objectClass : objectClassRegistry ) { if ( done.contains( objectClass.getOid() ) ) { continue; } else { done.add( objectClass.getOid() ); } buildReference( objectClass ); } }
public ObjectClass copy() ObjectClass copy = new ObjectClass( oid ); copy.copy( this );
if ( oc0.getType() != oc1.getType() ) if ( oc0.getSuperiorOids().size() != oc1.getSuperiorOids().size() ) for ( int i = 0; i < oc0.getSuperiorOids().size(); i++ ) if ( !oc0.getSuperiorOids().get( i ).equals( oc1.getSuperiorOids().get( i ) ) ) for ( int i = 0; i < oc0.getMustAttributeTypeOids().size(); i++ ) if ( !oc0.getMustAttributeTypeOids().get( i ).equals( oc1.getMustAttributeTypeOids().get( i ) ) ) for ( int i = 0; i < oc0.getMayAttributeTypeOids().size(); i++ ) if ( !oc0.getMayAttributeTypeOids().get( i ).equals( oc1.getMayAttributeTypeOids().get( i ) ) )
private List<AttributeType> getMustRecursive( List<AttributeType> musts, Set<ObjectClass> processed, ObjectClass objectClass ) { if ( objectClass != null ) { if ( processed.contains( objectClass ) ) { // We have found a cycle. It has already been reported, // don't add a new error, just exit. return null; } processed.add( objectClass ); for ( AttributeType must : objectClass.getMustAttributeTypes() ) { musts.add( must ); } for ( ObjectClass superior : objectClass.getSuperiors() ) { getMustRecursive( musts, processed, superior ); } } return musts; }
if ( topObjectClass.equals( objectClass ) ) objectClassAttributeValues.add( objectClass.getName() ); objectClassAttributeValues.add( objectClass.getName() ); List<ObjectClass> superiors = objectClass.getSuperiors(); if ( ( superiors != null ) && ( superiors.size() > 0 ) ) objectClassAttributeValues.add( topObjectClass.getName() );
List<String> superiorOids = objectClass.getSuperiorOids(); objectClass.getSuperiors().clear(); switch ( objectClass.getType() ) if ( superior.getType() != ObjectClassTypeEnum.ABSTRACT ) objectClass.getOid(), superior.getObjectType(), superior ); if ( superior.getType() == ObjectClassTypeEnum.STRUCTURAL ) String msg = I18n.err( I18n.ERR_13767_AUX_OC_CANNOT_INHERIT_FROM_STRUCT_OC, objectClass.getOid(), superior ); if ( superior.getType() == ObjectClassTypeEnum.AUXILIARY ) String msg = I18n.err( I18n.ERR_13768_STRUCT_OC_CANNOT_INHERIT_FROM_AUX_OC, objectClass.getOid(), superior ); objectClass.getType() ) ); objectClass.getSuperiors().add( superior ); objectClass.getOid(), superiorName );
private void resolveRecursive( ObjectClass objectClass, Set<String> processed ) List<String> superiorOids = objectClass.getSuperiorOids(); ObjectClass superior = null; if ( !processed.contains( superior.getOid() ) ) processed.add( objectClass.getOid() ); for ( String mayOid : objectClass.getMayAttributeTypeOids() ) for ( String mustOid : objectClass.getMustAttributeTypeOids() )
objectClass.unlock(); for ( AttributeType mayAttributeType : objectClass.getMayAttributeTypes() ) for ( AttributeType mustAttributeType : objectClass.getMustAttributeTypes() ) for ( ObjectClass superiorObjectClass : objectClass.getSuperiors() ) objectClass.lock();
List<String> mustAttributeTypeOids = objectClass.getMustAttributeTypeOids(); objectClass.getMustAttributeTypes().clear(); objectClass.getOid() ); if ( objectClass.getMustAttributeTypes().contains( attributeType ) ) objectClass.getOid(), mustAttributeTypeName ); if ( objectClass.getMayAttributeTypes().contains( attributeType ) ) objectClass.getOid(), mustAttributeTypeName ); objectClass.getMustAttributeTypes().add( attributeType ); objectClass.getOid(), mustAttributeTypeName );
if ( objectClass.getMayAttributeTypes() != null ) for ( AttributeType may : objectClass.getMayAttributeTypes() ) if ( objectClass.getMustAttributeTypes() != null ) for ( AttributeType must : objectClass.getMustAttributeTypes() ) if ( objectClass.getSuperiors() != null ) for ( ObjectClass superior : objectClass.getSuperiors() ) if ( !objectClassRegistry.contains( objectClass.getOid() ) )
Set<ObjectClass> descendants = oidToDescendants.get( ancestor.getOid() ); oidToDescendants.put( ancestor.getOid(), descendants ); registerDescendants( objectClass, ancestor.getSuperiors() );
List<String> mayAttributeTypeOids = objectClass.getMayAttributeTypeOids(); objectClass.getMayAttributeTypes().clear(); String msg = I18n.err( I18n.ERR_13779_COLLECTIVE_NOT_ALLOWED_IN_MAY, mayAttributeTypeName, objectClass.getOid() ); if ( objectClass.getMayAttributeTypes().contains( attributeType ) ) I18n.ERR_13770_CANNOT_REGISTER_DUPLICATE_AT_IN_MAY, objectClass.getOid(), mayAttributeTypeName ); objectClass.getMayAttributeTypes().add( attributeType ); String msg = I18n.err( I18n.ERR_13771_CANNOT_REGISTER_AT_IN_MAY_DOES_NOT_EXIST, objectClass.getOid(), mayAttributeTypeName );
objectClassRegistry.unregisterDescendants( objectClass, objectClass.getSuperiors() ); if ( objectClass.getMayAttributeTypes() != null ) for ( AttributeType may : objectClass.getMayAttributeTypes() ) if ( objectClass.getMustAttributeTypes() != null ) for ( AttributeType must : objectClass.getMustAttributeTypes() ) if ( objectClass.getSuperiors() != null ) for ( ObjectClass superior : objectClass.getSuperiors() )
if ( objectClass.getSuperiorOids() != null && objectClass.getSuperiorOids().size() > 0 ) for ( String superiorOid : objectClass.getSuperiorOids() ) if ( objectClass.getMayAttributeTypeOids() != null && objectClass.getMayAttributeTypeOids().size() > 0 ) for ( String mayAttrOid : objectClass.getMayAttributeTypeOids() ) if ( objectClass.getMustAttributeTypeOids() != null && objectClass.getMustAttributeTypeOids().size() > 0 ) for ( String mustAttrOid : objectClass.getMustAttributeTypeOids() )
private void resolve( ObjectClass objectClass ) { // This set is used to avoid having more than one error // for an ObjectClass. It's mandatory when processing // the Superiors, as they may be broken and referenced more than once. Set<String> processed = new HashSet<>(); // Store the ObjectClass itself in the processed, to avoid cycle processed.add( objectClass.getOid() ); // Call the recursive method, as we may have superiors to deal with resolveRecursive( objectClass, processed ); // Check that the MAY and MUST AT are consistent (no AT in MAY and in MUST // in one of its superior List<AttributeType> musts = getMustRecursive( new ArrayList<AttributeType>(), new HashSet<ObjectClass>(), objectClass ); if ( musts != null ) { for ( AttributeType may : objectClass.getMayAttributeTypes() ) { if ( musts.contains( may ) ) { // This is not allowed. LdapSchemaException ldapSchemaException = new LdapSchemaException( LdapSchemaExceptionCodes.OC_DUPLICATE_AT_IN_MAY_AND_MUST ); ldapSchemaException.setSourceObject( objectClass ); ldapSchemaException.setOtherObject( may ); errorHandler.handle( LOG, ldapSchemaException.getMessage(), ldapSchemaException ); } } } }
ObjectClass oc = schemaManager.getObjectClassRegistry().get( ocOid ); if ( oc.isStructural() ) ObjectClass oc = schemaManager.getObjectClassRegistry().get( ocOid ); for ( ObjectClass superior : oc.getSuperiors() ) if ( oc.isStructural() ) {} )[0]; LOG.debug( "The top level object class is {}", result.getName() ); return result;
/** * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( "item : " ); sb.append( item.getName() ); return sb.toString(); } }
public class MainActivity extends Activity { ObjectClass obj=new ObjectClass(); LinkedHashMap<String, ObjectClass> mLinkedHashMap = new LinkedHashMap<String, ObjectClass>(); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); obj.id=1; obj.name="hello"; mLinkedHashMap.put("test", obj); Gson gson = new Gson(); String list = gson.toJson(mLinkedHashMap); Intent intent = new Intent(this, secondActivity.class); intent.putExtra("list", list); startActivity(intent); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; } }