Examples of OTBool


Examples of org.opentransactions.otjavalib.util.Utility.OTBool

        return null;
    }

    // ------------------------------------------------------
    public static int getNymboxLowLevel(String serverID, String nymID) {
        OTBool bWasSent = new OTBool(false);

        return Helpers.getNymboxLowLevel(serverID, nymID, bWasSent);
    }
View Full Code Here

Examples of org.opentransactions.otjavalib.util.Utility.OTBool

        }

        //-------------------------------------------------
        // -- SECTION 1: "GET NYMBOX"
        //
        OTBool bWasMsgSent = new OTBool(false);

        int nGetNymbox = Helpers.getNymboxLowLevel(serverID, nymID, bWasMsgSent); // bWasMsgSent is output from this call.       

        if (bWasMsgSent.getBooleanValue()) {
            System.out.println("Utility.getNymbox(): FYI: Utility.getNymboxLowLevel apparently SENT the request. nGetNymbox is: " + nGetNymbox);
        }
        // -----------------------------------------------------------
        if ((false == bWasMsgSent.getBooleanValue()) || // UPDATE: This might've been a bug:  Removing this for now, since I still want to give it one last chance with the getRequest call, just below.
                ((nGetNymbox <= 0) && ((-1) != nGetNymbox))) {
            System.out.println("Utility.getNymbox(): Failure: Utility.getNymboxLowLevel returned unexpected value: " + nGetNymbox);
            return (-1);
        }   // NOTE: for getNymbox, there is no '0' return value, which is why you don't see me handling it here.
        // -----------------------------------------------------------
        if ((-1) == nGetNymbox) // we'll try re-syncing the request number, then try again.
        {
            System.out.println("Utility.getNymbox(): FYI: Utility.getNymboxLowLevel returned -1. (Re-trying...)");

            final int nGetRequest = Helpers.getRequestNumber(serverID, nymID);

            if (1 != nGetRequest) {
                System.out.println("Utility.getNymbox(): Failure: Utility.getNymboxLowLevel failed, then I tried to resync with getRequestNumber and then that failed too. (I give up.)");
                return (-1);
            }
            // ---------------------------------

            final String strLastReplyReceived = Helpers.getLastReplyReceived();
            // I had to do this bit because getRequestNumber doesn't return the actual
            // reply itself. But in this case, I needed it.
            if (!Helpers.isValid(strLastReplyReceived)) // THIS SHOULD NEVER HAPPEN.
            {
                System.out.println("Utility.getNymbox(): "
                        + "ERROR in Utility.getLastReplyReceived(): why was this string not set, when Utility.getRequestNumber was otherwise an apparent success?");
                return (-1); // (SHOULD NEVER HAPPEN. This string is set in the getRequestNumber function.)
            }
            //-------------------------------------------------

            // BY THIS POINT, we have received a server reply:  @getRequest
            // (Unless it is malformed.) It's definitely not null, nor empty.

            //-------------------------------------------------

            // Grab the NymboxHash on the @getRequest reply, and also the one I
            // already had on my client-side Nym... (So we can compare them.)
            //
            //      If the hashes do NOT match, then I DO need to download nymbox and box receipts.
            /*
             *      ===> If the NymboxHash is changed from what I expected, then I need to re-download the
             *      nymbox (and any box receipts I don't already have.)
             *
             *      Then I need to process the Nymbox. But first, see if my missing server reply is in there.
             *      If it is, then I have the server reply! (As if we had succeeded in the first place!!)
             *      Next, process the Nymbox (which processes that reply) and then return strReply like normal.
             *
             *      (Clearly this is just going to be a normal part of the getRequest syncronization.)
             *
             *      By the time that much is done, I will KNOW the request number, the nymbox, the box receipts,
             *      etc are ALL syncronized properly, and that I THEN processed the Nymbox successfully.
             *
             *
             *      NOTICE: In this example I do NOT want to pull out my sent message from the outbuffer (using
             *      the request number) and try to harvest all the transaction numbers. Why not? Because possibly the
             *      server DID reply! And if I processed that reply properly, it would sync my transaction numbers
             *      properly just from that! ===>
             *
             *      ===> Therefore, I need to see FIRST if the old message has a reply WAITING in the Nymbox. THEN
             *      I need to process the Nymbox. ONLY if the reply wasn't there, can I THEN pull out the message
             *      from my outbuffer and harvest it. (Which I am reticent to do, until I am SURE the server
             *      really never saw that message in the first place.)
             *
             *      However, as long as my NymboxHash hasn't changed, then I'm safe! But if it HAS changed,
             *      then I HAVE to A. download it B. SEE if the reply is there for the request number, then
             *      C. process it. ... If the reply wasn't there, THEN Harvest the transaction #s (for transaction
             *      messages) and then re-try.
             */

            //-------------------------------------------------      
            // Grabbing again in case it's changed.
            //
            final String strServerHash = otapiJNI.OTAPI_Basic_Message_GetNymboxHash(strLastReplyReceived);
            final boolean bServerHash = Helpers.isValid(strServerHash);
            if (!bServerHash) {
                System.out.println("Utility.getNymbox(): Warning: Unable to retrieve server-side "
                        + "NymboxHash from server @getRequest reply:\n\n"
                        + strLastReplyReceived);
            }
            //-------------------------------------------------               
            strLocalHash = otapiJNI.OTAPI_Basic_GetNym_NymboxHash(serverID, nymID);
            bLocalHash = Helpers.isValid(strLocalHash);

            if (!bLocalHash) {
                System.out.println("Utility.getNymbox(2): Warning: Unable to retrieve client-side NymboxHash "
                        + "for:\n serverID: " + serverID + "\n nymID: " + nymID);
            }
            //-------------------------------------------------

            if (bForceDownload
                    || !bLocalHash
                    || !bServerHash
                    || (bServerHash && bLocalHash
                    && !strServerHash.equals(strLocalHash))) // the hashes don't match -- so let's definitely re-try to download the latest nymbox.
            {
                // the getRequest worked, and the server hashes don't match,
                // so let's try the call again...
                //
                nGetNymbox = Helpers.getNymboxLowLevel(serverID, nymID, bWasMsgSent);

                if ((false == bWasMsgSent.getBooleanValue())
                        || ((nGetNymbox <= 0) && ((-1) != nGetNymbox))) {
                    System.out.println("Utility.getNymbox(2): Failure: Utility.getNymboxLowLevel returned unexpected value: " + nGetNymbox);
                    return (-1);
                } else if ((-1) == nGetNymbox) // we'll try re-syncing the request number, then try again.
                {
View Full Code Here

Examples of org.opentransactions.otjavalib.util.Utility.OTBool

    }

    public static int getAndProcessNymbox(String serverID, String nymID, OTBool bWasMsgSent, boolean bForceDownload) {
        final int nRequestNumber = 0;

        OTBool bFoundNymboxItem = new OTBool(false); // bFoundNymboxItem is output bool, telling caller whether it was found.

        return Helpers.getAndProcessNymbox(serverID, nymID, bWasMsgSent, bForceDownload, nRequestNumber, bFoundNymboxItem,
                false, false, false, false, false);
    }
View Full Code Here

Examples of org.opentransactions.otjavalib.util.Utility.OTBool

                if (nGetNymbox < 1) {
                    System.out.println("Utility.getAndProcessNymbox(): Failure: Utility.getNymbox returned: " + nGetNymbox);
                    return (-1);
                }

                OTBool bWasFound = new OTBool(false);

                if (Helpers.insureHaveAllBoxReceipts(serverID, nymID, nymID, 0, // nBoxType = 0 aka nymbox
                        nProcess, bWasFound)) // This will tell us whether the processNymbox reply was found in the Nymbox
                {
                    // we FOUND the processNymbox reply in the Nymbox!
                    //
                    if (bWasFound.getBooleanValue()) {
                        // Thus, no need to clawback any transaction numbers,
                        // since the server clearly already processed this processNymbox
                        // transaction, since I have a reply to it already sitting in my Nymbox.
                        //
//                        final int nRemoved = otapiJNI.OTAPI_Basic_RemoveSentMessage(Integer.toString(nProcess), serverID, nymID);
View Full Code Here

Examples of org.opentransactions.otjavalib.util.Utility.OTBool

        return strResponseMessage;
    }

    // ---------------------------------------------------
    public static int getRequestNumber(String serverID, String nymID) {
        OTBool bWasSent = new OTBool(false);

        return Helpers.getRequestNumber(serverID, nymID, bWasSent);
    }
View Full Code Here

Examples of org.opentransactions.otjavalib.util.Utility.OTBool

        return false;
    }

    // called by insureHaveAllBoxReceipts     DONE
    public static boolean getBoxReceiptWithErrorCorrection(String serverID, String nymID, String accountID, int nBoxType, String strTransactionNum) {
        OTBool bWasSent = new OTBool(false), bWasRequestSent = new OTBool(false);
        // ------------------------------------------
        if (Helpers.getBoxReceiptLowLevel(serverID, nymID, accountID, nBoxType, strTransactionNum, bWasSent)) {
            return true;
        } else if (bWasSent.getBooleanValue() && (1 == Helpers.getRequestNumber(serverID, nymID, bWasRequestSent))) // this might be out of sync, if it failed... we'll re-sync, and re-try.
        {
            if (bWasRequestSent.getBooleanValue()
                    && Helpers.getBoxReceiptLowLevel(serverID, nymID, accountID, nBoxType, strTransactionNum, bWasSent)) {
                return true;
            } else {
                System.out.println("Utility.getBoxReceiptWithErrorCorrection(): Utility.getBoxReceiptLowLevel failed, then Utility.getRequestNumber succeeded, then Utility.getBoxReceiptLowLevel failed again. (I give up.)");
            }
        } else {
            System.out.println("Utility.getBoxReceiptWithErrorCorrection(): Utility.getBoxReceiptLowLevel failed, then Utility.getRequestNumber failed. (I give up.) Was getRequest message sent: " + bWasRequestSent.getBooleanValue());
        }
        return false;
    }
View Full Code Here

Examples of org.opentransactions.otjavalib.util.Utility.OTBool

    // This function assumes you just downloaded the latest version of the box (inbox, outbox, or nymbox)
    // and its job is to make sure all the related box receipts are downloaded as well and available, though
    // not necessarily loaded into memory. (Yet.)
    // DONE
    public static boolean insureHaveAllBoxReceipts(String serverID, String nymID, String accountID, int nBoxType) {
        OTBool bFoundIt = new OTBool(false);

        final int nRequestSeeking = 0;

        return insureHaveAllBoxReceipts(serverID, nymID, accountID, nBoxType, nRequestSeeking, bFoundIt);
    }
View Full Code Here

Examples of org.opentransactions.otjavalib.util.Utility.OTBool

    public static boolean getTransactionNumbers(String serverID, String nymID, boolean bForceFirstCall) // defaults to true.
    {
// System.out.println("DEBUGGING -- 1.");
        //
        OTBool bWasSent = new OTBool(false);
        int nGetNumbers = -1;

        if (bForceFirstCall) {
            nGetNumbers = Helpers.getTransactionNumLowLevel(serverID, nymID, bWasSent);   // <============ FIRST TRY
        } else {
            nGetNumbers = -1;
        }

// System.out.println("DEBUGGING -- 2.");

        if (!bForceFirstCall || // if the first call didn't happen, due to bForceFirstCall being false, that means the caller wants the rest of this to happen as though it did. 
                (bWasSent.getBooleanValue() && (nGetNumbers >= 1))
                || (!bWasSent.getBooleanValue() && (nGetNumbers == 0))) {
            // System.out.println("DEBUGGING -- 3.");

            // Because it was successful, we have to now SIGN FOR those numbers we requested.
            //
            int nProcess = Helpers.getAndProcessNymbox(serverID, nymID, bWasSent, true); // bForceDownload=true

            // System.out.println("DEBUGGING -- 4.");

            if ((bWasSent.getBooleanValue() && (1 == nProcess))
                    || (!bWasSent.getBooleanValue() && (0 == nProcess))) {
                // System.out.println("DEBUGGING -- 5.");
                return true;
            }
        } else if ((nGetNumbers < (-1)) || // If value is LESS THAN (-1) (which is an unexpected value)
                !bWasSent.getBooleanValue()) // or if the getTransactionNum message WASN'T EVEN SENT, then return.
        {
            // System.out.println("DEBUGGING -- 6.");

            System.out.println("Utility.getTransactionNumbers: Failure: Utility.getTransactionNumLowLevel returned unexpected value: " + nGetNumbers);
            return false;
        } // -----------------------------------------------------------------
        // Below this point, the message WAS sent.  -1 is error, 0 is failure, >0 is success.
        // Now it's just about whether a reply was successful, or was even received.
        //
        else if (((-1) == nGetNumbers) || // Message sent, but then error receiving or loading the reply.
                ((0) == nGetNumbers)) // Received a reply, but status == failure on that reply.
        {
// System.out.println("DEBUGGING -- 7.");

            if ((-1) == nGetNumbers) {
                System.out.println("Utility.getTransactionNumbers: FYI: Utility.getTransactionNumLowLevel did send, but returned error (-1). (Re-trying...)");
            } else if ((0) == nGetNumbers) {
                System.out.println("Utility.getTransactionNumbers: FYI: Utility.getTransactionNumLowLevel did send, but returned failure (0). (Re-trying...)");
            }

            // ---------------------------------
            final int nGetRequest = Helpers.getRequestNumber(serverID, nymID);

// System.out.println("DEBUGGING -- 8.");

            if (1 != nGetRequest) {
                System.out.println("Utility.getTransactionNumbers: Failure: Utility.getTransactionNumLowLevel failed, then "
                        + "I tried to resync with getRequestNumber and then that failed too. (I give up.)");
                return false;
            }
            // ---------------------------------

// System.out.println("DEBUGGING -- 9.");

            OTBool bWasProcessSent = new OTBool(false);
            OTBool bFoundNymboxItem = new OTBool(false);

            final int nProcessNymbox = Helpers.getAndProcessNymbox(serverID, nymID, bWasProcessSent, true);   //boolean bForceDownload=true

// System.out.println("DEBUGGING -- 10.");

            if ((!bWasProcessSent.getBooleanValue() && ((nProcessNymbox < 0) || (nProcessNymbox > 1)))
                    || (bWasProcessSent.getBooleanValue() && (nProcessNymbox != 1))) // -1 error, 0 failed (harvesting success), 1 success, >1 failed (harvesting NOT done) RequestNum is returned.
            {
                // System.out.println("DEBUGGING -- 11.");

                // todo: if request num is returned probably don't have to do anything with it.
                // Why not?  Because future processNymbox will iterate Nymbox and search for all found
                // items in the sent message buffer, and REMOVE them from it (as clearly they will be
                // processed already.)
                // The ones left over in the sent buffer, after this? Must be harvested!
                // Hmm, solution: Use the "Flush Sent Messages" function, which is already
                // there. Have it be smart enough to harvest all sent messages before flushing,
                //
                //
                if (bWasProcessSent.getBooleanValue() && nProcessNymbox > 1) {
                    // System.out.println("DEBUGGING -- 12.");

                    String strNymbox = otapiJNI.OTAPI_Basic_LoadNymboxNoVerify(serverID, nymID);      // FLUSH SENT MESSAGES!!!!  (AND HARVEST.)

                    // System.out.println("DEBUGGING -- 13.");

                    // *******************************************************
                    if (Helpers.isValid(strNymbox)) {
                        otapiJNI.OTAPI_Basic_FlushSentMessages(false, //harvesting for retry == false
                                serverID,
                                nymID,
                                strNymbox);
                    }
                    // System.out.println("DEBUGGING -- 14.");
                }

                System.out.println("Utility.getTransactionNumbers: Failure: Utility.getAndProcessNymbox. Returned value: " + nProcessNymbox);
                return false;
            }

// System.out.println("DEBUGGING -- 15.");

            // -----------------------------------------------------------------

            nGetNumbers = Helpers.getTransactionNumLowLevel(serverID, nymID, bWasSent)// <================= SECOND TRY

// System.out.println("DEBUGGING -- 16.");

            // -----------------------------------------------------------------

            if ((bWasSent.getBooleanValue() && (nGetNumbers >= 1)) || // if message was sent, and was a success.
                    (!bWasSent.getBooleanValue() && (nGetNumbers == 0))) // Or if message wasn't sent due to "you already signed out too many numbers--you need to process your Nymbox..."
            {
// System.out.println("DEBUGGING -- 17.");

                int nProcess = Helpers.getAndProcessNymbox(serverID, nymID, bWasSent, true); // bForceDownload=true

// System.out.println("DEBUGGING -- 18.");

                if ((bWasSent.getBooleanValue() && (1 == nProcess))
                        || (!bWasSent.getBooleanValue() && (0 == nProcess))) {
// System.out.println("DEBUGGING -- 19.");

                    return true;
                }
            } else if ((nGetNumbers < (-1))
                    || (!bWasSent.getBooleanValue() && nGetNumbers != 0)) {
// System.out.println("DEBUGGING -- 20.");

                System.out.println("Utility.getTransactionNumbers: Failure: Utility.getTransactionNumLowLevel returned unexpected value: " + nGetNumbers);
                return false;
            } else if (((-1) == nGetNumbers)
                    || ((0) == nGetNumbers)) {
                // System.out.println("DEBUGGING -- 21.");

                if ((-1) == nGetNumbers) {
                    System.out.println("Utility.getTransactionNumbers: Failure: Utility.getTransactionNumLowLevel did send, but returned error (-1), "
                            + "even after syncing the request number successfully. (Giving up.)");
                } else if ((0) == nGetNumbers) {
                    System.out.println("Utility.getTransactionNumbers: Failure: Utility.getTransactionNumLowLevel did send, but returned failure (0), "
                            + "even after syncing the request number successfully. (Giving up.)");
                }


                // System.out.println("DEBUGGING -- 22.");

                int nLast = Helpers.getAndProcessNymbox(serverID, nymID, bWasProcessSent, true);   //boolean bForceDownload=true
                if (((false == bWasProcessSent.getBooleanValue()) && ((nLast < 0) || (nLast > 1)))
                        || ((true == bWasProcessSent.getBooleanValue()) && (nLast != 1))) // -1 error, 0 failed (harvesting success), 1 success, >1 failed (harvesting NOT done) RequestNum is returned.
                {

                    // System.out.println("DEBUGGING -- 23.");

                    if (bWasProcessSent.getBooleanValue() && (nLast > 1)) {

                        // System.out.println("DEBUGGING -- 24.");

                        String strNymbox = otapiJNI.OTAPI_Basic_LoadNymboxNoVerify(serverID, nymID);      // FLUSH SENT MESSAGES!!!!  (AND HARVEST.)

                        // System.out.println("DEBUGGING -- 25.");

                        // *******************************************************
                        if (Helpers.isValid(strNymbox)) {
                            otapiJNI.OTAPI_Basic_FlushSentMessages(false, //harvesting for retry == false
                                    serverID,
                                    nymID,
                                    strNymbox);
                        }
                    }

                    System.out.println("Utility.getTransactionNumbers: Failure: Utility.getAndProcessNymbox. Returned value: " + nLast);
                    return false;
                }

                // System.out.println("DEBUGGING -- 27.");

                nGetNumbers = Helpers.getTransactionNumLowLevel(serverID, nymID, bWasSent);   // <============ FIRST TRY     

                // System.out.println("DEBUGGING -- 28.");

                if ((bWasSent.getBooleanValue() && (nGetNumbers >= 1))
                        || ((!bWasSent.getBooleanValue() && (nGetNumbers == 0)))) {
                    // System.out.println("DEBUGGING -- 29.");


                    int nProcess = Helpers.getAndProcessNymbox(serverID, nymID, bWasSent, true); // bForceDownload=true


                    // System.out.println("DEBUGGING -- 30.");


                    if ((bWasSent.getBooleanValue() && (1 == nProcess))
                            || (!bWasSent.getBooleanValue() && (0 == nProcess))) {
                        // System.out.println("DEBUGGING -- 31.");

                        return true;
                    }
                }
                if ((nGetNumbers < (-1)) || // If value is LESS THAN (-1) (which is an unexpected value)
                        !bWasSent.getBooleanValue()) // or if the getTransactionNum message WASN'T EVEN SENT, then return.
                {
                    // System.out.println("DEBUGGING -- 32.");

                    System.out.println("Utility.getTransactionNumbers: Failure: Utility.getTransactionNumLowLevel returned unexpected value: " + nGetNumbers);
                    return false;
                }
            }
        }

        // System.out.println("DEBUGGING -- 33.");

        // BY THIS POINT, we have SUCCESSFULLY sent the getTransactionNumLowLevel message,
        // and nGetNumbers contains its request number.
        // -----

        // No need to read the result, as getTransactionNumLowLevel() already read it,
        // and and it's available anytime via Utility.getLastReplyReceived()
        // -------------------------------------------------------------------------

        final String strLastReplyReceived = Helpers.getLastReplyReceived();

        if (!Helpers.isValid(strLastReplyReceived)) {
            System.out.println("Utility.getTransactionNumbers: "
                    + "ERROR in Utility.getLastReplyReceived(): why was this string not set, when Utility.getRequestNumber was otherwise an apparent success?");
            return false; // (SHOULD NEVER HAPPEN. This string is set in the getRequestNumber function.)
        }
        //-------------------------------------------------

        // BY THIS POINT, we have received a server reply:  @getTransactionNum
        // (Unless it is malformed.) It's definitely not null, nor empty.

        //-------------------------------------------------

        // Grab the NymboxHash on the @getTransactionNum reply, and also the one I
        // already had on my client-side Nym... (So we can compare them.)
        //
        final String strServerHash = otapiJNI.OTAPI_Basic_Message_GetNymboxHash(strLastReplyReceived);
        final boolean bServerhash = Helpers.isValid(strServerHash);
        if (!bServerhash) {
            System.out.println("Utility.getTransactionNumbers: Warning: Unable to retrieve server-side "
                    + "NymboxHash from OT, from server @getTransactionNum reply:\n\n"
                    + strLastReplyReceived);
//            return false;
        }
        //-------------------------------------------------               
        final String strLocalHash = otapiJNI.OTAPI_Basic_GetNym_NymboxHash(serverID, nymID);
        final boolean bLocalhash = Helpers.isValid(strLocalHash);
        if (!bLocalhash) {
            System.out.println("Utility.getTransactionNumbers: Warning: Unable to retrieve client-side NymboxHash from OT, "
                    + "for:\n serverID: " + serverID + "\n nymID: " + nymID);
//            return false;
        }
        //-------------------------------------------------

        if (!bServerhash || !bLocalhash
                || (bServerhash && bLocalhash
                && !strServerHash.equals(strLocalHash))) // the hashes don't match -- so let's definitely re-try to download the latest nymbox.
        {
            // the getRequest worked, and the server hashes don't match,
            // so let's get and process the Nymbox...
            //

            // System.out.println("DEBUGGING -- 34.");


            OTBool bWasProcessSent = new OTBool(false);
            OTBool bFoundNymboxItem = new OTBool(false);
            final int nGetNymbox = Helpers.getAndProcessNymbox(serverID, nymID, bWasProcessSent, true);   //boolean bForceDownload=true

            if (((false == bWasProcessSent.getBooleanValue()) && ((nGetNymbox < 0) || (nGetNymbox > 1)))
                    || ((true == bWasProcessSent.getBooleanValue()) && (nGetNymbox != 1))) // -1 error, 0 failed (harvesting success), 1 success, >1 failed (harvesting NOT done) RequestNum is returned.
            {
View Full Code Here

Examples of org.opentransactions.otjavalib.util.Utility.OTBool

        if (!Utility.VerifyStringVal(accountID)) {
            System.out.println("Utility.getIntermediaryFiles: invalid accountID: " + accountID);
            return false;
        }
        // -----------------------------------------------------
        OTBool bWasSentInbox = new OTBool(false),
                bWasSentAccount = new OTBool(false);
        // -----------------------------------------------------
        int nGetInboxAcct = Helpers.getInboxAccount(serverID, nymID, accountID, bWasSentInbox, bWasSentAccount, bForceDownload);

        if ( // if we received an error state, and the "getAccount" message wasn't even sent,
                // then no point doing a bunch of retries -- it failed.
                //
                ((-1) == nGetInboxAcct) && !bWasSentAccount.getBooleanValue()) {
            System.out.println("Utility.getIntermediaryFiles: Utility.getInboxAccount failed, without even sending getAccount. (Returning false.)");
            return false;
        } else if (!bWasSentInbox.getBooleanValue() && // If it wasn't sent, and 0 was returned, that means
                (0 == nGetInboxAcct)) // no error: we already have the latest inbox. (Nothing done.)
        {
            // we don't return true here because getOutbox has to happen also.
        } else if (1 != nGetInboxAcct) {
            System.out.println("Utility.getIntermediaryFiles: getInboxAccount failed. (Trying one more time...)");

            // --------------------------------------
            final int nGetRequest = Helpers.getRequestNumber(serverID, nymID);

            if (1 != nGetRequest) {
                System.out.println("Utility.getIntermediaryFiles(): Failure: Utility.getInboxAccount failed, then I tried to resync with getRequestNumber and then that failed too. (I give up.)");
                return false;
            }
            // --------------------------------------
            final int nSecondtry = Helpers.getInboxAccount(serverID, nymID, accountID, bWasSentInbox, bWasSentAccount, bForceDownload);

            if (((-1) == nSecondtry) && !bWasSentAccount.getBooleanValue()) {
                // if we received an error state, and the "getAccount" message wasn't even sent,
                // then no point doing a bunch of retries -- it failed.
                //
                System.out.println("Utility.getIntermediaryFiles: Utility.getInboxAccount failed a second time, without even sending getAccount. (Returning false.)");
                return false;
            }
            if (!bWasSentInbox.getBooleanValue() && // If it wasn't sent, and 0 was returned, that means
                    (0 == nSecondtry)) // no error: we already have the latest inbox. (Nothing done.)
            {
                // we don't return true here because getOutbox has to happen also.
            } else if (1 != nSecondtry) {
                System.out.println("Utility.getIntermediaryFiles: getInboxAccount re-try failed. (That's twice now--Returning false.) Value: " + nSecondtry);
                return false;
            }
            System.out.println("Utility.getIntermediaryFiles: getInboxAccount second call succeeded. (Continuing...)");
        }
        // *****************************************************************************

        OTBool bWasSentOutbox = new OTBool(false);

        int nGetOutbox = Helpers.getOutboxLowLevel(serverID, nymID, accountID, bWasSentOutbox, bForceDownload);

        if (((-1) == nGetOutbox) && !bWasSentOutbox.getBooleanValue()) {
            // if we received an error state, and the "getOutbox" message wasn't even sent,
            // then no point doing a bunch of retries -- it failed.
            //
            System.out.println("Utility.getIntermediaryFiles: Utility.getOutboxLowLevel failed, without even sending getOutbox. (Returning false.)");
            return false;
        } else if (!bWasSentOutbox.getBooleanValue() && // If it wasn't sent, and 0 was returned, that means the
                (0 == nGetOutbox)) // outbox we have is already the latest version.
        {
            return true;
        } else if (1 != nGetOutbox) {
            System.out.println("Utility.getIntermediaryFiles: getOutboxLowLevel failed. (Trying one more time...)");

            // --------------------------------------
            final int nGetRequest = Helpers.getRequestNumber(serverID, nymID);

            if (1 != nGetRequest) {
                System.out.println("Utility.getIntermediaryFiles(): Failure: Utility.getOutboxLowLevel failed, then I tried to resync with getRequestNumber and then that failed too. (I give up.)");
                return false;
            }
            // --------------------------------------
            final int nSecondtry = Helpers.getOutboxLowLevel(serverID, nymID, accountID, bWasSentOutbox, bForceDownload);

            if (((-1) == nSecondtry) && !bWasSentOutbox.getBooleanValue()) {
                // if we received an error state, and the "getOutbox" message wasn't even sent,
                // then no point doing a bunch of retries -- it failed.
                //
                System.out.println("Utility.getIntermediaryFiles: Utility.getOutboxLowLevel failed a second time, without even sending getOutbox. (Returning false.)");
                return false;
            }
            if (!bWasSentOutbox.getBooleanValue() && // If it wasn't sent, and 0 was returned, that means
                    (0 == nSecondtry)) // no error: we already have the latest outbox. (Nothing done.)
            {
                return true;
            } else if (1 != nSecondtry) {
                System.out.println("Utility.getIntermediaryFiles: getOutboxLowLevel re-try failed. (That's twice now--Returning false.) Value: " + nSecondtry);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.