Emmanuel Lecharny created DIRSTUDIO-1139:
--------------------------------------------

             Summary: Cannot add attribute with a null value in teh Entry editor
                 Key: DIRSTUDIO-1139
                 URL: https://issues.apache.org/jira/browse/DIRSTUDIO-1139
             Project: Directory Studio
          Issue Type: Bug
          Components: studio-ldapbrowser
    Affects Versions: 2.0.0-M12
            Reporter: Emmanuel Lecharny


The entry editor does not allow you to add an attribute with a null value, like 
a {{mail}} for instance (where value can be null, per IA5String syntax).

When saving the modified entry, you get the following exception :

{noformat}
!ENTRY org.eclipse.ui 4 0 2017-03-10 06:40:16.420
!MESSAGE Unhandled event loop exception
!STACK 0
...
Caused by: java.lang.RuntimeException: Empty value in attribute mail
        at 
org.apache.directory.studio.entryeditors.EntryEditorManager.saveSharedWorkingCopy(EntryEditorManager.java:991)
        at 
org.apache.directory.studio.entryeditors.EntryEditorInput.saveSharedWorkingCopy(EntryEditorInput.java:283)
        at 
org.apache.directory.studio.ldapbrowser.ui.editors.entry.EntryEditor.doSave(EntryEditor.java:221)
        ... 59 more
{noformat}

The code is :

{noformat}
...
                for ( IAttribute attribute : workingCopy.getAttributes() )
                {
                    for ( IValue value : attribute.getValues() )
                    {
                        if ( ( value.isEmpty()  )
                        {
                            // 
                            throw new RuntimeException( NLS.bind( Messages
                                .getString( 
"EntryEditorManager.EmptyValueInAttribute" ), attribute.getDescription() ) ); 
//$NON-NLS-1$
                        }
...
{noformat}

What we would like to do is :

{noformat}
...
                for ( IAttribute attribute : workingCopy.getAttributes() )
                {
                    for ( IValue value : attribute.getValues() )
                    {
                        LdapSyntax syntax = 
attribute.getEntry().getBrowserConnection().getSchema().getLdapSyntaxDescription(
 attribute.getDescription() );
                        
                        SyntaxChecker syntaxChecker = syntax.getSyntaxChecker();
                        
                        if (!syntax.getSyntaxChecker().isValidSyntax( 
value.getRawValue() ) )
                        {
                            // 
                            throw new RuntimeException( NLS.bind( Messages
                                .getString( 
"EntryEditorManager.EmptyValueInAttribute" ), attribute.getDescription() ) ); 
//$NON-NLS-1$
                        }
...
{noformat}

but sadly, the {{SyntaxChecker}} is not accessible in the {{LdapSyntax}} we get 
back (it's null).

That is annoying, but understandable, assuming that all the LDAP servers we are 
connected to aren't able to feed the Schema properly...



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to