/** * {@inheritDoc} */ public String getSchemaName( int ruleId ) throws LdapException { DITStructureRule ditStructureRule = byRuleId.get( ruleId ); if ( ditStructureRule != null ) { return ditStructureRule.getSchemaName(); } String msg = I18n.err( I18n.ERR_04263, ruleId ); LOG.warn( msg ); throw new LdapException( msg ); }
/** * {@inheritDoc} */ public DITStructureRule lookup( int ruleId ) throws LdapException { DITStructureRule ditStructureRule = byRuleId.get( ruleId ); if ( ditStructureRule == null ) { String msg = I18n.err( I18n.ERR_04265, ruleId ); LOG.debug( msg ); throw new LdapException( msg ); } if ( DEBUG ) { LOG.debug( "Found {} with ruleId: {}", ditStructureRule, ruleId ); } return ditStructureRule; }
/** * Gets the SchemaObject associated with an OID. * * @param oid the object identifier * @return the associated SchemaObject * @throws LdapException if oid does not exist */ public SchemaObject getSchemaObject( String oid ) throws LdapException { SchemaObject schemaObject = byOid.get( oid ); if ( schemaObject != null ) { return schemaObject; } else { String msg = I18n.err( I18n.ERR_04287, oid ); LOG.error( msg ); throw new LdapException( msg ); } }
/** * {@inheritDoc} */ public void register( DITStructureRule ditStructureRule ) throws LdapException { int ruleId = ditStructureRule.getRuleId(); if ( byRuleId.containsKey( ruleId ) ) { String msg = I18n.err( I18n.ERR_04264, ruleId ); LOG.warn( msg ); throw new LdapException( msg ); } byRuleId.put( ruleId, ditStructureRule ); if ( LOG.isDebugEnabled() ) { LOG.debug( "registered {} for OID {}", ditStructureRule, ruleId ); } }
/** * {@inheritDoc} */ public String getOidByName( String name ) throws LdapException { T schemaObject = byName.get( name ); if ( schemaObject == null ) { // last resort before giving up check with lower cased version String lowerCased = name.toLowerCase(); schemaObject = byName.get( lowerCased ); // ok this name is not for a schema object in the registry if ( schemaObject == null ) { throw new LdapException( I18n.err( I18n.ERR_04274, name ) ); } } // we found the schema object by key on the first lookup attempt return schemaObject.getOid(); }
/** * {@inheritDoc} */ public String getSchemaName( String oid ) throws LdapException { if ( !OID.isOID( oid ) ) { String msg = I18n.err( I18n.ERR_04267 ); LOG.warn( msg ); throw new LdapException( msg ); } SchemaObject schemaObject = byName.get( oid ); if ( schemaObject != null ) { return schemaObject.getSchemaName(); } String msg = I18n.err( I18n.ERR_04268, oid ); LOG.warn( msg ); throw new LdapException( msg ); }
/** * Gets the primary name associated with an OID. The primary name is the * first name specified for the OID. * * @param oid the object identifier * @return the primary name * @throws LdapException if oid does not exist */ public String getPrimaryName( String oid ) throws LdapException { SchemaObject schemaObject = byOid.get( oid ); if ( schemaObject != null ) { return schemaObject.getName(); } else { String msg = I18n.err( I18n.ERR_04286, oid ); LOG.error( msg ); throw new LdapException( msg ); } }
/** * Uses the syntaxChecker associated with the attributeType to check if the * value is valid. Repeated calls to this method do not attempt to re-check * the syntax of the wrapped value every time if the wrapped value does not * change. Syntax checks only result on the first check, and when the wrapped * value changes. * * @see ServerValue#isValid() */ public final boolean isValid( SyntaxChecker syntaxChecker ) throws LdapException { if ( syntaxChecker == null ) { String message = I18n.err( I18n.ERR_04139, toString() ); LOG.error( message ); throw new LdapException( message ); } valid = syntaxChecker.isValidSyntax( getReference() ); return valid; }
/** * {@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; }
/** * 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 lookup( String oid ) throws LdapException { if ( oid == null ) { return null; } T schemaObject = byName.get( oid ); if ( schemaObject == null ) { // let's try with trimming and lowercasing now schemaObject = byName.get( StringTools.trim( StringTools.toLowerCase( oid ) ) ); } if ( schemaObject == null ) { String msg = I18n.err( I18n.ERR_04269, schemaObjectType.name(), oid ); LOG.debug( msg ); throw new LdapException( msg ); } if ( DEBUG ) { LOG.debug( "Found {} with oid: {}", schemaObject, oid ); } return schemaObject; }
throw new LdapException( message ); throw new LdapException( message );
/** * {@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; }
/** * @see NameComponentNormalizer#normalizeByName(String, String) */ public Object normalizeByName( String name, byte[] value ) throws LdapException { AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( name ); if ( !attributeType.getSyntax().isHumanReadable() ) { return lookup( name ).normalize( new BinaryValue( value ) ); } else { try { String valStr = new String( value, "UTF-8" ); return lookup( name ).normalize( valStr ); } catch ( UnsupportedEncodingException uee ) { String message = I18n.err( I18n.ERR_04223 ); LOG.error( message ); throw new LdapException( message ); } } }
/** * @see NameComponentNormalizer#normalizeByName(String, String) */ public Object normalizeByName( String name, String value ) throws LdapException { AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( name ); if ( attributeType.getSyntax().isHumanReadable() ) { return lookup( name ).normalize( value ); } else { try { String unescaped = unescape( value ); byte[] valBytes = unescaped.getBytes( "UTF-8" ); return lookup( name ).normalize( new BinaryValue( valBytes ) ); } catch ( UnsupportedEncodingException uee ) { String message = I18n.err( I18n.ERR_04222 ); LOG.error( message ); throw new LdapException( message ); } } }
if ( entry.getEntry() != null ) throw new LdapException( I18n.err( I18n.ERR_12081 ) ); if ( ( entry.getEntry() == null ) ) throw new LdapException( I18n.err( I18n.ERR_12082 ) ); if ( entry.getEntry() != null ) throw new LdapException( I18n.err( I18n.ERR_12083 ) );
throw new LdapException( e.getMessage() ); throw new LdapException( ne.getMessage() );
throw new LdapException( I18n.err( I18n.ERR_309, oid ) ); throw new LdapException( I18n.err( I18n.ERR_309, oid ) );