directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r592082 [7/20] - in /directory/sandbox/felixk/studio-ldapbrowser-core: ./ META-INF/ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/directory/ src/main/java/org/apache/directory/studio/ sr...
Date Mon, 05 Nov 2007 16:52:07 GMT
Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ReloadSchemasJob.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ReloadSchemasJob.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ReloadSchemasJob.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ReloadSchemasJob.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,181 @@
+/*
+ *  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.studio.ldapbrowser.core.jobs;
+
+
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.connection.core.StudioProgressMonitor;
+import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
+import org.apache.directory.studio.ldapbrowser.core.events.BrowserConnectionUpdateEvent;
+import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry;
+import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.IRootDSE;
+import org.apache.directory.studio.ldapbrowser.core.model.SearchParameter;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearch.SearchScope;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.LdifEnumeration;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.container.LdifContentRecord;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema;
+
+
+/**
+ * Job to reload the schema.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ReloadSchemasJob extends AbstractNotificationJob
+{
+
+    /** The browser connection. */
+    private IBrowserConnection browserConnection;
+
+
+    /**
+     * Creates a new instance of ReloadSchemasJob.
+     * 
+     * @param browserConnection the browser connection
+     */
+    public ReloadSchemasJob( IBrowserConnection browserConnection )
+    {
+        this.browserConnection = browserConnection;
+        setName( BrowserCoreMessages.jobs__reload_schemas_name_1 );
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractEclipseJob#getConnections()
+     */
+    protected Connection[] getConnections()
+    {
+        return new Connection[]
+            { browserConnection.getConnection() };
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractEclipseJob#getLockedObjects()
+     */
+    protected Object[] getLockedObjects()
+    {
+        return new IBrowserConnection[]
+            { browserConnection };
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractNotificationJob#executeNotificationJob(org.apache.directory.studio.connection.core.StudioProgressMonitor)
+     */
+    protected void executeNotificationJob( StudioProgressMonitor monitor )
+    {
+        monitor.beginTask( " ", 3 ); //$NON-NLS-1$
+        monitor.reportProgress( " " ); //$NON-NLS-1$
+
+        monitor.setTaskName( BrowserCoreMessages.bind( BrowserCoreMessages.jobs__reload_schemas_task, new String[]
+            { browserConnection.getConnection().getName() } ) );
+        monitor.worked( 1 );
+
+        // load root DSE
+        monitor.reportProgress( BrowserCoreMessages.model__loading_rootdse );
+        InitializeAttributesJob.initializeAttributes( browserConnection.getRootDSE(), true, monitor );
+        monitor.worked( 1 );
+        
+        // load schema
+        monitor.reportProgress( BrowserCoreMessages.model__loading_schema );
+        reloadSchema( browserConnection, monitor );
+        monitor.worked( 1 );
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractNotificationJob#runNotification()
+     */
+    protected void runNotification()
+    {
+        BrowserConnectionUpdateEvent browserConnectionUpdateEvent = new BrowserConnectionUpdateEvent(
+            browserConnection, BrowserConnectionUpdateEvent.Detail.SCHEMA_UPDATED );
+        EventRegistry.fireBrowserConnectionUpdated( browserConnectionUpdateEvent, this );
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractEclipseJob#getErrorMessage()
+     */
+    protected String getErrorMessage()
+    {
+        return BrowserCoreMessages.jobs__reload_schemas_error_1;
+    }
+    
+
+    /**
+     * Reloads the schema.
+     * 
+     * @param browserConnection the browser connection
+     * @param monitor the progress monitor
+     */
+    public static void reloadSchema( IBrowserConnection browserConnection, StudioProgressMonitor monitor )
+    {
+        browserConnection.setSchema( Schema.DEFAULT_SCHEMA );
+
+        try
+        {
+            if ( browserConnection.getRootDSE().getAttribute( IRootDSE.ROOTDSE_ATTRIBUTE_SUBSCHEMASUBENTRY ) != null )
+            {
+                SearchParameter sp = new SearchParameter();
+                sp.setSearchBase( new LdapDN( browserConnection.getRootDSE().getAttribute( IRootDSE.ROOTDSE_ATTRIBUTE_SUBSCHEMASUBENTRY )
+                    .getStringValue() ) );
+                sp.setFilter( Schema.SCHEMA_FILTER );
+                sp.setScope( SearchScope.OBJECT );
+                sp.setReturningAttributes( new String[]
+                    { Schema.SCHEMA_ATTRIBUTE_OBJECTCLASSES, Schema.SCHEMA_ATTRIBUTE_ATTRIBUTETYPES,
+                        Schema.SCHEMA_ATTRIBUTE_LDAPSYNTAXES, Schema.SCHEMA_ATTRIBUTE_MATCHINGRULES,
+                        Schema.SCHEMA_ATTRIBUTE_MATCHINGRULEUSE, IAttribute.OPERATIONAL_ATTRIBUTE_CREATE_TIMESTAMP,
+                        IAttribute.OPERATIONAL_ATTRIBUTE_MODIFY_TIMESTAMP, } );
+                
+                LdifEnumeration le = ExportLdifJob.search( browserConnection, sp, monitor );
+                if ( le.hasNext( monitor ) )
+                {
+                    LdifContentRecord schemaRecord = ( LdifContentRecord ) le.next( monitor );
+                    Schema schema = new Schema();
+                    schema.loadFromRecord( schemaRecord );
+                    browserConnection.setSchema( schema );
+                    // TODO: Schema update event
+//                    EventRegistry.fireConnectionUpdated( new ConnectionUpdateEvent( this,
+//                        ConnectionUpdateEvent.EventDetail.SCHEMA_LOADED ), this );
+                }
+                else
+                {
+                    monitor.reportError( BrowserCoreMessages.model__no_schema_information );
+                }
+            }
+            else
+            {
+                monitor.reportError( BrowserCoreMessages.model__missing_schema_location );
+            }
+        }
+        catch ( Exception e )
+        {
+            monitor.reportError( BrowserCoreMessages.model__error_loading_schema, e );
+            e.printStackTrace();
+        }
+    }
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ReloadSchemasJob.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameEntryJob.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameEntryJob.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameEntryJob.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameEntryJob.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,232 @@
+/*
+ *  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.studio.ldapbrowser.core.jobs;
+
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.naming.ldap.Control;
+import javax.naming.ldap.ManageReferralControl;
+
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.name.Rdn;
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.connection.core.StudioProgressMonitor;
+import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
+import org.apache.directory.studio.ldapbrowser.core.events.EntryRenamedEvent;
+import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry;
+import org.apache.directory.studio.ldapbrowser.core.events.SearchUpdateEvent;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult;
+import org.apache.directory.studio.ldapbrowser.core.utils.DnUtils;
+
+
+/**
+ * Job to rename an entry.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class RenameEntryJob extends AbstractNotificationJob
+{
+
+    /** The browser connection. */
+    private IBrowserConnection browserConnection;
+
+    /** The old entry. */
+    private IEntry oldEntry;
+
+    /** The new rdn. */
+    private Rdn newRdn;
+
+    /** The delete old rdn flag. */
+    private boolean deleteOldRdn;
+
+    /** The new entry. */
+    private IEntry newEntry;
+
+    /** The updated searches. */
+    private Set<ISearch> updatedSearchesSet = new HashSet<ISearch>();
+
+
+    /**
+     * Creates a new instance of RenameEntryJob.
+     * 
+     * @param entry the entry to rename
+     * @param newRdn the new rdn
+     * @param deleteOldRdn the delete old rdn flag
+     */
+    public RenameEntryJob( IEntry entry, Rdn newRdn, boolean deleteOldRdn )
+    {
+        this.browserConnection = entry.getBrowserConnection();
+        this.oldEntry = entry;
+        this.newEntry = entry;
+        this.newRdn = newRdn;
+        this.deleteOldRdn = deleteOldRdn;
+
+        setName( BrowserCoreMessages.jobs__rename_entry_name );
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractEclipseJob#getConnections()
+     */
+    protected Connection[] getConnections()
+    {
+        return new Connection[]
+            { browserConnection.getConnection() };
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractEclipseJob#getLockedObjects()
+     */
+    protected Object[] getLockedObjects()
+    {
+        List<Object> l = new ArrayList<Object>();
+        l.add( oldEntry.getParententry() );
+        return l.toArray();
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractNotificationJob#executeNotificationJob(org.apache.directory.studio.connection.core.StudioProgressMonitor)
+     */
+    protected void executeNotificationJob( StudioProgressMonitor monitor )
+    {
+        monitor.beginTask( BrowserCoreMessages.bind( BrowserCoreMessages.jobs__rename_entry_task, new String[]
+            { oldEntry.getDn().getUpName() } ), 3 );
+        monitor.reportProgress( " " ); //$NON-NLS-1$
+        monitor.worked( 1 );
+
+        IEntry parent = oldEntry.getParententry();
+        LdapDN newDn = DnUtils.composeDn( newRdn, parent.getDn() );
+
+        // rename in directory
+        // TODO: use manual/simulated rename, if rename of subtree is not
+        // supported
+        renameEntry( browserConnection, oldEntry, newDn, deleteOldRdn, monitor );
+
+        if ( !monitor.errorsReported() )
+        {
+            // uncache old entry
+            browserConnection.uncacheEntryRecursive( oldEntry );
+
+            // rename in parent
+            parent.deleteChild( oldEntry );
+            newEntry = ReadEntryJob.getEntry( browserConnection, newDn, monitor );
+            parent.addChild( newEntry );
+            parent.setHasMoreChildren( false );
+
+            newEntry.setHasChildrenHint( oldEntry.hasChildren() );
+            if ( oldEntry.isChildrenInitialized() )
+            {
+                InitializeChildrenJob.initializeChildren( newEntry, monitor );
+            }
+
+            // rename in searches
+            ISearch[] searches = browserConnection.getSearchManager().getSearches();
+            for ( int j = 0; j < searches.length; j++ )
+            {
+                ISearch search = searches[j];
+                if ( search.getSearchResults() != null )
+                {
+                    ISearchResult[] searchResults = search.getSearchResults();
+                    for ( int k = 0; k < searchResults.length; k++ )
+                    {
+                        ISearchResult result = searchResults[k];
+                        if ( oldEntry.equals( result.getEntry() ) )
+                        {
+                            ISearchResult[] newsrs = new ISearchResult[searchResults.length - 1];
+                            System.arraycopy( searchResults, 0, newsrs, 0, k );
+                            System.arraycopy( searchResults, k + 1, newsrs, k, searchResults.length - k - 1 );
+                            search.setSearchResults( newsrs );
+                            searchResults = newsrs;
+                            k--;
+                            updatedSearchesSet.add( search );
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractNotificationJob#runNotification()
+     */
+    protected void runNotification()
+    {
+        if ( oldEntry != null && newEntry != null )
+        {
+            EventRegistry.fireEntryUpdated( new EntryRenamedEvent( oldEntry, newEntry ), this );
+        }
+        for ( ISearch search : updatedSearchesSet )
+        {
+            EventRegistry.fireSearchUpdated( new SearchUpdateEvent( search,
+                SearchUpdateEvent.EventDetail.SEARCH_PERFORMED ), this );
+        }
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractEclipseJob#getErrorMessage()
+     */
+    protected String getErrorMessage()
+    {
+        return BrowserCoreMessages.jobs__rename_entry_error;
+    }
+
+
+    /**
+     * Renames the entry.
+     * 
+     * @param browserConnection the browser connection
+     * @param oldEntry the old entry
+     * @param newDn the new DN
+     * @param deleteOldRdn the delete old RDN flag
+     * @param monitor the progress monitor
+     */
+    static void renameEntry( IBrowserConnection browserConnection, IEntry oldEntry, LdapDN newDn, boolean deleteOldRdn,
+        StudioProgressMonitor monitor )
+    {
+        // dn
+        String oldDnString = oldEntry.getDn().getUpName();
+        String newDnString = newDn.getUpName();
+
+        // controls
+        Control[] controls = null;
+        if ( oldEntry.isReferral() )
+        {
+            controls = new Control[]
+                { new ManageReferralControl() };
+        }
+
+        browserConnection.getConnection().getJNDIConnectionWrapper().rename( oldDnString, newDnString, deleteOldRdn, controls,
+            monitor );
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameEntryJob.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameValuesJob.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameValuesJob.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameValuesJob.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameValuesJob.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,176 @@
+/*
+ *  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.studio.ldapbrowser.core.jobs;
+
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.directory.studio.connection.core.StudioProgressMonitor;
+import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
+import org.apache.directory.studio.ldapbrowser.core.events.AttributesInitializedEvent;
+import org.apache.directory.studio.ldapbrowser.core.events.EntryModificationEvent;
+import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry;
+import org.apache.directory.studio.ldapbrowser.core.events.ValueRenamedEvent;
+import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.IValue;
+import org.apache.directory.studio.ldapbrowser.core.model.impl.Attribute;
+import org.apache.directory.studio.ldapbrowser.core.model.impl.Value;
+
+
+/**
+ * Job to rename the attribute description of values asynchronously.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class RenameValuesJob extends AbstractAttributeModificationJob
+{
+
+    /** The entry to modify. */
+    private IEntry entry;
+
+    /** The old values. */
+    private IValue[] oldValues;
+
+    /** The new attribute description. */
+    private String newAttributeDescription;
+
+    /** The created values. */
+    private IValue[] createdValues;
+
+
+    /**
+     * Creates a new instance of RenameValuesJob.
+     * 
+     * @param entry the entry to modify
+     * @param oldValues the old values
+     * @param newAttributeDescription the new attribute description
+     */
+    public RenameValuesJob( IEntry entry, IValue[] oldValues, String newAttributeDescription )
+    {
+        this.entry = entry;
+        this.oldValues = oldValues;
+        this.newAttributeDescription = newAttributeDescription;
+
+        setName( oldValues.length == 1 ? BrowserCoreMessages.jobs__rename_value_name_1
+            : BrowserCoreMessages.jobs__rename_value_name_n );
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractAttributeModificationJob#executeAttributeModificationJob(org.apache.directory.studio.connection.core.StudioProgressMonitor)
+     */
+    protected void executeAttributeModificationJob( StudioProgressMonitor monitor )
+    {
+        monitor.beginTask( oldValues.length == 1 ? BrowserCoreMessages.jobs__rename_value_task_1
+            : BrowserCoreMessages.jobs__rename_value_task_n, 2 );
+        monitor.reportProgress( " " ); //$NON-NLS-1$
+        monitor.worked( 1 );
+
+        for ( IValue oldValue : oldValues )
+        {
+            if ( oldValue.getAttribute().getEntry() != entry )
+            {
+                return;
+            }
+        }
+
+        IValue[] newValues = new IValue[oldValues.length];
+        for ( int i = 0; i < oldValues.length; i++ )
+        {
+            IAttribute attribute = entry.getAttribute( newAttributeDescription );
+            if ( attribute == null )
+            {
+                attribute = new Attribute( entry, newAttributeDescription );
+            }
+
+            newValues[i] = new Value( attribute, oldValues[i].getRawValue() );
+        }
+
+        CreateValuesJob.createValues( entry.getBrowserConnection(), entry, newValues, monitor );
+        if ( !monitor.errorsReported() )
+        {
+            DeleteAttributesValueJob.deleteAttributesAndValues( entry.getBrowserConnection(), entry, null, oldValues,
+                monitor );
+        }
+        if ( !monitor.errorsReported() )
+        {
+            createdValues = newValues;
+        }
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractAttributeModificationJob#getModifiedEntry()
+     */
+    protected IEntry getModifiedEntry()
+    {
+        return entry;
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractAttributeModificationJob#getAffectedAttributeDescriptions()
+     */
+    protected String[] getAffectedAttributeDescriptions()
+    {
+        Set<String> attributeDescriptionSet = new HashSet<String>();
+        attributeDescriptionSet.add( newAttributeDescription );
+        for ( IValue oldValue : oldValues )
+        {
+            attributeDescriptionSet.add( oldValue.getAttribute().getDescription() );
+        }
+        return attributeDescriptionSet.toArray( new String[attributeDescriptionSet.size()] );
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractNotificationJob#runNotification()
+     */
+    protected void runNotification()
+    {
+        EntryModificationEvent event;
+
+        if ( createdValues != null && createdValues.length > 0 )
+        {
+            event = new ValueRenamedEvent( entry.getBrowserConnection(), entry, oldValues[0], createdValues[0] );
+        }
+        else
+        {
+            event = new AttributesInitializedEvent( entry );
+        }
+
+        EventRegistry.fireEntryUpdated( event, this );
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractEclipseJob#getErrorMessage()
+     */
+    protected String getErrorMessage()
+    {
+        return oldValues.length == 1 ? BrowserCoreMessages.jobs__rename_value_error_1
+            : BrowserCoreMessages.jobs__rename_value_error_n;
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameValuesJob.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/SearchJob.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/SearchJob.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/SearchJob.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/SearchJob.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,707 @@
+/*
+ *  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.studio.ldapbrowser.core.jobs;
+
+
+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 javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+import javax.naming.ldap.BasicControl;
+import javax.naming.ldap.Control;
+
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.connection.core.StudioProgressMonitor;
+import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
+import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry;
+import org.apache.directory.studio.ldapbrowser.core.events.SearchUpdateEvent;
+import org.apache.directory.studio.ldapbrowser.core.model.AttributeHierarchy;
+import org.apache.directory.studio.ldapbrowser.core.model.ConnectionException;
+import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.IRootDSE;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult;
+import org.apache.directory.studio.ldapbrowser.core.model.ReferralException;
+import org.apache.directory.studio.ldapbrowser.core.model.SearchParameter;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection.ReferralHandlingMethod;
+import org.apache.directory.studio.ldapbrowser.core.model.impl.BaseDNEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.impl.Entry;
+import org.apache.directory.studio.ldapbrowser.core.model.impl.Value;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.ObjectClassDescription;
+import org.apache.directory.studio.ldapbrowser.core.utils.DnUtils;
+import org.apache.directory.studio.ldapbrowser.core.utils.JNDIUtils;
+import org.apache.directory.studio.ldapbrowser.core.utils.Utils;
+
+
+/**
+ * Job to perform search operations. 
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SearchJob extends AbstractNotificationJob
+{
+
+    /** The searches. */
+    private ISearch[] searches;
+
+
+    /**
+     * Creates a new instance of SearchJob.
+     * 
+     * @param searches the searches
+     */
+    public SearchJob( ISearch[] searches )
+    {
+        this.searches = searches;
+        setName( BrowserCoreMessages.jobs__search_name );
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractEclipseJob#getConnections()
+     */
+    protected Connection[] getConnections()
+    {
+        Connection[] connections = new Connection[searches.length];
+        for ( int i = 0; i < connections.length; i++ )
+        {
+            connections[i] = searches[i].getBrowserConnection().getConnection();
+        }
+        return connections;
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractEclipseJob#getLockedObjects()
+     */
+    protected Object[] getLockedObjects()
+    {
+        List<Object> l = new ArrayList<Object>();
+        l.addAll( Arrays.asList( searches ) );
+        return l.toArray();
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractNotificationJob#executeNotificationJob(org.apache.directory.studio.connection.core.StudioProgressMonitor)
+     */
+    protected void executeNotificationJob( StudioProgressMonitor monitor )
+    {
+        monitor.beginTask( " ", searches.length + 1 ); //$NON-NLS-1$
+        monitor.reportProgress( " " ); //$NON-NLS-1$
+
+        for ( int pi = 0; pi < searches.length; pi++ )
+        {
+            ISearch search = searches[pi];
+
+            monitor.setTaskName( BrowserCoreMessages.bind( BrowserCoreMessages.jobs__search_task, new String[]
+                { search.getName() } ) );
+            monitor.worked( 1 );
+
+            if ( search.getBrowserConnection() != null )
+            {
+                searchAndUpdateModel( search.getBrowserConnection(), search, monitor );
+            }
+        }
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractNotificationJob#runNotification()
+     */
+    protected void runNotification()
+    {
+        for ( int pi = 0; pi < searches.length; pi++ )
+        {
+            EventRegistry.fireSearchUpdated( new SearchUpdateEvent( searches[pi],
+                SearchUpdateEvent.EventDetail.SEARCH_PERFORMED ), this );
+        }
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractEclipseJob#getErrorMessage()
+     */
+    protected String getErrorMessage()
+    {
+        return searches.length == 1 ? BrowserCoreMessages.jobs__search_error_1
+            : BrowserCoreMessages.jobs__search_error_n;
+    }
+
+
+    /**
+     * Searches the directory and updates the browser model.
+     * 
+     * @param browserConnection the browser connection
+     * @param search the search
+     * @param monitor the progress monitor
+     */
+    public static void searchAndUpdateModel( IBrowserConnection browserConnection, ISearch search,
+        StudioProgressMonitor monitor )
+    {
+        try
+        {
+            if ( !monitor.isCanceled() )
+            {
+                // add returning attributes for children and alias detection
+                SearchParameter searchParameter = getSearchParameter( search );
+                ArrayList<ISearchResult> searchResultList = new ArrayList<ISearchResult>();
+
+                try
+                {
+                    // search
+                    NamingEnumeration<SearchResult> enumeration = search( browserConnection, searchParameter, monitor );
+
+                    // iterate through the search result
+                    while ( !monitor.isCanceled() && enumeration.hasMore() )
+                    {
+                        SearchResult sr = enumeration.nextElement(); // TODO: referrals exception
+                        LdapDN dn = JNDIUtils.getDn( sr );
+
+                        // get entry from cache or create it
+                        IEntry entry = browserConnection.getEntryFromCache( dn );
+                        if ( entry == null )
+                        {
+                            entry = createAndCacheEntry( browserConnection, dn );
+                        }
+
+                        // initialize special flags
+                        initFlags( entry, sr, searchParameter );
+
+                        // fill the attributes
+                        fillAttributes( entry, sr, search.getSearchParameter() );
+
+                        searchResultList
+                            .add( new org.apache.directory.studio.ldapbrowser.core.model.impl.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 ( Exception e )
+                {
+                    ConnectionException ce = JNDIUtils.createConnectionException( searchParameter, e );
+
+                    if ( ce.getLdapStatusCode() == 3 || ce.getLdapStatusCode() == 4 || ce.getLdapStatusCode() == 11 )
+                    {
+                        search.setCountLimitExceeded( true );
+                    }
+                    else if ( ce instanceof ReferralException )
+                    {
+                        if ( search.getReferralsHandlingMethod() == ReferralHandlingMethod.FOLLOW )
+                        {
+                            ReferralException re = ( ReferralException ) ce;
+                            ISearch[] referralSearches = re.getReferralSearches();
+                            for ( int i = 0; i < referralSearches.length; i++ )
+                            {
+                                ISearch referralSearch = referralSearches[i];
+
+                                searchAndUpdateModel( referralSearch.getBrowserConnection(), 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 )
+        {
+            if ( search != null )
+            {
+                search.setSearchResults( new ISearchResult[0] );
+            }
+            monitor.reportError( e );
+        }
+    }
+
+
+    static NamingEnumeration<SearchResult> search( IBrowserConnection browserConnection, SearchParameter parameter,
+        StudioProgressMonitor monitor )
+    {
+        String searchBase = parameter.getSearchBase().getUpName();
+        SearchControls controls = new SearchControls();
+        switch ( parameter.getScope() )
+        {
+            case OBJECT:
+                controls.setSearchScope( SearchControls.OBJECT_SCOPE );
+                break;
+            case ONELEVEL:
+                controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+                break;
+            case SUBTREE:
+                controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
+                break;
+            default:
+                controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+        }
+        controls.setReturningAttributes( parameter.getReturningAttributes() );
+        controls.setCountLimit( parameter.getCountLimit() );
+        controls.setTimeLimit( parameter.getTimeLimit() );
+        String filter = parameter.getFilter();
+        String derefAliasMethod = getDerefAliasMethod( parameter );
+        String handleReferralsMethod = getReferralsHandlingMethod( parameter );
+
+        Control[] ldapControls = null;
+        if ( parameter.getControls() != null )
+        {
+            org.apache.directory.studio.ldapbrowser.core.model.Control[] ctls = parameter.getControls();
+            ldapControls = new Control[ctls.length];
+            for ( int i = 0; i < ctls.length; i++ )
+            {
+                ldapControls[i] = new BasicControl( ctls[i].getOid(), ctls[i].isCritical(), ctls[i].getControlValue() );
+            }
+        }
+
+        NamingEnumeration<SearchResult> result = browserConnection.getConnection().getJNDIConnectionWrapper().search(
+            searchBase, filter, controls, derefAliasMethod, handleReferralsMethod, ldapControls, monitor );
+        return result;
+    }
+
+
+    private static String getDerefAliasMethod( SearchParameter parameter )
+    {
+        String m = "always"; //$NON-NLS-1$
+
+        switch ( parameter.getAliasesDereferencingMethod() )
+        {
+            case NEVER:
+                m = "never"; //$NON-NLS-1$
+                break;
+            case ALWAYS:
+                m = "always"; //$NON-NLS-1$
+                break;
+            case FINDING:
+                m = "finding"; //$NON-NLS-1$
+                break;
+            case SEARCH:
+                m = "searching"; //$NON-NLS-1$
+                break;
+        }
+
+        return m;
+    }
+
+
+    private static String getReferralsHandlingMethod( SearchParameter parameter )
+    {
+        String m = "follow"; //$NON-NLS-1$
+
+        switch ( parameter.getReferralsHandlingMethod() )
+        {
+            case IGNORE:
+                m = "ignore"; //$NON-NLS-1$
+                break;
+            case FOLLOW:
+                // m = "follow"; //$NON-NLS-1$
+                m = "throw"; //$NON-NLS-1$
+                break;
+        }
+
+        return m;
+    }
+
+
+    private static SearchParameter getSearchParameter( ISearch search )
+    {
+        SearchParameter searchParameter = ( SearchParameter ) search.getSearchParameter().clone();
+
+        // add children detetion attributes
+        if ( search.isInitHasChildrenFlag() )
+        {
+            if ( search.getBrowserConnection().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.getBrowserConnection().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.getBrowserConnection().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 )
+        {
+            IBrowserConnection connection = search.getBrowserConnection();
+            Set<String> suppportedConrolSet = new HashSet<String>();
+            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() );
+                }
+            }
+
+            org.apache.directory.studio.ldapbrowser.core.model.Control[] controls = searchParameter.getControls();
+            List<org.apache.directory.studio.ldapbrowser.core.model.Control> controlList = new ArrayList<org.apache.directory.studio.ldapbrowser.core.model.Control>();
+            for ( int i = 0; i < controls.length; i++ )
+            {
+                if ( suppportedConrolSet.contains( controls[i].getOid().toLowerCase() ) )
+                {
+                    controlList.add( controls[i] );
+                }
+            }
+            searchParameter.setControls( controlList
+                .toArray( new org.apache.directory.studio.ldapbrowser.core.model.Control[controlList.size()] ) );
+        }
+
+        return searchParameter;
+    }
+
+
+    /**
+     * Creates the entry and puts it into the BrowserConnection's entry cache.
+     * 
+     * @param browserConnection the browser connection
+     * @param dn the DN of the entry
+     * 
+     * @return the created entry
+     */
+    private static IEntry createAndCacheEntry( IBrowserConnection browserConnection, LdapDN dn )
+    {
+        IEntry entry = null;
+
+        // build tree to parent
+        LinkedList<LdapDN> parentDnList = new LinkedList<LdapDN>();
+        LdapDN parentDN = dn;
+        while ( parentDN != null && browserConnection.getEntryFromCache( parentDN ) == null )
+        {
+            parentDnList.addFirst( parentDN );
+            parentDN = DnUtils.getParent( parentDN );
+        }
+        for ( LdapDN aDN : parentDnList )
+        {
+            parentDN = DnUtils.getParent( aDN );
+            if ( parentDN == null )
+            {
+                entry = new BaseDNEntry( aDN, browserConnection );
+                browserConnection.cacheEntry( entry );
+            }
+            else if ( browserConnection.getEntryFromCache( parentDN ) != null )
+            {
+                IEntry parentEntry = browserConnection.getEntryFromCache( parentDN );
+                entry = new Entry( parentEntry, aDN.getRdn() );
+                entry.setDirectoryEntry( true );
+
+                parentEntry.addChild( entry );
+                // parentEntry.setAttributesInitialized(false, this);
+
+                parentEntry.setChildrenInitialized( true );
+                parentEntry.setHasMoreChildren( true );
+                parentEntry.setHasChildrenHint( true );
+
+                browserConnection.cacheEntry( entry );
+            }
+            else
+            {
+                // ??
+            }
+        }
+
+        return entry;
+    }
+
+
+    /**
+     * Initializes the following flags of the entry:
+     * <ul>
+     * <li>hasChildren</li>
+     * <li>isAlias</li>
+     * <li>isReferral</li>
+     * <li>isSubentry</li>
+     * </ul>
+     * 
+     * @param entry the entry
+     * @param sr the the JNDI search result
+     * @param searchParameter the search parameters
+     */
+    private static void initFlags( IEntry entry, SearchResult sr, SearchParameter searchParameter )
+        throws NamingException
+    {
+        NamingEnumeration<? extends Attribute> attributeEnumeration = sr.getAttributes().getAll();
+        while ( attributeEnumeration.hasMore() )
+        {
+            Attribute attribute = attributeEnumeration.next();
+            String attributeDescription = attribute.getID();
+            NamingEnumeration<?> valueEnumeration = attribute.getAll();
+            while ( valueEnumeration.hasMore() )
+            {
+                Object o = valueEnumeration.next();
+                if ( o instanceof String )
+                {
+                    String value = ( String ) o;
+
+                    if ( searchParameter.isInitHasChildrenFlag() )
+                    {
+                        // hasChildren flag
+                        if ( IAttribute.OPERATIONAL_ATTRIBUTE_HAS_SUBORDINATES.equalsIgnoreCase( attributeDescription ) )
+                        {
+                            if ( "FALSE".equalsIgnoreCase( value ) ) { //$NON-NLS-1$
+                                entry.setHasChildrenHint( false );
+                            }
+                        }
+                        if ( IAttribute.OPERATIONAL_ATTRIBUTE_NUM_SUBORDINATES.equalsIgnoreCase( attributeDescription ) )
+                        {
+                            if ( "0".equalsIgnoreCase( value ) ) { //$NON-NLS-1$
+                                entry.setHasChildrenHint( false );
+                            }
+                        }
+                        if ( IAttribute.OPERATIONAL_ATTRIBUTE_SUBORDINATE_COUNT.equalsIgnoreCase( attributeDescription ) )
+                        {
+                            if ( "0".equalsIgnoreCase( value ) ) { //$NON-NLS-1$
+                                entry.setHasChildrenHint( false );
+                            }
+                        }
+                    }
+
+                    if ( searchParameter.isInitAliasAndReferralFlag() )
+                    {
+                        if ( IAttribute.OBJECTCLASS_ATTRIBUTE.equalsIgnoreCase( attributeDescription ) )
+                        {
+                            if ( ObjectClassDescription.OC_ALIAS.equalsIgnoreCase( value ) )
+                            {
+                                entry.setAlias( true );
+                            }
+                            if ( ObjectClassDescription.OC_REFERRAL.equalsIgnoreCase( value ) )
+                            {
+                                entry.setReferral( true );
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        if ( ( searchParameter.getControls() != null && Arrays.asList( searchParameter.getControls() ).contains(
+            org.apache.directory.studio.ldapbrowser.core.model.Control.SUBENTRIES_CONTROL ) )
+            || ISearch.FILTER_SUBENTRY.equalsIgnoreCase( searchParameter.getFilter() ) )
+        {
+            entry.setSubentry( true );
+            entry.setHasChildrenHint( false );
+        }
+    }
+
+
+    /**
+     * Fills the attributes and values of the search result into the entry.
+     * Clears existing attributes and values in the entry.
+     * 
+     * @param entry the entry
+     * @param sr the JNDI search result
+     * @param searchParameter the search parameters
+     */
+    private static void fillAttributes( IEntry entry, SearchResult sr, SearchParameter searchParameter )
+        throws NamingException
+    {
+        if ( searchParameter.getReturningAttributes() == null || searchParameter.getReturningAttributes().length > 0 )
+        {
+            // clear old attributes defined as returning attributes or clear all
+            if ( searchParameter.getReturningAttributes() != null )
+            {
+                String[] ras = searchParameter.getReturningAttributes();
+
+                // special case *
+                if ( Arrays.asList( ras ).contains( ISearch.ALL_USER_ATTRIBUTES ) )
+                {
+                    // clear all user attributes
+                    IAttribute[] oldAttributes = entry.getAttributes();
+                    for ( int i = 0; oldAttributes != null && i < oldAttributes.length; i++ )
+                    {
+                        if ( !oldAttributes[i].isOperationalAttribute() )
+                        {
+                            entry.deleteAttribute( oldAttributes[i] );
+                        }
+                    }
+                }
+
+                // special case +
+                if ( Arrays.asList( ras ).contains( ISearch.ALL_OPERATIONAL_ATTRIBUTES ) )
+                {
+                    // clear all operational attributes
+                    IAttribute[] oldAttributes = entry.getAttributes();
+                    for ( int i = 0; oldAttributes != null && i < oldAttributes.length; i++ )
+                    {
+                        if ( oldAttributes[i].isOperationalAttribute() )
+                        {
+                            entry.deleteAttribute( oldAttributes[i] );
+                        }
+                    }
+                }
+
+                for ( int r = 0; r < ras.length; r++ )
+                {
+                    // clear attributes requested from server, also include sub-types
+                    AttributeHierarchy ah = entry.getAttributeWithSubtypes( ras[r] );
+                    if ( ah != null )
+                    {
+                        for ( Iterator<IAttribute> it = ah.iterator(); it.hasNext(); )
+                        {
+                            IAttribute attribute = it.next();
+                            entry.deleteAttribute( attribute );
+                        }
+                    }
+                }
+            }
+            else
+            {
+                // clear all
+                IAttribute[] oldAttributes = entry.getAttributes();
+                for ( int i = 0; oldAttributes != null && i < oldAttributes.length; i++ )
+                {
+                    entry.deleteAttribute( oldAttributes[i] );
+                }
+            }
+
+            // additional clear old attributes if the record contains the attribute
+            NamingEnumeration<? extends Attribute> attributeEnumeration = sr.getAttributes().getAll();
+            while ( attributeEnumeration.hasMore() )
+            {
+                Attribute attribute = attributeEnumeration.next();
+                String attributeDescription = attribute.getID();
+                IAttribute oldAttribute = entry.getAttribute( attributeDescription );
+                if ( oldAttribute != null )
+                {
+                    entry.deleteAttribute( oldAttribute );
+                }
+            }
+
+            // set new attributes and values
+            attributeEnumeration = sr.getAttributes().getAll();
+            while ( attributeEnumeration.hasMore() )
+            {
+                Attribute attribute = attributeEnumeration.next();
+                String attributeDescription = attribute.getID();
+
+                IAttribute studioAttribute = null;
+                if ( entry.getAttribute( attributeDescription ) == null )
+                {
+                    studioAttribute = new org.apache.directory.studio.ldapbrowser.core.model.impl.Attribute( entry,
+                        attributeDescription );
+                    entry.addAttribute( studioAttribute );
+                }
+                else
+                {
+                    studioAttribute = entry.getAttribute( attributeDescription );
+                }
+
+                NamingEnumeration<?> valueEnumeration = attribute.getAll();
+                while ( valueEnumeration.hasMore() )
+                {
+                    Object value = valueEnumeration.next();
+                    studioAttribute.addValue( new Value( studioAttribute, value ) );
+                }
+            }
+        }
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/SearchJob.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/AttributeDescription.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/AttributeDescription.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/AttributeDescription.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/AttributeDescription.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,287 @@
+/*
+ *  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.studio.ldapbrowser.core.model;
+
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.directory.studio.ldapbrowser.core.model.schema.AttributeTypeDescription;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema;
+
+
+/**
+ * This class implements an attribute description as 
+ * specified in RFC4512, section 2.5:
+ * 
+ *    An attribute description is represented by the ABNF:
+ *
+ *      attributedescription = attributetype options
+ *      attributetype = oid
+ *      options = *( SEMI option )
+ *      option = 1*keychar
+ *
+ *   where <attributetype> identifies the attribute type and each <option>
+ *   identifies an attribute option.  Both <attributetype> and <option>
+ *   productions are case insensitive.  The order in which <option>s
+ *   appear is irrelevant.  That is, any two <attributedescription>s that
+ *   consist of the same <attributetype> and same set of <option>s are
+ *   equivalent.
+ *
+ *   Examples of valid attribute descriptions:
+ *
+ *      2.5.4.0
+ *      cn;lang-de;lang-en
+ *      owner
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AttributeDescription implements Serializable
+{
+
+    private static final long serialVersionUID = 1L;
+
+    /** The user provided description. */
+    private String description;
+
+    /** The parsed attribute type. */
+    private String parsedAttributeType;
+
+    /** The parsed language tag option list. */
+    private List<String> parsedLangList;
+
+    /** The parsed option list, except the language tags. */
+    private List<String> parsedOptionList;
+
+
+    /**
+     * Creates a new instance of AttributeDescription.
+     * 
+     * @param description the user provided description
+     */
+    public AttributeDescription( String description )
+    {
+        this.description = description;
+
+        String[] attributeDescriptionComponents = description.split( IAttribute.OPTION_DELIMITER );
+        this.parsedAttributeType = attributeDescriptionComponents[0];
+        this.parsedLangList = new ArrayList<String>();
+        this.parsedOptionList = new ArrayList<String>();
+        for ( String component : attributeDescriptionComponents )
+        {
+            if ( component.startsWith( IAttribute.OPTION_LANG_PREFIX ) )
+            {
+                this.parsedLangList.add( component );
+            }
+            else
+            {
+                this.parsedOptionList.add( component );
+            }
+        }
+    }
+
+
+    /**
+     * Gets the user provided description.
+     * 
+     * @return the user provided description
+     */
+    public String getDescription()
+    {
+        return description;
+    }
+
+
+    /**
+     * Gets the parsed attribute type.
+     * 
+     * @return the parsed attribute type
+     */
+    public String getParsedAttributeType()
+    {
+        return parsedAttributeType;
+    }
+
+
+    /**
+     * Gets the list of parsed language tags.
+     * 
+     * @return the list of parsed language tags
+     */
+    public List<String> getParsedLangList()
+    {
+        return parsedLangList;
+    }
+
+
+    /**
+     * Gets the list of parsed options, except the language tags.
+     * 
+     * @return the list of parsed options, except the language tags
+     */
+    public List<String> getParsedOptionList()
+    {
+        return parsedOptionList;
+    }
+
+
+    /**
+     * Returns the attribute description with the numeric OID
+     * instead of the descriptive attribute type.
+     * 
+     * @param schema the schema
+     * 
+     * @return the attribute description with the numeric OID
+     */
+    public String toOidString( Schema schema )
+    {
+        if ( schema == null )
+        {
+            return description;
+        }
+
+        AttributeTypeDescription atd = schema.getAttributeTypeDescription( parsedAttributeType );
+        String oidString = atd.getNumericOID();
+
+        if ( !parsedLangList.isEmpty() )
+        {
+            for ( Iterator<String> it = parsedLangList.iterator(); it.hasNext(); )
+            {
+                String element = it.next();
+                oidString += element;
+
+                if ( it.hasNext() || !parsedOptionList.isEmpty() )
+                {
+                    oidString += IAttribute.OPTION_DELIMITER;
+                }
+            }
+        }
+        if ( !parsedOptionList.isEmpty() )
+        {
+            for ( Iterator<String> it = parsedOptionList.iterator(); it.hasNext(); )
+            {
+                String element = it.next();
+                oidString += element;
+
+                if ( it.hasNext() )
+                {
+                    oidString += IAttribute.OPTION_DELIMITER;
+                }
+            }
+        }
+
+        return oidString;
+    }
+
+
+    /**
+     * Checks if the given attribute description is subtype of 
+     * this attriubte description.
+     * 
+     * @param other the other attribute description
+     * @param schema the schema
+     * 
+     * @return true, if the other attribute description is a 
+     *         subtype of this attribute description.
+     */
+    public boolean isSubtypeOf( AttributeDescription other, Schema schema )
+    {
+        // this=name, other=givenName;lang-de -> false
+        // this=name;lang-en, other=givenName;lang-de -> false
+        // this=givenName, other=name -> true
+        // this=givenName;lang-de, other=givenName -> true
+        // this=givenName;lang-de, other=name -> true
+        // this=givenName;lang-en, other=name;lang-de -> false
+        // this=givenName, other=givenName;lang-de -> false
+
+        // check equal descriptions
+        if ( this.toOidString( schema ).equals( other.toOidString( schema ) ) )
+        {
+            return false;
+        }
+
+        // check type
+        AttributeTypeDescription myAtd = schema.getAttributeTypeDescription( this.getParsedAttributeType() );
+        AttributeTypeDescription otherAtd = schema.getAttributeTypeDescription( other.getParsedAttributeType() );
+        if ( myAtd != otherAtd )
+        {
+            AttributeTypeDescription superiorAtd = null;
+            String superiorName = myAtd.getSuperiorAttributeTypeDescriptionName();
+            while ( superiorName != null )
+            {
+                superiorAtd = schema.getAttributeTypeDescription( superiorName );
+                if ( superiorAtd == otherAtd )
+                {
+                    break;
+                }
+                superiorName = superiorAtd.getSuperiorAttributeTypeDescriptionName();
+            }
+            if ( superiorAtd != otherAtd )
+            {
+                return false;
+            }
+        }
+
+        // check options
+        List<String> myOptionsList = new ArrayList<String>( this.getParsedOptionList() );
+        List<String> otherOptionsList = new ArrayList<String>( other.getParsedOptionList() );
+        otherOptionsList.removeAll( myOptionsList );
+        if ( !otherOptionsList.isEmpty() )
+        {
+            return false;
+        }
+
+        // check language tags
+        List<String> myLangList = new ArrayList<String>( this.getParsedLangList() );
+        List<String> otherLangList = new ArrayList<String>( other.getParsedLangList() );
+        for ( String myLang : myLangList )
+        {
+            for ( Iterator<String> otherIt = otherLangList.iterator(); otherIt.hasNext(); )
+            {
+                String otherLang = otherIt.next();
+                if ( otherLang.endsWith( "-" ) )
+                {
+                    if ( myLang.toLowerCase().startsWith( otherLang.toLowerCase() ) )
+                    {
+                        otherIt.remove();
+                    }
+                }
+                else
+                {
+                    if ( myLang.equalsIgnoreCase( otherLang ) )
+                    {
+                        otherIt.remove();
+                    }
+                }
+            }
+        }
+        if ( !otherLangList.isEmpty() )
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/AttributeDescription.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/AttributeHierarchy.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/AttributeHierarchy.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/AttributeHierarchy.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/AttributeHierarchy.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,151 @@
+/*
+ *  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.studio.ldapbrowser.core.model;
+
+
+import java.util.Arrays;
+import java.util.Iterator;
+
+
+/**
+ * An AttributeHierarchy is a container for an attribute including all its subtypes. 
+ * <p>
+ * Example:
+ * <ul>
+ * <li>attributeDescription is <code>name</code>
+ * <li>attributes contains <code>cn:test1</code>, <code>sn:test2</code> and <code>givenName:test3</code>
+ * </ul>
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AttributeHierarchy
+{
+
+    /** The entry */
+    private IEntry entry;
+
+    /** The attribute description */
+    private String attributeDescription;
+
+    /** The attributes */
+    private IAttribute[] attributes;
+
+
+    /**
+     * Creates a new instance of AttributeHierarchy.
+     *
+     * @param entry the entry
+     * @param attributeDescription the attribute description
+     * @param attributes the attributes
+     */
+    public AttributeHierarchy( IEntry entry, String attributeDescription, IAttribute[] attributes )
+    {
+        if ( entry == null || attributeDescription == null || attributes == null || attributes.length < 1
+            || attributes[0] == null )
+        {
+            throw new IllegalArgumentException( "Empty AttributeHierachie" );
+        }
+        this.entry = entry;
+        this.attributeDescription = attributeDescription;
+        this.attributes = attributes;
+    }
+
+
+    /**
+     * Gets the attributes.
+     *
+     * @return the attributes
+     */
+    public IAttribute[] getAttributes()
+    {
+        return attributes;
+    }
+
+
+    /**
+     * Checks whether the given attribute is contained 
+     * in this attribute hierarchy. 
+     *
+     * @param attribute the attribute to check
+     * @return true if the attribute is contained in this attribute hierarchy
+     */
+    public boolean contains( IAttribute attribute )
+    {
+        return Arrays.asList( attributes ).contains( attribute );
+    }
+
+
+    /**
+     * Returns an iterator over the elements of this attribute hierarchy.
+     *
+     * @return an iterator over the elements of this attribute hierarchy
+     */
+    public Iterator<IAttribute> iterator()
+    {
+        return Arrays.asList( attributes ).iterator();
+    }
+
+
+    /**
+     * Gets the first attribute.
+     *
+     * @return the first attribute
+     */
+    public IAttribute getAttribute()
+    {
+        return attributes[0];
+    }
+
+
+    /**
+     * Gets the number of attributes.
+     *
+     * @return the number of attributes
+     */
+    public int size()
+    {
+        return attributes.length;
+    }
+
+
+    /**
+     * Gets the attribute description.
+     *
+     * @return the attribute description
+     */
+    public String getAttributeDescription()
+    {
+        return attributeDescription;
+    }
+
+
+    /**
+     * Gets the entry.
+     *
+     * @return the entry
+     */
+    public IEntry getEntry()
+    {
+        return entry;
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/AttributeHierarchy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/BookmarkParameter.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/BookmarkParameter.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/BookmarkParameter.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/BookmarkParameter.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,137 @@
+/*
+ *  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.studio.ldapbrowser.core.model;
+
+
+import java.io.Serializable;
+
+import javax.naming.InvalidNameException;
+
+import org.apache.directory.shared.ldap.name.LdapDN;
+
+
+/**
+ * A Bean class to hold the bookmark parameters. 
+ * It is used to make bookmarks persistent.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class BookmarkParameter implements Serializable
+{
+
+    /** The serialVersionUID. */
+    private static final long serialVersionUID = 105108281861642267L;
+
+    /** The target DN. */
+    private LdapDN dn;
+
+    /** The symbolic name. */
+    private String name;
+
+
+    /**
+     * Creates a new instance of BookmarkParameter.
+     */
+    public BookmarkParameter()
+    {
+    }
+
+
+    /**
+     * Creates a new instance of BookmarkParameter.
+     *
+     * @param dn the target DN
+     * @param name the symbolic name
+     */
+    public BookmarkParameter( LdapDN dn, String name )
+    {
+        this.dn = dn;
+        this.name = name;
+    }
+
+
+    /**
+     * Gets the target DN.
+     * 
+     * @return the target DN
+     */
+    public LdapDN getDn()
+    {
+        return dn;
+    }
+
+
+    /**
+     * Sets the target DN.
+     * 
+     * @param dn the target DN
+     */
+    public void setDn( LdapDN dn )
+    {
+        this.dn = dn;
+    }
+
+
+    /**
+     * Sets the target DN.
+     * 
+     *  * @deprecated This method will be removed in the next version. The DN/RDN/RDNPart 
+     * classes are replaced with the shared-ldap LdapDN/Rdn/ATAV. This method just 
+     * remains to provide backward compatibility of the old browserconnections.xml
+     * file that stores searches and bookmarks.
+     * 
+     * @param dn the target DN
+     */
+    public void setDn( DN dn )
+    {
+        try
+        {
+            setDn( new LdapDN( dn.toString() ) );
+        }
+        catch ( InvalidNameException e )
+        {
+        }
+    }
+    
+    
+    /**
+     * Gets the symbolic name.
+     * 
+     * @return the symbolic name
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+
+    /**
+     * Sets the symbolic name.
+     * 
+     * @param name the symbolic name
+     */
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/BookmarkParameter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ConnectionException.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ConnectionException.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ConnectionException.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ConnectionException.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,69 @@
+/*
+ *  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.studio.ldapbrowser.core.model;
+
+
+public class ConnectionException extends Exception
+{
+
+    public static final int STAUS_CODE_TIMELIMIT_EXCEEDED = 3;
+    public static final int STAUS_CODE_SIZELIMIT_EXCEEDED = 4;
+    public static final int STAUS_CODE_ADMINLIMIT_EXCEEDED = 11;
+    
+    private static final long serialVersionUID = 1L;
+
+    private int ldapStatusCode;
+
+    private Throwable originalThrowable;
+
+
+    public ConnectionException( int ldapStatusCode, String message, Throwable originalThrowable )
+    {
+        super( message );
+        this.ldapStatusCode = ldapStatusCode;
+        this.originalThrowable = originalThrowable;
+    }
+
+
+    public ConnectionException( String message )
+    {
+        this( -1, message, null );
+    }
+
+
+    public ConnectionException( Throwable t )
+    {
+        this( -1, t.getMessage(), t );
+    }
+
+
+    public int getLdapStatusCode()
+    {
+        return ldapStatusCode;
+    }
+
+
+    public Throwable getOriginalThrowable()
+    {
+        return originalThrowable;
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ConnectionException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/Control.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/Control.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/Control.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/Control.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,218 @@
+/*
+ *  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.studio.ldapbrowser.core.model;
+
+
+import java.io.Serializable;
+
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.lines.LdifControlLine;
+
+
+/**
+ * The Control class represents a LDAP control as defined in RFC 4511
+ * <pre>
+ * Control ::= SEQUENCE {
+ *     controlType             LDAPOID,
+ *     criticality             BOOLEAN DEFAULT FALSE,
+ *     controlValue            OCTET STRING OPTIONAL }
+ * </pre>
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class Control implements Serializable
+{
+
+    /** The serialVersionUID. */
+    private static final long serialVersionUID = -1289018814649849178L;
+
+    /**
+     * The subentries control as defined in RFC 3672.
+     */
+    public static final Control SUBENTRIES_CONTROL = new Control( "Subentries Control", "1.3.6.1.4.1.4203.1.10.1",
+        false, new byte[]
+            { 0x01, 0x01, ( byte ) 0xFF } );
+
+    /** The symbolic name. */
+    private String name;
+
+    /** The oid. */
+    private String oid;
+
+    /** The critical. */
+    private boolean critical;
+
+    /** The control value. */
+    private transient byte[] controlValue;
+
+
+    /**
+     * Creates a new instance of Control.
+     */
+    public Control()
+    {
+    }
+
+
+    /**
+     * Creates a new instance of Control.
+     *
+     * @param name the symbolic name
+     * @param oid the oid
+     * @param critical the criticality
+     * @param controlValue the control value
+     */
+    public Control( String name, String oid, boolean critical, byte[] controlValue )
+    {
+        super();
+        this.name = name == null ? "" : name;
+        this.oid = oid;
+        this.critical = critical;
+        this.controlValue = controlValue;
+    }
+
+
+    /**
+     * Gets the control value.
+     * 
+     * @return the control value
+     */
+    public byte[] getControlValue()
+    {
+        return controlValue;
+    }
+
+
+    /**
+     * Gets the oid.
+     * 
+     * @return the oid
+     */
+    public String getOid()
+    {
+        return oid;
+    }
+
+
+    /**
+     * Checks if is critical.
+     * 
+     * @return true, if is critical
+     */
+    public boolean isCritical()
+    {
+        return critical;
+    }
+
+
+    /**
+     * Gets the symbolic name.
+     * 
+     * @return the name
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String toString()
+    {
+
+        if ( oid == null )
+        {
+            return "";
+        }
+
+        LdifControlLine line = LdifControlLine.create( getOid(), isCritical() ? " true" : " false", getControlValue() );
+        String s = line.toRawString();
+        s = s.substring( line.getRawControlSpec().length(), s.length() );
+        s = s.substring( line.getRawControlType().length(), s.length() );
+        s = s.substring( 0, s.length() - line.getRawNewLine().length() );
+
+        // System.out.println(s);
+
+        return s;
+    }
+
+
+    /**
+     * Sets the control value.
+     * 
+     * @param controlValue the control value
+     */
+    public void setControlValue( byte[] controlValue )
+    {
+        this.controlValue = controlValue;
+    }
+
+
+    /**
+     * Sets the critical.
+     * 
+     * @param critical the critical
+     */
+    public void setCritical( boolean critical )
+    {
+        this.critical = critical;
+    }
+
+
+    /**
+     * Sets the symbolic name.
+     * 
+     * @param name the name
+     */
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+
+    /**
+     * Sets the oid.
+     * 
+     * @param oid the oid
+     */
+    public void setOid( String oid )
+    {
+        this.oid = oid;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean equals( Object obj )
+    {
+        if ( obj == null || !( obj instanceof Control ) )
+        {
+            return false;
+        }
+        Control other = ( Control ) obj;
+
+        return this.toString().equals( other.toString() );
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/Control.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message