Search in sources :

Example 1 with InvalidQueryLocatorFault

use of com.salesforce.soap.partner.fault.InvalidQueryLocatorFault in project tdi-studio-se by Talend.

the class PartnerSamples method loadQueryResults.

private ArrayList loadQueryResults(QueryResult qr) {
    ArrayList returnVal = new ArrayList();
    if (qr.getSize() > 0) {
        boolean keepLooping = true;
        while (keepLooping) {
            for (int i = 0; i < qr.getRecords().length; i++) {
                MessageElement[] records = qr.getRecords(i).get_any();
                HashMap fields = new HashMap();
                if (qr.getRecords(i).getId() != null)
                    fields.put("id", qr.getRecords(i).getId());
                for (int j = 0; j < records.length; j++) {
                    MessageElement record = records[j];
                    if (!fields.containsKey(record.getName()))
                        fields.put(record.getName().toLowerCase(), record);
                }
                returnVal.add(fields);
            }
            if (qr.isDone())
                keepLooping = false;
            else
                try {
                    qr = binding.queryMore(qr.getQueryLocator());
                } catch (InvalidQueryLocatorFault e) {
                    System.out.println("\nFailed to query, error message was: \n" + e.getExceptionMessage());
                    getUserInput("\nHit return to continue...");
                } catch (ApiFault af) {
                    System.out.println("\nFailed to query, error message was: \n" + af.getExceptionMessage());
                    getUserInput("\nHit return to continue...");
                } catch (RemoteException e) {
                    e.printStackTrace();
                    getUserInput("\nHit return to continue...");
                }
        }
    }
    return returnVal;
}
Also used : ApiFault(com.salesforce.soap.partner.fault.ApiFault) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) InvalidQueryLocatorFault(com.salesforce.soap.partner.fault.InvalidQueryLocatorFault) MessageElement(org.apache.axis.message.MessageElement) RemoteException(java.rmi.RemoteException)

Aggregations

ApiFault (com.salesforce.soap.partner.fault.ApiFault)1 InvalidQueryLocatorFault (com.salesforce.soap.partner.fault.InvalidQueryLocatorFault)1 RemoteException (java.rmi.RemoteException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 MessageElement (org.apache.axis.message.MessageElement)1