2929
3030import com .odoojava .api .OdooXmlRpcProxy .RPCProtocol ;
3131import com .odoojava .api .OdooXmlRpcProxy .RPCServices ;
32- import com .googlecode .jsonrpc4j .JsonRpcHttpClient ;
32+ import com .googlecode .jsonrpc4j .*;
33+ import com .googlecode .jsonrpc4j .JsonRpcClientException ;
3334
3435/**
3536 * *
@@ -222,10 +223,24 @@ int authenticate() throws XmlRpcException, Exception {
222223 // JSONRPC part
223224 try {
224225 id = authenticate_json_rpc ();
226+ System .out .println ("json rpc login" );
227+
228+ } catch (JsonRpcClientException e ) {
229+ // TODO Auto-generated catch block
230+ String exc = e .getMessage ();
231+ System .out .println ("Json rpc issue possibly caused by https://github.com/OCA/server-tools/issues/1237" );
232+
233+
225234 } catch (Throwable e ) {
226235 // TODO Auto-generated catch block
236+
237+ System .out .println ("General exception" );
227238 e .printStackTrace ();
228239 }
240+ finally {
241+ System .out .println ("something bad potentially happened during connexion through JsonRPC" );
242+ }
243+
229244 if (id instanceof Integer ) {
230245 userID = (Integer ) id ;
231246 } else {
@@ -270,7 +285,7 @@ public Object[] call_report_jsonrpc(String reportModel, String reportMethod, Arr
270285 methodparams .add (password );
271286 methodparams .add (reportModel );
272287 methodparams .add (reportMethod );
273- methodparams .add ( args );
288+ methodparams .add (args );
274289
275290 jsonparams .put ("args" , methodparams );
276291
@@ -389,12 +404,12 @@ public Object executeCommand(final String objectName, final String commandName,
389404 * @param commandName Command name to execute
390405 * @param parameters List of parameters for the command. For easy of use,
391406 * consider the OdooCommand object or ObjectAdapter
392- * @param context The user context
407+ * @param context The user context
393408 * @return The result of the call
394409 * @throws XmlRpcException
395410 */
396- public Object executeCommandKw (final String objectName , final String commandName , final Object [] parameters , Context context )
397- throws XmlRpcException {
411+ public Object executeCommandKw (final String objectName , final String commandName , final Object [] parameters ,
412+ Context context ) throws XmlRpcException {
398413
399414 List <Object > paramsList = new ArrayList <>();
400415 paramsList .addAll (Arrays .asList (new Object [] { databaseName , userID , password , objectName , commandName }));
@@ -403,7 +418,7 @@ public Object executeCommandKw(final String objectName, final String commandName
403418 }
404419
405420 Map <String , Context > c = new HashMap <>();
406- c .put ("context" ,context );
421+ c .put ("context" , context );
407422 paramsList .add (c );
408423 return objectClient .execute ("execute_kw" , paramsList );
409424
@@ -425,16 +440,16 @@ public Object executeCommandWithContext(final String objectName, final String co
425440 final Object [] parameters ) throws XmlRpcException {
426441 Object [] connectionParams = new Object [] { databaseName , userID , password , objectName , commandName };
427442
428- if (this .getServerVersion ().getMajor () < 13 ){
443+ if (this .getServerVersion ().getMajor () < 13 ) {
429444 // Combine the parameters with the context
430445 Object [] params = new Object [1 + (parameters == null ? 0 : parameters .length )];
431446 if (parameters != null && parameters .length > 0 ) {
432447 System .arraycopy (parameters , 0 , params , 0 , parameters .length );
433448 }
434449 System .arraycopy (new Object [] { getContext () }, 0 , params , parameters .length , 1 );
435450 return executeCommand (objectName , commandName , params );
436- }else {
437- return executeCommandKw (objectName , commandName , parameters ,getContext ());
451+ } else {
452+ return executeCommandKw (objectName , commandName , parameters , getContext ());
438453 }
439454
440455 }
0 commit comments