/* * Copyright (c) 2015, salesforce.com, inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided * that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, this list of conditions and the * following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and * the following disclaimer in the documentation and/or other materials provided with the distribution. * * Neither the name of salesforce.com, inc. nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * BulkTK: JavaScript library to wrap Force.com Bulk API. Extends ForceTK. * Dependencies: * jquery - http://jquery.com/ * ForceTK - https://github.com/developerforce/Force.com-JavaScript-REST-Toolkit/blob/master/forcetk.js * jxon - https://github.com/developerforce/Force.com-JavaScript-REST-Toolkit/blob/master/jxon.js * (originally from the [Ratatosk](https://github.com/wireload/Ratatosk) * project; this version preserves case in element and attribute names) */ forcetk.Client.prototype.xmlHeader = "\n"; /* * Low level utility function to call the Bulk API. * @param path resource path * @param parseXML set to true to parse XML response * @param callback function to which response will be passed * @param [error=null] function to which jqXHR will be passed in case of error * @param [method="GET"] HTTP method for call * @param [contentType=null] Content type of payload - e.g. 'application/xml; charset=UTF-8' * @param [payload=null] payload for POST * @param [parseXML=false] set to true to parse XML response */ forcetk.Client.prototype.bulkAjax = function(path, parseXML, callback, error, method, contentType, payload, retry) { var that = this; var url = this.instanceUrl + path; if (this.debug) { console.log('bulkAjax sending: ', payload); } return $.ajax({ type: method || "GET", async: this.asyncAjax, url: (this.proxyUrl !== null) ? this.proxyUrl: url, contentType: method == "DELETE" ? null : contentType, cache: false, processData: false, data: payload, success: function(data, textStatus, jqXHR) { var respContentType = jqXHR.getResponseHeader('Content-Type'); // Naughty Bulk API doesn't always set Content-Type! if (parseXML && ((respContentType && respContentType.indexOf('application/xml') === 0) || data.indexOf('