[ 
https://issues.apache.org/jira/browse/DIRSTUDIO-1079?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15043702#comment-15043702
 ] 

Emmanuel Lecharny edited comment on DIRSTUDIO-1079 at 12/6/15 5:16 AM:
-----------------------------------------------------------------------

Thanks for pointing me to the right class/line.

It's with an OpenLDAP server. The {{EntryCSN}} AT is NON-MODIFIABLE, but 
strange enough, the schema pulled from the server does not expose this 
attribute, so that make senses that's is being copied from the other entry.

Funny enough, the problem is not existing when using the ldif editor.

The problem is that we are testing the AT modifiable flag, and for some 
specific attributes that are not returned by schemas (DirX, etc), we have a 
HashSet which is supposed to contain the non-user modifiable attributes, and 
the {{SchemaUtils.isModifiable()}} method is testing the attributes against 
this hashSet :

{noformat}
    public static boolean isModifiable( AttributeType atd )
    {
        ...
        // Check some default no-user-modification attributes
        // e.g. Siemens DirX doesn't provide a good schema.
        // TODO: make default no-user-modification attributes configurable
        if ( CollectionUtils.containsAny( 
NON_MODIFIABLE_ATTRIBUTE_OIDS_AND_NAMES, getLowerCaseIdentifiers( atd ) ) )
        {
            return false;
        }

        return true;
    }
{noformat}

So we could expect this hashSet to contain the {{entryCSN}} attribute, but...

Here is the way this hashSet is initialized :

{noformat}
    /** The well-known non-modifiable attributes */
    public static final Set<String> NON_MODIFIABLE_ATTRIBUTE_OIDS_AND_NAMES = 
new HashSet<String>();
    static
    {
        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings.toLowerCase( 
SchemaConstants.CREATE_TIMESTAMP_AT ) );
        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings.toLowerCase( 
SchemaConstants.CREATE_TIMESTAMP_AT_OID ) );
        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings.toLowerCase( 
SchemaConstants.CREATORS_NAME_AT ) );
        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings.toLowerCase( 
SchemaConstants.CREATORS_NAME_AT_OID ) );
        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings.toLowerCase( 
SchemaConstants.MODIFY_TIMESTAMP_AT ) );
        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings.toLowerCase( 
SchemaConstants.MODIFY_TIMESTAMP_AT_OID ) );
        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings.toLowerCase( 
SchemaConstants.MODIFIERS_NAME_AT ) );
        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings.toLowerCase( 
SchemaConstants.MODIFIERS_NAME_AT_OID ) );

        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings.toLowerCase( 
SchemaConstants.SUBSCHEMA_SUBENTRY_AT ) );
        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings.toLowerCase( 
SchemaConstants.SUBSCHEMA_SUBENTRY_AT_OID ) );
        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings.toLowerCase( 
SchemaConstants.STRUCTURAL_OBJECT_CLASS_AT ) );
        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES
            .add( Strings.toLowerCase( 
SchemaConstants.STRUCTURAL_OBJECT_CLASS_AT_OID ) );
        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings.toLowerCase( 
SchemaConstants.GOVERNING_STRUCTURE_RULE_AT ) );
        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings
            .toLowerCase( SchemaConstants.GOVERNING_STRUCTURE_RULE_AT_OID ) );

        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings.toLowerCase( 
SchemaConstants.ENTRY_UUID_AT ) );
        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings.toLowerCase( 
SchemaConstants.ENTRY_UUID_AT_OID ) );
        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings.toLowerCase( 
SchemaConstants.ENTRY_CSN_AT ) );
        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings.toLowerCase( 
SchemaConstants.ENTRY_DN_AT ) );
        ...
{noformat}

All is there (except the ENTRY_CSN_OID), so we are fine, except that we are 
*NOT* filling the right hashSet. Most certainly a bad copy/paste (and that was 
back from 2009, commit 754547 ;-)...

I'm going to fix that.


was (Author: elecharny):
Thanks for pointing me to the right class/line.

It's with an OpenLDAP server. The {{EntryCSN}} AT is NON-MODIFIABLE, but 
strange enough, the schema pulled from the server does not expose this 
attribute, so that make senses that's is being copied from the other entry.

Funny enough, the problem is not existing when using the ldif editor.

The problem is that we are testing the AT modifiable flag, and for some 
specific attributes that are not returned by schemas (DirX, etc), we have a 
HashSet which is supposed to contain the non-user modifiable attributes, and 
the {{SchemaUtils.isModifiable()}} method is testing the attributes against 
this hashSet :

{nofomat}
    public static boolean isModifiable( AttributeType atd )
    {
        ...
        // Check some default no-user-modification attributes
        // e.g. Siemens DirX doesn't provide a good schema.
        // TODO: make default no-user-modification attributes configurable
        if ( CollectionUtils.containsAny( 
NON_MODIFIABLE_ATTRIBUTE_OIDS_AND_NAMES, getLowerCaseIdentifiers( atd ) ) )
        {
            return false;
        }

        return true;
    }
{noformat}

So we could expect this hashSet to contain the {{entryCSN}} attribute, but...

Here is the way this hashSet is initialized :

{noFormat}
    /** The well-known non-modifiable attributes */
    public static final Set<String> NON_MODIFIABLE_ATTRIBUTE_OIDS_AND_NAMES = 
new HashSet<String>();
    static
    {
        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings.toLowerCase( 
SchemaConstants.CREATE_TIMESTAMP_AT ) );
        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings.toLowerCase( 
SchemaConstants.CREATE_TIMESTAMP_AT_OID ) );
        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings.toLowerCase( 
SchemaConstants.CREATORS_NAME_AT ) );
        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings.toLowerCase( 
SchemaConstants.CREATORS_NAME_AT_OID ) );
        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings.toLowerCase( 
SchemaConstants.MODIFY_TIMESTAMP_AT ) );
        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings.toLowerCase( 
SchemaConstants.MODIFY_TIMESTAMP_AT_OID ) );
        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings.toLowerCase( 
SchemaConstants.MODIFIERS_NAME_AT ) );
        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings.toLowerCase( 
SchemaConstants.MODIFIERS_NAME_AT_OID ) );

        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings.toLowerCase( 
SchemaConstants.SUBSCHEMA_SUBENTRY_AT ) );
        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings.toLowerCase( 
SchemaConstants.SUBSCHEMA_SUBENTRY_AT_OID ) );
        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings.toLowerCase( 
SchemaConstants.STRUCTURAL_OBJECT_CLASS_AT ) );
        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES
            .add( Strings.toLowerCase( 
SchemaConstants.STRUCTURAL_OBJECT_CLASS_AT_OID ) );
        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings.toLowerCase( 
SchemaConstants.GOVERNING_STRUCTURE_RULE_AT ) );
        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings
            .toLowerCase( SchemaConstants.GOVERNING_STRUCTURE_RULE_AT_OID ) );

        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings.toLowerCase( 
SchemaConstants.ENTRY_UUID_AT ) );
        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings.toLowerCase( 
SchemaConstants.ENTRY_UUID_AT_OID ) );
        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings.toLowerCase( 
SchemaConstants.ENTRY_CSN_AT ) );
        OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( Strings.toLowerCase( 
SchemaConstants.ENTRY_DN_AT ) );
        ...
{noFormat}

All is there (except the ENTRY_CSN_OID), so we are fine, except that we are 
*NOT* filling the right hashSet. Most certainly a bad copy/paste (and that was 
back from 2009, commit 754547 ;-)...

I'm going to fix that.

> Creating a new entry using an existing one fails because teh entryCSN at is 
> being copied
> ----------------------------------------------------------------------------------------
>
>                 Key: DIRSTUDIO-1079
>                 URL: https://issues.apache.org/jira/browse/DIRSTUDIO-1079
>             Project: Directory Studio
>          Issue Type: Bug
>          Components: studio-ldapbrowser
>    Affects Versions: 2.0.0-M9 (2.0.0.v20150606-M9)
>            Reporter: Emmanuel Lecharny
>            Priority: Minor
>
> When we create a new entry using an existing entry as a template, if the 
> existing entry has an {{entryCSN}} attribute, it will be present in the new 
> entry. This is not good because first this is an operational attribute and 
> second because this attribute will be rejected by the remote server



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to