You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2009/02/09 22:02:50 UTC
svn commit: r742729 - in /directory/studio/trunk:
connection-core/src/main/java/org/apache/directory/studio/connection/core/
ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/
ldapbrowser-common/src/main/ja...
Author: seelmann
Date: Mon Feb 9 21:02:49 2009
New Revision: 742729
URL: http://svn.apache.org/viewvc?rev=742729&view=rev
Log:
Fix for DIRSTUDIO-456:
o Enabled and fixed rename action in New Entry wizard
o Removed IEntry.isConsistent() method which didn't return useful information when false
o Added SchemaUtils.getEntryIncompleteMessages() which returns useful warn messages when entry in incomplete
o Added useful warn messages in New Entry wizard
o Wait till attribute page becomes visible before activating value editor
Added:
directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/Messages.java
directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/messages.properties
directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/messages_de.properties
Modified:
directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/messages_de.properties
directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserLabelProvider.java
directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/EntryEditorWidgetContentProvider.java
directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/NewEntryAttributesWizardPage.java
directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameValuesJob.java
directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IEntry.java
directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/AbstractEntry.java
directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DelegateEntry.java
directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DummyEntry.java
directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/SchemaUtils.java
directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewLabelDecorator.java
Modified: directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/messages_de.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/messages_de.properties?rev=742729&r1=742728&r2=742729&view=diff
==============================================================================
--- directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/messages_de.properties (original)
+++ directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/messages_de.properties Mon Feb 9 21:02:49 2009
@@ -37,8 +37,8 @@
jobs__check_network_task=Netzwerkparameter \u00FCberpr\u00FCfen
jobs__check_network_error=Die Verbindung schlug fehl
-jobs__open_connections_name_1=Offene Verbindung
-jobs__open_connections_name_n=Offene Verbindungen
+jobs__open_connections_name_1=Verbindung wird geöffnet
+jobs__open_connections_name_n=Verbindungen werden geöffnet
jobs__open_connections_task=Verbindungen am \u00D6ffenen {0}
jobs__open_connections_error_1=Fehler beim \u00D6ffnen der Verbindung
jobs__open_connections_error_n=Fehler beim \u00D6ffnen der Verbindungen
Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserLabelProvider.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserLabelProvider.java?rev=742729&r1=742728&r2=742729&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserLabelProvider.java (original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserLabelProvider.java Mon Feb 9 21:02:49 2009
@@ -38,15 +38,12 @@
import org.apache.directory.studio.ldapbrowser.core.model.impl.BaseDNEntry;
import org.apache.directory.studio.ldapbrowser.core.model.impl.DirectoryMetadataEntry;
import org.apache.directory.studio.ldapbrowser.core.model.impl.ReferralBaseEntry;
-import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.RGB;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
@@ -519,27 +516,6 @@
*/
public Font getFont( Object element )
{
-
- IEntry entry = null;
- if ( element instanceof IEntry )
- {
- entry = ( IEntry ) element;
- }
- else if ( element instanceof ISearchResult )
- {
- entry = ( ( ISearchResult ) element ).getEntry();
- }
-
- if ( entry != null )
- {
- if ( !entry.isConsistent() )
- {
- FontData[] fontData = PreferenceConverter.getFontDataArray( BrowserCommonActivator.getDefault()
- .getPreferenceStore(), BrowserCommonConstants.PREFERENCE_ERROR_FONT );
- return BrowserCommonActivator.getDefault().getFont( fontData );
- }
- }
-
return null;
}
@@ -549,27 +525,6 @@
*/
public Color getForeground( Object element )
{
-
- IEntry entry = null;
- if ( element instanceof IEntry )
- {
- entry = ( IEntry ) element;
- }
- else if ( element instanceof ISearchResult )
- {
- entry = ( ( ISearchResult ) element ).getEntry();
- }
-
- if ( entry != null )
- {
- if ( !entry.isConsistent() )
- {
- RGB rgb = PreferenceConverter.getColor( BrowserCommonActivator.getDefault().getPreferenceStore(),
- BrowserCommonConstants.PREFERENCE_ERROR_COLOR );
- return BrowserCommonActivator.getDefault().getColor( rgb );
- }
- }
-
return null;
}
Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/EntryEditorWidgetContentProvider.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/EntryEditorWidgetContentProvider.java?rev=742729&r1=742728&r2=742729&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/EntryEditorWidgetContentProvider.java (original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/EntryEditorWidgetContentProvider.java Mon Feb 9 21:02:49 2009
@@ -136,7 +136,7 @@
boolean oai = entry.isOperationalAttributesInitialized();
boolean ai = entry.isAttributesInitialized();
- if ( ( !ai || ( !oai && showOperationalAttributes && entry.isConsistent() ) ) && entry.isDirectoryEntry() )
+ if ( ( !ai || ( !oai && showOperationalAttributes ) ) && entry.isDirectoryEntry() )
{
InitializeAttributesRunnable runnable = new InitializeAttributesRunnable( new IEntry[]
{ entry }, showOperationalAttributes );
Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/NewEntryAttributesWizardPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/NewEntryAttributesWizardPage.java?rev=742729&r1=742728&r2=742729&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/NewEntryAttributesWizardPage.java (original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/NewEntryAttributesWizardPage.java Mon Feb 9 21:02:49 2009
@@ -21,6 +21,8 @@
package org.apache.directory.studio.ldapbrowser.common.wizards;
+import java.util.Collection;
+
import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.EntryEditorWidget;
@@ -36,7 +38,12 @@
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.DummyEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils;
+import org.eclipse.jface.dialogs.IPageChangedListener;
+import org.eclipse.jface.dialogs.PageChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.IWizardContainer;
+import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
@@ -85,13 +92,46 @@
public NewEntryAttributesWizardPage( String pageName, NewEntryWizard wizard )
{
super( pageName );
- setTitle( Messages.getString("NewEntryAttributesWizardPage.Attributes") ); //$NON-NLS-1$
- setDescription( Messages.getString("NewEntryAttributesWizardPage.PleaseEnterAttributesForEntry") ); //$NON-NLS-1$
+ setTitle( Messages.getString( "NewEntryAttributesWizardPage.Attributes" ) ); //$NON-NLS-1$
+ setDescription( Messages.getString( "NewEntryAttributesWizardPage.PleaseEnterAttributesForEntry" ) ); //$NON-NLS-1$
setImageDescriptor( BrowserCommonActivator.getDefault().getImageDescriptor(
BrowserCommonConstants.IMG_ENTRY_WIZARD ) );
setPageComplete( false );
this.wizard = wizard;
+
+ IWizardContainer container = wizard.getContainer();
+ if ( container instanceof WizardDialog )
+ {
+ WizardDialog dialog = ( WizardDialog ) container;
+ dialog.addPageChangedListener( new IPageChangedListener()
+ {
+ public void pageChanged( PageChangedEvent event )
+ {
+ if ( getControl().isVisible() )
+ {
+ for ( IAttribute attribute : NewEntryAttributesWizardPage.this.wizard.getPrototypeEntry()
+ .getAttributes() )
+ {
+ for ( IValue value : attribute.getValues() )
+ {
+ if ( value.isEmpty() )
+ {
+ mainWidget.getViewer().setSelection( new StructuredSelection( value ), true );
+ OpenDefaultEditorAction openDefaultEditorAction = actionGroup
+ .getOpenDefaultEditorAction();
+ if ( openDefaultEditorAction.isEnabled() )
+ {
+ openDefaultEditorAction.run();
+ }
+ return;
+ }
+ }
+ }
+ }
+ }
+ } );
+ }
}
@@ -138,8 +178,6 @@
if ( visible )
{
DummyEntry newEntry = wizard.getPrototypeEntry();
- IValue editValue = null;
-
try
{
EventRegistry.suspendEventFireingInCurrentThread();
@@ -172,16 +210,11 @@
String[] newMust = newEntry.getSubschema().getMustAttributeNames();
for ( int i = 0; i < newMust.length; i++ )
{
- if ( newEntry.getAttribute( newMust[i] ) == null )
+ if ( newEntry.getAttributeWithSubtypes( newMust[i] ) == null )
{
IAttribute att = new Attribute( newEntry, newMust[i] );
newEntry.addAttribute( att );
att.addEmptyValue();
-
- if ( editValue == null )
- {
- editValue = att.getValues()[0];
- }
}
}
}
@@ -197,17 +230,6 @@
// set focus to the viewer
mainWidget.getViewer().getControl().setFocus();
-
- // start editing if there is an empty value
- if ( editValue != null )
- {
- mainWidget.getViewer().setSelection( new StructuredSelection( editValue ), true );
- OpenDefaultEditorAction openDefaultEditorAction = actionGroup.getOpenDefaultEditorAction();
- if ( openDefaultEditorAction.isEnabled() )
- {
- openDefaultEditorAction.run();
- }
- }
}
else
{
@@ -223,8 +245,24 @@
*/
private void validate()
{
- if ( wizard.getPrototypeEntry() != null && wizard.getPrototypeEntry().isConsistent() )
+ if ( wizard.getPrototypeEntry() != null )
{
+ Collection<String> messages = SchemaUtils.getEntryIncompleteMessages( wizard.getPrototypeEntry() );
+ if ( messages != null && !messages.isEmpty() )
+ {
+ StringBuffer sb = new StringBuffer();
+ for ( String message : messages )
+ {
+ sb.append( message );
+ sb.append( ' ' );
+ }
+ setMessage( sb.toString(), WizardPage.WARNING );
+ }
+ else
+ {
+ setMessage( null );
+ }
+
setPageComplete( true );
}
else
Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameValuesJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameValuesJob.java?rev=742729&r1=742728&r2=742729&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameValuesJob.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameValuesJob.java Mon Feb 9 21:02:49 2009
@@ -102,6 +102,7 @@
if ( attribute == null )
{
attribute = new Attribute( entry, newAttributeDescription );
+ entry.addAttribute( attribute );
}
newValues[i] = new Value( attribute, oldValues[i].getRawValue() );
Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IEntry.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IEntry.java?rev=742729&r1=742728&r2=742729&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IEntry.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IEntry.java Mon Feb 9 21:02:49 2009
@@ -85,21 +85,6 @@
/**
- * Checks if this entry with its attributes is consistent. The following
- * conditions must be fulfilled:
- *
- * <ul>
- * <li>The objectClass attribute must be present</li>
- * <li>All must attributes must be present</li>
- * <li>There mustn't be any empty value</li>
- * </ul>
- *
- * @return true if this entry is consistent
- */
- public abstract boolean isConsistent();
-
-
- /**
* Indicates whether this entry exists in directory. Otherwise it
* is a new entry created from the user and not still written to directory.
*
Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/AbstractEntry.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/AbstractEntry.java?rev=742729&r1=742728&r2=742729&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/AbstractEntry.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/AbstractEntry.java Mon Feb 9 21:02:49 2009
@@ -30,9 +30,6 @@
import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.name.Rdn;
-import org.apache.directory.shared.ldap.schema.ObjectClassTypeEnum;
-import org.apache.directory.shared.ldap.schema.parsers.AttributeTypeDescription;
-import org.apache.directory.shared.ldap.schema.parsers.ObjectClassDescription;
import org.apache.directory.shared.ldap.util.LdapURL;
import org.apache.directory.studio.connection.core.Connection;
import org.apache.directory.studio.connection.core.jobs.StudioBulkRunnableWithProgress;
@@ -205,67 +202,6 @@
/**
* {@inheritDoc}
*/
- public boolean isConsistent()
- {
- AttributeInfo ai = getBrowserConnectionImpl().getAttributeInfo( this );
- if ( ai == null || ai.attributeMap == null )
- {
- return isDirectoryEntry();
- }
-
- // check empty attributes and empty values
- Map<String, IAttribute> aiAttributeMap = new HashMap<String, IAttribute>( ai.attributeMap );
- for ( IAttribute attribute : aiAttributeMap.values() )
- {
- if ( !attribute.isConsistent() )
- {
- return false;
- }
- }
-
- if ( !isDirectoryEntry() )
- {
- // check objectclass attribute
- if ( !ai.attributeMap.containsKey( IAttribute.OBJECTCLASS_ATTRIBUTE_OID.toLowerCase() ) )
- {
- return false;
- }
- IAttribute ocAttribute = ( IAttribute ) ai.attributeMap.get( IAttribute.OBJECTCLASS_ATTRIBUTE_OID
- .toLowerCase() );
- String[] ocValues = ocAttribute.getStringValues();
- boolean structuralObjectClassAvailable = false;
- for ( int i = 0; i < ocValues.length; i++ )
- {
- ObjectClassDescription ocd = getBrowserConnection().getSchema().getObjectClassDescription( ocValues[i] );
- if ( ocd.getKind() == ObjectClassTypeEnum.STRUCTURAL )
- {
- structuralObjectClassAvailable = true;
- break;
- }
- }
- if ( !structuralObjectClassAvailable )
- {
- return false;
- }
-
- // check must-attributes
- AttributeTypeDescription[] mustAtds = getSubschema().getMustAttributeTypeDescriptions();
- for ( AttributeTypeDescription mustAtd : mustAtds )
- {
- if ( !ai.attributeMap.containsKey( mustAtd.getNumericOid().toLowerCase() ) )
- {
- return false;
- }
- }
- }
-
- return true;
- }
-
-
- /**
- * {@inheritDoc}
- */
public boolean isDirectoryEntry()
{
return ( flags & IS_DIRECTORY_ENTRY_FLAG ) != 0;
Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DelegateEntry.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DelegateEntry.java?rev=742729&r1=742728&r2=742729&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DelegateEntry.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DelegateEntry.java Mon Feb 9 21:02:49 2009
@@ -542,22 +542,6 @@
/**
* {@inheritDoc}
*/
- public boolean isConsistent()
- {
- if ( getDelegate() != null )
- {
- return getDelegate().isConsistent();
- }
- else
- {
- return true;
- }
- }
-
-
- /**
- * {@inheritDoc}
- */
public void setAttributesInitialized( boolean b )
{
if ( !b )
Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DummyEntry.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DummyEntry.java?rev=742729&r1=742728&r2=742729&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DummyEntry.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DummyEntry.java Mon Feb 9 21:02:49 2009
@@ -30,8 +30,6 @@
import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.name.Rdn;
-import org.apache.directory.shared.ldap.schema.ObjectClassTypeEnum;
-import org.apache.directory.shared.ldap.schema.parsers.ObjectClassDescription;
import org.apache.directory.shared.ldap.util.LdapURL;
import org.apache.directory.studio.connection.core.jobs.StudioBulkRunnableWithProgress;
import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
@@ -170,9 +168,15 @@
*/
public AttributeHierarchy getAttributeWithSubtypes( String attributeDescription )
{
- AttributeDescription ad = new AttributeDescription( attributeDescription );
-
List<IAttribute> attributeList = new ArrayList<IAttribute>();
+
+ IAttribute myAttribute = getAttribute( attributeDescription );
+ if ( myAttribute != null )
+ {
+ attributeList.add( myAttribute );
+ }
+
+ AttributeDescription ad = new AttributeDescription( attributeDescription );
for ( IAttribute attribute : attributeMap.values() )
{
AttributeDescription other = attribute.getAttributeDescription();
@@ -365,58 +369,6 @@
/**
- * {@inheritDoc}
- */
- public boolean isConsistent()
- {
- // check empty attributes and empty values
- for ( IAttribute attribute : attributeMap.values() )
- {
- if ( !attribute.isConsistent() )
- {
- return false;
- }
- }
-
- // check objectClass attribute
- if ( !attributeMap.containsKey( IAttribute.OBJECTCLASS_ATTRIBUTE_OID.toLowerCase() ) )
- {
- return false;
- }
- IAttribute ocAttribute = attributeMap.get( IAttribute.OBJECTCLASS_ATTRIBUTE_OID.toLowerCase() );
- String[] ocValues = ocAttribute.getStringValues();
- boolean structuralObjectClassAvailable = false;
- for ( String ocValue : ocValues )
- {
- ObjectClassDescription ocd = this.getBrowserConnection().getSchema().getObjectClassDescription( ocValue );
- if ( ocd.getKind() == ObjectClassTypeEnum.STRUCTURAL )
- {
- structuralObjectClassAvailable = true;
- break;
- }
- }
- if ( !structuralObjectClassAvailable )
- {
- return false;
- }
-
- // check must-attributes
- String[] mustAttributeNames = getSubschema().getMustAttributeNames();
- for ( String mustAttributeName : mustAttributeNames )
- {
- AttributeDescription ad = new AttributeDescription( mustAttributeName );
- String oidString = ad.toOidString( getBrowserConnection().getSchema() );
- if ( !attributeMap.containsKey( oidString.toLowerCase() ) )
- {
- return false;
- }
- }
-
- return true;
- }
-
-
- /**
* This implementation always returns false.
*/
public boolean isDirectoryEntry()
Added: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/Messages.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/Messages.java?rev=742729&view=auto
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/Messages.java (added)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/Messages.java Mon Feb 9 21:02:49 2009
@@ -0,0 +1,31 @@
+package org.apache.directory.studio.ldapbrowser.core.model.schema;
+
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+
+public class Messages
+{
+ private static final String BUNDLE_NAME = "org.apache.directory.studio.ldapbrowser.core.model.schema.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME );
+
+
+ private Messages()
+ {
+ }
+
+
+ public static String getString( String key )
+ {
+ try
+ {
+ return RESOURCE_BUNDLE.getString( key );
+ }
+ catch ( MissingResourceException e )
+ {
+ return '!' + key + '!';
+ }
+ }
+}
Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/SchemaUtils.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/SchemaUtils.java?rev=742729&r1=742728&r2=742729&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/SchemaUtils.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/SchemaUtils.java Mon Feb 9 21:02:49 2009
@@ -29,6 +29,7 @@
import java.util.Set;
import java.util.TreeSet;
+import org.apache.directory.shared.ldap.schema.ObjectClassTypeEnum;
import org.apache.directory.shared.ldap.schema.UsageEnum;
import org.apache.directory.shared.ldap.schema.parsers.AbstractSchemaDescription;
import org.apache.directory.shared.ldap.schema.parsers.AttributeTypeDescription;
@@ -37,7 +38,11 @@
import org.apache.directory.shared.ldap.schema.parsers.MatchingRuleUseDescription;
import org.apache.directory.shared.ldap.schema.parsers.ObjectClassDescription;
import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
+import org.apache.directory.studio.ldapbrowser.core.model.AttributeHierarchy;
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.eclipse.osgi.util.NLS;
/**
@@ -53,11 +58,11 @@
{
public int compare( String s1, String s2 )
{
- if ( s1.matches( "[0-9\\.]+" ) && !s2.matches( "[0-9\\.]+" ) )
+ if ( s1.matches( "[0-9\\.]+" ) && !s2.matches( "[0-9\\.]+" ) ) //$NON-NLS-1$ //$NON-NLS-2$
{
return 1;
}
- else if ( !s1.matches( "[0-9\\.]+" ) && s2.matches( "[0-9\\.]+" ) )
+ else if ( !s1.matches( "[0-9\\.]+" ) && s2.matches( "[0-9\\.]+" ) ) //$NON-NLS-1$ //$NON-NLS-2$
{
return -1;
}
@@ -67,7 +72,7 @@
}
}
};
-
+
private static final Comparator<AbstractSchemaDescription> schemaElementNameComparator = new Comparator<AbstractSchemaDescription>()
{
public int compare( AbstractSchemaDescription s1, AbstractSchemaDescription s2 )
@@ -75,7 +80,8 @@
return SchemaUtils.toString( s1 ).compareToIgnoreCase( SchemaUtils.toString( s2 ) );
}
};
-
+
+
/**
* Gets the names of the given schema elements.
*
@@ -93,7 +99,7 @@
return nameSet;
}
-
+
/**
* Gets the names of the given schema elements.
*
@@ -105,7 +111,7 @@
{
return getNames( asds ).toArray( new String[0] );
}
-
+
/**
* Get the numeric OIDs of the given schema descriptions.
@@ -118,7 +124,7 @@
for ( AbstractSchemaDescription asd : descritpions )
{
oids.add( asd.getNumericOid() );
-
+
}
return oids;
}
@@ -376,8 +382,8 @@
* @return all attribute type descriptions using this matching rule for
* equality, substring or ordering matching
*/
- public static Collection<AttributeTypeDescription> getUsedFromAttributeTypeDescriptions( MatchingRuleDescription mrd,
- Schema schema )
+ public static Collection<AttributeTypeDescription> getUsedFromAttributeTypeDescriptions(
+ MatchingRuleDescription mrd, Schema schema )
{
Set<AttributeTypeDescription> usedFromSet = new TreeSet<AttributeTypeDescription>( schemaElementNameComparator );
for ( AttributeTypeDescription atd : schema.getAttributeTypeDescriptions() )
@@ -510,7 +516,7 @@
return null;
}
-
+
/**
* Gets the syntax length of the given or the
* superior attribute type description.
@@ -536,8 +542,8 @@
return -1;
}
-
-
+
+
/**
* Gets all matching rule description names the given attribute type
* description applies to according to the schema's matchin rul use
@@ -552,7 +558,7 @@
*/
public static Collection<String> getOtherMatchingRuleDescriptionNames( AttributeTypeDescription atd, Schema schema )
{
- Set<String> otherMatchingRules = new TreeSet<String>( nameAndOidComparator );
+ Set<String> otherMatchingRules = new TreeSet<String>( nameAndOidComparator );
for ( MatchingRuleUseDescription mrud : schema.getMatchingRuleUseDescriptions() )
{
Collection<String> atdSet = toLowerCaseSet( mrud.getApplicableAttributes() );
@@ -563,8 +569,8 @@
}
return otherMatchingRules;
}
-
-
+
+
/**
* Gets all attribute type descriptions using the given attribute type
* descriptions as superior.
@@ -575,7 +581,8 @@
* @return all attribute type descriptions using this attribute type
* description as superior
*/
- public static Collection<AttributeTypeDescription> getDerivedAttributeTypeDescriptions( AttributeTypeDescription atd, Schema schema )
+ public static Collection<AttributeTypeDescription> getDerivedAttributeTypeDescriptions(
+ AttributeTypeDescription atd, Schema schema )
{
Set<AttributeTypeDescription> derivedAtds = new TreeSet<AttributeTypeDescription>( schemaElementNameComparator );
for ( AttributeTypeDescription derivedAtd : schema.getAttributeTypeDescriptions() )
@@ -588,7 +595,8 @@
}
return derivedAtds;
}
-
+
+
/**
* Gets all object class description using the given attribute type
* description as must attribute.
@@ -639,11 +647,10 @@
}
return ocds;
}
-
-
-
- private static Collection<ObjectClassDescription> getExistingSuperiorObjectClassDescription( ObjectClassDescription ocd, Schema schema )
+
+ private static Collection<ObjectClassDescription> getExistingSuperiorObjectClassDescription(
+ ObjectClassDescription ocd, Schema schema )
{
List<ObjectClassDescription> superiorList = new ArrayList<ObjectClassDescription>();
for ( String superior : ocd.getSuperiorObjectClasses() )
@@ -656,7 +663,7 @@
return superiorList;
}
-
+
/**
* Gets the superior object class descriptions of the given object class description.
*
@@ -665,7 +672,8 @@
*
* @return the superior object class descriptions
*/
- public static List<ObjectClassDescription> getSuperiorObjectClassDescriptions( ObjectClassDescription ocd, Schema schema )
+ public static List<ObjectClassDescription> getSuperiorObjectClassDescriptions( ObjectClassDescription ocd,
+ Schema schema )
{
List<ObjectClassDescription> superiorList = new ArrayList<ObjectClassDescription>();
for ( String superior : ocd.getSuperiorObjectClasses() )
@@ -674,8 +682,8 @@
}
return superiorList;
}
-
-
+
+
/**
* Gets the sub object class descriptions of the given object class description.
*
@@ -697,7 +705,8 @@
}
return subOcds;
}
-
+
+
/**
* Gets the must attribute type description names of the given
* and all superior object class description, transitively.
@@ -708,9 +717,10 @@
* @return the must attribute type description names of the given
* and all superior object class description, transitively
*/
- public static Collection<String> getMustAttributeTypeDescriptionNamesTransitive( ObjectClassDescription ocd, Schema schema )
+ public static Collection<String> getMustAttributeTypeDescriptionNamesTransitive( ObjectClassDescription ocd,
+ Schema schema )
{
- Set<String> musts = new TreeSet<String>( nameAndOidComparator );
+ Set<String> musts = new TreeSet<String>( nameAndOidComparator );
musts.addAll( ocd.getMustAttributeTypes() );
Collection<ObjectClassDescription> superiors = getExistingSuperiorObjectClassDescription( ocd, schema );
for ( ObjectClassDescription superior : superiors )
@@ -719,8 +729,8 @@
}
return musts;
}
-
-
+
+
/**
* Gets the may attribute type description names of the given
* and all superior object class description, transitively.
@@ -731,9 +741,10 @@
* @return the may attribute type description names of the given
* and all superior object class description, transitively
*/
- public static Collection<String> getMayAttributeTypeDescriptionNamesTransitive( ObjectClassDescription ocd, Schema schema )
+ public static Collection<String> getMayAttributeTypeDescriptionNamesTransitive( ObjectClassDescription ocd,
+ Schema schema )
{
- Set<String> mays= new TreeSet<String>( nameAndOidComparator );
+ Set<String> mays = new TreeSet<String>( nameAndOidComparator );
mays.addAll( ocd.getMayAttributeTypes() );
Collection<ObjectClassDescription> superiors = getExistingSuperiorObjectClassDescription( ocd, schema );
for ( ObjectClassDescription superior : superiors )
@@ -743,6 +754,7 @@
return mays;
}
+
/**
* Gets the LDIF line of the given schema element, may be null.
*
@@ -755,8 +767,8 @@
String ldifLine = ldifLines != null && !ldifLines.isEmpty() ? ldifLines.get( 0 ) : null;
return ldifLine;
}
-
-
+
+
private static Collection<String> toLowerCaseSet( Collection<String> names )
{
Set<String> set = new HashSet<String>();
@@ -769,7 +781,8 @@
}
return set;
}
-
+
+
/**
* Gets the string representation of the given schema element.
*
@@ -798,7 +811,7 @@
{
if ( !first )
{
- sb.append( ", " );
+ sb.append( ", " ); //$NON-NLS-1$
}
sb.append( name );
first = false;
@@ -806,6 +819,91 @@
}
return sb.toString();
}
-
+
+
+ /**
+ * Checks if the given entry with its attributes is complete and return
+ * useful messages if it is not complete. The following checks are performed:
+ *
+ * <ul>
+ * <li>The objectClass attribute must be present</li>
+ * <li>A structural object class must be present</li>
+ * <li>All mandatory attributes must be present</li>
+ * <li>All attribute must be allowed according to the object classes</li>
+ * <li>There mustn't be any empty value</li>
+ * </ul>
+ *
+ * @return a collection with warn messages if the entry is complete, empty if the entry is complete
+ */
+ public static Collection<String> getEntryIncompleteMessages( IEntry entry )
+ {
+ Collection<String> messages = new ArrayList<String>();
+ if ( entry != null )
+ {
+ // check objectClass attribute
+ IAttribute ocAttribute = entry.getAttribute( IAttribute.OBJECTCLASS_ATTRIBUTE );
+ if ( ocAttribute == null )
+ {
+ messages.add( Messages.getString( "SchemaUtils.NoObjectClass" ) ); //$NON-NLS-1$
+ }
+ String[] ocValues = ocAttribute.getStringValues();
+ boolean structuralObjectClassAvailable = false;
+ for ( String ocValue : ocValues )
+ {
+ ObjectClassDescription ocd = entry.getBrowserConnection().getSchema().getObjectClassDescription(
+ ocValue );
+ if ( ocd.getKind() == ObjectClassTypeEnum.STRUCTURAL )
+ {
+ structuralObjectClassAvailable = true;
+ break;
+ }
+ }
+ if ( !structuralObjectClassAvailable )
+ {
+ messages.add( Messages.getString( "SchemaUtils.NoStructuralObjectClass" ) ); //$NON-NLS-1$
+ }
+
+ // check must-attributes
+ String[] mustAttributeNames = entry.getSubschema().getMustAttributeNames();
+ for ( String must : mustAttributeNames )
+ {
+ AttributeHierarchy ah = entry.getAttributeWithSubtypes( must );
+ if ( ah == null )
+ {
+ messages.add( NLS.bind( Messages.getString( "SchemaUtils.MandatoryAttributeIsMissing" ), must ) ); //$NON-NLS-1$
+ }
+ }
+
+ // check unallowed attributes
+ Set<AttributeTypeDescription> allAtds = entry.getSubschema().getAllAttributeTypeDescriptions();
+ for ( IAttribute attribute : entry.getAttributes() )
+ {
+ if ( !attribute.isOperationalAttribute() )
+ {
+ AttributeTypeDescription atd = attribute.getAttributeTypeDescription();
+ if ( !allAtds.contains( atd ) )
+ {
+ messages.add( NLS.bind( Messages.getString( "SchemaUtils.AttributeNotAllowed" ), attribute //$NON-NLS-1$
+ .getDescription() ) );
+ }
+ }
+ }
+
+ // check empty attributes and empty values
+ for ( IAttribute attribute : entry.getAttributes() )
+ {
+ for ( IValue value : attribute.getValues() )
+ {
+ if ( value.isEmpty() )
+ {
+ messages.add( NLS.bind( Messages.getString( "SchemaUtils.EmptyValue" ), //$NON-NLS-1$
+ attribute.getDescription() ) );
+ }
+ }
+ }
+ }
+
+ return messages;
+ }
}
Added: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/messages.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/messages.properties?rev=742729&view=auto
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/messages.properties (added)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/messages.properties Mon Feb 9 21:02:49 2009
@@ -0,0 +1,5 @@
+SchemaUtils.AttributeNotAllowed=According to the schema attribute {0} is not allowed.
+SchemaUtils.EmptyValue=Attribute {0} has an empty value, please insert a valid value.
+SchemaUtils.MandatoryAttributeIsMissing=Mandatory attribute {0} is missing, please add it.
+SchemaUtils.NoObjectClass=Entry has no objectClass attribute\!
+SchemaUtils.NoStructuralObjectClass=No structural objectClass provided\!
Added: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/messages_de.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/messages_de.properties?rev=742729&view=auto
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/messages_de.properties (added)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/messages_de.properties Mon Feb 9 21:02:49 2009
@@ -0,0 +1,5 @@
+SchemaUtils.AttributeNotAllowed=Gemäß Schema ist Attribut {0} nicht erlaubt.
+SchemaUtils.EmptyValue=Attribut {0} ist leer, bitte einen Wert eingeben.
+SchemaUtils.MandatoryAttributeIsMissing=Pflichtattribute {0} fehlt, bitte hinzufügen.
+SchemaUtils.NoObjectClass=Kein objectClass Attribut vorhanden\!
+SchemaUtils.NoStructuralObjectClass=Keine strukturelle Objektklasse vorhanden\!
Modified: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewLabelDecorator.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewLabelDecorator.java?rev=742729&r1=742728&r2=742729&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewLabelDecorator.java (original)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewLabelDecorator.java Mon Feb 9 21:02:49 2009
@@ -72,12 +72,7 @@
if ( entry != null )
{
- if ( !entry.isConsistent() )
- {
- decoration.addOverlay( BrowserUIPlugin.getDefault().getImageDescriptor(
- BrowserUIConstants.IMG_OVR_ERROR ), IDecoration.BOTTOM_LEFT );
- }
- else if ( !entry.isDirectoryEntry() )
+ if ( !entry.isDirectoryEntry() )
{
decoration.addOverlay( BrowserUIPlugin.getDefault().getImageDescriptor(
BrowserUIConstants.IMG_OVR_WARNING ), IDecoration.BOTTOM_LEFT );