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.setObsolete( description.isObsolete() ); schemaObject.setDescription( description.getDescription() ); schemaObject.setNames( description.getNames() ); schemaObject.setEnabled( schema.isEnabled() ); schemaObject.setReadOnly( false ); schemaObject.setSpecification( description.getSpecification() ); schemaObject.setSchemaName( schema.getSchemaName() ); schemaObject.setExtensions( description.getExtensions() );
description = original.getDescription(); isEnabled = original.isEnabled(); isObsolete = original.isObsolete(); isReadOnly = original.isReadOnly(); for ( String name : original.getNames() ) for ( String key : original.getExtensions().keySet() ) List<String> extensionValues = original.getExtensions().get( key ); schemaName = original.getSchemaName(); specification = original.getSpecification();
/** * Dump the reference operation as a String */ private String dump( String op, SchemaObject reference, SchemaObject referee ) { return op + " : " + reference.getObjectType() + "[" + reference.getOid() + "]/[" + referee.getObjectType() + "[" + referee.getOid() + "]"; }
/** * {@inheritDoc} */ public void renameSchema( String originalSchemaName, String newSchemaName ) { // Loop on all the SchemaObjects stored and remove those associated // with the give schemaName for ( T schemaObject : this ) { if ( originalSchemaName.equalsIgnoreCase( schemaObject.getSchemaName() ) ) { schemaObject.setSchemaName( newSchemaName ); if ( DEBUG ) { LOG.debug( "Renamed {} schemaName to {}", schemaObject, newSchemaName ); } } } }
if ( ! so0.getOid().equals( so1.getOid() ) ) if ( so0.isObsolete() != so1.isObsolete() ) if ( ! so0.getDescription().equals( so1.getDescription() ) )
sb.append( schemaObject.getObjectType() ); sb.append( ", " ); sb.append( schemaObject.getOid() ); sb.append( ", " ); sb.append( schemaObject.getName() );
I18n.err( I18n.ERR_11008, schemaObject.getOid() ) ); errors.add( error ); Throwable error = new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, I18n.err( I18n.ERR_11009, schemaObject.getOid(), copy.getSchemaName() ) ); errors.add( error ); String msg = I18n.err( I18n.ERR_11010, copy.getOid() ); LOG.info( msg ); Throwable error = new LdapProtocolErrorException( msg ); if ( schema.isEnabled() && copy.isEnabled() ) LOG.debug( "Added {} into the enabled schema {}", copy.getName(), schemaName ); String msg = "Cannot add the SchemaObject " + copy.getOid() + " into the registries, " + "the resulting registries would be inconsistent :" + StringTools.listToString( errors ); LOG.info( msg ); LOG.debug( "Added {} into the disabled schema {}", copy.getName(), schemaName ); return errors.isEmpty();
/** * Store the given SchemaObject into the OidRegistry. Available only to * the current package. A weak form (no check is done) of the register * method, define for clone methods. * * @param schemaObject The SchemaObject to inject into the OidRegistry */ /* No qualifier */void put( SchemaObject schemaObject ) { byOid.put( schemaObject.getOid(), schemaObject ); }
I18n.err( I18n.ERR_11011, schemaObject.getOid() ) ); errors.add( error ); return false; String msg = I18n.err( I18n.ERR_11012, schemaObject.getOid(), StringTools.setToString( referencing ) ); String msg = I18n.err( I18n.ERR_11013, schemaObject.getOid() ); LOG.info( msg ); Throwable error = new LdapProtocolErrorException( msg ); if ( schema.isEnabled() && schemaObject.isEnabled() ) LOG.debug( "Removed {} from the enabled schema {}", toDelete.getName(), schemaName ); String msg = "Cannot delete the SchemaObject " + schemaObject.getOid() + " from the registries, " + "the resulting registries would be inconsistent :" + StringTools.listToString( errors ); LOG.info( msg ); LOG.debug( "Removed {} from the disabled schema {}", schemaObject.getName(), schemaName ); return errors.isEmpty();
Set<SchemaObjectWrapper> content = schemaObjects.get( StringTools.toLowerCase( schemaObject.getSchemaName() ) ); globalOidRegistry.unregister( schemaObject.getOid() ); LOG.debug( "Unregistered {}:{}", schemaObject.getObjectType(), schemaObject.getOid() ); LOG.debug( "Unregistering of {}:{} failed, not found in Registries", schemaObject.getObjectType(), schemaObject.getOid() );
private SchemaObject copy( SchemaObject schemaObject ) { SchemaObject copy = null; if ( !( schemaObject instanceof LoadableSchemaObject ) ) { copy = schemaObject.copy(); } else { // Check the schemaObject here. if ( ( ( LoadableSchemaObject ) schemaObject ).isValid() ) { copy = schemaObject; } else { // We have an invalid SchemaObject, no need to go any further Throwable error = new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, I18n.err( I18n.ERR_11007, schemaObject.getOid() ) ); errors.add( error ); } } return copy; }
/** * {@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; }
/** * {@inheritDoc} */ public void unregisterSchemaElements( String schemaName ) throws LdapException { if ( schemaName == null ) { return; } // Loop on all the SchemaObjects stored and remove those associated // with the give schemaName for ( T schemaObject : this ) { if ( schemaName.equalsIgnoreCase( schemaObject.getSchemaName() ) ) { String oid = schemaObject.getOid(); SchemaObject removed = unregister( oid ); if ( DEBUG ) { LOG.debug( "Removed {} with oid {} from the registry", removed, oid ); } } } }
/** * Update the schemaName for this SchemaObject, accordingly to the X-SCHEMA parameter. If * not present, default to 'other' */ protected void setSchemaName( SchemaObject schemaObject ) { // Update the Schema if we have the X-SCHEMA extension List<String> schemaExtension = schemaObject.getExtensions().get( MetaSchemaConstants.X_SCHEMA ); if ( schemaExtension != null ) { String schemaName = schemaExtension.get( 0 ); if ( StringTools.isEmpty( schemaName ) ) { schemaObject.setSchemaName( MetaSchemaConstants.SCHEMA_OTHER ); } else { schemaObject.setSchemaName( schemaName ); } } else { schemaObject.setSchemaName( MetaSchemaConstants.SCHEMA_OTHER ); } } }
/** * 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; } }
/** * Retrieve the schema name for a specific SchemaObject, or return "other" if none is found. */ private String getSchemaName( SchemaObject schemaObject ) { String schemaName = StringTools.toLowerCase( schemaObject.getSchemaName() ); if ( loadedSchemas.containsKey( schemaName ) ) { return schemaName; } else { return MetaSchemaConstants.SCHEMA_OTHER; } }
/** * Unlink the SchemaObject references */ public void removeReference( List<Throwable> errors, SchemaObject schemaObject ) { try { schemaObject.removeFromRegistries( errors, this ); } catch ( LdapException ne ) { // Not allowed. String msg = I18n.err( I18n.ERR_04293, schemaObject.getName(), ne.getLocalizedMessage() ); Throwable error = new LdapSchemaViolationException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, msg ); errors.add( error ); LOG.info( msg ); } }
/** * Build the SchemaObject references */ public void buildReference( List<Throwable> errors, SchemaObject schemaObject ) { try { schemaObject.addToRegistries( errors, this ); } catch ( LdapException ne ) { // Not allowed. String msg = I18n.err( I18n.ERR_04292, schemaObject.getName(), ne.getLocalizedMessage() ); Throwable error = new LdapProtocolErrorException( msg ); errors.add( error ); LOG.info( msg ); } }