Skip to content
Permalink
Browse files
o Removed some calls to value.getString() which weren't necessary
o Fixed some potential error when using the Value.getString() method on
binary values
  • Loading branch information
elecharny committed May 9, 2019
1 parent ccb6586 commit 0e116e9f582caa288c3dd4204f5c87c171e198a8
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 32 deletions.
@@ -758,7 +758,15 @@ public static javax.naming.directory.Attribute toJndiAttribute( Attribute attrib
for ( Iterator<Value> valueIterator = attribute.iterator(); valueIterator.hasNext(); )
{
Value value = valueIterator.next();
jndiAttribute.add( value.getString() );

if ( value.isHumanReadable() )
{
jndiAttribute.add( value.getString() );
}
else
{
jndiAttribute.add( value.getBytes() );
}
}

return jndiAttribute;
@@ -581,8 +581,8 @@ public String getNormalized()


/**
* Get the wrapped value as a byte[]. If the original value
* is binary, this method will return a copy of the wrapped byte[]
* Get the wrapped value as a byte[], if and only if the Value is binary,
* otherwise returns null.
*
* @return the wrapped value as a byte[]
*/
@@ -383,13 +383,13 @@ private static LdifEntry generateModify( Dn parentDn, Entry entry, Rdn oldRdn, R
{
// No need to add something which has already been added
// in the previous modification
if ( !entry.contains( ava.getNormType(), ava.getValue().getString() )
&& !( ava.getNormType().equals( oldRdn.getNormType() ) && ava.getValue().getString().equals(
if ( !entry.contains( ava.getNormType(), ava.getValue() )
&& !( ava.getNormType().equals( oldRdn.getNormType() ) && ava.getValue().equals(
oldRdn.getValue() ) ) )
{
// Create the modification, which is an Remove
Modification modification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE,
new DefaultAttribute( ava.getType(), ava.getValue().getString() ) );
new DefaultAttribute( ava.getType(), ava.getValue() ) );

restored.addModification( modification );
}
@@ -525,7 +525,7 @@ public static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior,
for ( Ava atav : newRdn )
{
if ( !atav.equals( oldRdn.getAva() )
&& ( entry.contains( atav.getNormType(), atav.getValue().getString() ) ) )
&& ( entry.contains( atav.getNormType(), atav.getValue() ) ) )
{
existInEntry = true;
}
@@ -578,7 +578,7 @@ public static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior,
{
overlapping = true;
}
else if ( entry.contains( atav.getNormType(), atav.getValue().getString() ) )
else if ( entry.contains( atav.getNormType(), atav.getValue() ) )
{
existInEntry = true;
}
@@ -172,15 +172,7 @@ public Ava( SchemaManager schemaManager, Ava ava ) throws LdapInvalidDnException
}
}

StringBuilder sb = new StringBuilder( upType );
sb.append( '=' );

if ( ( value != null ) && ( value.getString() != null ) )
{
sb.append( value.getString() );
}

upName = sb.toString();
upName = getEscaped();

hashCode();
}
@@ -1358,20 +1358,6 @@ private Attribute getByteCode( LoadableSchemaObject description, String objectTy
}


/**
* Return a String value, from the given Value, even if it's a binary value
*
* @param attribute The Attribute to process
* @return The Attribute value as a String
*/
private String getStringValue( Attribute attribute )
{
Value value = attribute.get();

return value.getString();
}


/**
* Process the common attributes to all SchemaObjects :
* - obsolete
@@ -1405,7 +1391,7 @@ private void setSchemaObjectProperties( SchemaObject schemaObject, Entry entry,

if ( mDescription != null )
{
schemaObject.setDescription( getStringValue( mDescription ) );
schemaObject.setDescription( mDescription.getString() );
}

// The names field

0 comments on commit 0e116e9

Please sign in to comment.