Skip to content
Permalink
Browse files
Fixed 20 blocker issues (Sonar)
  • Loading branch information
elecharny committed Jan 2, 2019
1 parent 0169c46 commit cb78ad62bc5a3f7a9c038962b9cd3f38c0fe1919
Show file tree
Hide file tree
Showing 10 changed files with 123 additions and 151 deletions.
@@ -142,39 +142,6 @@ public boolean isDeleteOldRDN()
}


/**
* Set the flag to delete the old Rdn
*
* @param deleteOldRDN The deleteOldRDN to set.
*/
public void setDeleteOldRDN( boolean deleteOldRDN )
{
getDecorated().setDeleteOldRdn( deleteOldRDN );
}


/**
* Get the new Rdn
*
* @return Returns the newRDN.
*/
public Rdn getNewRDN()
{
return getDecorated().getNewRdn();
}


/**
* Set the new Rdn
*
* @param newRdn The newRdn to set.
*/
public void setNewRDN( Rdn newRdn )
{
getDecorated().setNewRdn( newRdn );
}


/**
* Get the newSuperior
*
@@ -533,121 +533,122 @@ public void anonymizeFile( String ldifFile, Writer writer ) throws LdapException
return;
}

LdifReader ldifReader = new LdifReader( inputFile, schemaManager );
int count = 0;
List<LdifEntry> errors = new ArrayList<>();
List<String> errorTexts = new ArrayList<>();

try
try ( LdifReader ldifReader = new LdifReader( inputFile, schemaManager ) )
{
for ( LdifEntry ldifEntry : ldifReader )
int count = 0;
List<LdifEntry> errors = new ArrayList<>();
List<String> errorTexts = new ArrayList<>();

try
{
count++;

try
for ( LdifEntry ldifEntry : ldifReader )
{
if ( ldifEntry.isEntry() && !ldifEntry.isChangeAdd() )
{
// process a full entry. Add changes aren't processed here.
Entry newEntry = anonymizeEntry( ldifEntry );

writer.write( LdifUtils.convertToLdif( newEntry ) );
writer.write( "\n" );
}
else if ( ldifEntry.isChangeDelete() )
count++;

try
{
// A Delete operation
LdifEntry newLdifEntry = anonymizeChangeDelete( ldifEntry );

if ( ldifEntry != null )
if ( ldifEntry.isEntry() && !ldifEntry.isChangeAdd() )
{
writer.write( newLdifEntry.toString() );
// process a full entry. Add changes aren't processed here.
Entry newEntry = anonymizeEntry( ldifEntry );

writer.write( LdifUtils.convertToLdif( newEntry ) );
writer.write( "\n" );
}
}
else if ( ldifEntry.isChangeAdd() )
{
// A Add operation
LdifEntry newLdifEntry = anonymizeChangeAdd( ldifEntry );

if ( ldifEntry != null )
else if ( ldifEntry.isChangeDelete() )
{
writer.write( newLdifEntry.toString() );
writer.write( "\n" );
// A Delete operation
LdifEntry newLdifEntry = anonymizeChangeDelete( ldifEntry );

if ( ldifEntry != null )
{
writer.write( newLdifEntry.toString() );
writer.write( "\n" );
}
}
}
else if ( ldifEntry.isChangeModify() )
{
// A Modify operation
LdifEntry newLdifEntry = anonymizeChangeModify( ldifEntry );

if ( ldifEntry != null )
else if ( ldifEntry.isChangeAdd() )
{
writer.write( newLdifEntry.toString() );
writer.write( "\n" );
// A Add operation
LdifEntry newLdifEntry = anonymizeChangeAdd( ldifEntry );

if ( ldifEntry != null )
{
writer.write( newLdifEntry.toString() );
writer.write( "\n" );
}
}
}
else if ( ldifEntry.isChangeModDn() || ldifEntry.isChangeModRdn() )
{
// A MODDN operation
LdifEntry newLdifEntry = anonymizeChangeModDn( ldifEntry );

if ( ldifEntry != null )
else if ( ldifEntry.isChangeModify() )
{
writer.write( newLdifEntry.toString() );
writer.write( "\n" );
// A Modify operation
LdifEntry newLdifEntry = anonymizeChangeModify( ldifEntry );

if ( ldifEntry != null )
{
writer.write( newLdifEntry.toString() );
writer.write( "\n" );
}
}
else if ( ldifEntry.isChangeModDn() || ldifEntry.isChangeModRdn() )
{
// A MODDN operation
LdifEntry newLdifEntry = anonymizeChangeModDn( ldifEntry );

if ( ldifEntry != null )
{
writer.write( newLdifEntry.toString() );
writer.write( "\n" );
}
}

System.out.print( '.' );

if ( count % 100 == 0 )
{
println();
}
}

System.out.print( '.' );

if ( count % 100 == 0 )
catch ( Exception e )
{
println();
System.out.print( '*' );

if ( count % 100 == 0 )
{
println();
}

errors.add( ldifEntry );
errorTexts.add( e.getMessage() );
}
}
catch ( Exception e )

println();

if ( !errors.isEmpty() )
{
System.out.print( '*' );

if ( count % 100 == 0 )
println( "There are " + errors.size() + " bad entries" );
int i = 0;

for ( LdifEntry ldifEntry : errors )
{
println();
println( "---------------------------------------------------" );
println( "error : " + errorTexts.get( i ) );
println( ldifEntry.getDn().toString() );
i++;
}

errors.add( ldifEntry );
errorTexts.add( e.getMessage() );
}
}

println();

if ( !errors.isEmpty() )
finally
{
println( "There are " + errors.size() + " bad entries" );
int i = 0;

for ( LdifEntry ldifEntry : errors )
println();

if ( !errors.isEmpty() )
{
println( "---------------------------------------------------" );
println( "error : " + errorTexts.get( i ) );
println( ldifEntry.getDn().toString() );
i++;
println( "There are " + errors.size() + " bad entries" );
}

println( "Nb entries : " + count );
}
}
finally
{
println();

if ( !errors.isEmpty() )
{
println( "There are " + errors.size() + " bad entries" );
}

println( "Nb entries : " + count );
ldifReader.close();
}
}


@@ -73,24 +73,22 @@ public MultipleResponseFuture( LdapConnection connection, int messageId )
@Override
public boolean cancel( boolean mayInterruptIfRunning )
{
if ( cancelled )
if ( !cancelled )
{
return cancelled;
// set the cancel flag first
cancelled = true;

// Send an abandonRequest only if this future exists
if ( !connection.isRequestCompleted( messageId ) )
{
connection.abandon( messageId );
}

// then clear the queue, cause the might be some incoming messages before this abandon request
// hits the server
queue.clear();
}

// set the cancel flag first
cancelled = true;

// Send an abandonRequest only if this future exists
if ( !connection.isRequestCompleted( messageId ) )
{
connection.abandon( messageId );
}

// then clear the queue, cause the might be some incoming messages before this abandon request
// hits the server
queue.clear();

return cancelled;
}

@@ -255,7 +255,7 @@ public Iterator<String> registeredResponseControls()
@Override
public boolean isControlRegistered( String oid )
{
return requestControlFactories.containsKey( oid ) | responseControlFactories.containsKey( oid );
return requestControlFactories.containsKey( oid ) || responseControlFactories.containsKey( oid );
}


@@ -55,10 +55,11 @@ public class VirtualListViewRequestImpl extends AbstractControl implements Virtu
/** The assertionValue */
private byte[] assertionValue;

private static final boolean OFFSET_CHOICE = true;

/** A flag used for the target. It default to OFFSET */
private boolean targetType = OFFSET;
private boolean targetType = OFFSET_CHOICE;

private static final boolean OFFSET = true;
private static final boolean ASSERTION_VALUE = false;


@@ -128,7 +129,7 @@ public int getOffset()
public void setOffset( int offset )
{
this.offset = offset;
targetType = OFFSET;
targetType = OFFSET_CHOICE;
}


@@ -199,7 +200,7 @@ public void setContextId( byte[] contextId )
@Override
public boolean hasOffset()
{
return targetType == OFFSET;
return targetType == OFFSET_CHOICE;
}


@@ -280,7 +281,7 @@ public String toString()
sb.append( " afterCount : '" ).append( afterCount ).append( "'\n" );
sb.append( " target : \n" );

if ( targetType == OFFSET )
if ( targetType == OFFSET_CHOICE )
{
sb.append( " offset : '" ).append( offset ).append( "'\n" );
sb.append( " contentCount : '" ).append( contentCount ).append( "'\n" );
@@ -63,7 +63,8 @@ public StartTransactionResponseImpl( int messageId, ResultCodeEnum resultCode, b
{
case SUCCESS:
this.transactionId = Strings.copy( transactionId );
// pass through ...
break;

case CANCELED:
case CANNOT_CANCEL:
case NO_SUCH_OPERATION:
@@ -244,12 +244,11 @@ else if ( ava instanceof byte[] )
}

// Now, parse the Ldif and convert it to a LdifEntry
LdifReader reader = new LdifReader();
List<LdifEntry> ldifEntries = reader.parseLdif( sb.toString() );

try
List<LdifEntry> ldifEntries = null;

try ( LdifReader reader = new LdifReader() )
{
reader.close();
ldifEntries = reader.parseLdif( sb.toString() );
}
catch ( IOException e )
{
@@ -163,15 +163,19 @@ public static NoticeOfDisconnect createNoticeOfDisconnect( ResultCodeEnum rcode
{
case UNAVAILABLE:
nod = UNAVAILABLE;
break;

case PROTOCOL_ERROR:
nod = PROTOCOLERROR;
break;

case STRONG_AUTH_REQUIRED:
nod = STRONGAUTHREQUIRED;
break;

default:
nod = new NoticeOfDisconnect( rcode );
break;
}

nod.getLdapResult().setDiagnosticMessage( rcode.toString() + ": The server will disconnect!" );
@@ -1411,8 +1411,9 @@ public static Object unescapeValue( String value )
{
// '#' are allowed if not in first position
bytes[pos++] = '#';
break;
}

break;

case ' ':
if ( ( i == 0 ) || ( i == chars.length - 1 ) )

0 comments on commit cb78ad6

Please sign in to comment.