public void register( String schema, ObjectClass objectClass ) throws NamingException { if ( byOid.containsKey( objectClass.getOid() ) ) { NamingException e = new NamingException( "objectClass w/ OID " + objectClass.getOid() + " has already been registered!" ); monitor.registerFailed( objectClass, e ); throw e; } oidRegistry.register( objectClass.getName(), objectClass.getOid() ); byOid.put( objectClass.getOid(), objectClass ); oidToSchema.put( objectClass.getOid(), schema ); monitor.registered( objectClass ); }
public void register( String schema, ObjectClass dITContentRule ) throws NamingException { if ( byOid.containsKey( dITContentRule.getOid() ) || bootstrap.hasObjectClass( dITContentRule.getOid() ) ) { NamingException e = new NamingException( "dITContentRule w/ OID " + dITContentRule.getOid() + " has already been registered!" ); monitor.registerFailed( dITContentRule, e ); throw e; } oidRegistry.register( dITContentRule.getName(), dITContentRule.getOid() ); byOid.put( dITContentRule.getOid(), dITContentRule ); oidToSchema.put( dITContentRule.getOid(), schema ); monitor.registered( dITContentRule ); }
/** * Update the associated SUPERIORS ObjectClasses, even if the SchemaObject is readOnly * * @param superiors the object classes to set */ public void updateSuperiors( List<ObjectClass> superiors ) { this.superiors.clear(); this.superiors.addAll( superiors ); // update the OIDS now superiorOids.clear(); for ( ObjectClass oc : superiors ) { superiorOids.add( oc.getOid() ); } }
/** * Build the ObjectClasses references */ private void buildObjectClassReferences( List<Throwable> errors ) { // Remember the OC we have already processed Set<String> done = new HashSet<String>(); // The ObjectClass for ( ObjectClass objectClass : objectClassRegistry ) { if ( done.contains( objectClass.getOid() ) ) { continue; } else { done.add( objectClass.getOid() ); } buildReference( errors, objectClass ); } }
/** * Add an Auxiliary ObjectClass * * @param oid The ObjectClass */ public void addAuxObjectClasses( ObjectClass objectClass ) { if ( locked ) { throw new UnsupportedOperationException( I18n.err( I18n.ERR_04441, getName() ) ); } if ( !isReadOnly ) { if ( !auxObjectClassOids.contains( objectClass.getOid() ) ) { auxObjectClasses.add( objectClass ); auxObjectClassOids.add( objectClass.getOid() ); } } }
/** * Add some superior ObjectClasses * * @param objectClasses The superior ObjectClasses */ public void addSuperior( ObjectClass... objectClasses ) { if ( locked ) { throw new UnsupportedOperationException( I18n.err( I18n.ERR_04441, getName() ) ); } if ( !isReadOnly ) { for ( ObjectClass objectClass : objectClasses ) { if ( !superiorOids.contains( objectClass.getOid() ) ) { superiorOids.add( objectClass.getOid() ); superiors.add( objectClass ); } } } }
/** * @param auxObjectClasses the auxObjectClasses to set */ public void setAuxObjectClasses( List<ObjectClass> auxObjectClasses ) { if ( locked ) { throw new UnsupportedOperationException( I18n.err( I18n.ERR_04441, getName() ) ); } if ( !isReadOnly ) { this.auxObjectClasses = auxObjectClasses; // update the OIDS now auxObjectClassOids.clear(); for ( ObjectClass oc : auxObjectClasses ) { auxObjectClassOids.add( oc.getOid() ); } } }
/** * Sets the superior object classes * * @param superiors the object classes to set */ public void setSuperiors( List<ObjectClass> superiors ) { if ( locked ) { throw new UnsupportedOperationException( I18n.err( I18n.ERR_04441, getName() ) ); } if ( !isReadOnly ) { this.superiors = superiors; // update the OIDS now superiorOids.clear(); for ( ObjectClass oc : superiors ) { superiorOids.add( oc.getOid() ); } } }
private void getSuperiors( ObjectClass oc, Set ocSeen, List result ) throws NamingException { ObjectClass[] superiors = oc.getSuperClasses(); for ( int i = 0; i < superiors.length; i++ ) { ObjectClass parent = superiors[i]; // Skip 'top' if ( "top".equals( parent.getName() ) ) { continue; } if ( !ocSeen.contains( parent.getOid() ) ) { ocSeen.add( parent.getOid() ); result.add( parent ); } // Recurse on the parent getSuperiors( parent, ocSeen, result ); } }
/** * Sets the structural object class this rule applies to * * @param structuralObjectClass the structural object class to set */ public void setStructuralObjectClass( ObjectClass structuralObjectClass ) { if ( locked ) { throw new UnsupportedOperationException( I18n.err( I18n.ERR_04441, getName() ) ); } if ( !isReadOnly ) { this.structuralObjectClass = structuralObjectClass; this.structuralObjectClassOid = structuralObjectClass.getOid(); } }
private void resolve( ObjectClass objectClass, List<Throwable> errors ) { // 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<String>(); // 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, errors ); // 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. Throwable error = new LdapProtocolErrorException( I18n.err( I18n.ERR_04299, objectClass.getOid() ) ); errors.add( error ); return; } } } }
/** * Compute all ObjectClasses superiors, MAY and MUST attributes. * @throws NamingException */ private void computeSuperiors() throws NamingException { Iterator objectClasses = globalRegistries.getObjectClassRegistry().list(); superiors = new HashMap(); allMust = new HashMap(); allMay = new HashMap(); allowed = new HashMap(); while ( objectClasses.hasNext() ) { List ocSuperiors = new ArrayList(); ObjectClass objectClass = (ObjectClass)objectClasses.next(); superiors.put( objectClass.getOid(), ocSuperiors ); computeOCSuperiors( objectClass, ocSuperiors, new HashSet() ); Set atSeen = new HashSet(); computeMustAttributes( objectClass, atSeen ); computeMayAttributes( objectClass, atSeen ); superiors.put( objectClass.getName(), ocSuperiors ); } }
String oid = parents[i].getOid();
Set<ObjectClass> descendants = oidToDescendants.get( ancestor.getOid() );
List ocSuperiors = (List)superiors.get( objectClass.getOid() );
objectClass.setOid( getResolveOid( objectClass.getOid() ) );