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 2008/07/11 13:50:48 UTC
svn commit: r675924 - in /directory/studio/trunk:
ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/
ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/
ldapbrowser-core/sr...
Author: seelmann
Date: Fri Jul 11 04:50:47 2008
New Revision: 675924
URL: http://svn.apache.org/viewvc?rev=675924&view=rev
Log:
Fix for DIRSTUDIO-209
Modified:
directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/EntryEditorWidgetContentProvider.java
directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/AbstractAttributeModificationJob.java
directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/InitializeAttributesRunnable.java
directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/Schema.java
directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/SchemaUtils.java
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=675924&r1=675923&r2=675924&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 Fri Jul 11 04:50:47 2008
@@ -126,19 +126,19 @@
*/
public Object[] getElements( Object inputElement )
{
+ boolean showOperationalAttributes = BrowserCommonActivator.getDefault().getPreferenceStore().getBoolean(
+ BrowserCommonConstants.PREFERENCE_ENTRYEDITOR_SHOW_OPERATIONAL_ATTRIBUTES );
if ( inputElement != null && inputElement instanceof IEntry )
{
IEntry entry = ( IEntry ) inputElement;
- boolean soa = BrowserCommonActivator.getDefault().getPreferenceStore().getBoolean(
- BrowserCommonConstants.PREFERENCE_ENTRYEDITOR_SHOW_OPERATIONAL_ATTRIBUTES );
boolean oai = entry.isOperationalAttributesInitialized();
- boolean ai = entry.isAttributesInitialized();
- if ( ( !ai || ( !oai && soa ) ) && entry.isDirectoryEntry() )
+ boolean ai = entry.isAttributesInitialized();
+ if ( ( !ai || ( !oai && showOperationalAttributes ) ) && entry.isDirectoryEntry() )
{
InitializeAttributesRunnable runnable = new InitializeAttributesRunnable( new IEntry[]
- { entry }, soa );
+ { entry }, showOperationalAttributes );
StudioBrowserJob job = new StudioBrowserJob( runnable );
job.execute();
return new Object[0];
@@ -146,7 +146,7 @@
else
{
IAttribute[] attributes = entry.getAttributes();
- Object[] values = getValues( attributes );
+ Object[] values = getValues( attributes, showOperationalAttributes );
return values;
}
}
@@ -154,7 +154,7 @@
{
AttributeHierarchy ah = ( AttributeHierarchy ) inputElement;
IAttribute[] attributes = ah.getAttributes();
- Object[] values = getValues( attributes );
+ Object[] values = getValues( attributes, showOperationalAttributes );
return values;
}
else
@@ -168,27 +168,31 @@
* Gets the values of the given attributes.
*
* @param attributes the attributes
+ * @param showOperationalAttributes true if operational attributes are visible
*
* @return the values
*/
- private Object[] getValues( IAttribute[] attributes )
+ private Object[] getValues( IAttribute[] attributes, boolean showOperationalAttributes )
{
List<Object> valueList = new ArrayList<Object>();
- for ( int i = 0; attributes != null && i < attributes.length; i++ )
+ for ( IAttribute attribute : attributes )
{
- IValue[] values = attributes[i].getValues();
- if ( this.preferences == null || !this.preferences.isUseFolding()
- || ( values.length <= this.preferences.getFoldingThreshold() ) )
+ if ( !attribute.isOperationalAttribute() || showOperationalAttributes )
{
- for ( int j = 0; j < values.length; j++ )
+ IValue[] values = attribute.getValues();
+ if ( this.preferences == null || !this.preferences.isUseFolding()
+ || ( values.length <= this.preferences.getFoldingThreshold() ) )
{
- valueList.add( values[j] );
+ for ( IValue value : values )
+ {
+ valueList.add( value );
+ }
+ }
+ else
+ {
+ // if folding threshold is exceeded then return the attribute itself
+ valueList.add( attribute );
}
- }
- else
- {
- // if folding threshold is exceeded then return the attribute itself
- valueList.add( attributes[i] );
}
}
return valueList.toArray();
Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/AbstractAttributeModificationJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/AbstractAttributeModificationJob.java?rev=675924&r1=675923&r2=675924&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/AbstractAttributeModificationJob.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/AbstractAttributeModificationJob.java Fri Jul 11 04:50:47 2008
@@ -51,7 +51,8 @@
{
// reload affected attributes
String[] attributeDescriptions = getAffectedAttributeDescriptions();
- InitializeAttributesRunnable.initializeAttributes( getModifiedEntry(), attributeDescriptions, monitor );
+ InitializeAttributesRunnable.initializeAttributes( getModifiedEntry(), attributeDescriptions, false,
+ monitor );
}
}
}
Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/InitializeAttributesRunnable.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/InitializeAttributesRunnable.java?rev=675924&r1=675923&r2=675924&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/InitializeAttributesRunnable.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/InitializeAttributesRunnable.java Fri Jul 11 04:50:47 2008
@@ -205,7 +205,7 @@
}
returningAttributes = ( String[] ) raSet.toArray( new String[raSet.size()] );
- initializeAttributes( entry, returningAttributes, monitor );
+ initializeAttributes( entry, returningAttributes, true, monitor );
entry.setOperationalAttributesInitialized( initOperationalAttributes );
}
@@ -216,9 +216,10 @@
*
* @param entry the entry
* @param attributes the returning attributes
+ * @param clearAllAttributes true to clear all old attributes before searching
* @param monitor the progress monitor
*/
- public static void initializeAttributes( IEntry entry, String[] attributes, StudioProgressMonitor monitor )
+ public static void initializeAttributes( IEntry entry, String[] attributes, boolean clearAllAttributes, StudioProgressMonitor monitor )
{
monitor.reportProgress( BrowserCoreMessages.bind( BrowserCoreMessages.jobs__init_entries_progress_att,
new String[]
@@ -246,6 +247,22 @@
referralsHandlingMethod = ReferralHandlingMethod.MANAGE;
}
+ if ( clearAllAttributes )
+ {
+ // Clear all attributes (user and operational)
+ // Must be done here because SearchRunnable.searchAndUpdateModel only clears
+ // requested attributes. If the user switches the "Show operational attributes"
+ // property then the operational attributes are not cleared.
+ IAttribute[] oldAttributes = entry.getAttributes();
+ if ( oldAttributes != null )
+ {
+ for ( IAttribute oldAttribute : oldAttributes )
+ {
+ entry.deleteAttribute( oldAttribute );
+ }
+ }
+ }
+
// search
ISearch search = new Search( null, entry.getBrowserConnection(), entry.getDn(),
entry.isSubentry() ? ISearch.FILTER_SUBENTRY : ISearch.FILTER_TRUE, attributes, SearchScope.OBJECT, 0,
@@ -282,17 +299,27 @@
}
browserConnection.getRootDSE().setChildrenInitialized( false );
- // load all user attributes
- ISearch search = new Search( null, browserConnection, LdapDN.EMPTY_LDAPDN, ISearch.FILTER_TRUE, new String[]
- { ISearch.ALL_USER_ATTRIBUTES }, SearchScope.OBJECT, 0, 0, Connection.AliasDereferencingMethod.NEVER,
- Connection.ReferralHandlingMethod.IGNORE, false, null );
- SearchRunnable.searchAndUpdateModel( browserConnection, search, monitor );
-
+ // delete old attributes
+ IAttribute[] oldAttributes = browserConnection.getRootDSE().getAttributes();
+ if ( oldAttributes != null )
+ {
+ for ( IAttribute oldAttribute : oldAttributes )
+ {
+ browserConnection.getRootDSE().deleteAttribute( oldAttribute );
+ }
+ }
+
// load well-known Root DSE attributes and operational attributes
- search = new Search( null, browserConnection, LdapDN.EMPTY_LDAPDN, ISearch.FILTER_TRUE, ROOT_DSE_ATTRIBUTES,
+ ISearch search = new Search( null, browserConnection, LdapDN.EMPTY_LDAPDN, ISearch.FILTER_TRUE, ROOT_DSE_ATTRIBUTES,
SearchScope.OBJECT, 0, 0, Connection.AliasDereferencingMethod.NEVER,
Connection.ReferralHandlingMethod.IGNORE, false, null );
SearchRunnable.searchAndUpdateModel( browserConnection, search, monitor );
+
+ // load all user attributes
+ search = new Search( null, browserConnection, LdapDN.EMPTY_LDAPDN, ISearch.FILTER_TRUE, new String[]
+ { ISearch.ALL_USER_ATTRIBUTES }, SearchScope.OBJECT, 0, 0, Connection.AliasDereferencingMethod.NEVER,
+ Connection.ReferralHandlingMethod.IGNORE, false, null );
+ SearchRunnable.searchAndUpdateModel( browserConnection, search, monitor );
// the list of entries under the Root DSE
Map<LdapDN, IEntry> rootDseEntries = new HashMap<LdapDN, IEntry>();
Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/Schema.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/Schema.java?rev=675924&r1=675923&r2=675924&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/Schema.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/Schema.java Fri Jul 11 04:50:47 2008
@@ -90,6 +90,15 @@
DUMMY_LDAP_SYNTAX.setDescription( "" );
}
+ public static final HashMap<String,List<String>> DUMMY_EXTENSIONS;
+ static
+ {
+ DUMMY_EXTENSIONS = new HashMap<String, List<String>>();
+ List<String> dummyValues = new ArrayList<String>();
+ dummyValues.add("DUMMY");
+ DUMMY_EXTENSIONS.put( "X-DUMMY", dummyValues );
+ }
+
public static final Schema DEFAULT_SCHEMA;
static
{
@@ -476,6 +485,7 @@
ObjectClassDescription ocd = new ObjectClassDescription();
ocd.setNumericOid( nameOrOid );
ocd.setNames( names );
+ ocd.setExtensions( DUMMY_EXTENSIONS );
return ocd;
}
}
@@ -562,6 +572,7 @@
atd.setNames( attributeTypes );
atd.setUserModifiable( false );
atd.setUsage( UsageEnum.USER_APPLICATIONS );
+ atd.setExtensions( DUMMY_EXTENSIONS );
return atd;
}
}
@@ -635,6 +646,7 @@
// DUMMY
LdapSyntaxDescription lsd = new LdapSyntaxDescription();
lsd.setNumericOid( numericOid );
+ lsd.setExtensions( DUMMY_EXTENSIONS );
return lsd;
}
}
@@ -713,6 +725,7 @@
// DUMMY
MatchingRuleDescription mrd = new MatchingRuleDescription();
mrd.setNumericOid( nameOrOid );
+ mrd.setExtensions( DUMMY_EXTENSIONS );
return mrd;
}
}
@@ -791,6 +804,7 @@
// DUMMY
MatchingRuleUseDescription mrud = new MatchingRuleUseDescription();
mrud.setNumericOid( nameOrOid );
+ mrud.setExtensions( DUMMY_EXTENSIONS );
return mrud;
}
}
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=675924&r1=675923&r2=675924&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 Fri Jul 11 04:50:47 2008
@@ -194,15 +194,23 @@
}
+ /**
+ * An attribute type is marked as operational if either
+ * <li>the usage differs from USER_APPLICATIONS or
+ * <li>if is not declared in the schema and contains the dummy extension
+ *
+ * @param atd the attribute type description
+ *
+ * @return true, if is operational
+ */
public static boolean isOperational( AttributeTypeDescription atd )
{
- return !atd.isUserModifiable() || atd.getUsage() != UsageEnum.USER_APPLICATIONS;
+ return atd.getUsage() != UsageEnum.USER_APPLICATIONS || atd.getExtensions() == Schema.DUMMY_EXTENSIONS;
}
public static boolean isModifyable( AttributeTypeDescription atd )
{
-
if ( atd == null )
{
return false;