Openbravo Issue Tracking System - Retail Modules
View Issue Details
0035601Retail ModulesStoreServerpublic2017-03-22 16:402017-03-31 12:30
mtaal 
mtaal 
normalminorhave not tried
closedfixed 
5
 
RR17Q2RR17Q2 
AugustoMauch
No
0035601: Transition to offline is not triggered at every location in the MultiServerJSONProcess code
There are different ways in which an exception from the call to central is handled in the multi-server-json-process code. In one place a transition to offline is done [1], while in the other [2] this is not done.

[1]
https://code.openbravo.com/erp/pmods/org.openbravo.mobile.core/file/553553b86771/src/org/openbravo/mobile/core/servercontroller/MultiServerJSONProcess.java#l390 [^]

[2]
https://code.openbravo.com/erp/pmods/org.openbravo.mobile.core/file/553553b86771/src/org/openbravo/mobile/core/servercontroller/MultiServerJSONProcess.java#l361 [^]
See the code links
In both locations in the code the same behavior should be done: transition to offline.
No tags attached.
related to design defect 0035667RR17Q3 closed mtaal Move duplicate code together in one method in MultiServerJSONProcess 
Issue History
2017-03-22 16:40mtaalNew Issue
2017-03-22 16:40mtaalAssigned To => mtaal
2017-03-22 16:40mtaalTriggers an Emergency Pack => No
2017-03-29 14:25mtaalNote Added: 0095647
2017-03-29 14:27hgbotCheckin
2017-03-29 14:27hgbotNote Added: 0095648
2017-03-29 14:27hgbotStatusnew => resolved
2017-03-29 14:27hgbotResolutionopen => fixed
2017-03-29 14:27hgbotFixed in SCM revision => http://code.openbravo.com/erp/pmods/org.openbravo.mobile.core/rev/012e6b7ab09cfdfc418a351f098d40560a1ac59f [^]
2017-03-29 14:29mtaalReview Assigned To => AugustoMauch
2017-03-30 13:29AugustoMauchNote Added: 0095708
2017-03-30 13:30AugustoMauchStatusresolved => new
2017-03-30 13:30AugustoMauchResolutionfixed => open
2017-03-30 13:30AugustoMauchNote Edited: 0095708bug_revision_view_page.php?bugnote_id=0095708#r14919
2017-03-30 13:30AugustoMauchNote Edited: 0095708bug_revision_view_page.php?bugnote_id=0095708#r14920
2017-03-30 16:45AugustoMauchNote Edited: 0095708bug_revision_view_page.php?bugnote_id=0095708#r14925
2017-03-31 12:27mtaalNote Added: 0095760
2017-03-31 12:28mtaalStatusnew => scheduled
2017-03-31 12:28mtaalNote Added: 0095762
2017-03-31 12:28mtaalStatusscheduled => resolved
2017-03-31 12:28mtaalFixed in Version => RR17Q2
2017-03-31 12:28mtaalResolutionopen => fixed
2017-03-31 12:29mtaalRelationship addedrelated to 0035667
2017-03-31 12:30AugustoMauchNote Added: 0095763
2017-03-31 12:30AugustoMauchStatusresolved => closed

Notes
(0095647)
mtaal   
2017-03-29 14:25   
Tested this by forcing the code in MultiServerJSONProcess to go into the first if and then throwing an exception:

    if (true || executeOnlyInCentral(jsonSent)) {
      final JSONObject jsonToCentral = new JSONObject(jsonSent.toString());
      // sent along from the store to central, set the source to STORE
      jsonToCentral.put(SOURCE_PROP, SOURCE_STORE);
      // prevent cycling around
      jsonToCentral.remove(CALL_ONLY_CENTRAL_PROP);
      JSONObject centralResult = null;
      try {
        centralResult = MobileServerRequestExecutor.getInstance().executeCentralRequest(
            MobileServerUtils.OBWSPATH + this.getClass().getName(), jsonToCentral);
        if (true) {
          throw new Exception("TEST");
        }
      } catch (Throwable t) {
        log.error(t.getMessage(), t);
(0095648)
hgbot   
2017-03-29 14:27   
Repository: erp/pmods/org.openbravo.mobile.core
Changeset: 012e6b7ab09cfdfc418a351f098d40560a1ac59f
Author: Martin Taal <martin.taal <at> openbravo.com>
Date: Wed Mar 29 14:26:56 2017 +0200
URL: http://code.openbravo.com/erp/pmods/org.openbravo.mobile.core/rev/012e6b7ab09cfdfc418a351f098d40560a1ac59f [^]

Fixes issue 35601: Transition to offline is not triggered at every location in the MultiServerJSONProcess code
In case of only central request then use the same transition to offline code and returning error as in other places in this class.

---
M src/org/openbravo/mobile/core/servercontroller/MultiServerJSONProcess.java
---
(0095708)
AugustoMauch   
2017-03-30 13:29   
(edited on: 2017-03-30 16:45)
The code that handlers the flow when there is an exception here [1] and here [2] is duplicated. It would be better if this code is extracted to a function.

Also, this line [3] states that the transition to offline will only be done if the node is not transitioning. But the transition to offline should be done if the node is transitioning to online, right?

[1] https://code.openbravo.com/erp/pmods/org.openbravo.mobile.core/file/012e6b7ab09c/src/org/openbravo/mobile/core/servercontroller/MultiServerJSONProcess.java#l361 [^]
[2] https://code.openbravo.com/erp/pmods/org.openbravo.mobile.core/file/012e6b7ab09c/src/org/openbravo/mobile/core/servercontroller/MultiServerJSONProcess.java#l418 [^]
[3] https://code.openbravo.com/erp/pmods/org.openbravo.mobile.core/file/012e6b7ab09c/src/org/openbravo/mobile/core/servercontroller/MultiServerJSONProcess.java#l432 [^]

(0095760)
mtaal   
2017-03-31 12:27   
As only code needs to copied in a separate method the choice is made to do this in a new issue in the Q3 release.
(0095762)
mtaal   
2017-03-31 12:28   
Remaining changes will be done in related issue
(0095763)
AugustoMauch   
2017-03-31 12:30   
Code reviewed and verified