You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2006/12/18 18:15:08 UTC
svn commit: r488345 [5/12] - in /directory/sandbox/pamarcelot/ldapstudio:
ldapstudio-browser-core/ ldapstudio-browser-core/META-INF/
ldapstudio-browser-core/about_files/ ldapstudio-browser-core/lib/
ldapstudio-browser-core/src/ ldapstudio-browser-core/...
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/ConnectionModifyHandler.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/ConnectionModifyHandler.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/ConnectionModifyHandler.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/ConnectionModifyHandler.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,616 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.core.internal.model;
+
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.LinkedList;
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCoreConstants;
+import org.apache.directory.ldapstudio.browser.core.BrowserCoreMessages;
+import org.apache.directory.ldapstudio.browser.core.BrowserCorePlugin;
+import org.apache.directory.ldapstudio.browser.core.jobs.ExtendedProgressMonitor;
+import org.apache.directory.ldapstudio.browser.core.model.DN;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.IReferralHandler;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.core.model.URL;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.LdifEnumeration;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.container.LdifChangeAddRecord;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.container.LdifChangeDeleteRecord;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.container.LdifChangeModDnRecord;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.container.LdifChangeModifyRecord;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.container.LdifContainer;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.container.LdifModSpec;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.container.LdifRecord;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.lines.LdifAttrValLine;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.lines.LdifChangeTypeLine;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.lines.LdifCommentLine;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.lines.LdifDeloldrdnLine;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.lines.LdifDnLine;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.lines.LdifModSpecSepLine;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.lines.LdifNewrdnLine;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.lines.LdifNewsuperiorLine;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.lines.LdifSepLine;
+import org.apache.directory.ldapstudio.browser.core.utils.ModelConverter;
+
+
+class ConnectionModifyHandler
+{
+
+ private Connection connection;
+
+ private ModificationLogger modificationLogger;
+
+ private int suspendDepth;
+
+ private LinkedList recordQueue;
+
+
+ ConnectionModifyHandler( Connection connection )
+ {
+ this.connection = connection;
+
+ this.modificationLogger = new ModificationLogger( connection );
+ }
+
+
+ void connectionClosed()
+ {
+ this.suspendDepth = 0;
+ this.recordQueue.clear();
+ this.recordQueue = null;
+ }
+
+
+ void connectionOpened()
+ {
+ this.suspendDepth = 0;
+ this.recordQueue = new LinkedList();
+ }
+
+
+ void create( IValue[] valuesToCreate, ExtendedProgressMonitor monitor )
+ {
+ for ( int i = 0; !monitor.isCanceled() && i < valuesToCreate.length; i++ )
+ {
+
+ LdifChangeModifyRecord cmr = new LdifChangeModifyRecord( LdifDnLine.create( valuesToCreate[i]
+ .getAttribute().getEntry().getDn().toString() ) );
+ ModelConverter.addControls( cmr, valuesToCreate[i].getAttribute().getEntry() );
+ cmr.setChangeType( LdifChangeTypeLine.createModify() );
+
+ LdifModSpec modSpec = LdifModSpec.createAdd( valuesToCreate[i].getAttribute().getDescription() );
+ if ( valuesToCreate[i].isString() )
+ {
+ modSpec.addAttrVal( LdifAttrValLine.create( valuesToCreate[i].getAttribute().getDescription(),
+ valuesToCreate[i].getStringValue() ) );
+ }
+ else
+ {
+ modSpec.addAttrVal( LdifAttrValLine.create( valuesToCreate[i].getAttribute().getDescription(),
+ valuesToCreate[i].getBinaryValue() ) );
+ }
+ modSpec.finish( LdifModSpecSepLine.create() );
+ cmr.addModSpec( modSpec );
+ cmr.finish( LdifSepLine.create() );
+
+ try
+ {
+ this.applyModificationAndLog( cmr, monitor );
+ }
+ catch ( ConnectionException e )
+ {
+ monitor.reportError( e );
+ }
+ }
+ }
+
+
+ void modify( IValue oldValue, IValue newValue, ExtendedProgressMonitor monitor )
+ {
+ try
+ {
+ LdifChangeModifyRecord cmr = new LdifChangeModifyRecord( LdifDnLine.create( oldValue.getAttribute()
+ .getEntry().getDn().toString() ) );
+ ModelConverter.addControls( cmr, oldValue.getAttribute().getEntry() );
+ cmr.setChangeType( LdifChangeTypeLine.createModify() );
+
+ if ( oldValue.getAttribute().getValueSize() == 1 )
+ {
+ LdifModSpec modSpec = LdifModSpec.createReplace( oldValue.getAttribute().getDescription() );
+ if ( newValue.isString() )
+ {
+ modSpec.addAttrVal( LdifAttrValLine.create( oldValue.getAttribute().getDescription(), newValue
+ .getStringValue() ) );
+ }
+ else
+ {
+ modSpec.addAttrVal( LdifAttrValLine.create( oldValue.getAttribute().getDescription(), newValue
+ .getBinaryValue() ) );
+ }
+ modSpec.finish( LdifModSpecSepLine.create() );
+ cmr.addModSpec( modSpec );
+ cmr.finish( LdifSepLine.create() );
+ }
+ else
+ {
+ LdifModSpec modSpec1 = LdifModSpec.createAdd( oldValue.getAttribute().getDescription() );
+ if ( newValue.isString() )
+ {
+ modSpec1.addAttrVal( LdifAttrValLine.create( oldValue.getAttribute().getDescription(), newValue
+ .getStringValue() ) );
+ }
+ else
+ {
+ modSpec1.addAttrVal( LdifAttrValLine.create( oldValue.getAttribute().getDescription(), newValue
+ .getBinaryValue() ) );
+ }
+ modSpec1.finish( LdifModSpecSepLine.create() );
+ cmr.addModSpec( modSpec1 );
+
+ LdifModSpec modSpec2 = LdifModSpec.createDelete( oldValue.getAttribute().getDescription() );
+ if ( oldValue.isString() )
+ {
+ modSpec2.addAttrVal( LdifAttrValLine.create( oldValue.getAttribute().getDescription(), oldValue
+ .getStringValue() ) );
+ }
+ else
+ {
+ modSpec2.addAttrVal( LdifAttrValLine.create( oldValue.getAttribute().getDescription(), oldValue
+ .getBinaryValue() ) );
+ }
+ modSpec2.finish( LdifModSpecSepLine.create() );
+ cmr.addModSpec( modSpec2 );
+ cmr.finish( LdifSepLine.create() );
+ }
+
+ this.applyModificationAndLog( cmr, monitor );
+
+ }
+ catch ( ConnectionException e )
+ {
+ monitor.reportError( e );
+ }
+ }
+
+
+ void delete( IValue[] valuesToDelete, ExtendedProgressMonitor monitor )
+ {
+ try
+ {
+ for ( int i = 0; !monitor.isCanceled() && i < valuesToDelete.length; i++ )
+ {
+ LdifChangeModifyRecord cmr = new LdifChangeModifyRecord( LdifDnLine.create( valuesToDelete[i]
+ .getAttribute().getEntry().getDn().toString() ) );
+ ModelConverter.addControls( cmr, valuesToDelete[i].getAttribute().getEntry() );
+ cmr.setChangeType( LdifChangeTypeLine.createModify() );
+
+ LdifModSpec modSpec = LdifModSpec.createDelete( valuesToDelete[i].getAttribute().getDescription() );
+ if ( valuesToDelete[i].isString() )
+ {
+ modSpec.addAttrVal( LdifAttrValLine.create( valuesToDelete[i].getAttribute().getDescription(),
+ valuesToDelete[i].getStringValue() ) );
+ }
+ else
+ {
+ modSpec.addAttrVal( LdifAttrValLine.create( valuesToDelete[i].getAttribute().getDescription(),
+ valuesToDelete[i].getBinaryValue() ) );
+ }
+ modSpec.finish( LdifModSpecSepLine.create() );
+ cmr.addModSpec( modSpec );
+ cmr.finish( LdifSepLine.create() );
+
+ this.applyModificationAndLog( cmr, monitor );
+ }
+ }
+ catch ( ConnectionException e )
+ {
+ monitor.reportError( e );
+ }
+ }
+
+
+ void delete( IAttribute[] attriubtesToDelete, ExtendedProgressMonitor monitor )
+ {
+ try
+ {
+ for ( int i = 0; !monitor.isCanceled() && i < attriubtesToDelete.length; i++ )
+ {
+ LdifChangeModifyRecord cmr = new LdifChangeModifyRecord( LdifDnLine.create( attriubtesToDelete[i]
+ .getEntry().getDn().toString() ) );
+ ModelConverter.addControls( cmr, attriubtesToDelete[i].getEntry() );
+ cmr.setChangeType( LdifChangeTypeLine.createModify() );
+
+ LdifModSpec modSpec = LdifModSpec.createDelete( attriubtesToDelete[i].getDescription() );
+ modSpec.finish( LdifModSpecSepLine.create() );
+ cmr.addModSpec( modSpec );
+ cmr.finish( LdifSepLine.create() );
+
+ this.applyModificationAndLog( cmr, monitor );
+ }
+ }
+ catch ( ConnectionException e )
+ {
+ monitor.reportError( e );
+ }
+ }
+
+
+ void create( IEntry entryToCreate, ExtendedProgressMonitor monitor )
+ {
+ try
+ {
+ LdifChangeAddRecord car = ModelConverter.entryToLdifChangeAddRecord( entryToCreate );
+ this.applyModificationAndLog( car, monitor );
+
+ // connection.cacheEntry(entryToCreate);
+ // entryToCreate.setDirectoryEntry(true);
+ }
+ catch ( ConnectionException e )
+ {
+ monitor.reportError( e );
+ }
+ }
+
+
+ void rename( IEntry entryToRename, DN newDn, boolean deleteOldRdn, ExtendedProgressMonitor monitor )
+ {
+ try
+ {
+ LdifChangeModDnRecord cmdr = new LdifChangeModDnRecord( LdifDnLine
+ .create( entryToRename.getDn().toString() ) );
+ ModelConverter.addControls( cmdr, entryToRename );
+ cmdr.setChangeType( LdifChangeTypeLine.createModDn() );
+
+ cmdr.setNewrdn( LdifNewrdnLine.create( newDn.getRdn().toString() ) );
+ cmdr.setDeloldrdn( deleteOldRdn ? LdifDeloldrdnLine.create1() : LdifDeloldrdnLine.create0() );
+ cmdr.finish( LdifSepLine.create() );
+
+ this.applyModificationAndLog( cmdr, monitor );
+
+ uncacheChildren( entryToRename );
+
+ }
+ catch ( ConnectionException e )
+ {
+ monitor.reportError( e );
+ }
+ }
+
+
+ void move( IEntry entryToMove, DN newSuperior, ExtendedProgressMonitor monitor )
+ {
+ try
+ {
+ LdifChangeModDnRecord cmdr = new LdifChangeModDnRecord( LdifDnLine.create( entryToMove.getDn().toString() ) );
+ ModelConverter.addControls( cmdr, entryToMove );
+ cmdr.setChangeType( LdifChangeTypeLine.createModDn() );
+
+ cmdr.setNewrdn( LdifNewrdnLine.create( entryToMove.getRdn().toString() ) );
+ cmdr.setDeloldrdn( LdifDeloldrdnLine.create0() );
+ cmdr.setNewsuperior( LdifNewsuperiorLine.create( newSuperior.toString() ) );
+ cmdr.finish( LdifSepLine.create() );
+
+ this.applyModificationAndLog( cmdr, monitor );
+
+ uncacheChildren( entryToMove );
+
+ }
+ catch ( ConnectionException e )
+ {
+ monitor.reportError( e );
+ }
+ }
+
+
+ private void uncacheChildren( IEntry entry )
+ {
+ IEntry[] children = entry.getChildren();
+ if ( entry.getChildren() != null )
+ {
+ for ( int i = 0; i < children.length; i++ )
+ {
+ uncacheChildren( children[i] );
+ }
+ }
+ connection.uncacheEntry( entry );
+ }
+
+
+ void delete( IEntry entry, ExtendedProgressMonitor monitor )
+ {
+ try
+ {
+ LdifChangeDeleteRecord cdr = new LdifChangeDeleteRecord( LdifDnLine.create( entry.getDn().toString() ) );
+ ModelConverter.addControls( cdr, entry );
+ cdr.setChangeType( LdifChangeTypeLine.createDelete() );
+ cdr.finish( LdifSepLine.create() );
+
+ this.applyModificationAndLog( cdr, monitor );
+
+ connection.uncacheEntry( entry );
+
+ }
+ catch ( ConnectionException e )
+ {
+ monitor.reportError( e );
+ }
+ }
+
+
+ void importLdif( LdifEnumeration enumeration, Writer logWriter, boolean continueOnError,
+ ExtendedProgressMonitor monitor )
+ {
+ int importedCount = 0;
+ int errorCount = 0;
+ try
+ {
+ while ( !monitor.isCanceled() && enumeration.hasNext( monitor ) )
+ {
+ LdifContainer container = enumeration.next( monitor );
+
+ if ( container instanceof LdifRecord )
+ {
+
+ LdifRecord record = ( LdifRecord ) container;
+ try
+ {
+ this.applyModificationAndLog( record, monitor );
+
+ String dn = record.getDnLine().getValueAsString();
+ IEntry entry = connection.getEntryFromCache( new DN( dn ) );
+ if ( entry != null )
+ {
+ if ( record instanceof LdifChangeDeleteRecord )
+ {
+ connection.uncacheEntry( entry );
+ }
+ else
+ {
+ entry.setAttributesInitialized( false, connection );
+ }
+ }
+
+ logModification( logWriter, record, monitor );
+
+ importedCount++;
+ }
+ catch ( Exception e )
+ {
+
+ logModificationError( logWriter, record, e, monitor );
+
+ errorCount++;
+
+ if ( !continueOnError )
+ {
+ monitor.reportError( e );
+ return;
+ }
+ }
+
+ monitor.reportProgress( BrowserCoreMessages.bind(
+ BrowserCoreMessages.ldif__imported_n_entries_m_errors, new String[]
+ { "" + importedCount, "" + errorCount } ) ); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ else
+ {
+ logWriter.write( container.toRawString() );
+ }
+ }
+
+ if ( errorCount > 0 )
+ {
+ monitor.reportError( BrowserCoreMessages.bind( BrowserCoreMessages.ldif__n_errors_see_logfile,
+ new String[]
+ { "" + errorCount } ) ); //$NON-NLS-1$
+ }
+ }
+ catch ( Exception e )
+ {
+ monitor.reportError( e );
+ }
+ }
+
+
+ boolean isSuspended()
+ {
+ return this.suspendDepth > 0;
+ }
+
+
+ void suspend()
+ {
+ this.suspendDepth++;
+ }
+
+
+ void resume( ExtendedProgressMonitor monitor )
+ {
+ try
+ {
+ this.suspendDepth--;
+ this.commit( monitor );
+ }
+ catch ( Exception e )
+ {
+ monitor.reportError( e );
+ }
+ }
+
+
+ void reset()
+ {
+ this.recordQueue.clear();
+ this.suspendDepth = 0;
+ }
+
+
+ private void commit( ExtendedProgressMonitor monitor ) throws ConnectionException
+ {
+ if ( this.suspendDepth == 0 && !recordQueue.isEmpty() )
+ {
+
+ final LdifRecord[] records = ( LdifRecord[] ) this.recordQueue.toArray( new LdifRecord[this.recordQueue
+ .size()] );
+ this.reset();
+
+ for ( int i = 0; i < records.length; i++ )
+ {
+ try
+ {
+ int referralsHandlingMethod = connection.getReferralsHandlingMethod();
+ // int referralsHandlingMethod =
+ // IConnection.HANDLE_REFERRALS_IGNORE;
+ connection.connectionProvider.applyModification( records[i], referralsHandlingMethod, monitor );
+
+ StringWriter writer = new StringWriter();
+ this.logModification( writer, records[i], monitor );
+ this.modificationLogger.log( writer.toString() );
+
+ }
+ catch ( ConnectionException ce )
+ {
+
+ if ( ce instanceof ReferralException )
+ {
+
+ if ( connection.getReferralsHandlingMethod() == IConnection.HANDLE_REFERRALS_FOLLOW )
+ {
+
+ // get referral handler
+ IReferralHandler referralHandler = BrowserCorePlugin.getDefault().getReferralHandler();
+ if ( referralHandler == null )
+ {
+ throw new ConnectionException( BrowserCoreMessages.model__no_referral_handler );
+ }
+
+ // for all referrals
+ ReferralException re = ( ReferralException ) ce;
+ for ( int r = 0; r < re.getReferrals().length; r++ )
+ {
+
+ // parse referral URL
+ String referral = re.getReferrals()[r];
+ URL referralUrl = new URL( referral );
+
+ // get referral connection
+ IConnection referralConnection = referralHandler.getReferralConnection( referralUrl );
+ if ( referralConnection == null )
+ {
+ // throw new
+ // ConnectionException(BrowserCoreMessages.model__no_referral_connection);
+ continue;
+ }
+
+ // open connection
+ if ( !referralConnection.isOpened() )
+ {
+ referralConnection.open( monitor );
+ }
+
+ ( ( Connection ) referralConnection ).modifyHandler.applyModificationAndLog(
+ records[i], monitor );
+
+ }
+ }
+
+ }
+ else
+ {
+
+ StringWriter writer = new StringWriter();
+ this.logModificationError( writer, records[i], ce, monitor );
+ this.modificationLogger.log( writer.toString() );
+
+ throw ce;
+ }
+ }
+ }
+ }
+ }
+
+
+ ModificationLogger getModificationLogger()
+ {
+ return modificationLogger;
+ }
+
+
+ private void logModificationError( Writer logWriter, LdifRecord record, Exception e, ExtendedProgressMonitor monitor )
+ {
+ try
+ {
+ DateFormat df = new SimpleDateFormat( BrowserCoreConstants.DATEFORMAT );
+
+ String errorComment = "#!ERROR " + e.getMessage(); //$NON-NLS-1$
+ errorComment = errorComment.replaceAll( "\r", " " ); //$NON-NLS-1$ //$NON-NLS-2$
+ errorComment = errorComment.replaceAll( "\n", " " ); //$NON-NLS-1$ //$NON-NLS-2$
+ LdifCommentLine errorCommentLine = LdifCommentLine.create( errorComment );
+
+ logWriter.write( LdifCommentLine.create( "#!RESULT ERROR" ).toFormattedString() ); //$NON-NLS-1$
+ logWriter.write( LdifCommentLine.create(
+ "#!CONNECTION ldap://" + connection.getHost() + ":" + connection.getPort() ).toFormattedString() ); //$NON-NLS-1$ //$NON-NLS-2$
+ logWriter.write( LdifCommentLine.create( "#!DATE " + df.format( new Date() ) ).toFormattedString() ); //$NON-NLS-1$
+ logWriter.write( errorCommentLine.toFormattedString() );
+ logWriter.write( record.toFormattedString() );
+ }
+ catch ( IOException ioe )
+ {
+ monitor.reportError( BrowserCoreMessages.model__error_logging_modification, ioe );
+ }
+ }
+
+
+ private void logModification( Writer logWriter, LdifRecord record, ExtendedProgressMonitor monitor )
+ {
+ try
+ {
+ DateFormat df = new SimpleDateFormat( BrowserCoreConstants.DATEFORMAT );
+ logWriter.write( LdifCommentLine.create( "#!RESULT OK" ).toFormattedString() ); //$NON-NLS-1$
+ logWriter.write( LdifCommentLine.create(
+ "#!CONNECTION ldap://" + connection.getHost() + ":" + connection.getPort() ).toFormattedString() ); //$NON-NLS-1$ //$NON-NLS-2$
+ logWriter.write( LdifCommentLine.create( "#!DATE " + df.format( new Date() ) ).toFormattedString() ); //$NON-NLS-1$
+ logWriter.write( record.toFormattedString() );
+ }
+ catch ( IOException ioe )
+ {
+ monitor.reportError( BrowserCoreMessages.model__error_logging_modification, ioe );
+ }
+ }
+
+
+ private void applyModificationAndLog( LdifRecord record, ExtendedProgressMonitor monitor )
+ throws ConnectionException
+ {
+ this.recordQueue.add( record );
+ this.commit( monitor );
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/ConnectionSearchHandler.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/ConnectionSearchHandler.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/ConnectionSearchHandler.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/ConnectionSearchHandler.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,590 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.core.internal.model;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCoreMessages;
+import org.apache.directory.ldapstudio.browser.core.jobs.ExtendedProgressMonitor;
+import org.apache.directory.ldapstudio.browser.core.model.AttributeHierachie;
+import org.apache.directory.ldapstudio.browser.core.model.Control;
+import org.apache.directory.ldapstudio.browser.core.model.DN;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.IRootDSE;
+import org.apache.directory.ldapstudio.browser.core.model.ISearch;
+import org.apache.directory.ldapstudio.browser.core.model.ISearchResult;
+import org.apache.directory.ldapstudio.browser.core.model.ModelModificationException;
+import org.apache.directory.ldapstudio.browser.core.model.SearchParameter;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.LdifEnumeration;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.container.LdifContainer;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.container.LdifContentRecord;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.lines.LdifAttrValLine;
+import org.apache.directory.ldapstudio.browser.core.model.schema.ObjectClassDescription;
+import org.apache.directory.ldapstudio.browser.core.utils.Utils;
+
+
+public class ConnectionSearchHandler
+{
+
+ private Connection connection;
+
+
+ ConnectionSearchHandler( Connection connection )
+ {
+ this.connection = connection;
+ }
+
+
+ void connectionClosed()
+ {
+ }
+
+
+ void connectionOpened()
+ {
+ }
+
+
+ boolean existsEntry( DN dn, ExtendedProgressMonitor monitor )
+ {
+ SearchParameter sp = new SearchParameter();
+ sp.setSearchBase( dn );
+ sp.setFilter( ISearch.FILTER_TRUE );
+ sp.setScope( ISearch.SCOPE_OBJECT );
+ sp.setReturningAttributes( ISearch.NO_ATTRIBUTES );
+
+ try
+ {
+ LdifEnumeration le = connection.connectionProvider.search( sp, monitor );
+ return le.hasNext( monitor );
+ }
+ catch ( ConnectionException e )
+ {
+ monitor.reportError( e );
+ return false;
+ }
+ }
+
+
+ IEntry getEntry( DN dn, ExtendedProgressMonitor monitor )
+ {
+ try
+ {
+ // first check cache
+ IEntry entry = connection.getEntryFromCache( dn );
+ if ( entry != null )
+ {
+ return entry;
+ }
+
+ // search in directory
+ ISearch search = new Search( null, connection, dn, null, ISearch.NO_ATTRIBUTES, ISearch.SCOPE_OBJECT, 1, 0,
+ IConnection.DEREFERENCE_ALIASES_NEVER, IConnection.HANDLE_REFERRALS_IGNORE, true, true, null );
+ this.search( search, monitor );
+ ISearchResult[] srs = search.getSearchResults();
+ if ( srs.length > 0 )
+ {
+ return srs[0].getEntry();
+ }
+ else
+ {
+ monitor.reportError( BrowserCoreMessages.model__no_such_entry );
+ return null;
+ }
+ }
+ catch ( Exception e )
+ {
+ monitor.reportError( e.getMessage(), e );
+ return null;
+ }
+ }
+
+
+ void search( ISearch search, ExtendedProgressMonitor monitor )
+ {
+
+ try
+ {
+
+ if ( !monitor.isCanceled() )
+ {
+
+ // add returning attributes for children and alias detection
+ SearchParameter searchParameter = getSearchParameter( search );
+ ArrayList searchResultList = new ArrayList();
+
+ try
+ {
+
+ // search
+ LdifEnumeration enumeration = connection.connectionProvider.search( searchParameter, monitor );
+
+ // iterate through the search result
+ while ( !monitor.isCanceled() && enumeration.hasNext( monitor ) )
+ {
+ LdifContainer container = enumeration.next( monitor );
+ if ( container instanceof LdifContentRecord )
+ {
+
+ LdifContentRecord record = ( LdifContentRecord ) container;
+ DN dn = new DN( record.getDnLine().getValueAsString() );
+
+ // get entry from cache or create it
+ IEntry entry = connection.getEntryFromCache( dn );
+ if ( entry == null )
+ {
+ entry = createAndCacheEntry( dn );
+ }
+
+ // initialize special flags
+ initFlags( entry, record, searchParameter );
+
+ // fill the attributes
+ fillAttributes( entry, record, searchParameter );
+
+ searchResultList
+ .add( new org.apache.directory.ldapstudio.browser.core.internal.model.SearchResult(
+ entry, search ) );
+
+ monitor
+ .reportProgress( searchResultList.size() == 1 ? BrowserCoreMessages.model__retrieved_1_entry
+ : BrowserCoreMessages.bind( BrowserCoreMessages.model__retrieved_n_entries,
+ new String[]
+ { Integer.toString( searchResultList.size() ) } ) );
+ }
+ }
+ }
+ catch ( ConnectionException ce )
+ {
+
+ if ( ce.getLdapStatusCode() == 3 || ce.getLdapStatusCode() == 4 || ce.getLdapStatusCode() == 11 )
+ {
+ search.setCountLimitExceeded( true );
+ }
+ else if ( ce instanceof ReferralException )
+ {
+
+ if ( search.getReferralsHandlingMethod() == IConnection.HANDLE_REFERRALS_FOLLOW )
+ {
+
+ ReferralException re = ( ReferralException ) ce;
+ ISearch[] referralSearches = re.getReferralSearches();
+ for ( int i = 0; i < referralSearches.length; i++ )
+ {
+ ISearch referralSearch = referralSearches[i];
+
+ // open connection
+ if ( !referralSearch.getConnection().isOpened() )
+ {
+ referralSearch.getConnection().open( monitor );
+ }
+
+ referralSearch.getConnection().search( referralSearch, monitor );
+
+ ISearchResult[] referralSearchResults = referralSearch.getSearchResults();
+ for ( int j = 0; referralSearchResults != null && j < referralSearchResults.length; j++ )
+ {
+ ISearchResult referralSearchResult = referralSearchResults[j];
+ referralSearchResult.setSearch( search );
+ searchResultList.add( referralSearchResult );
+ }
+ }
+ }
+ }
+ else
+ {
+ monitor.reportError( ce );
+ }
+ }
+
+ monitor.reportProgress( searchResultList.size() == 1 ? BrowserCoreMessages.model__retrieved_1_entry
+ : BrowserCoreMessages.bind( BrowserCoreMessages.model__retrieved_n_entries, new String[]
+ { Integer.toString( searchResultList.size() ) } ) );
+ monitor.worked( 1 );
+
+ search.setSearchResults( ( ISearchResult[] ) searchResultList
+ .toArray( new ISearchResult[searchResultList.size()] ) );
+ }
+ }
+ catch ( Exception e )
+ {
+ monitor.reportError( e );
+ }
+ }
+
+
+ private IEntry createAndCacheEntry( DN dn ) throws ModelModificationException
+ {
+ IEntry entry = null;
+
+ // build tree to parent
+ LinkedList parentDnList = new LinkedList();
+ DN parentDN = dn;
+ while ( parentDN != null && connection.getEntryFromCache( parentDN ) == null )
+ {
+ parentDnList.addFirst( parentDN );
+ parentDN = parentDN.getParentDn();
+ }
+ for ( Iterator it = parentDnList.iterator(); it.hasNext(); )
+ {
+ DN aDN = ( DN ) it.next();
+ if ( aDN.getParentDn() == null )
+ {
+ entry = new BaseDNEntry( aDN, connection, connection );
+ connection.cacheEntry( entry );
+ }
+ else if ( connection.getEntryFromCache( aDN.getParentDn() ) != null )
+ {
+ IEntry parentEntry = connection.getEntryFromCache( aDN.getParentDn() );
+ entry = new Entry( parentEntry, aDN.getRdn(), connection );
+ entry.setDirectoryEntry( true );
+
+ parentEntry.addChild( entry, connection );
+ // parentEntry.setAttributesInitialized(false, this);
+
+ parentEntry.setChildrenInitialized( true, connection );
+ parentEntry.setHasMoreChildren( true, connection );
+ parentEntry.setHasChildrenHint( true, connection );
+
+ connection.cacheEntry( entry );
+ }
+ else
+ {
+ // ??
+ }
+ }
+
+ return entry;
+ }
+
+
+ private void initFlags( IEntry entry, LdifContentRecord record, SearchParameter search )
+ {
+
+ LdifAttrValLine[] lines = record.getAttrVals();
+ for ( int i = 0; i < lines.length; i++ )
+ {
+
+ String attributeName = lines[i].getUnfoldedAttributeDescription();
+
+ if ( search.isInitChildrenFlag() )
+ {
+ // hasChildren flag
+ if ( IAttribute.OPERATIONAL_ATTRIBUTE_HAS_SUBORDINATES.equalsIgnoreCase( attributeName ) )
+ {
+ if ( "FALSE".equalsIgnoreCase( lines[i].getValueAsString() ) ) { //$NON-NLS-1$
+ entry.setHasChildrenHint( false, connection );
+ }
+ }
+ if ( IAttribute.OPERATIONAL_ATTRIBUTE_NUM_SUBORDINATES.equalsIgnoreCase( attributeName ) )
+ {
+ if ( "0".equalsIgnoreCase( lines[i].getValueAsString() ) ) { //$NON-NLS-1$
+ entry.setHasChildrenHint( false, connection );
+ }
+ }
+ if ( IAttribute.OPERATIONAL_ATTRIBUTE_SUBORDINATE_COUNT.equalsIgnoreCase( attributeName ) )
+ {
+ if ( "0".equalsIgnoreCase( lines[i].getValueAsString() ) ) { //$NON-NLS-1$
+ entry.setHasChildrenHint( false, connection );
+ }
+ }
+ }
+
+ if ( search.isInitAliasAndReferralFlag() )
+ {
+ if ( IAttribute.OBJECTCLASS_ATTRIBUTE.equalsIgnoreCase( attributeName ) )
+ {
+ if ( ObjectClassDescription.OC_ALIAS.equalsIgnoreCase( lines[i].getValueAsString() ) )
+ {
+ entry.setAlias( true );
+ }
+ if ( ObjectClassDescription.OC_REFERRAL.equalsIgnoreCase( lines[i].getValueAsString() ) )
+ {
+ entry.setReferral( true );
+ }
+ }
+ }
+
+ }
+
+ if ( search.getControls() != null
+ && Arrays.asList( search.getControls() ).contains( Control.SUBENTRIES_CONTROL ) )
+ {
+ entry.setSubentry( true );
+ entry.setHasChildrenHint( false, connection );
+ }
+
+ }
+
+
+ private SearchParameter getSearchParameter( ISearch search )
+ {
+ SearchParameter searchParameter = ( SearchParameter ) search.getSearchParameter().clone();
+
+ // add children detetion attributes
+ if ( search.isInitChildrenFlag() )
+ {
+ if ( search.getConnection().getSchema().hasAttributeTypeDescription(
+ IAttribute.OPERATIONAL_ATTRIBUTE_HAS_SUBORDINATES )
+ && !Utils.containsIgnoreCase( Arrays.asList( searchParameter.getReturningAttributes() ),
+ IAttribute.OPERATIONAL_ATTRIBUTE_HAS_SUBORDINATES ) )
+ {
+ String[] returningAttributes = new String[searchParameter.getReturningAttributes().length + 1];
+ System.arraycopy( searchParameter.getReturningAttributes(), 0, returningAttributes, 0, searchParameter
+ .getReturningAttributes().length );
+ returningAttributes[returningAttributes.length - 1] = IAttribute.OPERATIONAL_ATTRIBUTE_HAS_SUBORDINATES;
+ searchParameter.setReturningAttributes( returningAttributes );
+ }
+ else if ( search.getConnection().getSchema().hasAttributeTypeDescription(
+ IAttribute.OPERATIONAL_ATTRIBUTE_NUM_SUBORDINATES )
+ && !Utils.containsIgnoreCase( Arrays.asList( searchParameter.getReturningAttributes() ),
+ IAttribute.OPERATIONAL_ATTRIBUTE_NUM_SUBORDINATES ) )
+ {
+ String[] returningAttributes = new String[searchParameter.getReturningAttributes().length + 1];
+ System.arraycopy( searchParameter.getReturningAttributes(), 0, returningAttributes, 0, searchParameter
+ .getReturningAttributes().length );
+ returningAttributes[returningAttributes.length - 1] = IAttribute.OPERATIONAL_ATTRIBUTE_NUM_SUBORDINATES;
+ searchParameter.setReturningAttributes( returningAttributes );
+ }
+ else if ( search.getConnection().getSchema().hasAttributeTypeDescription(
+ IAttribute.OPERATIONAL_ATTRIBUTE_SUBORDINATE_COUNT )
+ && !Utils.containsIgnoreCase( Arrays.asList( searchParameter.getReturningAttributes() ),
+ IAttribute.OPERATIONAL_ATTRIBUTE_SUBORDINATE_COUNT ) )
+ {
+ String[] returningAttributes = new String[searchParameter.getReturningAttributes().length + 1];
+ System.arraycopy( searchParameter.getReturningAttributes(), 0, returningAttributes, 0, searchParameter
+ .getReturningAttributes().length );
+ returningAttributes[returningAttributes.length - 1] = IAttribute.OPERATIONAL_ATTRIBUTE_SUBORDINATE_COUNT;
+ searchParameter.setReturningAttributes( returningAttributes );
+ }
+ }
+
+ // to init the alias/referral flag we need the objectClass
+ if ( search.isInitAliasAndReferralFlag() )
+ {
+ if ( !Utils.containsIgnoreCase( Arrays.asList( searchParameter.getReturningAttributes() ),
+ IAttribute.OBJECTCLASS_ATTRIBUTE ) )
+ {
+ String[] returningAttributes = new String[searchParameter.getReturningAttributes().length + 1];
+ System.arraycopy( searchParameter.getReturningAttributes(), 0, returningAttributes, 0, searchParameter
+ .getReturningAttributes().length );
+ returningAttributes[returningAttributes.length - 1] = IAttribute.OBJECTCLASS_ATTRIBUTE;
+ searchParameter.setReturningAttributes( returningAttributes );
+ }
+ }
+
+ // if returning attributes are requested but objectClass isn't included
+ // then add it
+ if ( search.getReturningAttributes() == null || search.getReturningAttributes().length > 0 )
+ {
+ if ( !Utils.containsIgnoreCase( Arrays.asList( searchParameter.getReturningAttributes() ),
+ IAttribute.OBJECTCLASS_ATTRIBUTE ) )
+ {
+ String[] returningAttributes = new String[searchParameter.getReturningAttributes().length + 1];
+ System.arraycopy( searchParameter.getReturningAttributes(), 0, returningAttributes, 0, searchParameter
+ .getReturningAttributes().length );
+ returningAttributes[returningAttributes.length - 1] = IAttribute.OBJECTCLASS_ATTRIBUTE;
+ searchParameter.setReturningAttributes( returningAttributes );
+ }
+ }
+
+ // filter controls if not supported by server
+ if ( searchParameter.getControls() != null )
+ {
+
+ Set suppportedConrolSet = new HashSet();
+ if ( connection.getRootDSE() != null
+ && connection.getRootDSE().getAttribute( IRootDSE.ROOTDSE_ATTRIBUTE_SUPPORTEDCONTROL ) != null )
+ {
+ IAttribute scAttribute = connection.getRootDSE().getAttribute(
+ IRootDSE.ROOTDSE_ATTRIBUTE_SUPPORTEDCONTROL );
+ String[] supportedControls = scAttribute.getStringValues();
+ for ( int i = 0; i < supportedControls.length; i++ )
+ {
+ suppportedConrolSet.add( supportedControls[i].toLowerCase() );
+ }
+ }
+
+ Control[] controls = searchParameter.getControls();
+ List controlList = new ArrayList();
+ for ( int i = 0; i < controls.length; i++ )
+ {
+ if ( suppportedConrolSet.contains( controls[i].getOid().toLowerCase() ) )
+ {
+ controlList.add( controls[i] );
+ }
+ }
+ searchParameter.setControls( ( Control[] ) controlList.toArray( new Control[controlList.size()] ) );
+ }
+
+ return searchParameter;
+ }
+
+
+ private void fillAttributes( IEntry entry, LdifContentRecord record, SearchParameter search )
+ throws ModelModificationException
+ {
+
+ if ( search.getReturningAttributes() == null || search.getReturningAttributes().length > 0 )
+ {
+
+ LdifAttrValLine[] lines = record.getAttrVals();
+
+ // clear old attributes defined as returing attributes or all
+ if ( search.getReturningAttributes() != null )
+ {
+ String[] ras = search.getReturningAttributes();
+ for ( int r = 0; r < ras.length; r++ )
+ {
+ String ra = ras[r];
+
+ IAttribute oldAttribute = entry.getAttribute( ra );
+ if ( oldAttribute != null )
+ {
+ if ( ra.equals( ISearch.ALL_USER_ATTRIBUTES ) && !oldAttribute.isOperationalAttribute() )
+ {
+ try
+ {
+ entry.deleteAttribute( oldAttribute, connection );
+ }
+ catch ( ModelModificationException e )
+ {
+ }
+ }
+ if ( ra.equals( ISearch.ALL_OPERATIONAL_ATTRIBUTES ) && oldAttribute.isOperationalAttribute() )
+ {
+ try
+ {
+ entry.deleteAttribute( oldAttribute, connection );
+ }
+ catch ( ModelModificationException e )
+ {
+ }
+ }
+ }
+
+ AttributeHierachie ah = entry.getAttributeWithSubtypes( ra );
+ if ( ah != null )
+ {
+ for ( Iterator it = ah.iterator(); it.hasNext(); )
+ {
+ IAttribute attribute = ( IAttribute ) it.next();
+ try
+ {
+ entry.deleteAttribute( attribute, connection );
+ }
+ catch ( ModelModificationException e )
+ {
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ // clear all
+ IAttribute[] oldAttributes = entry.getAttributes();
+ for ( int i = 0; oldAttributes != null && i < oldAttributes.length; i++ )
+ {
+ try
+ {
+ entry.deleteAttribute( oldAttributes[i], connection );
+ }
+ catch ( ModelModificationException e )
+ {
+ }
+ }
+ }
+
+ // Set attributeNameSet = null;
+ // if(search.getReturningAttributes() != null) {
+ // attributeNameSet = new
+ // HashSet(Arrays.asList(search.getReturningAttributes()));
+ // }
+ // IAttribute[] oldAttributes = entry.getAttributes();
+ // for(int i=0; oldAttributes!=null&&i<oldAttributes.length;
+ // i++) {
+ //
+ // if(attributeNameSet == null ||
+ // attributeNameSet.contains(oldAttributes[i].getDescription())
+ // ||
+ // (attributeNameSet.contains(ISearch.ALL_USER_ATTRIBUTES) &&
+ // !oldAttributes[i].isOperationalAttribute()) ||
+ // (attributeNameSet.contains(ISearch.ALL_OPERATIONAL_ATTRIBUTES)
+ // && oldAttributes[i].isOperationalAttribute())
+ // ) {
+ // try {
+ // entry.deleteAttribute(oldAttributes[i], connection);
+ // } catch (ModelModificationException e) {
+ // }
+ // }
+ // }
+
+ // additional clear old attributes if the record contains the
+ // attribute
+ for ( int i = 0; i < lines.length; i++ )
+ {
+ String attributeDesc = lines[i].getUnfoldedAttributeDescription();
+ IAttribute oldAttribute = entry.getAttribute( attributeDesc );
+ if ( oldAttribute != null )
+ {
+ try
+ {
+ entry.deleteAttribute( oldAttribute, connection );
+ }
+ catch ( ModelModificationException mme )
+ {
+ }
+ }
+ }
+
+ // set new attributes and values
+ for ( int i = 0; i < lines.length; i++ )
+ {
+
+ IAttribute attribute = null;
+ String attributeName = lines[i].getUnfoldedAttributeDescription();
+ // attributeName = attributeName.replaceAll(";binary", "");
+ if ( entry.getAttribute( attributeName ) == null )
+ {
+ attribute = new Attribute( entry, attributeName );
+ entry.addAttribute( attribute, connection );
+ }
+ else
+ {
+ attribute = entry.getAttribute( attributeName );
+ }
+
+ attribute.addValue( new Value( attribute, lines[i].getValueAsObject() ), connection );
+ }
+ }
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/Credentials.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/Credentials.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/Credentials.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/Credentials.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.core.internal.model;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.ConnectionParameter;
+import org.apache.directory.ldapstudio.browser.core.model.ICredentials;
+
+
+public class Credentials implements ICredentials
+{
+
+ private String bindDN;
+
+ private String bindPassword;
+
+ private ConnectionParameter connectionParameter;
+
+
+ public Credentials( String bindDN, String bindPassword, ConnectionParameter connectionParameter )
+ {
+ this.bindDN = bindDN;
+ this.bindPassword = bindPassword;
+ this.connectionParameter = connectionParameter;
+ }
+
+
+ public ConnectionParameter getConnectionParameter()
+ {
+ return connectionParameter;
+ }
+
+
+ public String getBindDN()
+ {
+ return bindDN;
+ }
+
+
+ public String getBindPassword()
+ {
+ return bindPassword;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/DelegateEntry.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/DelegateEntry.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/DelegateEntry.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/DelegateEntry.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,543 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.core.internal.model;
+
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCorePlugin;
+import org.apache.directory.ldapstudio.browser.core.events.AttributeAddedEvent;
+import org.apache.directory.ldapstudio.browser.core.events.AttributeDeletedEvent;
+import org.apache.directory.ldapstudio.browser.core.events.AttributesInitializedEvent;
+import org.apache.directory.ldapstudio.browser.core.events.ChildrenInitializedEvent;
+import org.apache.directory.ldapstudio.browser.core.events.EmptyValueAddedEvent;
+import org.apache.directory.ldapstudio.browser.core.events.EmptyValueDeletedEvent;
+import org.apache.directory.ldapstudio.browser.core.events.EntryModificationEvent;
+import org.apache.directory.ldapstudio.browser.core.events.EntryUpdateListener;
+import org.apache.directory.ldapstudio.browser.core.events.EventRegistry;
+import org.apache.directory.ldapstudio.browser.core.events.ModelModifier;
+import org.apache.directory.ldapstudio.browser.core.events.ValueAddedEvent;
+import org.apache.directory.ldapstudio.browser.core.events.ValueDeletedEvent;
+import org.apache.directory.ldapstudio.browser.core.events.ValueModifiedEvent;
+import org.apache.directory.ldapstudio.browser.core.events.ValueRenamedEvent;
+import org.apache.directory.ldapstudio.browser.core.internal.search.LdapSearchPageScoreComputer;
+import org.apache.directory.ldapstudio.browser.core.model.AttributeHierachie;
+import org.apache.directory.ldapstudio.browser.core.model.DN;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.ModelModificationException;
+import org.apache.directory.ldapstudio.browser.core.model.RDN;
+import org.apache.directory.ldapstudio.browser.core.model.URL;
+import org.apache.directory.ldapstudio.browser.core.model.schema.Subschema;
+import org.eclipse.search.ui.ISearchPageScoreComputer;
+
+
+public class DelegateEntry implements IEntry, EntryUpdateListener
+{
+
+ private static final long serialVersionUID = -4488685394817691963L;
+
+ // private IConnection connection;
+ private String connectionName;
+
+ private DN dn;
+
+ private boolean entryDoesNotExist;
+
+ private IEntry delegate;
+
+
+ protected DelegateEntry()
+ {
+ }
+
+
+ public DelegateEntry( IConnection connection, DN dn )
+ {
+ this.connectionName = connection.getName();
+ this.dn = dn;
+ this.entryDoesNotExist = false;
+ this.delegate = null;
+ EventRegistry.addEntryUpdateListener( this );
+ }
+
+
+ protected IEntry getDelegate()
+ {
+ if ( this.delegate != null && !this.delegate.getConnection().isOpened() )
+ {
+ this.entryDoesNotExist = false;
+ this.delegate = null;
+ }
+ return delegate;
+ }
+
+
+ protected void setDelegate( IEntry delegate )
+ {
+ this.delegate = delegate;
+ }
+
+
+ public IConnection getConnection()
+ {
+ if ( this.getDelegate() != null )
+ return getDelegate().getConnection();
+ else
+ return BrowserCorePlugin.getDefault().getConnectionManager().getConnection( this.connectionName );
+ // return connection;
+ }
+
+
+ public DN getDn()
+ {
+ if ( this.getDelegate() != null )
+ return getDelegate().getDn();
+ else
+ return dn;
+ }
+
+
+ public URL getUrl()
+ {
+ if ( this.getDelegate() != null )
+ return getDelegate().getUrl();
+ else
+ return new URL( getConnection(), getDn() );
+ }
+
+
+ public boolean isAttributesInitialized()
+ {
+ if ( this.getDelegate() != null )
+ return getDelegate().isAttributesInitialized();
+ else if ( this.entryDoesNotExist )
+ return true;
+ else
+ return false;
+ }
+
+
+ public boolean isChildrenInitialized()
+ {
+ if ( this.getDelegate() != null )
+ return getDelegate().isChildrenInitialized();
+ else if ( this.entryDoesNotExist )
+ return true;
+ else
+ return false;
+ }
+
+
+ public boolean isDirectoryEntry()
+ {
+ if ( this.getDelegate() != null )
+ return getDelegate().isDirectoryEntry();
+ else
+ return true;
+ }
+
+
+ public void addAttribute( IAttribute attributeToAdd, ModelModifier source ) throws ModelModificationException
+ {
+ if ( this.getDelegate() != null )
+ getDelegate().addAttribute( attributeToAdd, source );
+ }
+
+
+ public void addChild( IEntry childrenToAdd, ModelModifier source )
+ {
+ if ( this.getDelegate() != null )
+ getDelegate().addChild( childrenToAdd, source );
+ }
+
+
+ public void deleteAttribute( IAttribute attributeToDelete, ModelModifier source ) throws ModelModificationException
+ {
+ if ( this.getDelegate() != null )
+ getDelegate().deleteAttribute( attributeToDelete, source );
+ }
+
+
+ public void deleteChild( IEntry childrenToDelete, ModelModifier source )
+ {
+ if ( this.getDelegate() != null )
+ getDelegate().deleteChild( childrenToDelete, source );
+ }
+
+
+ public IAttribute getAttribute( String attributeDescription )
+ {
+ if ( this.getDelegate() != null )
+ return getDelegate().getAttribute( attributeDescription );
+ else
+ return null;
+ }
+
+
+ public AttributeHierachie getAttributeWithSubtypes( String attributeDescription )
+ {
+ if ( this.getDelegate() != null )
+ return getDelegate().getAttributeWithSubtypes( attributeDescription );
+ else
+ return null;
+ }
+
+
+ public IAttribute[] getAttributes()
+ {
+ if ( this.getDelegate() != null )
+ return getDelegate().getAttributes();
+ else
+ return null;
+ }
+
+
+ public IEntry getParententry()
+ {
+ if ( this.getDelegate() != null )
+ return getDelegate().getParententry();
+ else
+ return null;
+ }
+
+
+ public RDN getRdn()
+ {
+ if ( this.getDelegate() != null )
+ return getDelegate().getRdn();
+ else
+ return this.dn.getRdn();
+ }
+
+
+ public IEntry[] getChildren()
+ {
+ if ( this.getDelegate() != null )
+ return getDelegate().getChildren();
+ else
+ return null;
+ }
+
+
+ public int getChildrenCount()
+ {
+ if ( this.getDelegate() != null )
+ return getDelegate().getChildrenCount();
+ else
+ return -1;
+ }
+
+
+ public String getChildrenFilter()
+ {
+ if ( this.getDelegate() != null )
+ return getDelegate().getChildrenFilter();
+ else
+ return null;
+ }
+
+
+ public Subschema getSubschema()
+ {
+ if ( this.getDelegate() != null )
+ return getDelegate().getSubschema();
+ else
+ return null;
+ }
+
+
+ public boolean hasMoreChildren()
+ {
+ if ( this.getDelegate() != null )
+ return getDelegate().hasMoreChildren();
+ else
+ return false;
+ }
+
+
+ public boolean hasParententry()
+ {
+ if ( this.getDelegate() != null )
+ return getDelegate().hasParententry();
+ else
+ return false;
+ }
+
+
+ public boolean hasChildren()
+ {
+ if ( this.getDelegate() != null )
+ return getDelegate().hasChildren();
+ else
+ return true;
+ }
+
+
+ public boolean isConsistent()
+ {
+ if ( this.getDelegate() != null )
+ return getDelegate().isConsistent();
+ else
+ return true;
+ }
+
+
+ public void setAttributesInitialized( boolean b, ModelModifier source )
+ {
+
+ if ( !b )
+ {
+ if ( this.getDelegate() != null )
+ {
+ getDelegate().setAttributesInitialized( b, source );
+ }
+ setDelegate( null );
+ this.entryDoesNotExist = false;
+ }
+ else
+ /* if(b) */{
+ if ( this.getDelegate() == null )
+ {
+ setDelegate( this.getConnection().getEntryFromCache( this.dn ) );
+ if ( this.getDelegate() == null )
+ {
+ // entry doesn't exist!
+ this.entryDoesNotExist = true;
+ }
+ }
+ if ( this.getDelegate() != null )
+ {
+ getDelegate().setAttributesInitialized( b, source );
+ }
+ }
+ }
+
+
+ public void setDirectoryEntry( boolean b )
+ {
+ if ( this.getDelegate() != null )
+ getDelegate().setDirectoryEntry( b );
+ }
+
+
+ public void setHasMoreChildren( boolean b, ModelModifier source )
+ {
+ if ( this.getDelegate() != null )
+ getDelegate().setHasMoreChildren( b, source );
+ }
+
+
+ public void setHasChildrenHint( boolean b, ModelModifier source )
+ {
+ if ( this.getDelegate() != null )
+ getDelegate().setHasChildrenHint( b, source );
+ }
+
+
+ public void setChildrenFilter( String filter )
+ {
+ if ( this.getDelegate() != null )
+ getDelegate().setChildrenFilter( filter );
+ }
+
+
+ public void setChildrenInitialized( boolean b, ModelModifier source )
+ {
+
+ if ( !b )
+ {
+ if ( this.getDelegate() != null )
+ {
+ getDelegate().setChildrenInitialized( b, source );
+ }
+ // setDelegate(null);
+ this.entryDoesNotExist = false;
+ }
+ else
+ /* if(b) */{
+ if ( this.getDelegate() == null )
+ {
+ setDelegate( this.getConnection().getEntryFromCache( this.dn ) );
+ if ( this.getDelegate() == null )
+ {
+ // entry doesn't exist!
+ this.entryDoesNotExist = true;
+ }
+ }
+ if ( this.getDelegate() != null )
+ {
+ getDelegate().setChildrenInitialized( b, source );
+ }
+ }
+ }
+
+
+ public boolean isAlias()
+ {
+ if ( this.getDelegate() != null )
+ return getDelegate().isAlias();
+ else
+ return false;
+ }
+
+
+ public void setAlias( boolean b )
+ {
+ if ( this.getDelegate() != null )
+ getDelegate().setAlias( b );
+ }
+
+
+ public boolean isReferral()
+ {
+ if ( this.getDelegate() != null )
+ return getDelegate().isReferral();
+ else
+ return false;
+ }
+
+
+ public void setReferral( boolean b )
+ {
+ if ( this.getDelegate() != null )
+ getDelegate().setReferral( b );
+ }
+
+
+ public boolean isSubentry()
+ {
+ if ( this.getDelegate() != null )
+ return getDelegate().isSubentry();
+ else
+ return false;
+ }
+
+
+ public void setSubentry( boolean b )
+ {
+ if ( this.getDelegate() != null )
+ getDelegate().setSubentry( b );
+ }
+
+
+ public void entryUpdated( EntryModificationEvent event )
+ {
+
+ if ( event.getModifiedEntry() == this.getDelegate() )
+ {
+
+ if ( event instanceof AttributeAddedEvent )
+ {
+ AttributeAddedEvent e = ( AttributeAddedEvent ) event;
+ AttributeAddedEvent delegateEvent = new AttributeAddedEvent( e.getOriginalConnection(), this, e
+ .getAddedAttribute(), e.getSource() );
+ EventRegistry.fireEntryUpdated( delegateEvent, this );
+ }
+ else if ( event instanceof AttributeDeletedEvent )
+ {
+ AttributeDeletedEvent e = ( AttributeDeletedEvent ) event;
+ AttributeDeletedEvent delegateEvent = new AttributeDeletedEvent( e.getOriginalConnection(), this, e
+ .getDeletedAttribute(), e.getSource() );
+ EventRegistry.fireEntryUpdated( delegateEvent, this );
+ }
+ else if ( event instanceof AttributesInitializedEvent )
+ {
+ AttributesInitializedEvent e = ( AttributesInitializedEvent ) event;
+ AttributesInitializedEvent delegateEvent = new AttributesInitializedEvent( this, e.getSource() );
+ EventRegistry.fireEntryUpdated( delegateEvent, this );
+ }
+ else if ( event instanceof EmptyValueAddedEvent )
+ {
+ EmptyValueAddedEvent e = ( EmptyValueAddedEvent ) event;
+ EmptyValueAddedEvent delegateEvent = new EmptyValueAddedEvent( e.getOriginalConnection(), this, e
+ .getModifiedAttribute(), e.getAddedValue(), e.getSource() );
+ EventRegistry.fireEntryUpdated( delegateEvent, this );
+ }
+ else if ( event instanceof EmptyValueDeletedEvent )
+ {
+ EmptyValueDeletedEvent e = ( EmptyValueDeletedEvent ) event;
+ EmptyValueDeletedEvent delegateEvent = new EmptyValueDeletedEvent( e.getOriginalConnection(), this, e
+ .getModifiedAttribute(), e.getDeletedValue(), e.getSource() );
+ EventRegistry.fireEntryUpdated( delegateEvent, this );
+ }
+ // EntryAddedEvent
+ // EntryDeletedEvent
+ // EntryMovedEvent
+ // EntryRenamedEvent
+ else if ( event instanceof ChildrenInitializedEvent )
+ {
+ ChildrenInitializedEvent e = ( ChildrenInitializedEvent ) event;
+ ChildrenInitializedEvent delegateEvent = new ChildrenInitializedEvent( this, e.getSource() );
+ EventRegistry.fireEntryUpdated( delegateEvent, this );
+ }
+ else if ( event instanceof ValueAddedEvent )
+ {
+ ValueAddedEvent e = ( ValueAddedEvent ) event;
+ ValueAddedEvent delegateEvent = new ValueAddedEvent( e.getOriginalConnection(), this, e
+ .getModifiedAttribute(), e.getAddedValue(), e.getSource() );
+ EventRegistry.fireEntryUpdated( delegateEvent, this );
+ }
+ else if ( event instanceof ValueDeletedEvent )
+ {
+ ValueDeletedEvent e = ( ValueDeletedEvent ) event;
+ ValueDeletedEvent delegateEvent = new ValueDeletedEvent( e.getOriginalConnection(), this, e
+ .getModifiedAttribute(), e.getDeletedValue(), e.getSource() );
+ EventRegistry.fireEntryUpdated( delegateEvent, this );
+ }
+ else if ( event instanceof ValueModifiedEvent )
+ {
+ ValueModifiedEvent e = ( ValueModifiedEvent ) event;
+ ValueModifiedEvent delegateEvent = new ValueModifiedEvent( e.getOriginalConnection(), this, e
+ .getModifiedAttribute(), e.getOldValue(), e.getNewValue(), e.getSource() );
+ EventRegistry.fireEntryUpdated( delegateEvent, this );
+ }
+ else if ( event instanceof ValueRenamedEvent )
+ {
+ ValueRenamedEvent e = ( ValueRenamedEvent ) event;
+ ValueRenamedEvent delegateEvent = new ValueRenamedEvent( e.getOriginalConnection(), this, e
+ .getOldValue(), e.getNewValue(), e.getSource() );
+ EventRegistry.fireEntryUpdated( delegateEvent, this );
+ }
+ // ValuesSetEvent
+
+ }
+ }
+
+
+ public Object getAdapter( Class adapter )
+ {
+
+ if ( adapter.isAssignableFrom( ISearchPageScoreComputer.class ) )
+ {
+ return new LdapSearchPageScoreComputer();
+ }
+ if ( adapter == IConnection.class )
+ {
+ return this.getConnection();
+ }
+ if ( adapter == IEntry.class )
+ {
+ return this;
+ }
+ return null;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/DirectoryMetadataEntry.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/DirectoryMetadataEntry.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/DirectoryMetadataEntry.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/DirectoryMetadataEntry.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.core.internal.model;
+
+
+import org.apache.directory.ldapstudio.browser.core.events.ModelModifier;
+import org.apache.directory.ldapstudio.browser.core.model.DN;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.ModelModificationException;
+
+
+public class DirectoryMetadataEntry extends BaseDNEntry
+{
+
+ private static final long serialVersionUID = 1340597532850853276L;
+
+ private boolean schemaEntry;
+
+
+ protected DirectoryMetadataEntry()
+ {
+ }
+
+
+ public DirectoryMetadataEntry( DN dn, IConnection connection, ModelModifier source )
+ throws ModelModificationException
+ {
+ super();
+ this.baseDn = dn;
+ // this.connectionName = connection.getName();
+ this.connection = connection;
+ this.schemaEntry = false;
+ }
+
+
+ public boolean hasChildren()
+ {
+ if ( getDn().equals( getConnection().getSchema().getDn() ) )
+ {
+ return false;
+ }
+ else
+ {
+ return super.hasChildren();
+ }
+ }
+
+
+ public boolean isSchemaEntry()
+ {
+ return schemaEntry;
+ }
+
+
+ public void setSchemaEntry( boolean schemaEntry )
+ {
+ this.schemaEntry = schemaEntry;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/DummyConnection.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/DummyConnection.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/DummyConnection.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/DummyConnection.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,426 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.core.internal.model;
+
+
+import java.io.Writer;
+
+import org.apache.directory.ldapstudio.browser.core.BookmarkManager;
+import org.apache.directory.ldapstudio.browser.core.SearchManager;
+import org.apache.directory.ldapstudio.browser.core.jobs.ExtendedProgressMonitor;
+import org.apache.directory.ldapstudio.browser.core.model.ConnectionParameter;
+import org.apache.directory.ldapstudio.browser.core.model.DN;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.IRootDSE;
+import org.apache.directory.ldapstudio.browser.core.model.ISearch;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.core.model.SearchParameter;
+import org.apache.directory.ldapstudio.browser.core.model.URL;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.LdifEnumeration;
+import org.apache.directory.ldapstudio.browser.core.model.schema.Schema;
+
+
+public class DummyConnection implements IConnection
+{
+
+ private static final long serialVersionUID = 3671686808330691741L;
+
+ private Schema schema;
+
+
+ public DummyConnection( Schema schema )
+ {
+ this.schema = schema;
+ }
+
+
+ public void bind( ExtendedProgressMonitor monitor )
+ {
+ }
+
+
+ public boolean canClose()
+ {
+ return false;
+ }
+
+
+ public boolean canOpen()
+ {
+ return false;
+ }
+
+
+ public void close()
+ {
+ }
+
+
+ public void connect( ExtendedProgressMonitor monitor )
+ {
+ }
+
+
+ public void create( IEntry entryToCreate, ExtendedProgressMonitor monitor )
+ {
+ }
+
+
+ public void create( IValue[] valuesToCreate, ExtendedProgressMonitor monitor )
+ {
+ }
+
+
+ public void delete( IEntry entryToDelete, ExtendedProgressMonitor monitor )
+ {
+ }
+
+
+ public void delete( IValue[] valuesToDelete, ExtendedProgressMonitor monitor )
+ {
+
+ }
+
+
+ public void delete( IAttribute[] attriubtesToDelete, ExtendedProgressMonitor monitor )
+ {
+
+ }
+
+
+ public boolean existsEntry( DN dn, ExtendedProgressMonitor monitor )
+ {
+ return false;
+ }
+
+
+ public LdifEnumeration exportLdif( SearchParameter searchParameter, ExtendedProgressMonitor pm )
+ throws ConnectionException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public void fetchRootDSE( ExtendedProgressMonitor monitor )
+ {
+ }
+
+
+ public int getAuthMethod()
+ {
+ return AUTH_ANONYMOUS;
+ }
+
+
+ public DN getBaseDN()
+ {
+ return new DN();
+ }
+
+
+ public IEntry[] getBaseDNEntries()
+ {
+ return new IEntry[0];
+ }
+
+
+ public String getBindPrincipal()
+ {
+ return null;
+ }
+
+
+ public String getBindPassword()
+ {
+ return null;
+ }
+
+
+ public BookmarkManager getBookmarkManager()
+ {
+ return null;
+ }
+
+
+ public ConnectionParameter getConnectionParameter()
+ {
+ return null;
+ }
+
+
+ public int getCountLimit()
+ {
+ return 0;
+ }
+
+
+ public int getAliasesDereferencingMethod()
+ {
+ return DEREFERENCE_ALIASES_NEVER;
+ }
+
+
+ public int getEncryptionMethod()
+ {
+ return ENCYRPTION_NONE;
+ }
+
+
+ public IEntry getEntry( DN dn, ExtendedProgressMonitor monitor )
+ {
+ return null;
+ }
+
+
+ public IEntry getEntryFromCache( DN dn )
+ {
+ return null;
+ }
+
+
+ public String getHost()
+ {
+ return null;
+ }
+
+
+ public IEntry[] getMetadataEntries()
+ {
+ return new IEntry[0];
+ }
+
+
+ public String getName()
+ {
+ return null;
+ }
+
+
+ public int getPort()
+ {
+ return -1;
+ }
+
+
+ public IRootDSE getRootDSE()
+ {
+ return null;
+ }
+
+
+ public Schema getSchema()
+ {
+ return schema;
+ }
+
+
+ public SearchManager getSearchManager()
+ {
+ return null;
+ }
+
+
+ public int getTimeLimit()
+ {
+ return 0;
+ }
+
+
+ public void importLdif( LdifEnumeration enumeration, Writer logWriter, boolean continueOnError,
+ ExtendedProgressMonitor monitor )
+ {
+
+ }
+
+
+ public boolean isFetchBaseDNs()
+ {
+ return false;
+ }
+
+
+ public boolean isOpened()
+ {
+ return true;
+ }
+
+
+ public boolean isSuspended()
+ {
+ return true;
+ }
+
+
+ public void modify( IValue oldValue, IValue newVaue, ExtendedProgressMonitor monitor )
+ {
+ }
+
+
+ public void open( ExtendedProgressMonitor monitor )
+ {
+ }
+
+
+ public void reloadSchema( ExtendedProgressMonitor monitor )
+ {
+ }
+
+
+ public void move( IEntry entryToMove, DN newSuperior, ExtendedProgressMonitor monitor )
+ {
+ }
+
+
+ public void rename( IEntry entryToRename, DN newDn, boolean deleteOldRdn, ExtendedProgressMonitor monitor )
+ {
+ }
+
+
+ public void reset()
+ {
+ }
+
+
+ public void resume( ExtendedProgressMonitor monitor )
+ {
+ }
+
+
+ public void search( ISearch searchRequest, ExtendedProgressMonitor monitor )
+ {
+ }
+
+
+ public void setAuthMethod( int authMethod )
+ {
+ }
+
+
+ public void setBaseDN( DN baseDN )
+ {
+ }
+
+
+ public void setBindPrincipal( String bindPrincipal )
+ {
+ }
+
+
+ public void setBindPassword( String bindPassword )
+ {
+ }
+
+
+ public void setConnectionParameter( ConnectionParameter connectionParameter )
+ {
+ }
+
+
+ public void setCountLimit( int countLimit )
+ {
+ }
+
+
+ public void setAliasesDereferencingMethod( int aliasesDereferencingMethod )
+ {
+ }
+
+
+ public void setEncryptionMethod( int encryptionMethod )
+ {
+ }
+
+
+ public void setFetchBaseDNs( boolean fetchBaseDNs )
+ {
+ }
+
+
+ public void setHost( String host )
+ {
+ }
+
+
+ public void setName( String name )
+ {
+ }
+
+
+ public void setPort( int port )
+ {
+ }
+
+
+ public void setSchema( Schema schema )
+ {
+ this.schema = schema;
+ }
+
+
+ public void setTimeLimit( int timeLimit )
+ {
+
+ }
+
+
+ public void suspend()
+ {
+
+ }
+
+
+ public Object getAdapter( Class adapter )
+ {
+ return null;
+ }
+
+
+ public Object clone()
+ {
+ return this;
+ }
+
+
+ public ModificationLogger getModificationLogger()
+ {
+ return null;
+ }
+
+
+ public int getReferralsHandlingMethod()
+ {
+ return HANDLE_REFERRALS_IGNORE;
+ }
+
+
+ public void setReferralsHandlingMethod( int referralsHandlingMethod )
+ {
+ }
+
+
+ public URL getUrl()
+ {
+ return null;
+ }
+
+}