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