@ -120,7 +120,7 @@ public class ActFmSyncThread {
public static interface SyncMessageCallback {
public void runOnSuccess ( ) ;
public void runOnErrors ( List < JSON Object > errors ) ;
public void runOnErrors ( List < JSON Array > errors ) ;
}
public static enum ModelType {
@ -282,7 +282,7 @@ public class ActFmSyncThread {
}
@Override
public void runOnErrors ( List < JSON Object > errors ) { /**/ }
public void runOnErrors ( List < JSON Array > errors ) { /**/ }
} ;
@SuppressWarnings ( "nls" )
@ -382,14 +382,14 @@ public class ActFmSyncThread {
}
Set < SyncMessageCallback > callbacksExecutedThisLoop = new HashSet < SyncMessageCallback > ( ) ;
Map < Integer , List < JSON Object > > errorMap = buildErrorMap ( errors ) ;
Map < Integer , List < JSON Array > > errorMap = buildErrorMap ( errors ) ;
for ( int i = 0 ; i < messageBatch . size ( ) ; i + + ) {
ClientToServerMessage < ? > message = messageBatch . get ( i ) ;
incrementProgress ( ) ;
try {
SyncMessageCallback r = pendingCallbacks . remove ( message ) ;
if ( r ! = null & & ! callbacksExecutedThisLoop . contains ( r ) ) {
List < JSON Object > errorList = errorMap . get ( i ) ;
List < JSON Array > errorList = errorMap . get ( i ) ;
if ( errorList = = null | | errorList . isEmpty ( ) )
r . runOnSuccess ( ) ;
else
@ -415,19 +415,18 @@ public class ActFmSyncThread {
}
private Map < Integer , List < JSON Object > > buildErrorMap ( JSONArray errors ) {
Map < Integer , List < JSON Object > > result = new HashMap < Integer , List < JSON Object > > ( ) ;
private Map < Integer , List < JSON Array > > buildErrorMap ( JSONArray errors ) {
Map < Integer , List < JSON Array > > result = new HashMap < Integer , List < JSON Array > > ( ) ;
if ( errors ! = null ) {
for ( int i = 0 ; i < errors . length ( ) ; i + + ) {
JSON Object error = errors . optJSONObject ( i ) ;
if ( error ! = null & & error . has( "index" ) ) { //$NON-NLS-1$
int index = error . optInt ( "index" ) ; //$NON-NLS-1$
List < JSON Object > errorList = result . get ( index ) ;
JSON Array error = errors . optJSONArray ( i ) ;
if ( error ! = null & & error . length( ) > 0 ) {
int index = error . optInt ( 0 ) ;
List < JSON Array > errorList = result . get ( index ) ;
if ( errorList = = null ) {
errorList = new LinkedList < JSON Object > ( ) ;
errorList = new LinkedList < JSON Array > ( ) ;
result . put ( index , errorList ) ;
}
error . remove ( "index" ) ; //$NON-NLS-1$
errorList . add ( error ) ;
}
}