Refine search
/** * Deletes the working directory. * * @param wkdir the working directory to delete * @throws IOException if the working directory cannot be deleted */ public static void doDelete( File wkdir ) throws IOException { if ( wkdir.exists() ) { try { FileUtils.deleteDirectory( wkdir ); } catch ( IOException e ) { LOG.error( I18n.err( I18n.ERR_115 ), e ); } } if ( wkdir.exists() ) { throw new IOException( I18n.err( I18n.ERR_116, wkdir ) ); } }
/** * Check if the mechanism exists. */ private boolean checkMechanism( String saslMechanism ) throws Exception { // Guard clause: Reject unsupported SASL mechanisms. if ( !ldapServer.getSupportedMechanisms().contains( saslMechanism ) ) { LOG.error( I18n.err( I18n.ERR_160, saslMechanism ) ); return false; } else { return true; } }
private static void monitorContext( DnsContext dnsContext ) throws Exception { try { RecordStore store = dnsContext.getStore(); List<ResourceRecord> records = dnsContext.getResourceRecords(); StringBuffer sb = new StringBuffer(); sb.append( "Monitoring context:" ); sb.append( "\n\t" + "store: " + store ); sb.append( "\n\t" + "records: " + records ); LOG.debug( sb.toString() ); } catch ( Exception e ) { // This is a monitor. No exceptions should bubble up. LOG.error( I18n.err( I18n.ERR_154 ), e ); } }
/** * {@inheritDoc} */ @Override public void put( PartitionTxn partitionTxn, K key, V value ) throws LdapException { try { if ( ( value == null ) || ( key == null ) ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_594 ) ); } V existingVal = bt.insert( key, value ); if ( existingVal == null ) { count++; } } catch ( IOException ioe ) { LOG.error( I18n.err( I18n.ERR_131, key, name ), ioe ); throw new LdapOtherException( ioe.getMessage(), ioe ); } }
/** * {@inheritDoc} */ @Override public void remove( PartitionTxn partitionTxn, K key, V value ) throws LdapException { try { if ( key == null ) { return; } org.apache.directory.mavibot.btree.Tuple<K, V> tuple = bt.delete( key, value ); // We decrement the counter only when the key was found if ( tuple != null ) { count--; } } catch ( Exception e ) { LOG.error( I18n.err( I18n.ERR_132, key, value, name ), e ); } }
/** * {@inheritDoc} */ public Index<? extends Object, E, Long> getUserIndex( String id ) throws IndexNotFoundException { try { id = schemaManager.getAttributeTypeRegistry().getOidByName( id ); } catch ( LdapException e ) { LOG.error( I18n.err( I18n.ERR_1, id ), e.getLocalizedMessage() ); throw new IndexNotFoundException( I18n.err( I18n.ERR_1, id ), id, e ); } if ( userIndices.containsKey( id ) ) { return userIndices.get( id ); } throw new IndexNotFoundException( I18n.err( I18n.ERR_3, id, name ) ); }
/** * {@inheritDoc} */ public Index<?, E, Long> getIndex( String id ) throws IndexNotFoundException { try { id = schemaManager.getAttributeTypeRegistry().getOidByName( id ); } catch ( LdapException e ) { LOG.error( I18n.err( I18n.ERR_1, id ), e.getLocalizedMessage() ); throw new IndexNotFoundException( I18n.err( I18n.ERR_1, id ), id, e ); } if ( userIndices.containsKey( id ) ) { return userIndices.get( id ); } if ( systemIndices.containsKey( id ) ) { return systemIndices.get( id ); } throw new IndexNotFoundException( I18n.err( I18n.ERR_2, id, name ) ); }
private void deliverNamingExceptionEvent( Exception e ) { LOG.error( I18n.err( I18n.ERR_118 ), e ); NamingExceptionEvent evt = null; if ( e instanceof NamingException ) { evt = new NamingExceptionEvent( source, ( NamingException ) e ); } else { NamingException ne = new NamingException( I18n.err( I18n.ERR_119 ) ); ne.setRootCause( e ); evt = new NamingExceptionEvent( source, ne ); } listener.namingExceptionThrown( evt ); }
/** * {@inheritDoc} */ public Index<?, E, Long> getSystemIndex( String id ) throws IndexNotFoundException { try { id = schemaManager.getAttributeTypeRegistry().getOidByName( id ); } catch ( LdapException e ) { LOG.error( I18n.err( I18n.ERR_1, id ), e.getLocalizedMessage() ); throw new IndexNotFoundException( I18n.err( I18n.ERR_1, id ), id, e ); } if ( systemIndices.containsKey( id ) ) { return systemIndices.get( id ); } throw new IndexNotFoundException( I18n.err( I18n.ERR_2, id, name ) ); }
/** * Create the KRB5_KEY attribute with all the associated keys. * * @param keys The keys to inject in the attribute * @return The create attribute * @throws LdapException If we had an error while adding a key in the attribute */ private Attribute getKeyAttribute( Map<EncryptionType, EncryptionKey> keys ) throws LdapException { Attribute keyAttribute = new DefaultAttribute( krb5KeyAT ); for ( EncryptionKey encryptionKey : keys.values() ) { try { ByteBuffer buffer = ByteBuffer.allocate( encryptionKey.computeLength() ); encryptionKey.encode( buffer ); keyAttribute.add( buffer.array() ); } catch ( EncoderException ioe ) { LOG.error( I18n.err( I18n.ERR_122 ), ioe ); LOG_KRB.error( I18n.err( I18n.ERR_122 ), ioe ); } } return keyAttribute; }
private boolean disableSchema( String schemaName ) throws LdapException { Schema schema = schemaManager.getLoadedSchema( schemaName ); if ( schema == null ) { // This is not possible. We can't enable a schema which is not loaded. String msg = I18n.err( I18n.ERR_85, schemaName ); LOG.error( msg ); throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, msg ); } return schemaManager.disable( schemaName ); }
/** * Check if we have to add an operational attribute, or if the admin has injected one */ private boolean checkAddOperationalAttribute( boolean isAdmin, Entry entry, AttributeType attribute ) throws LdapException { if ( entry.containsAttribute( attribute ) ) { if ( !isAdmin ) { // Wrong ! String message = I18n.err( I18n.ERR_30, attribute ); LOG.error( message ); throw new LdapNoPermissionException( message ); } else { return true; } } else { return false; } }
@Override public Dn deserialize( BufferHandler bufferHandler ) throws IOException { ObjectInputStream in = new ObjectInputStream( new ByteArrayInputStream( bufferHandler.getBuffer() ) ); try { Dn dn = new Dn(); dn.readExternal( in ); return dn; } catch ( ClassNotFoundException cnfe ) { LOG.error( I18n.err( I18n.ERR_134, cnfe.getLocalizedMessage() ) ); throw new IOException( cnfe.getLocalizedMessage() ); } }
/** * {@inheritDoc} */ @Override public Dn fromBytes( byte[] buffer, int pos ) throws IOException { int length = buffer.length - pos; ObjectInputStream in = new ObjectInputStream( new ByteArrayInputStream( buffer, pos, length ) ); try { Dn dn = new Dn(); dn.readExternal( in ); return dn; } catch ( ClassNotFoundException cnfe ) { LOG.error( I18n.err( I18n.ERR_134, cnfe.getLocalizedMessage() ) ); throw new IOException( cnfe.getLocalizedMessage() ); } }