function AdfXmlHttpDataTransferService(a){this.Init(a)}AdfObject.createSubclass(AdfXmlHttpDataTransferService,AdfDataTransferService);AdfXmlHttpDataTransferService.InitClass=function(){this._MULTIPART_FRAME="_afrDTSFrame";this._ADF_STREAMING_IFRAME_ID="_adfStreamingIframe";this._XMLHTTP_TYPE=0;this._MULTIPART_TYPE=1;this._STREAMING_TYPE=2;this._POLLING_TYPE=3};
AdfXmlHttpDataTransferService.prototype.Init=function(a){AdfXmlHttpDataTransferService.superclass.Init.call(this);this._state=AdfDataTransferService.STATE_READY;this._requestQueue=[];this._stateChangeListeners=null;this._window=a;this._suspendCount=this._reqCount=this._streamingCount=0;this._pageUnloading=!1};AdfXmlHttpDataTransferService.prototype.dispose=function(){this.pageUnloading();this._window=this._stateChangeListeners=this._requestQueue=null};
AdfXmlHttpDataTransferService.prototype.pageUnloading=function(){this._pageUnloading=!0};AdfXmlHttpDataTransferService.__broadcastRequestStatusChanged=function(a,b){AdfLogger.LOGGER.fine("Broadcasting:",b);for(var d=a?a.length:0,e=0;e<d;e++){var f=a[e];if(f.requestStatusChanged)try{f.requestStatusChanged(b)}catch(g){AdfLogger.LOGGER.logError(g,AdfLogger.WARNING,"Error delivering Datatransfer request status changed to:",f)}}};
AdfXmlHttpDataTransferService.prototype._addRequestToQueue=function(a,b,d,e,f,g,h,k){a=new AdfXmlHttpDataTransferRequest(a,b,d,e,f,g,h);this._requestQueue.push(a);a.setStatus(AdfDataTransferRequestEvent.STATUS_QUEUED);try{var l=new AdfDataTransferRequestEvent(AdfDataTransferRequestEvent.STATUS_QUEUED,b,null);AdfXmlHttpDataTransferService.__broadcastRequestStatusChanged(g,l)}catch(m){AdfLogger.LOGGER.severe("Error on listener callback invocation - STATUS_QUEUED\n")}this._state<=k&&1==this._requestQueue.length&&
this._doNextRequest();return a};AdfXmlHttpDataTransferService.prototype.sendRequest=function(a,b,d,e,f){return this._addRequestToQueue(AdfXmlHttpDataTransferService._XMLHTTP_TYPE,a,b,d,e,f,null,AdfDataTransferService.STATE_READY)};AdfXmlHttpDataTransferService.prototype.sendPollingRequest=function(a,b){return this._addRequestToQueue(AdfXmlHttpDataTransferService._POLLING_TYPE,null,a,null,null,b,null,AdfDataTransferService.STATE_READY)};
AdfXmlHttpDataTransferService.prototype.sendMultiPartRequest=function(a,b,d,e,f,g,h){var k=null;null==a?a={_htmlForm:e}:a._htmlForm=e;if(null!=e.nodeType&&"FORM"==e.nodeName){if(f||d){var k=null,k=e.ownerDocument?e.ownerDocument:this._getDomDocument(),l;for(l in f)this._appendParamNode(k,e,l,f[l]);for(l in d)this._appendParamNode(k,e,l,d[l])}k=this._addRequestToQueue(AdfXmlHttpDataTransferService._MULTIPART_TYPE,a,b,d,null,g,h,AdfDataTransferService.STATE_READY)}else{if(f)for(l in f)e.append(l,f[l]);
a._formData=!0;k=this._addRequestToQueue(AdfXmlHttpDataTransferService._MULTIPART_TYPE,a,b,d,e,g,h,AdfDataTransferService.STATE_READY)}return k};
AdfXmlHttpDataTransferService.prototype.sendStreamingRequest=function(a,b){a=-1==a.indexOf("?")?a+"?":a+"\x26";a=a+"Adf-Rich-Message\x3dtrue\x26unique\x3d"+(new Date).getTime();for(var d in b)a+="\x26"+d+"\x3d"+b[d];d=AdfAgent.AGENT;d.getPlatform()==AdfAgent.IE_PLATFORM&&9>d.getVersion()&&(a+="\x26oracle.adf.view.rich.forceHTML\x3dtrue");return this._addRequestToQueue(AdfXmlHttpDataTransferService._STREAMING_TYPE,null,a,null,null,null,null,AdfDataTransferService.TRANSFER_COMPLETE)};
AdfXmlHttpDataTransferService.prototype.streamingResponsesOutstanding=function(){return 0<this._streamingCount};AdfXmlHttpDataTransferService.prototype.processStreamingResponse=function(a){AdfAssert.assert(this._streamingFrame,"Unexpected streaming response");this._isSuspended()||1<this._reqCount?(this._streamingMsgQueue||(this._streamingMsgQueue=[]),this._streamingMsgQueue.push(a)):(this._processQueuedStreamingMessages(),AdfAgent.AGENT.execScript(this._streamingFrame.contentWindow,a))};
AdfXmlHttpDataTransferService.prototype._processQueuedStreamingMessages=function(){if(this._streamingMsgQueue){for(var a=AdfAgent.AGENT;this._streamingMsgQueue&&0<this._streamingMsgQueue.length;)a.execScript(this._streamingFrame.contentWindow,this._streamingMsgQueue.shift());this._streamingMsgQueue=null}};
AdfXmlHttpDataTransferService.prototype.notifyStreamingRequestComplete=function(){var a=this._streamingFrame.contentWindow.document;a.removeChild(a.documentElement);this._streamingFrame=null;this._streamingCount--;AdfAssert.assert(0<=this._streamingCount,"Streaming request underflow");this._requestDone()};
AdfXmlHttpDataTransferService.prototype._doTransfer=function(){var a=this._requestQueue.shift();if(a.getStatus()==AdfDataTransferRequestEvent.STATUS_ABORTED)AdfLogger.LOGGER.fine("Transfer request aborted beforing sending to server:",a);else switch(a.setStatus(AdfDataTransferRequestEvent.STATUS_SEND_BEFORE),AdfLogger.LOGGER.fine("Transfer start:",a),this._reqCount++,AdfAssert.assert(2>=this._reqCount,"Request count overflow"),a.getType()){case AdfXmlHttpDataTransferService._XMLHTTP_TYPE:this._doXmlHttpTransfer(a);
break;case AdfXmlHttpDataTransferService._POLLING_TYPE:this._doXmlHttpTransfer(a,AdfDhtmlActiveData._requestCallback);break;case AdfXmlHttpDataTransferService._MULTIPART_TYPE:null!=a.getContent()?this._doXmlHttpTransfer(a,AdfDhtmlMultipartUpload._requestCallback):this._doTransferThroughIframe(a);break;case AdfXmlHttpDataTransferService._STREAMING_TYPE:this._streamingCount++;page.scheduleTimer(this,this._doStreamingTransfer,a,0);break;default:AdfAssert.assert(!1,"Unknown transfer type"),this._reqCount--}};
AdfXmlHttpDataTransferService.prototype.suspend=function(){this._suspendCount++};AdfXmlHttpDataTransferService.prototype.resume=function(){this._suspendCount--;AdfAssert.assert(0<=this._suspendCount,"Suspend count underflow");this._isSuspended()||this._doNextRequest()};AdfXmlHttpDataTransferService.prototype._isSuspended=function(){return 0<this._suspendCount};
AdfXmlHttpDataTransferService.prototype._doXmlHttpTransfer=function(a,b){var d=new AdfXMLRequest,e=d.__dtsRequestContext=a.getContext();d.__dtsRequestListeners=a.getListeners();a.setAdfXMLRequest(d);d.setSynchronous(e&&e.__isSynchronous?!0:!1);void 0!==b?d.setCallback(b):d.setCallback(AdfXmlHttpDataTransferService._requestCallback);var f=!1;null!=e&&e._formData&&(f=!0);f||d.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset\x3dUTF-8");f=a.getHeaderParams();if(null!=f)for(var g in f){var h=
f[g];AdfCollections.isArray(h)&&(h=h.join(","));d.setRequestHeader(g,h)}f=this._window;(g=a.getActionURL())||(g=""+f.document.location.href);f=f.name;h=AdfPage.PAGE.getPageStateId();g=AdfXmlHttpDataTransferService.__encodeWindowIdOnUrl(g,f);e&&e.richPostback&&(g=AdfXmlHttpDataTransferService.__encodePageIdOnUrl(g,h));e=a.getEventListeners();if(null!=e)for(f=0;f<e.length;f+=2)d.addEventListener(e[f],e[f+1]);AdfPage.PAGE.__perfTimings(!1,!1,!0,"Request sent to server: ",g);e=AdfLogger.LOGGER;e.fine("Request sent to server:",
a);e.getLogWriter().flush();d.send(g,a.getContent())};
AdfXmlHttpDataTransferService.prototype._doTransferThroughIframe=function(a){var b=a.getContext(),d=b._htmlForm,e=this._window.name,f=AdfPage.PAGE.getPageStateId(),e=AdfXmlHttpDataTransferService.__encodeWindowIdOnUrl(a.getActionURL(),e),e=AdfXmlHttpDataTransferService.__encodePageIdOnUrl(e,f);AdfAssert.assert(d.action,"form action cannot be null for multiform post");var f=AdfXmlHttpDataTransferService._MULTIPART_FRAME,g=AdfAgent.AGENT,h=this._getDomDocument(),k=h.getElementById(f),l,g=g.getPlatform()==
AdfAgent.IE_PLATFORM;null==this._iframeLoadCallback&&(this._iframeLoadCallback=this.createCallback(this._handleIFrameLoad));k||(k=h.createElement("iframe"),k.name=f,k.id=f,k.dataset.postReqCounter=0,l=k.style,l.top=l.left="0px",l.width=l.height="1px",l.position="absolute",l.visibility="hidden",h.body.appendChild(k),g||(k.onload=this._iframeLoadCallback));g?(k=h.frames[f],k.name=f,l=k.document):l=k.contentDocument;l.firstChild&&l.removeChild(l.firstChild);this._dtsContext=b;this._dtsRequestlisteners=
a.getListeners();this._htmlForm=d;this._savedActionUrl=d.action;this._savedTarget=d.target;d.method="POST";d.action=e;d.target=f;this._appendParamNode(h,d,"Adf-Rich-Message","true");this._appendParamNode(h,d,"partial","true");this._appendParamNode(h,d,AdfXmlHttpDataTransferService._WINDOW_PARAM,this._window.name);AdfAgent.AGENT.autoCompleteForm(d);try{(k.parentNode?k:k.frameElement).dataset.postReqCounter++,d.submit(),g&&(this._iframeLoadTimerId=AdfPage.PAGE.scheduleTimer(this,this._handleIFrameLoad,
null,50))}catch(m){AdfInputFileUtils.addUploadErrorMessage(),this._requestDone()}};AdfXmlHttpDataTransferService.prototype._appendParamNode=function(a,b,d,e){AdfAssert.assert(null!=b);var f=this._paramNodes;f||(this._paramNodes=f=[]);a=a.createElement("input");a.type="hidden";a.name=d;a.value=e;f.push(a);b.insertBefore(a,b.firstChild)};
AdfXmlHttpDataTransferService.prototype._clearParamNodes=function(){var a=this._paramNodes;if(a){for(var b=a[0].parentNode,d=a.length,e=0;e<d;e++)b&&b.removeChild(a[e]);delete this._paramNodes}};
AdfXmlHttpDataTransferService.prototype._doStreamingTransfer=function(a){this._streamingMsgQueue=null;var b=this._getDomDocument(),d=b.getElementById(AdfXmlHttpDataTransferService._ADF_STREAMING_IFRAME_ID);d||(d=b.createElement("DIV"),d.id=AdfXmlHttpDataTransferService._ADF_STREAMING_IFRAME_ID,d.style.display="none",b.body.appendChild(d));var e=this._window.name,e=AdfXmlHttpDataTransferService.__encodeWindowIdOnUrl(a.getActionURL(),e);d.innerHTML='\x3cIFRAME id \x3d "iFrameID" src\x3d"'+e+'"\x3e\x3c/IFRAME\x3e';
b.getElementById("iFrameID").addEventListener("load",function(){AdfPage.PAGE.getDataTransferService().processStreamingResponse("parent.AdfPage.PAGE.streamingResponseComplete();")});this._streamingFrame=d.firstChild;AdfAssert.assertDomElement(this._streamingFrame);AdfAssert.assert("IFRAME"==this._streamingFrame.tagName);a.setStreamingIFrame(this._streamingFrame)};
AdfXmlHttpDataTransferService.prototype._handleIFrameLoad=function(){var a=this._getDomDocument(),b=AdfAgent.AGENT.getPlatform()==AdfAgent.IE_PLATFORM,d=AdfXmlHttpDataTransferService._MULTIPART_FRAME;b?(a=a.frames[d],d=a.document):(a=a.getElementById(d),d=a.contentDocument);try{if(!d.documentElement||!d.documentElement.firstChild||b&&"complete"!=d.readyState)this._iframeLoadTimerId=AdfPage.PAGE.scheduleTimer(this,this._handleIFrameLoad,null,50);else{var e=AdfPage.PAGE,f=this._iframeLoadTimerId;f&&
(delete this._iframeLoadTimerId,e.cancelTimer(f));e.scheduleTimer(this,AdfXmlHttpDataTransferService._removeFrame,a,1);this._onIFrameLoadComplete(d,this._dtsContext,this._dtsRequestlisteners)}}catch(g){this._pageUnloading||(AdfXmlHttpDataTransferService._alertError("unknown"),AdfLogger.LOGGER.logErrorAsSevere(g,"Error ("+g.message+") while performing Data Transfer request")),this._htmlForm.action=this._savedActionUrl,this._htmlForm.target=this._savedTarget}};
AdfXmlHttpDataTransferService.prototype._onIFrameLoadComplete=function(a,b,d){try{var e=new AdfIFrameDataTransferRequestEvent(a,b);AdfXmlHttpDataTransferService.__broadcastRequestStatusChanged(d,e)}finally{for(;a.firstChild;)a.firstChild&&a.removeChild(a.firstChild);this._htmlForm.action=this._savedActionUrl;this._htmlForm.target=this._savedTarget;this._clearParamNodes();this._requestDone()}};
AdfXmlHttpDataTransferService.prototype._handleRequestCallback=function(a){if(a.getCompletionState()==AdfXMLRequest.COMPLETED){var b=0;try{b=a.getStatus()}catch(e){}try{if(200!=b&&302!=b&&0!=b)this._pageUnloading||(AdfXmlHttpDataTransferService._alertError(b),AdfLogger.LOGGER.severe("Error StatusCode(",b,") while performing Data Transfer request\n"));else if(!this._pageUnloading){this._broadcastStateChangeEvent(AdfDataTransferService.TRANSFER_COMPLETE);var d=new AdfDataTransferRequestEvent(AdfDataTransferRequestEvent.STATUS_COMPLETE,
a.__dtsRequestContext,a);AdfXmlHttpDataTransferService.__broadcastRequestStatusChanged(a.__dtsRequestListeners,d)}}finally{try{this._pageUnloading||this._setResponseIdentifierFromResponseHeader(a)}catch(e){b="Not able to retrieve response id from header.Error ("+e.message,b+="). The response id in page object will not be up-to-date.",AdfLogger.LOGGER.warning(b)}a.cleanup();delete a;this._pageUnloading||this._requestDone()}}};
AdfXmlHttpDataTransferService.prototype._setResponseIdentifierFromResponseHeader=function(a){if(null!=AdfPage.PAGE.getResponseIdentifier()&&a.getResponseHeader){var b=a.getResponseHeader("Adf-Context-Id");b||(b=a.getResponseHeader("X-ORACLE-DMS-ECID"));b&&AdfPage.PAGE.__setResponseIdentifier(b)}};
AdfXmlHttpDataTransferService.prototype._requestDone=function(){this._requestQueue&&(this._reqCount--,AdfAssert.assert(0<=this._reqCount,"Request count underflow"),1==this._reqCount&&1==this._streamingCount&&this._processQueuedStreamingMessages(),0==this._requestQueue.length&&(this._state!=AdfDataTransferService.TRANSFER_COMPLETE&&this._broadcastStateChangeEvent(AdfDataTransferService.TRANSFER_COMPLETE),this._broadcastStateChangeEvent(AdfDataTransferService.STATE_READY)),AdfPage.PAGE.scheduleTimer(this,
this._doNextRequest,null,1))};AdfXmlHttpDataTransferService.prototype._doNextRequest=function(){!(this._isSuspended()||0<this._reqCount)&&0<this._requestQueue.length&&(this._state!=AdfDataTransferService.STATE_BUSY&&this._broadcastStateChangeEvent(AdfDataTransferService.STATE_BUSY),this._doTransfer())};AdfXmlHttpDataTransferService._requestCallback=function(a){AdfLogger.LOGGER.finer("Request complete:",a);var b=AdfPage.PAGE.getDataTransferService(!0);b&&b._handleRequestCallback(a)};
AdfXmlHttpDataTransferService.prototype.addStateChangeListener=function(a,b){AdfAssert.assertFunction(a);AdfAssert.assertObjectOrNull(b);var d=this._stateChangeListeners;d||(this._stateChangeListeners=d=[]);d.push(a);d.push(b)};
AdfXmlHttpDataTransferService.prototype.removeStateChangeListener=function(a,b){AdfAssert.assertFunction(a);AdfAssert.assertObjectOrNull(b);var d=this._stateChangeListeners;AdfAssert.assert(d,"stateChangeListeners must exist");for(var e=d.length,f=0;f<e;f++){var g=d[f];f++;g==a&&d[f]===b&&d.splice(f-1,2)}0==d.length&&(this._stateChangeListeners=null)};AdfXmlHttpDataTransferService.prototype.getDTSState=function(){return this._state};
AdfXmlHttpDataTransferService.prototype._broadcastStateChangeEvent=function(a){this._state=a;var b=this._stateChangeListeners;if(b)for(var d=b.length,e=0;e<d;e++)try{var f=b[e];e++;var g=b[e];if(0==(null!=g?f.call(g,a):f(a)))break}catch(h){AdfLogger.LOGGER.logErrorAsWarning(h,"Error on DTS State Change Listener")}};AdfXmlHttpDataTransferService.prototype._getDomDocument=function(){return this._window.document};
AdfXmlHttpDataTransferService._alertError=function(a){var b=AdfPage.PAGE.getFailedConnectionText();if(null!=b){b+=" (status\x3d";b+=a;if(a=AdfPage.PAGE.getResponseIdentifier())b+=",ecid\x3d",b+=a;b+=")";alert(b)}};AdfXmlHttpDataTransferService._WINDOW_PARAM="Adf-Window-Id";
AdfXmlHttpDataTransferService.__encodeWindowIdOnUrl=function(a,b){var d=a,e=AdfXmlHttpDataTransferService._WINDOW_PARAM+"\x3d",f=e+b;-1==d.indexOf(e)?(d+=-1==d.indexOf("?")?"?":"\x26",d+=f):d=d.replace(/adf-window-id=[^&#]*/,f);return d};AdfXmlHttpDataTransferService.__encodePageIdOnUrl=function(a,b){if(null==b||void 0==b)return a;var d=a,e=AdfDhtmlPage._PAGE_STATE_ID+"\x3d",f=e+b;-1==d.indexOf(e)?(d+=-1==d.indexOf("?")?"?":"\x26",d+=f):d=d.replace(/Adf-Page-Id=[^&#]*/,f);return d};
AdfXmlHttpDataTransferService._removeFrame=function(a){if(a=a.parentNode?a:a.frameElement)if(a.dataset.postReqCounter--,0>=a.dataset.postReqCounter){a.onload="void(0);";var b=a.parentNode;b&&b.removeChild(a)}};