/** * Checks to see if the alias names of a schema description match another * description. The order of the alias names do matter. * * @param asd0 the schema description to compare * @param asd1 the schema description to compare * @return true if alias names match exactly, false otherwise */ public static boolean aliasNamesMatch( SchemaObject so0, SchemaObject so1 ) { // check sizes first if ( so0.getNames().size() != so1.getNames().size() ) { return false; } // check contents and order must match too for ( int i = 0; i < so0.getNames().size(); i++ ) { if ( ! so0.getNames().get( i ).equals( so1.getNames().get( i ) ) ) { return false; } } return true; } }
/** * Gets the names associated with an OID. An OID is unique however it may * have many names used to refer to it. A good example is the cn and * commonName attribute names for OID 2.5.4.3. Within a server one name * within the set must be chosen as the primary name. This is used to * name certain things within the server internally. If there is more than * one name then the first name is taken to be the primary. * * @param oid the OID for which we return the set of common names * @return a sorted set of names * @throws LdapException if oid does not exist */ public List<String> getNameSet( String oid ) throws LdapException { SchemaObject schemaObject = byOid.get( oid ); if ( null == schemaObject ) { String msg = I18n.err( I18n.ERR_04288, oid ); LOG.error( msg ); throw new LdapException( msg ); } List<String> names = schemaObject.getNames(); if ( IS_DEBUG ) { LOG.debug( "looked up names '{}' for OID '{}'", ArrayUtils.toString( names ), oid ); } return names; }
/** * {@inheritDoc} */ public T unregister( String numericOid ) throws LdapException { if ( !OID.isOID( numericOid ) ) { String msg = I18n.err( I18n.ERR_04272, numericOid ); LOG.error( msg ); throw new LdapException( msg ); } T schemaObject = byName.remove( numericOid ); for ( String name : schemaObject.getNames() ) { byName.remove( name ); } // And remove the SchemaObject from the oidRegistry oidRegistry.unregister( numericOid ); if ( DEBUG ) { LOG.debug( "Removed {} with oid {} from the registry", schemaObject, numericOid ); } return schemaObject; }
for ( String name : original.getNames() )
/** * {@inheritDoc} */ public T unregister( T schemaObject ) throws LdapException { String oid = schemaObject.getOid(); if ( !byName.containsKey( oid ) ) { String msg = I18n.err( I18n.ERR_04273, schemaObjectType.name(), oid ); LOG.warn( msg ); throw new LdapException( msg ); } // Remove the oid T removed = byName.remove( oid ); /* * Remove the aliases/names from the name map along with their toLowerCase * versions of the name. */ for ( String name : schemaObject.getNames() ) { byName.remove( StringTools.trim( StringTools.toLowerCase( name ) ) ); } // And unregister the oid -> schemaObject relation oidRegistry.unregister( oid ); return removed; }
for ( String name : schemaObject.getNames() )
private final void injectCommon( SchemaObject object, ServerEntry entry, SchemaManager schemaManager ) throws LdapException { injectNames( object.getNames(), entry, schemaManager ); entry.put( MetaSchemaConstants.M_OBSOLETE_AT, getBoolean( object.isObsolete() ) ); entry.put( MetaSchemaConstants.M_OID_AT, object.getOid() ); if ( object.getDescription() != null ) { entry.put( MetaSchemaConstants.M_DESCRIPTION_AT, object.getDescription() ); } }
schemaObject.setNames( description.getNames() );