From f5cdf9b95411fbc05550bb71f8c02a013b4d76b4 Mon Sep 17 00:00:00 2001 From: Jason Best Date: Thu, 27 Sep 2018 13:12:33 -0400 Subject: [PATCH 1/3] Wrap single resource keys in single quotes, not double. There is an illegal path error if double quotes are used on the remote personal web server. --- package.json | 2 +- src/SDataSingleResourceRequest.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 88a41a0..7f876cb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "SDataJavaScriptClientLib", - "version": "1.3.0", + "version": "1.3.1", "repository": { "type": "git", "url": "https://github.com/Saleslogix/SDataJavaScriptClientLib" diff --git a/src/SDataSingleResourceRequest.js b/src/SDataSingleResourceRequest.js index c79289f..0b9b1a0 100644 --- a/src/SDataSingleResourceRequest.js +++ b/src/SDataSingleResourceRequest.js @@ -49,7 +49,7 @@ }, setResourceKey: function(value) { this.key = value; - this.setResourceSelector("\"" + this.key + "\""); + this.setResourceSelector("'" + this.key + "'"); return this; }, getResourceKey: function() { From 75ebf4a78b4468cd1e2307433a3f3bd2135a326e Mon Sep 17 00:00:00 2001 From: Jason Best Date: Thu, 27 Sep 2018 13:45:18 -0400 Subject: [PATCH 2/3] Build --- deploy/sdata-client-debug.js | 2 +- deploy/sdata-client.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/deploy/sdata-client-debug.js b/deploy/sdata-client-debug.js index bbbfec9..6b1ddd0 100644 --- a/deploy/sdata-client-debug.js +++ b/deploy/sdata-client-debug.js @@ -527,7 +527,7 @@ }, setResourceKey: function(value) { this.key = value; - this.setResourceSelector("\"" + this.key + "\""); + this.setResourceSelector("'" + this.key + "'"); return this; }, getResourceKey: function() { diff --git a/deploy/sdata-client.js b/deploy/sdata-client.js index 3837c84..a20c6d5 100644 --- a/deploy/sdata-client.js +++ b/deploy/sdata-client.js @@ -1,4 +1,4 @@ /* * */ -(function(){var b=window.Sage,e=b,a=b.namespace("Sage.SData.Client.Ajax");var f=function(j){return((j>=200&&j<300)||j===304)};var c=function(n,m){if(n.readyState==4){if(f(n.status)){if(m.success){m.success.call(m.scope||this,n,m)}}else{if(n.status===0){var l=false;try{l=(n.statusText==="")}catch(j){l=true}if(l){var k=m.aborted||m.failure;if(k){k.call(m.scope||this,n,m)}}else{if(m.failure){m.failure.call(m.scope||this,n,m)}}}else{if(m.failure){m.failure.call(m.scope||this,n,m)}}}}};var g=function(l,k){var j=k.timeout||k.failure;if(j){j.call(k.scope||this,l,k)}};var d=function(k,j){k.ontimeout=function(){g.call(k,k,j)}};var i=function(k,j){k.onreadystatechange=function(){c.call(k,k,j)}};var h=function(k){var j=[];for(var l in k){j.push(encodeURIComponent(l)+"="+encodeURIComponent(k[l]))}return j.join("&")};b.apply(b.SData.Client.Ajax,{request:function(p){p=e.apply({},p);p.params=e.apply({},p.params);p.headers=e.apply({},p.headers);if(p.cache!==true){p.params[p.cacheParam||"_t"]=(new Date()).getTime()}p.method=p.method||"GET";var k=h(p.params);if(k){p.url=p.url+(/\?/.test(p.url)?"&":"?")+k}var m=new XMLHttpRequest();if(p.user){m.open(p.method,p.url,p.async!==false,p.user,p.password)}else{m.open(p.method,p.url,p.async!==false)}if(p.withCredentials){m.withCredentials=true}try{m.setRequestHeader("Accept",p.accept||"*/*");m.setRequestHeader("X-Requested-With","XMLHttpRequest");if(p.contentType){m.setRequestHeader("Content-Type",p.contentType)}for(var q in p.headers){m.setRequestHeader(q,p.headers[q])}var j=p.etagCache;if(p.cache&&j&&j.etag){m.setRequestHeader("If-None-Match",j.etag)}}catch(l){}if(p.async!==false){if(typeof p.requestTimeout==="number"&&p.requestTimeout>=0&&typeof m.timeout==="number"){m.timeout=p.requestTimeout;d(m,p)}i(m,p);m.send(p.body||null)}else{m.send(p.body||null);c(m,p)}return m},cancel:function(j){j.abort()}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataBaseRequest=b.Class.define({service:null,uri:null,completeHeaders:null,extendedHeaders:null,constructor:function(d){this.base.apply(this,arguments);this.service=d;this.completeHeaders={};this.extendedHeaders={};this.uri=new b.SData.Client.SDataUri();var f,e;if(this.service){this.uri.setVersion(this.service.getVersion());f=this.service.getIncludeContent();if(typeof f!=="undefined"){this.uri.setIncludeContent(f)}this.uri.setServer(this.service.getVirtualDirectory()?this.service.getVirtualDirectory():"sdata");this.uri.setScheme(this.service.getProtocol());this.uri.setHost(this.service.getServerName());this.uri.setPort(this.service.getPort());e=this.service.getCompact();if(typeof e!=="undefined"){this.uri.setCompact(e)}}},clone:function(){return new b.SData.Client.SDataBaseRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},setRequestHeader:function(d,e){this.completeHeaders[d]=e},extendRequestHeader:function(d,e){this.extendedHeaders[d]=e},clearRequestHeader:function(d){delete this.completeHeaders[d];delete this.extendedHeaders[d]},getAccept:function(){return this.extendedHeaders.Accept},setAccept:function(d){this.extendRequestHeader("Accept",d);return this},getService:function(){return this.service},getUri:function(){return this.uri},setUri:function(d){this.uri=d;return this},getServerName:function(){return this.uri.getHost()},setServerName:function(d){this.uri.setHost(d);return this},getVirtualDirectory:function(){return this.uri.getServer()},setVirtualDirectory:function(d){this.uri.setServer(d);return this},getProtocol:function(){return this.uri.getScheme()},setProtocol:function(d){this.uri.setScheme(d);return this},getPort:function(){return this.uri.getPort()},setPort:function(d){this.uri.setPort(d);return this},getQueryArgs:function(){return this.uri.getQueryArgs()},setQueryArgs:function(e,d){this.uri.setQueryArgs(e,d);return this},getQueryArg:function(d){return this.uri.getQueryArg(d)},setQueryArg:function(d,e){this.uri.setQueryArg(d,e);return this},build:function(d){return this.uri.build(d)},toString:function(d){return this.build(d)}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataApplicationRequest=b.SData.Client.SDataBaseRequest.extend({constructor:function(){this.base.apply(this,arguments);if(this.service){this.uri.setProduct(this.service.getApplicationName()?this.service.getApplicationName():"-");this.uri.setContract(this.service.getContractName()?this.service.getContractName():"-");this.uri.setCompanyDataset(this.service.getDataSet()?this.service.getDataSet():"-")}},clone:function(){return new b.SData.Client.SDataApplicationRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},getApplicationName:function(){return this.uri.getProduct()},setApplicationName:function(d){this.uri.setProduct(d);return this},getContractName:function(){return this.uri.getContract()},setContractName:function(d){this.uri.setContract(d);return this},getDataSet:function(){return this.uri.getCompanyDataset()},setDataSet:function(d){this.uri.setCompanyDataset(d);return this},getResourceKind:function(){return this.uri.getCollectionType()},setResourceKind:function(d){this.uri.setCollectionType(d);return this}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataResourceCollectionRequest=b.SData.Client.SDataApplicationRequest.extend({constructor:function(){this.base.apply(this,arguments)},clone:function(){return new b.SData.Client.SDataResourceCollectionRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},getCount:function(){return this.uri.getCount()},setCount:function(d){this.uri.setCount(d);return this},getStartIndex:function(){return this.uri.getStartIndex()},setStartIndex:function(d){this.uri.setStartIndex(d);return this},read:function(d){return this.service.readFeed(this,d)}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataNamedQueryRequest=b.SData.Client.SDataResourceCollectionRequest.extend({constructor:function(){this.base.apply(this,arguments);this.uri.setPathSegment(c.SDataUri.ResourcePropertyIndex,c.SDataUri.NamedQuerySegment)},clone:function(){return new b.SData.Client.SDataNamedQueryRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},getQueryName:function(){return this.uri.getPathSegment(c.SDataUri.ResourcePropertyIndex+1)},setQueryName:function(d){this.uri.setPathSegment(c.SDataUri.ResourcePropertyIndex+1,d);return this}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataSingleResourceRequest=b.SData.Client.SDataApplicationRequest.extend({key:"",constructor:function(){this.base.apply(this,arguments)},clone:function(){return new b.SData.Client.SDataSingleResourceRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},read:function(d){return this.service.readEntry(this,d)},update:function(e,d){return this.service.updateEntry(this,e,d)},create:function(e,d){return this.service.createEntry(this,e,d)},"delete":function(e,d){return this.service.deleteEntry(this,e,d)},getResourceSelector:function(){return this.uri.getCollectionPredicate()},setResourceSelector:function(d){this.uri.setCollectionPredicate(d);return this},setResourceKey:function(d){this.key=d;this.setResourceSelector('"'+this.key+'"');return this},getResourceKey:function(){return this.key}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataResourcePropertyRequest=b.SData.Client.SDataSingleResourceRequest.extend({constructor:function(){this.base.apply(this,arguments)},clone:function(){return new b.SData.Client.SDataResourcePropertyRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},readFeed:function(d){return this.service.readFeed(this,d)},getResourceProperty:function(){return this.uri.getPathSegment(b.SData.Client.SDataUri.ResourcePropertyIndex)},setResourceProperty:function(d){this.uri.setPathSegment(b.SData.Client.SDataUri.ResourcePropertyIndex,d);return this}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataSystemRequest=b.SData.Client.SDataBaseRequest.extend({constructor:function(){this.base.apply(this,arguments);this.uri.setPathSegment(b.SData.Client.SDataUri.ProductPathIndex,b.SData.Client.SDataUri.SystemSegment)},clone:function(){return new b.SData.Client.SDataSystemRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},getCategory:function(){this.uri.getPathSegment(b.SData.Client.SDataUri.ContractTypePathIndex)},setCategory:function(d){this.uri.setPathSegment(b.SData.Client.SDataUri.ContractTypePathIndex,d);return this},read:function(d){return this.service.readFeed(this,d)}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataTemplateResourceRequest=b.SData.Client.SDataApplicationRequest.extend({constructor:function(){this.base.apply(this,arguments);this.uri.setPathSegment(b.SData.Client.SDataUri.ResourcePropertyIndex,b.SData.Client.SDataUri.TemplateSegment)},clone:function(){return new b.SData.Client.SDataTemplateResourceRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},read:function(d){return this.service.readEntry(this,d)}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataServiceOperationRequest=b.SData.Client.SDataApplicationRequest.extend({constructor:function(){this.base.apply(this,arguments);this.uri.setPathSegment(c.SDataUri.ResourcePropertyIndex,c.SDataUri.ServiceMethodSegment)},clone:function(){return new b.SData.Client.SDataServiceOperationRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},execute:function(e,d){return this.service.executeServiceOperation(this,e,d)},getOperationName:function(){return this.uri.getPathSegment(c.SDataUri.ResourcePropertyIndex+1)},setOperationName:function(d){this.uri.setPathSegment(c.SDataUri.ResourcePropertyIndex+1,d);return this}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataBatchRequest=b.SData.Client.SDataApplicationRequest.extend({items:null,constructor:function(){this.base.apply(this,arguments);this.items=[];this.uri.setPathSegment(b.SData.Client.SDataUri.ResourcePropertyIndex,b.SData.Client.SDataUri.BatchSegment)},clone:function(){return new b.SData.Client.SDataBatchRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri)).setItems(this.items.slice(0))},getItems:function(){return this.items},setItems:function(d){this.items=d;return this},using:function(f,d){if(this.service){this.service.registerBatchScope(this)}else{throw"A service must be associated with the batch request."}try{f.call(d||this,this)}catch(g){this.service.clearBatchScope(this);throw g}this.service.clearBatchScope(this);return this},add:function(d){this.items.push(d)},commit:function(d){this.service.commitBatch(this,d)}})})();(function(){var b=window.Sage,a=b,d=b.namespace("Sage.SData.Client"),c=/^true$/i;b.SData.Client.SDataUri=b.Class.define({scheme:"http",host:"",server:"",port:-1,version:null,queryArgs:null,pathSegments:null,constructor:function(e){this.base.apply(this,arguments);a.apply(this,e);this.queryArgs=a.apply({},e&&e.queryArgs);this.pathSegments=(e&&e.pathSegments&&e.pathSegments.slice(0))||[];this.version=(e&&e.version&&a.apply({},e.version))||{major:1,minor:0}},clone:function(){return new b.SData.Client.SDataUri(this)},getVersion:function(){return this.version},setVersion:function(e){this.version=a.apply({major:0,minor:0},e);return this},getScheme:function(){return this.scheme},setScheme:function(e){this.scheme=e;return this},getHost:function(){return this.host},setHost:function(e){this.host=e;return this},getPort:function(){return this.port},setPort:function(e){this.port=e;return this},getServer:function(){return this.server},setServer:function(e){this.server=e;return this},getQueryArgs:function(){return this.queryArgs},setQueryArgs:function(f,e){this.queryArgs=e?f:a.apply(this.queryArgs,f);return this},getQueryArg:function(e){return this.queryArgs[e]},setQueryArg:function(e,f){this.queryArgs[e]=f;return this},getPathSegments:function(){return this.pathSegments},setPathSegments:function(e){this.pathSegments=e;return this},getPathSegment:function(e){return this.pathSegments.length>e?this.pathSegments[e]:false},setPathSegment:function(f,h,e){if(!h&&!e){this.pathSegments[f]=null}else{if(typeof h==="object"){this.pathSegments[f]=a.apply({},h,this.pathSegments[f])}else{var g={};if(h){g.text=h}if(e){g.predicate=e}this.pathSegments[f]=a.apply({},g,this.pathSegments[f])}}return this},getStartIndex:function(){return this.queryArgs[d.SDataUri.QueryArgNames.StartIndex]?parseInt(this.queryArgs[d.SDataUri.QueryArgNames.StartIndex]):-1},setStartIndex:function(e){this.queryArgs[d.SDataUri.QueryArgNames.StartIndex]=e;return this},getCount:function(){return this.queryArgs[d.SDataUri.QueryArgNames.Count]?parseInt(this.queryArgs[d.SDataUri.QueryArgNames.Count]):-1},setCount:function(e){this.queryArgs[d.SDataUri.QueryArgNames.Count]=e;return this},getIncludeContent:function(){var e,f;e=this.version.major>=1?d.SDataUri.QueryArgNames.IncludeContent:d.SDataUri.QueryArgNames.LegacyIncludeContent;f=this.queryArgs[e];if(typeof f!=="undefined"){return c.test(f)}else{return f}},setCompact:function(e){this.queryArgs[d.SDataUri.QueryArgNames.Compact]=e;return this},getCompact:function(){return this.queryArgs[d.SDataUri.QueryArgNames.Compact]},setIncludeContent:function(f){var e=this.version.major>=1?d.SDataUri.QueryArgNames.IncludeContent:d.SDataUri.QueryArgNames.LegacyIncludeContent;this.queryArgs[e]=""+f;return this},appendPath:function(f){var e=typeof f==="string"?{text:f}:f;this.pathSegments.push(e);return this},toString:function(e){return this.build(e)},build:function(f){var e=[];e.push(this.getScheme()||d.SDataUri.Http);e.push(d.SDataUri.SchemeSuffix);e.push(d.SDataUri.PathSegmentPrefix);e.push(d.SDataUri.PathSegmentPrefix);e.push(this.getHost());if(this.getPort()>0){e.push(d.SDataUri.PortPrefix,this.getPort())}e.push(d.SDataUri.PathSegmentPrefix);var k=this.getPathSegments();var o=[];var h=this.getServer();if(h&&h.length>0){o=o.concat(h.split("/"))}for(var j=0;j0){e.push(d.SDataUri.QueryPrefix);e.push(m.join(d.SDataUri.QueryArgPrefix))}return e.join("")},getProduct:function(){return this.getPathSegment(d.SDataUri.ProductPathIndex)},setProduct:function(e){return this.setPathSegment(d.SDataUri.ProductPathIndex,e)},getContract:function(){return this.getPathSegment(d.SDataUri.ContractTypePathIndex)},setContract:function(e){return this.setPathSegment(d.SDataUri.ContractTypePathIndex,e)},getCompanyDataset:function(){return this.getPathSegment(d.SDataUri.CompanyDatasetPathIndex)},setCompanyDataset:function(e){return this.setPathSegment(d.SDataUri.CompanyDatasetPathIndex,e)},getCollectionType:function(){return this.getPathSegment(d.SDataUri.CollectionTypePathIndex)},setCollectionType:function(e){return this.setPathSegment(d.SDataUri.CollectionTypePathIndex,e)},getCollectionPredicate:function(){var e=this.getPathSegment(d.SDataUri.CollectionTypePathIndex);return(e&&e.predicate)||false},setCollectionPredicate:function(e){return this.setPathSegment(d.SDataUri.CollectionTypePathIndex,{predicate:e})}});b.apply(b.SData.Client.SDataUri,{Http:"http",Https:"https",PathSegmentPrefix:"/",PortPrefix:":",QueryArgPrefix:"&",QueryArgValuePrefix:"=",QueryPrefix:"?",SchemeSuffix:":",UnspecifiedPort:-1,UriName:"uri",QueryArgNames:{Compact:"_compact",Count:"count",Exclude:"exclude",Format:"format",Include:"include",IncludeContent:"_includeContent",LegacyIncludeContent:"includeContent",IncludeSchema:"includeSchema",Language:"language",OrderBy:"orderby",Precedence:"precedence",ReturnDelta:"returnDelta",Search:"search",Select:"select",StartIndex:"startIndex",Thumbnail:"thumbnail",TrackingID:"trackingID",Where:"where"},ProductPathIndex:0,ContractTypePathIndex:1,CompanyDatasetPathIndex:2,CollectionTypePathIndex:3,ResourcePropertyIndex:4,ServiceMethodSegment:"$service",TemplateSegment:"$template",SystemSegment:"$system",NamedQuerySegment:"$queries",BatchSegment:"$batch"})})();(function(){var d=window.Sage,c=d,f=d.namespace("Sage.SData.Client"),b=function(g){return typeof g!=="undefined"},a=function(g){return g&&g["#text"]?g["#text"]:g},e=/^(.+?):(.*)$/;d.SData.Client.SDataService=d.Evented.extend({uri:null,useCredentialedRequest:false,useCrossDomainCookies:false,userAgent:"Sage",userName:false,password:"",batchScope:null,timeout:0,cache:false,cacheParam:"_t",_etags:{},maxGetUriLength:2000,constructor:function(h,i,g){this.base.call(this,h);this.setUri(h);if(b(h.includeContent)){this.uri.setIncludeContent(h.includeContent)}if(b(h.version)){this.uri.setVersion(h.version)}if(b(h.cache)){this.cache=h.cache}if(b(h.cacheParam)){this.cacheParam=h.cacheParam}if(b(h.compact)){this.uri.setCompact(h.compact)}if(b(h.userName)){this.userName=h.userName}if(b(h.password)){this.password=h.password}if(b(h.json)){this.json=h.json}if(b(h.maxGetUriLength)){this.maxGetUriLength=h.maxGetUriLength}if(b(h.timeout)){this.timeout=h.timeout}if(b(h.useCredentialedRequest)){this.useCredentialedRequest=h.useCredentialedRequest}if(b(h.useCrossDomainCookies)){this.useCrossDomainCookies=h.useCrossDomainCookies}this.addEvents("beforerequest","requestcomplete","requestexception","requestaborted","requesttimeout")},setUri:function(h){if(b(h.uri)){this.uri=new d.SData.Client.SDataUri(h.uri)}else{this.uri=new d.SData.Client.SDataUri();var g=this.parseUri(h);if(b(g.serverName)){this.uri.setHost(g.serverName)}if(b(g.virtualDirectory)){this.uri.setServer(g.virtualDirectory)}if(b(g.applicationName)){this.uri.setProduct(g.applicationName)}if(b(g.contractName)){this.uri.setContract(g.contractName)}if(b(g.dataSet)){this.uri.setCompanyDataset(g.dataSet)}if(b(g.port)){this.uri.setPort(g.port)}if(b(g.protocol)){this.uri.setScheme(g.protocol)}}return this},parseUri:function(j){var g={},i=typeof j==="object"?j.url:j;var h=(typeof parseUri==="function")&&window.parseUri(i);if(h){if(h.host){g.serverName=h.host}var k=h.path.split("/").slice(1);if(k[0]){g.virtualDirectory=k[0]}if(k[1]){g.applicationName=k[1]}if(k[2]){g.contractName=k[2]}if(k[3]){g.dataSet=k[3]}if(h.port){g.port=parseInt(h.port)}if(h.protocol){g.protocol=h.protocol}}return g},isJsonEnabled:function(){return this.json},enableJson:function(){this.json=true;return this},disableJson:function(){this.json=false;return this},getVersion:function(){return this.uri.getVersion()},setVersion:function(g){this.uri.setVersion(g);return this},getUri:function(){return this.uri},getUserName:function(){return this.userName},setUserName:function(g){this.userName=g;return this},getPassword:function(){return this.password},setPassword:function(g){this.password=g;return this},getProtocol:function(){return this.uri.getScheme()},setProtocol:function(g){this.uri.setScheme(g);return this},getServerName:function(){return this.uri.getHost()},setServerName:function(g){this.uri.setHost(g);return this},getPort:function(){return this.uri.getPort()},setPort:function(g){this.uri.setPort(g);return this},getVirtualDirectory:function(){return this.uri.getServer()},setVirtualDirectory:function(g){this.uri.setServer(g);return this},getApplicationName:function(){return this.uri.getProduct()},setApplicationName:function(g){this.uri.setProduct(g);return this},getContractName:function(){return this.uri.getContract()},setContractName:function(g){this.uri.setContract(g);return this},getDataSet:function(){return this.uri.getCompanyDataset()},setDataSet:function(g){this.uri.setCompanyDataset(g);return this},getIncludeContent:function(){return this.uri.getIncludeContent()},setIncludeContent:function(g){this.uri.setIncludeContent(g);return this},getCompact:function(){return this.uri.getCompact()},setCompact:function(g){this.uri.setCompact(g);return this},setMaxGetUriLength:function(g){this.maxGetUriLength=g;return this},getMaxGetUriLength:function(){return this.maxGetUriLength},getUserAgent:function(){return this.userAgent},setUserAgent:function(g){this.userAgent=g;return this},registerBatchScope:function(g){this.batchScope=g},clearBatchScope:function(g){this.batchScope=null},createBasicAuthToken:function(){return"Basic "+Base64.encode(this.userName+":"+this.password)},createHeadersForRequest:function(g){var h={"X-Authorization-Mode":"no-challenge"};if(this.userName&&!this.useCredentialedRequest){h.Authorization=h["X-Authorization"]=this.createBasicAuthToken()}return h},extendAcceptRequestHeader:function(g,h){if(g){return g.split(/\s*,\s*/).join(";"+h+",")+";"+h}return g},executeRequest:function(i,h,j){if(this.json){i.setQueryArg("format","json")}var g=i.build();var k=c.apply({async:h.async,headers:{},method:"GET",url:g,cache:h.cache||this.cache,cacheParam:h.cacheParam||this.cacheParam,etagCache:this._etags[g]},{scope:this,success:function(l,m){var p=l.responseText;if(l.status===304){p=this._etags[g].responseText}var q=l.getResponseHeader&&l.getResponseHeader("Content-Type");var o=this.processFeed(p,q);var n=l.getResponseHeader("etag");this._etags[g]={etag:n,responseText:p};this.fireEvent("requestcomplete",i,m,o);if(h.success){h.success.call(h.scope||this,o)}},failure:function(l,m){this.fireEvent("requestexception",i,m,l);if(h.failure){h.failure.call(h.scope||this,l,m)}},aborted:function(l,m){this.fireEvent("requestaborted",i,m,l);if(h.aborted){h.aborted.call(h.scope||this,l,m)}},timeout:function(l,m){this.fireEvent("requesttimeout",i,m,l);if(h.timeout){h.timeout.call(h.scope||this,l,m)}}},j);c.apply(k.headers,this.createHeadersForRequest(i),i.completeHeaders);if(typeof this.timeout==="number"){k.requestTimeout=this.timeout}if(i.extendedHeaders.Accept){k.headers.Accept=this.extendAcceptRequestHeader(k.headers.Accept,i.extendedHeaders.Accept)}if(this.useCredentialedRequest||this.useCrossDomainCookies){k.withCredentials=true}if(this.useCredentialedRequest&&this.userName){k.user=this.userName;k.password=this.password}this.fireEvent("beforerequest",i,k);if(typeof k.result!=="undefined"){if(h.success){h.success.call(h.scope||this,k.result)}return}return f.Ajax.request(k)},abortRequest:function(g){f.Ajax.cancel(g)},readFeed:function(i,g){g=g||{};if(this.batchScope){this.batchScope.add({url:i.build(),method:"GET"});return}var j={headers:{Accept:this.json?"application/json,*/*":"application/atom+xml;type=feed,*/*"}};var h=i.build();if(g.httpMethodOverride||(typeof h==="string"&&h.length>this.maxGetUriLength)){if(this.json){i.setQueryArg("format","json")}j.headers["X-HTTP-Method-Override"]="GET";j.method="POST";j.body=i.build();j.url=i.build(true)}return this.executeRequest(i,g,j)},readEntry:function(j,g){g=g||{};if(this.batchScope){var i={url:j.build(),method:"GET"};var h=j.getResourceKey();if(typeof h==="string"&&h.length>0){i.key=h}this.batchScope.add(i);return}var k=c.apply({},{success:function(m){var l=m["$resources"][0]||false;if(g.success){g.success.call(g.scope||this,l)}}},g);return this.executeRequest(j,k,{headers:{Accept:this.json?"application/json,*/*":"application/atom+xml;type=entry,*/*"}})},createEntry:function(j,i,h){h=h||{};if(this.batchScope){this.batchScope.add({url:j.build(),entry:i,method:"POST"});return}var l=c.apply({},{success:function(n){var m=n["$resources"][0]||false;if(h.success){h.success.call(h.scope||this,m)}}},h);var k=c.apply({},{method:"POST"});if(this.isJsonEnabled()){c.apply(k,{body:JSON.stringify(i),headers:{"Content-Type":"application/json"}})}else{var g=new XML.ObjTree();g.attr_prefix="@";c.apply(k,{body:g.writeXML(this.formatEntry(i)),headers:{"Content-Type":"application/atom+xml;type=entry",Accept:"application/atom+xml;type=entry,*/*"}})}return this.executeRequest(j,l,k)},updateEntry:function(j,i,h){h=h||{};if(this.batchScope){this.batchScope.add({url:j.build(),entry:i,method:"PUT",etag:i["$etag"]});return}var m=c.apply({},{success:function(o){var n=o["$resources"][0]||false;if(h.success){h.success.call(h.scope||this,n)}}},h);var l={},k={method:"PUT",headers:l};if(i["$etag"]&&!(h&&h.ignoreETag)){l["If-Match"]=i["$etag"]}if(this.isJsonEnabled()){l["Content-Type"]="application/json";k.body=JSON.stringify(i)}else{var g=new XML.ObjTree();g.attr_prefix="@";l["Content-Type"]="application/atom+xml;type=entry";l.Accept="application/atom+xml;type=entry,*/*";k.body=g.writeXML(this.formatEntry(i))}return this.executeRequest(j,m,k)},deleteEntry:function(i,h,g){g=g||{};if(this.batchScope){this.batchScope.add({url:i.build(),method:"DELETE",etag:!(g&&g.ignoreETag)&&h["$etag"]});return}var k={},j={method:"DELETE",headers:k};if(h["$etag"]&&!(g&&g.ignoreETag)){k["If-Match"]=h["$etag"]}return this.executeRequest(i,g,j)},executeServiceOperation:function(j,i,h){var l=c.apply({},{success:function(o){var n=o["$resources"][0]||false,m=n&&n.response,q=m&&m["$resources"],p=q&&q[0];if(p&&p["$name"]){n.response={};n.response[p["$name"]]=p}if(h.success){h.success.call(h.scope||this,n)}}},h);var k=c.apply({},{method:"POST"});if(this.isJsonEnabled()){c.apply(k,{body:JSON.stringify(i),headers:{"Content-Type":"application/json"}})}else{var g=new XML.ObjTree();g.attr_prefix="@";c.apply(k,{body:g.writeXML(this.formatEntry(i)),headers:{"Content-Type":"application/atom+xml;type=entry",Accept:"application/atom+xml;type=entry,*/*"}})}return this.executeRequest(j,l,k)},commitBatch:function(g,p){p=p||{};var k=g.getItems(),o,m,n={"$resources":[]};for(var h=0;h=200&&j<300)||j===304)};var c=function(n,m){if(n.readyState==4){if(f(n.status)){if(m.success){m.success.call(m.scope||this,n,m)}}else{if(n.status===0){var l=false;try{l=(n.statusText==="")}catch(j){l=true}if(l){var k=m.aborted||m.failure;if(k){k.call(m.scope||this,n,m)}}else{if(m.failure){m.failure.call(m.scope||this,n,m)}}}else{if(m.failure){m.failure.call(m.scope||this,n,m)}}}}};var g=function(l,k){var j=k.timeout||k.failure;if(j){j.call(k.scope||this,l,k)}};var d=function(k,j){k.ontimeout=function(){g.call(k,k,j)}};var i=function(k,j){k.onreadystatechange=function(){c.call(k,k,j)}};var h=function(k){var j=[];for(var l in k){j.push(encodeURIComponent(l)+"="+encodeURIComponent(k[l]))}return j.join("&")};b.apply(b.SData.Client.Ajax,{request:function(p){p=e.apply({},p);p.params=e.apply({},p.params);p.headers=e.apply({},p.headers);if(p.cache!==true){p.params[p.cacheParam||"_t"]=(new Date()).getTime()}p.method=p.method||"GET";var k=h(p.params);if(k){p.url=p.url+(/\?/.test(p.url)?"&":"?")+k}var m=new XMLHttpRequest();if(p.user){m.open(p.method,p.url,p.async!==false,p.user,p.password)}else{m.open(p.method,p.url,p.async!==false)}if(p.withCredentials){m.withCredentials=true}try{m.setRequestHeader("Accept",p.accept||"*/*");m.setRequestHeader("X-Requested-With","XMLHttpRequest");if(p.contentType){m.setRequestHeader("Content-Type",p.contentType)}for(var q in p.headers){m.setRequestHeader(q,p.headers[q])}var j=p.etagCache;if(p.cache&&j&&j.etag){m.setRequestHeader("If-None-Match",j.etag)}}catch(l){}if(p.async!==false){if(typeof p.requestTimeout==="number"&&p.requestTimeout>=0&&typeof m.timeout==="number"){m.timeout=p.requestTimeout;d(m,p)}i(m,p);m.send(p.body||null)}else{m.send(p.body||null);c(m,p)}return m},cancel:function(j){j.abort()}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataBaseRequest=b.Class.define({service:null,uri:null,completeHeaders:null,extendedHeaders:null,constructor:function(d){this.base.apply(this,arguments);this.service=d;this.completeHeaders={};this.extendedHeaders={};this.uri=new b.SData.Client.SDataUri();var f,e;if(this.service){this.uri.setVersion(this.service.getVersion());f=this.service.getIncludeContent();if(typeof f!=="undefined"){this.uri.setIncludeContent(f)}this.uri.setServer(this.service.getVirtualDirectory()?this.service.getVirtualDirectory():"sdata");this.uri.setScheme(this.service.getProtocol());this.uri.setHost(this.service.getServerName());this.uri.setPort(this.service.getPort());e=this.service.getCompact();if(typeof e!=="undefined"){this.uri.setCompact(e)}}},clone:function(){return new b.SData.Client.SDataBaseRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},setRequestHeader:function(d,e){this.completeHeaders[d]=e},extendRequestHeader:function(d,e){this.extendedHeaders[d]=e},clearRequestHeader:function(d){delete this.completeHeaders[d];delete this.extendedHeaders[d]},getAccept:function(){return this.extendedHeaders.Accept},setAccept:function(d){this.extendRequestHeader("Accept",d);return this},getService:function(){return this.service},getUri:function(){return this.uri},setUri:function(d){this.uri=d;return this},getServerName:function(){return this.uri.getHost()},setServerName:function(d){this.uri.setHost(d);return this},getVirtualDirectory:function(){return this.uri.getServer()},setVirtualDirectory:function(d){this.uri.setServer(d);return this},getProtocol:function(){return this.uri.getScheme()},setProtocol:function(d){this.uri.setScheme(d);return this},getPort:function(){return this.uri.getPort()},setPort:function(d){this.uri.setPort(d);return this},getQueryArgs:function(){return this.uri.getQueryArgs()},setQueryArgs:function(e,d){this.uri.setQueryArgs(e,d);return this},getQueryArg:function(d){return this.uri.getQueryArg(d)},setQueryArg:function(d,e){this.uri.setQueryArg(d,e);return this},build:function(d){return this.uri.build(d)},toString:function(d){return this.build(d)}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataApplicationRequest=b.SData.Client.SDataBaseRequest.extend({constructor:function(){this.base.apply(this,arguments);if(this.service){this.uri.setProduct(this.service.getApplicationName()?this.service.getApplicationName():"-");this.uri.setContract(this.service.getContractName()?this.service.getContractName():"-");this.uri.setCompanyDataset(this.service.getDataSet()?this.service.getDataSet():"-")}},clone:function(){return new b.SData.Client.SDataApplicationRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},getApplicationName:function(){return this.uri.getProduct()},setApplicationName:function(d){this.uri.setProduct(d);return this},getContractName:function(){return this.uri.getContract()},setContractName:function(d){this.uri.setContract(d);return this},getDataSet:function(){return this.uri.getCompanyDataset()},setDataSet:function(d){this.uri.setCompanyDataset(d);return this},getResourceKind:function(){return this.uri.getCollectionType()},setResourceKind:function(d){this.uri.setCollectionType(d);return this}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataResourceCollectionRequest=b.SData.Client.SDataApplicationRequest.extend({constructor:function(){this.base.apply(this,arguments)},clone:function(){return new b.SData.Client.SDataResourceCollectionRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},getCount:function(){return this.uri.getCount()},setCount:function(d){this.uri.setCount(d);return this},getStartIndex:function(){return this.uri.getStartIndex()},setStartIndex:function(d){this.uri.setStartIndex(d);return this},read:function(d){return this.service.readFeed(this,d)}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataNamedQueryRequest=b.SData.Client.SDataResourceCollectionRequest.extend({constructor:function(){this.base.apply(this,arguments);this.uri.setPathSegment(c.SDataUri.ResourcePropertyIndex,c.SDataUri.NamedQuerySegment)},clone:function(){return new b.SData.Client.SDataNamedQueryRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},getQueryName:function(){return this.uri.getPathSegment(c.SDataUri.ResourcePropertyIndex+1)},setQueryName:function(d){this.uri.setPathSegment(c.SDataUri.ResourcePropertyIndex+1,d);return this}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataSingleResourceRequest=b.SData.Client.SDataApplicationRequest.extend({key:"",constructor:function(){this.base.apply(this,arguments)},clone:function(){return new b.SData.Client.SDataSingleResourceRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},read:function(d){return this.service.readEntry(this,d)},update:function(e,d){return this.service.updateEntry(this,e,d)},create:function(e,d){return this.service.createEntry(this,e,d)},"delete":function(e,d){return this.service.deleteEntry(this,e,d)},getResourceSelector:function(){return this.uri.getCollectionPredicate()},setResourceSelector:function(d){this.uri.setCollectionPredicate(d);return this},setResourceKey:function(d){this.key=d;this.setResourceSelector("'"+this.key+"'");return this},getResourceKey:function(){return this.key}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataResourcePropertyRequest=b.SData.Client.SDataSingleResourceRequest.extend({constructor:function(){this.base.apply(this,arguments)},clone:function(){return new b.SData.Client.SDataResourcePropertyRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},readFeed:function(d){return this.service.readFeed(this,d)},getResourceProperty:function(){return this.uri.getPathSegment(b.SData.Client.SDataUri.ResourcePropertyIndex)},setResourceProperty:function(d){this.uri.setPathSegment(b.SData.Client.SDataUri.ResourcePropertyIndex,d);return this}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataSystemRequest=b.SData.Client.SDataBaseRequest.extend({constructor:function(){this.base.apply(this,arguments);this.uri.setPathSegment(b.SData.Client.SDataUri.ProductPathIndex,b.SData.Client.SDataUri.SystemSegment)},clone:function(){return new b.SData.Client.SDataSystemRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},getCategory:function(){this.uri.getPathSegment(b.SData.Client.SDataUri.ContractTypePathIndex)},setCategory:function(d){this.uri.setPathSegment(b.SData.Client.SDataUri.ContractTypePathIndex,d);return this},read:function(d){return this.service.readFeed(this,d)}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataTemplateResourceRequest=b.SData.Client.SDataApplicationRequest.extend({constructor:function(){this.base.apply(this,arguments);this.uri.setPathSegment(b.SData.Client.SDataUri.ResourcePropertyIndex,b.SData.Client.SDataUri.TemplateSegment)},clone:function(){return new b.SData.Client.SDataTemplateResourceRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},read:function(d){return this.service.readEntry(this,d)}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataServiceOperationRequest=b.SData.Client.SDataApplicationRequest.extend({constructor:function(){this.base.apply(this,arguments);this.uri.setPathSegment(c.SDataUri.ResourcePropertyIndex,c.SDataUri.ServiceMethodSegment)},clone:function(){return new b.SData.Client.SDataServiceOperationRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},execute:function(e,d){return this.service.executeServiceOperation(this,e,d)},getOperationName:function(){return this.uri.getPathSegment(c.SDataUri.ResourcePropertyIndex+1)},setOperationName:function(d){this.uri.setPathSegment(c.SDataUri.ResourcePropertyIndex+1,d);return this}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataBatchRequest=b.SData.Client.SDataApplicationRequest.extend({items:null,constructor:function(){this.base.apply(this,arguments);this.items=[];this.uri.setPathSegment(b.SData.Client.SDataUri.ResourcePropertyIndex,b.SData.Client.SDataUri.BatchSegment)},clone:function(){return new b.SData.Client.SDataBatchRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri)).setItems(this.items.slice(0))},getItems:function(){return this.items},setItems:function(d){this.items=d;return this},using:function(f,d){if(this.service){this.service.registerBatchScope(this)}else{throw"A service must be associated with the batch request."}try{f.call(d||this,this)}catch(g){this.service.clearBatchScope(this);throw g}this.service.clearBatchScope(this);return this},add:function(d){this.items.push(d)},commit:function(d){this.service.commitBatch(this,d)}})})();(function(){var b=window.Sage,a=b,d=b.namespace("Sage.SData.Client"),c=/^true$/i;b.SData.Client.SDataUri=b.Class.define({scheme:"http",host:"",server:"",port:-1,version:null,queryArgs:null,pathSegments:null,constructor:function(e){this.base.apply(this,arguments);a.apply(this,e);this.queryArgs=a.apply({},e&&e.queryArgs);this.pathSegments=(e&&e.pathSegments&&e.pathSegments.slice(0))||[];this.version=(e&&e.version&&a.apply({},e.version))||{major:1,minor:0}},clone:function(){return new b.SData.Client.SDataUri(this)},getVersion:function(){return this.version},setVersion:function(e){this.version=a.apply({major:0,minor:0},e);return this},getScheme:function(){return this.scheme},setScheme:function(e){this.scheme=e;return this},getHost:function(){return this.host},setHost:function(e){this.host=e;return this},getPort:function(){return this.port},setPort:function(e){this.port=e;return this},getServer:function(){return this.server},setServer:function(e){this.server=e;return this},getQueryArgs:function(){return this.queryArgs},setQueryArgs:function(f,e){this.queryArgs=e?f:a.apply(this.queryArgs,f);return this},getQueryArg:function(e){return this.queryArgs[e]},setQueryArg:function(e,f){this.queryArgs[e]=f;return this},getPathSegments:function(){return this.pathSegments},setPathSegments:function(e){this.pathSegments=e;return this},getPathSegment:function(e){return this.pathSegments.length>e?this.pathSegments[e]:false},setPathSegment:function(f,h,e){if(!h&&!e){this.pathSegments[f]=null}else{if(typeof h==="object"){this.pathSegments[f]=a.apply({},h,this.pathSegments[f])}else{var g={};if(h){g.text=h}if(e){g.predicate=e}this.pathSegments[f]=a.apply({},g,this.pathSegments[f])}}return this},getStartIndex:function(){return this.queryArgs[d.SDataUri.QueryArgNames.StartIndex]?parseInt(this.queryArgs[d.SDataUri.QueryArgNames.StartIndex]):-1},setStartIndex:function(e){this.queryArgs[d.SDataUri.QueryArgNames.StartIndex]=e;return this},getCount:function(){return this.queryArgs[d.SDataUri.QueryArgNames.Count]?parseInt(this.queryArgs[d.SDataUri.QueryArgNames.Count]):-1},setCount:function(e){this.queryArgs[d.SDataUri.QueryArgNames.Count]=e;return this},getIncludeContent:function(){var e,f;e=this.version.major>=1?d.SDataUri.QueryArgNames.IncludeContent:d.SDataUri.QueryArgNames.LegacyIncludeContent;f=this.queryArgs[e];if(typeof f!=="undefined"){return c.test(f)}else{return f}},setCompact:function(e){this.queryArgs[d.SDataUri.QueryArgNames.Compact]=e;return this},getCompact:function(){return this.queryArgs[d.SDataUri.QueryArgNames.Compact]},setIncludeContent:function(f){var e=this.version.major>=1?d.SDataUri.QueryArgNames.IncludeContent:d.SDataUri.QueryArgNames.LegacyIncludeContent;this.queryArgs[e]=""+f;return this},appendPath:function(f){var e=typeof f==="string"?{text:f}:f;this.pathSegments.push(e);return this},toString:function(e){return this.build(e)},build:function(f){var e=[];e.push(this.getScheme()||d.SDataUri.Http);e.push(d.SDataUri.SchemeSuffix);e.push(d.SDataUri.PathSegmentPrefix);e.push(d.SDataUri.PathSegmentPrefix);e.push(this.getHost());if(this.getPort()>0){e.push(d.SDataUri.PortPrefix,this.getPort())}e.push(d.SDataUri.PathSegmentPrefix);var k=this.getPathSegments();var o=[];var h=this.getServer();if(h&&h.length>0){o=o.concat(h.split("/"))}for(var j=0;j0){e.push(d.SDataUri.QueryPrefix);e.push(m.join(d.SDataUri.QueryArgPrefix))}return e.join("")},getProduct:function(){return this.getPathSegment(d.SDataUri.ProductPathIndex)},setProduct:function(e){return this.setPathSegment(d.SDataUri.ProductPathIndex,e)},getContract:function(){return this.getPathSegment(d.SDataUri.ContractTypePathIndex)},setContract:function(e){return this.setPathSegment(d.SDataUri.ContractTypePathIndex,e)},getCompanyDataset:function(){return this.getPathSegment(d.SDataUri.CompanyDatasetPathIndex)},setCompanyDataset:function(e){return this.setPathSegment(d.SDataUri.CompanyDatasetPathIndex,e)},getCollectionType:function(){return this.getPathSegment(d.SDataUri.CollectionTypePathIndex)},setCollectionType:function(e){return this.setPathSegment(d.SDataUri.CollectionTypePathIndex,e)},getCollectionPredicate:function(){var e=this.getPathSegment(d.SDataUri.CollectionTypePathIndex);return(e&&e.predicate)||false},setCollectionPredicate:function(e){return this.setPathSegment(d.SDataUri.CollectionTypePathIndex,{predicate:e})}});b.apply(b.SData.Client.SDataUri,{Http:"http",Https:"https",PathSegmentPrefix:"/",PortPrefix:":",QueryArgPrefix:"&",QueryArgValuePrefix:"=",QueryPrefix:"?",SchemeSuffix:":",UnspecifiedPort:-1,UriName:"uri",QueryArgNames:{Compact:"_compact",Count:"count",Exclude:"exclude",Format:"format",Include:"include",IncludeContent:"_includeContent",LegacyIncludeContent:"includeContent",IncludeSchema:"includeSchema",Language:"language",OrderBy:"orderby",Precedence:"precedence",ReturnDelta:"returnDelta",Search:"search",Select:"select",StartIndex:"startIndex",Thumbnail:"thumbnail",TrackingID:"trackingID",Where:"where"},ProductPathIndex:0,ContractTypePathIndex:1,CompanyDatasetPathIndex:2,CollectionTypePathIndex:3,ResourcePropertyIndex:4,ServiceMethodSegment:"$service",TemplateSegment:"$template",SystemSegment:"$system",NamedQuerySegment:"$queries",BatchSegment:"$batch"})})();(function(){var d=window.Sage,c=d,f=d.namespace("Sage.SData.Client"),b=function(g){return typeof g!=="undefined"},a=function(g){return g&&g["#text"]?g["#text"]:g},e=/^(.+?):(.*)$/;d.SData.Client.SDataService=d.Evented.extend({uri:null,useCredentialedRequest:false,useCrossDomainCookies:false,userAgent:"Sage",userName:false,password:"",batchScope:null,timeout:0,cache:false,cacheParam:"_t",_etags:{},maxGetUriLength:2000,constructor:function(h,i,g){this.base.call(this,h);this.setUri(h);if(b(h.includeContent)){this.uri.setIncludeContent(h.includeContent)}if(b(h.version)){this.uri.setVersion(h.version)}if(b(h.cache)){this.cache=h.cache}if(b(h.cacheParam)){this.cacheParam=h.cacheParam}if(b(h.compact)){this.uri.setCompact(h.compact)}if(b(h.userName)){this.userName=h.userName}if(b(h.password)){this.password=h.password}if(b(h.json)){this.json=h.json}if(b(h.maxGetUriLength)){this.maxGetUriLength=h.maxGetUriLength}if(b(h.timeout)){this.timeout=h.timeout}if(b(h.useCredentialedRequest)){this.useCredentialedRequest=h.useCredentialedRequest}if(b(h.useCrossDomainCookies)){this.useCrossDomainCookies=h.useCrossDomainCookies}this.addEvents("beforerequest","requestcomplete","requestexception","requestaborted","requesttimeout")},setUri:function(h){if(b(h.uri)){this.uri=new d.SData.Client.SDataUri(h.uri)}else{this.uri=new d.SData.Client.SDataUri();var g=this.parseUri(h);if(b(g.serverName)){this.uri.setHost(g.serverName)}if(b(g.virtualDirectory)){this.uri.setServer(g.virtualDirectory)}if(b(g.applicationName)){this.uri.setProduct(g.applicationName)}if(b(g.contractName)){this.uri.setContract(g.contractName)}if(b(g.dataSet)){this.uri.setCompanyDataset(g.dataSet)}if(b(g.port)){this.uri.setPort(g.port)}if(b(g.protocol)){this.uri.setScheme(g.protocol)}}return this},parseUri:function(j){var g={},i=typeof j==="object"?j.url:j;var h=(typeof parseUri==="function")&&window.parseUri(i);if(h){if(h.host){g.serverName=h.host}var k=h.path.split("/").slice(1);if(k[0]){g.virtualDirectory=k[0]}if(k[1]){g.applicationName=k[1]}if(k[2]){g.contractName=k[2]}if(k[3]){g.dataSet=k[3]}if(h.port){g.port=parseInt(h.port)}if(h.protocol){g.protocol=h.protocol}}return g},isJsonEnabled:function(){return this.json},enableJson:function(){this.json=true;return this},disableJson:function(){this.json=false;return this},getVersion:function(){return this.uri.getVersion()},setVersion:function(g){this.uri.setVersion(g);return this},getUri:function(){return this.uri},getUserName:function(){return this.userName},setUserName:function(g){this.userName=g;return this},getPassword:function(){return this.password},setPassword:function(g){this.password=g;return this},getProtocol:function(){return this.uri.getScheme()},setProtocol:function(g){this.uri.setScheme(g);return this},getServerName:function(){return this.uri.getHost()},setServerName:function(g){this.uri.setHost(g);return this},getPort:function(){return this.uri.getPort()},setPort:function(g){this.uri.setPort(g);return this},getVirtualDirectory:function(){return this.uri.getServer()},setVirtualDirectory:function(g){this.uri.setServer(g);return this},getApplicationName:function(){return this.uri.getProduct()},setApplicationName:function(g){this.uri.setProduct(g);return this},getContractName:function(){return this.uri.getContract()},setContractName:function(g){this.uri.setContract(g);return this},getDataSet:function(){return this.uri.getCompanyDataset()},setDataSet:function(g){this.uri.setCompanyDataset(g);return this},getIncludeContent:function(){return this.uri.getIncludeContent()},setIncludeContent:function(g){this.uri.setIncludeContent(g);return this},getCompact:function(){return this.uri.getCompact()},setCompact:function(g){this.uri.setCompact(g);return this},setMaxGetUriLength:function(g){this.maxGetUriLength=g;return this},getMaxGetUriLength:function(){return this.maxGetUriLength},getUserAgent:function(){return this.userAgent},setUserAgent:function(g){this.userAgent=g;return this},registerBatchScope:function(g){this.batchScope=g},clearBatchScope:function(g){this.batchScope=null},createBasicAuthToken:function(){return"Basic "+Base64.encode(this.userName+":"+this.password)},createHeadersForRequest:function(g){var h={"X-Authorization-Mode":"no-challenge"};if(this.userName&&!this.useCredentialedRequest){h.Authorization=h["X-Authorization"]=this.createBasicAuthToken()}return h},extendAcceptRequestHeader:function(g,h){if(g){return g.split(/\s*,\s*/).join(";"+h+",")+";"+h}return g},executeRequest:function(i,h,j){if(this.json){i.setQueryArg("format","json")}var g=i.build();var k=c.apply({async:h.async,headers:{},method:"GET",url:g,cache:h.cache||this.cache,cacheParam:h.cacheParam||this.cacheParam,etagCache:this._etags[g]},{scope:this,success:function(l,m){var p=l.responseText;if(l.status===304){p=this._etags[g].responseText}var q=l.getResponseHeader&&l.getResponseHeader("Content-Type");var o=this.processFeed(p,q);var n=l.getResponseHeader("etag");this._etags[g]={etag:n,responseText:p};this.fireEvent("requestcomplete",i,m,o);if(h.success){h.success.call(h.scope||this,o)}},failure:function(l,m){this.fireEvent("requestexception",i,m,l);if(h.failure){h.failure.call(h.scope||this,l,m)}},aborted:function(l,m){this.fireEvent("requestaborted",i,m,l);if(h.aborted){h.aborted.call(h.scope||this,l,m)}},timeout:function(l,m){this.fireEvent("requesttimeout",i,m,l);if(h.timeout){h.timeout.call(h.scope||this,l,m)}}},j);c.apply(k.headers,this.createHeadersForRequest(i),i.completeHeaders);if(typeof this.timeout==="number"){k.requestTimeout=this.timeout}if(i.extendedHeaders.Accept){k.headers.Accept=this.extendAcceptRequestHeader(k.headers.Accept,i.extendedHeaders.Accept)}if(this.useCredentialedRequest||this.useCrossDomainCookies){k.withCredentials=true}if(this.useCredentialedRequest&&this.userName){k.user=this.userName;k.password=this.password}this.fireEvent("beforerequest",i,k);if(typeof k.result!=="undefined"){if(h.success){h.success.call(h.scope||this,k.result)}return}return f.Ajax.request(k)},abortRequest:function(g){f.Ajax.cancel(g)},readFeed:function(i,g){g=g||{};if(this.batchScope){this.batchScope.add({url:i.build(),method:"GET"});return}var j={headers:{Accept:this.json?"application/json,*/*":"application/atom+xml;type=feed,*/*"}};var h=i.build();if(g.httpMethodOverride||(typeof h==="string"&&h.length>this.maxGetUriLength)){if(this.json){i.setQueryArg("format","json")}j.headers["X-HTTP-Method-Override"]="GET";j.method="POST";j.body=i.build();j.url=i.build(true)}return this.executeRequest(i,g,j)},readEntry:function(j,g){g=g||{};if(this.batchScope){var i={url:j.build(),method:"GET"};var h=j.getResourceKey();if(typeof h==="string"&&h.length>0){i.key=h}this.batchScope.add(i);return}var k=c.apply({},{success:function(m){var l=m["$resources"][0]||false;if(g.success){g.success.call(g.scope||this,l)}}},g);return this.executeRequest(j,k,{headers:{Accept:this.json?"application/json,*/*":"application/atom+xml;type=entry,*/*"}})},createEntry:function(j,i,h){h=h||{};if(this.batchScope){this.batchScope.add({url:j.build(),entry:i,method:"POST"});return}var l=c.apply({},{success:function(n){var m=n["$resources"][0]||false;if(h.success){h.success.call(h.scope||this,m)}}},h);var k=c.apply({},{method:"POST"});if(this.isJsonEnabled()){c.apply(k,{body:JSON.stringify(i),headers:{"Content-Type":"application/json"}})}else{var g=new XML.ObjTree();g.attr_prefix="@";c.apply(k,{body:g.writeXML(this.formatEntry(i)),headers:{"Content-Type":"application/atom+xml;type=entry",Accept:"application/atom+xml;type=entry,*/*"}})}return this.executeRequest(j,l,k)},updateEntry:function(j,i,h){h=h||{};if(this.batchScope){this.batchScope.add({url:j.build(),entry:i,method:"PUT",etag:i["$etag"]});return}var m=c.apply({},{success:function(o){var n=o["$resources"][0]||false;if(h.success){h.success.call(h.scope||this,n)}}},h);var l={},k={method:"PUT",headers:l};if(i["$etag"]&&!(h&&h.ignoreETag)){l["If-Match"]=i["$etag"]}if(this.isJsonEnabled()){l["Content-Type"]="application/json";k.body=JSON.stringify(i)}else{var g=new XML.ObjTree();g.attr_prefix="@";l["Content-Type"]="application/atom+xml;type=entry";l.Accept="application/atom+xml;type=entry,*/*";k.body=g.writeXML(this.formatEntry(i))}return this.executeRequest(j,m,k)},deleteEntry:function(i,h,g){g=g||{};if(this.batchScope){this.batchScope.add({url:i.build(),method:"DELETE",etag:!(g&&g.ignoreETag)&&h["$etag"]});return}var k={},j={method:"DELETE",headers:k};if(h["$etag"]&&!(g&&g.ignoreETag)){k["If-Match"]=h["$etag"]}return this.executeRequest(i,g,j)},executeServiceOperation:function(j,i,h){var l=c.apply({},{success:function(o){var n=o["$resources"][0]||false,m=n&&n.response,q=m&&m["$resources"],p=q&&q[0];if(p&&p["$name"]){n.response={};n.response[p["$name"]]=p}if(h.success){h.success.call(h.scope||this,n)}}},h);var k=c.apply({},{method:"POST"});if(this.isJsonEnabled()){c.apply(k,{body:JSON.stringify(i),headers:{"Content-Type":"application/json"}})}else{var g=new XML.ObjTree();g.attr_prefix="@";c.apply(k,{body:g.writeXML(this.formatEntry(i)),headers:{"Content-Type":"application/atom+xml;type=entry",Accept:"application/atom+xml;type=entry,*/*"}})}return this.executeRequest(j,l,k)},commitBatch:function(g,p){p=p||{};var k=g.getItems(),o,m,n={"$resources":[]};for(var h=0;h Date: Fri, 18 Nov 2022 09:38:43 -0500 Subject: [PATCH 3/3] Guard against null/undefined feed when executing a service operation refs: INFORCRM-26488 --- deploy/sdata-client-debug.js | 6 +++++- deploy/sdata-client.js | 2 +- package.json | 2 +- src/SDataService.js | 6 +++++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/deploy/sdata-client-debug.js b/deploy/sdata-client-debug.js index c7054ee..7719bc3 100644 --- a/deploy/sdata-client-debug.js +++ b/deploy/sdata-client-debug.js @@ -1781,7 +1781,11 @@ XML.ObjTree.prototype.xml_escape = function ( text ) { executeServiceOperation: function(request, entry, options) { var o = S.apply({}, { success: function(feed) { - var entry = feed['$resources'][0] || false, + if (typeof feed === 'undefined' || feed === null) { + feed = {}; + } + + var entry = feed.$resources && feed.$resources[0] || false, response = entry && entry['response'], resources = response && response['$resources'], payload = resources && resources[0]; diff --git a/deploy/sdata-client.js b/deploy/sdata-client.js index e9d158c..14cb92d 100644 --- a/deploy/sdata-client.js +++ b/deploy/sdata-client.js @@ -1,4 +1,4 @@ /* * */ -var XML=window.XML;if(typeof(XML)=="undefined"){XML=function(){}}XML.ObjTree=function(){console.warn("xml obj transformation is not implemented.");return this};XML.ObjTree.VERSION="0.10";XML.ObjTree.prototype.xmlDecl='\n';XML.ObjTree.prototype.attr_prefix="-";XML.ObjTree.prototype.overrideMimeType="text/xml";XML.ObjTree.prototype.parseXML=function(a){console.warn("parseXML is not implemented.")};XML.ObjTree.prototype.parseHTTP=function(b,a,c){console.warn("parseHTTP is not implemented.")};XML.ObjTree.prototype.parseDOM=function(a){console.warn("praseDom is not implemented.")};XML.ObjTree.prototype.parseElement=function(a){console.warn("parseElement is not implemented.")};XML.ObjTree.prototype.addNode=function(c,a,b,d){console.warn("addNode is not implemented.")};XML.ObjTree.prototype.writeXML=function(a){console.warn("writeXML is not implemented.")};XML.ObjTree.prototype.hash_to_xml=function(b,a){console.warn("hash_to_xml is not implemented.")};XML.ObjTree.prototype.array_to_xml=function(a,b){console.warn("array_to_xml is not implemented.")};XML.ObjTree.prototype.scalar_to_xml=function(a,b){console.warn("scalar_to_xml is not implemented.")};XML.ObjTree.prototype.xml_escape=function(a){console.warn("xml_escape is not implemented.")};(function(){var b=window.Sage,e=b,a=b.namespace("Sage.SData.Client.Ajax");var f=function(j){return((j>=200&&j<300)||j===304)};var c=function(n,m){if(n.readyState==4){if(f(n.status)){if(m.success){m.success.call(m.scope||this,n,m)}}else{if(n.status===0){var l=false;try{l=(n.statusText==="")}catch(j){l=true}if(l){var k=m.aborted||m.failure;if(k){k.call(m.scope||this,n,m)}}else{if(m.failure){m.failure.call(m.scope||this,n,m)}}}else{if(m.failure){m.failure.call(m.scope||this,n,m)}}}}};var g=function(l,k){var j=k.timeout||k.failure;if(j){j.call(k.scope||this,l,k)}};var d=function(k,j){k.ontimeout=function(){g.call(k,k,j)}};var i=function(k,j){k.onreadystatechange=function(){c.call(k,k,j)}};var h=function(k){var j=[];for(var l in k){j.push(encodeURIComponent(l)+"="+encodeURIComponent(k[l]))}return j.join("&")};b.apply(b.SData.Client.Ajax,{request:function(p){p=e.apply({},p);p.params=e.apply({},p.params);p.headers=e.apply({},p.headers);if(p.cache!==true){p.params[p.cacheParam||"_t"]=(new Date()).getTime()}p.method=p.method||"GET";var k=h(p.params);if(k){p.url=p.url+(/\?/.test(p.url)?"&":"?")+k}var m=new XMLHttpRequest();if(p.user){m.open(p.method,p.url,p.async!==false,p.user,p.password)}else{m.open(p.method,p.url,p.async!==false)}if(p.withCredentials){m.withCredentials=true}try{m.setRequestHeader("Accept",p.accept||"*/*");m.setRequestHeader("X-Requested-With","XMLHttpRequest");if(p.contentType){m.setRequestHeader("Content-Type",p.contentType)}for(var q in p.headers){m.setRequestHeader(q,p.headers[q])}var j=p.etagCache;if(p.cache&&j&&j.etag){m.setRequestHeader("If-None-Match",j.etag)}}catch(l){}if(p.async!==false){if(typeof p.requestTimeout==="number"&&p.requestTimeout>=0&&typeof m.timeout==="number"){m.timeout=p.requestTimeout;d(m,p)}i(m,p);m.send(p.body||null)}else{m.send(p.body||null);c(m,p)}return m},cancel:function(j){j.abort()}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataBaseRequest=b.Class.define({service:null,uri:null,completeHeaders:null,extendedHeaders:null,constructor:function(d){this.base.apply(this,arguments);this.service=d;this.completeHeaders={};this.extendedHeaders={};this.uri=new b.SData.Client.SDataUri();var f,e;if(this.service){this.uri.setVersion(this.service.getVersion());f=this.service.getIncludeContent();if(typeof f!=="undefined"){this.uri.setIncludeContent(f)}this.uri.setServer(this.service.getVirtualDirectory()?this.service.getVirtualDirectory():"sdata");this.uri.setScheme(this.service.getProtocol());this.uri.setHost(this.service.getServerName());this.uri.setPort(this.service.getPort());e=this.service.getCompact();if(typeof e!=="undefined"){this.uri.setCompact(e)}}},clone:function(){return new b.SData.Client.SDataBaseRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},setRequestHeader:function(d,e){this.completeHeaders[d]=e},extendRequestHeader:function(d,e){this.extendedHeaders[d]=e},clearRequestHeader:function(d){delete this.completeHeaders[d];delete this.extendedHeaders[d]},getAccept:function(){return this.extendedHeaders.Accept},setAccept:function(d){this.extendRequestHeader("Accept",d);return this},getService:function(){return this.service},getUri:function(){return this.uri},setUri:function(d){this.uri=d;return this},getServerName:function(){return this.uri.getHost()},setServerName:function(d){this.uri.setHost(d);return this},getVirtualDirectory:function(){return this.uri.getServer()},setVirtualDirectory:function(d){this.uri.setServer(d);return this},getProtocol:function(){return this.uri.getScheme()},setProtocol:function(d){this.uri.setScheme(d);return this},getPort:function(){return this.uri.getPort()},setPort:function(d){this.uri.setPort(d);return this},getQueryArgs:function(){return this.uri.getQueryArgs()},setQueryArgs:function(e,d){this.uri.setQueryArgs(e,d);return this},getQueryArg:function(d){return this.uri.getQueryArg(d)},setQueryArg:function(d,e){this.uri.setQueryArg(d,e);return this},build:function(d){return this.uri.build(d)},toString:function(d){return this.build(d)}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataApplicationRequest=b.SData.Client.SDataBaseRequest.extend({constructor:function(){this.base.apply(this,arguments);if(this.service){this.uri.setProduct(this.service.getApplicationName()?this.service.getApplicationName():"-");this.uri.setContract(this.service.getContractName()?this.service.getContractName():"-");this.uri.setCompanyDataset(this.service.getDataSet()?this.service.getDataSet():"-")}},clone:function(){return new b.SData.Client.SDataApplicationRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},getApplicationName:function(){return this.uri.getProduct()},setApplicationName:function(d){this.uri.setProduct(d);return this},getContractName:function(){return this.uri.getContract()},setContractName:function(d){this.uri.setContract(d);return this},getDataSet:function(){return this.uri.getCompanyDataset()},setDataSet:function(d){this.uri.setCompanyDataset(d);return this},getResourceKind:function(){return this.uri.getCollectionType()},setResourceKind:function(d){this.uri.setCollectionType(d);return this}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataResourceCollectionRequest=b.SData.Client.SDataApplicationRequest.extend({constructor:function(){this.base.apply(this,arguments)},clone:function(){return new b.SData.Client.SDataResourceCollectionRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},getCount:function(){return this.uri.getCount()},setCount:function(d){this.uri.setCount(d);return this},getStartIndex:function(){return this.uri.getStartIndex()},setStartIndex:function(d){this.uri.setStartIndex(d);return this},read:function(d){return this.service.readFeed(this,d)}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataNamedQueryRequest=b.SData.Client.SDataResourceCollectionRequest.extend({constructor:function(){this.base.apply(this,arguments);this.uri.setPathSegment(c.SDataUri.ResourcePropertyIndex,c.SDataUri.NamedQuerySegment)},clone:function(){return new b.SData.Client.SDataNamedQueryRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},getQueryName:function(){return this.uri.getPathSegment(c.SDataUri.ResourcePropertyIndex+1)},setQueryName:function(d){this.uri.setPathSegment(c.SDataUri.ResourcePropertyIndex+1,d);return this}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataSingleResourceRequest=b.SData.Client.SDataApplicationRequest.extend({key:"",constructor:function(){this.base.apply(this,arguments)},clone:function(){return new b.SData.Client.SDataSingleResourceRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},read:function(d){return this.service.readEntry(this,d)},update:function(e,d){return this.service.updateEntry(this,e,d)},create:function(e,d){return this.service.createEntry(this,e,d)},"delete":function(e,d){return this.service.deleteEntry(this,e,d)},getResourceSelector:function(){return this.uri.getCollectionPredicate()},setResourceSelector:function(d){this.uri.setCollectionPredicate(d);return this},setResourceKey:function(d){this.key=d;this.setResourceSelector("'"+this.key+"'");return this},getResourceKey:function(){return this.key}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataResourcePropertyRequest=b.SData.Client.SDataSingleResourceRequest.extend({constructor:function(){this.base.apply(this,arguments)},clone:function(){return new b.SData.Client.SDataResourcePropertyRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},readFeed:function(d){return this.service.readFeed(this,d)},getResourceProperty:function(){return this.uri.getPathSegment(b.SData.Client.SDataUri.ResourcePropertyIndex)},setResourceProperty:function(d){this.uri.setPathSegment(b.SData.Client.SDataUri.ResourcePropertyIndex,d);return this}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataSystemRequest=b.SData.Client.SDataBaseRequest.extend({constructor:function(){this.base.apply(this,arguments);this.uri.setPathSegment(b.SData.Client.SDataUri.ProductPathIndex,b.SData.Client.SDataUri.SystemSegment)},clone:function(){return new b.SData.Client.SDataSystemRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},getCategory:function(){this.uri.getPathSegment(b.SData.Client.SDataUri.ContractTypePathIndex)},setCategory:function(d){this.uri.setPathSegment(b.SData.Client.SDataUri.ContractTypePathIndex,d);return this},read:function(d){return this.service.readFeed(this,d)}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataTemplateResourceRequest=b.SData.Client.SDataApplicationRequest.extend({constructor:function(){this.base.apply(this,arguments);this.uri.setPathSegment(b.SData.Client.SDataUri.ResourcePropertyIndex,b.SData.Client.SDataUri.TemplateSegment)},clone:function(){return new b.SData.Client.SDataTemplateResourceRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},read:function(d){return this.service.readEntry(this,d)}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataServiceOperationRequest=b.SData.Client.SDataApplicationRequest.extend({constructor:function(){this.base.apply(this,arguments);this.uri.setPathSegment(c.SDataUri.ResourcePropertyIndex,c.SDataUri.ServiceMethodSegment)},clone:function(){return new b.SData.Client.SDataServiceOperationRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},execute:function(e,d){return this.service.executeServiceOperation(this,e,d)},getOperationName:function(){return this.uri.getPathSegment(c.SDataUri.ResourcePropertyIndex+1)},setOperationName:function(d){this.uri.setPathSegment(c.SDataUri.ResourcePropertyIndex+1,d);return this}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataBatchRequest=b.SData.Client.SDataApplicationRequest.extend({items:null,constructor:function(){this.base.apply(this,arguments);this.items=[];this.uri.setPathSegment(b.SData.Client.SDataUri.ResourcePropertyIndex,b.SData.Client.SDataUri.BatchSegment)},clone:function(){return new b.SData.Client.SDataBatchRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri)).setItems(this.items.slice(0))},getItems:function(){return this.items},setItems:function(d){this.items=d;return this},using:function(f,d){if(this.service){this.service.registerBatchScope(this)}else{throw"A service must be associated with the batch request."}try{f.call(d||this,this)}catch(g){this.service.clearBatchScope(this);throw g}this.service.clearBatchScope(this);return this},add:function(d){this.items.push(d)},commit:function(d){this.service.commitBatch(this,d)}})})();(function(){var b=window.Sage,a=b,d=b.namespace("Sage.SData.Client"),c=/^true$/i;b.SData.Client.SDataUri=b.Class.define({scheme:"http",host:"",server:"",port:-1,version:null,queryArgs:null,pathSegments:null,constructor:function(e){this.base.apply(this,arguments);a.apply(this,e);this.queryArgs=a.apply({},e&&e.queryArgs);this.pathSegments=(e&&e.pathSegments&&e.pathSegments.slice(0))||[];this.version=(e&&e.version&&a.apply({},e.version))||{major:1,minor:0}},clone:function(){return new b.SData.Client.SDataUri(this)},getVersion:function(){return this.version},setVersion:function(e){this.version=a.apply({major:0,minor:0},e);return this},getScheme:function(){return this.scheme},setScheme:function(e){this.scheme=e;return this},getHost:function(){return this.host},setHost:function(e){this.host=e;return this},getPort:function(){return this.port},setPort:function(e){this.port=e;return this},getServer:function(){return this.server},setServer:function(e){this.server=e;return this},getQueryArgs:function(){return this.queryArgs},setQueryArgs:function(f,e){this.queryArgs=e?f:a.apply(this.queryArgs,f);return this},getQueryArg:function(e){return this.queryArgs[e]},setQueryArg:function(e,f){this.queryArgs[e]=f;return this},getPathSegments:function(){return this.pathSegments},setPathSegments:function(e){this.pathSegments=e;return this},getPathSegment:function(e){return this.pathSegments.length>e?this.pathSegments[e]:false},setPathSegment:function(f,h,e){if(!h&&!e){this.pathSegments[f]=null}else{if(typeof h==="object"){this.pathSegments[f]=a.apply({},h,this.pathSegments[f])}else{var g={};if(h){g.text=h}if(e){g.predicate=e}this.pathSegments[f]=a.apply({},g,this.pathSegments[f])}}return this},getStartIndex:function(){return this.queryArgs[d.SDataUri.QueryArgNames.StartIndex]?parseInt(this.queryArgs[d.SDataUri.QueryArgNames.StartIndex]):-1},setStartIndex:function(e){this.queryArgs[d.SDataUri.QueryArgNames.StartIndex]=e;return this},getCount:function(){return this.queryArgs[d.SDataUri.QueryArgNames.Count]?parseInt(this.queryArgs[d.SDataUri.QueryArgNames.Count]):-1},setCount:function(e){this.queryArgs[d.SDataUri.QueryArgNames.Count]=e;return this},getIncludeContent:function(){var e,f;e=this.version.major>=1?d.SDataUri.QueryArgNames.IncludeContent:d.SDataUri.QueryArgNames.LegacyIncludeContent;f=this.queryArgs[e];if(typeof f!=="undefined"){return c.test(f)}else{return f}},setCompact:function(e){this.queryArgs[d.SDataUri.QueryArgNames.Compact]=e;return this},getCompact:function(){return this.queryArgs[d.SDataUri.QueryArgNames.Compact]},setIncludeContent:function(f){var e=this.version.major>=1?d.SDataUri.QueryArgNames.IncludeContent:d.SDataUri.QueryArgNames.LegacyIncludeContent;this.queryArgs[e]=""+f;return this},appendPath:function(f){var e=typeof f==="string"?{text:f}:f;this.pathSegments.push(e);return this},toString:function(e){return this.build(e)},build:function(f){var e=[];e.push(this.getScheme()||d.SDataUri.Http);e.push(d.SDataUri.SchemeSuffix);e.push(d.SDataUri.PathSegmentPrefix);e.push(d.SDataUri.PathSegmentPrefix);e.push(this.getHost());if(this.getPort()>0){e.push(d.SDataUri.PortPrefix,this.getPort())}e.push(d.SDataUri.PathSegmentPrefix);var k=this.getPathSegments();var o=[];var h=this.getServer();if(h&&h.length>0){o=o.concat(h.split("/"))}for(var j=0;j0){e.push(d.SDataUri.QueryPrefix);e.push(m.join(d.SDataUri.QueryArgPrefix))}return e.join("")},getProduct:function(){return this.getPathSegment(d.SDataUri.ProductPathIndex)},setProduct:function(e){return this.setPathSegment(d.SDataUri.ProductPathIndex,e)},getContract:function(){return this.getPathSegment(d.SDataUri.ContractTypePathIndex)},setContract:function(e){return this.setPathSegment(d.SDataUri.ContractTypePathIndex,e)},getCompanyDataset:function(){return this.getPathSegment(d.SDataUri.CompanyDatasetPathIndex)},setCompanyDataset:function(e){return this.setPathSegment(d.SDataUri.CompanyDatasetPathIndex,e)},getCollectionType:function(){return this.getPathSegment(d.SDataUri.CollectionTypePathIndex)},setCollectionType:function(e){return this.setPathSegment(d.SDataUri.CollectionTypePathIndex,e)},getCollectionPredicate:function(){var e=this.getPathSegment(d.SDataUri.CollectionTypePathIndex);return(e&&e.predicate)||false},setCollectionPredicate:function(e){return this.setPathSegment(d.SDataUri.CollectionTypePathIndex,{predicate:e})}});b.apply(b.SData.Client.SDataUri,{Http:"http",Https:"https",PathSegmentPrefix:"/",PortPrefix:":",QueryArgPrefix:"&",QueryArgValuePrefix:"=",QueryPrefix:"?",SchemeSuffix:":",UnspecifiedPort:-1,UriName:"uri",QueryArgNames:{Compact:"_compact",Count:"count",Exclude:"exclude",Format:"format",Include:"include",IncludeContent:"_includeContent",LegacyIncludeContent:"includeContent",IncludeSchema:"includeSchema",Language:"language",OrderBy:"orderby",Precedence:"precedence",ReturnDelta:"returnDelta",Search:"search",Select:"select",StartIndex:"startIndex",Thumbnail:"thumbnail",TrackingID:"trackingID",Where:"where"},ProductPathIndex:0,ContractTypePathIndex:1,CompanyDatasetPathIndex:2,CollectionTypePathIndex:3,ResourcePropertyIndex:4,ServiceMethodSegment:"$service",TemplateSegment:"$template",SystemSegment:"$system",NamedQuerySegment:"$queries",BatchSegment:"$batch"})})();(function(){var d=window.Sage,c=d,f=d.namespace("Sage.SData.Client"),b=function(g){return typeof g!=="undefined"},a=function(g){return g&&g["#text"]?g["#text"]:g},e=/^(.+?):(.*)$/;d.SData.Client.SDataService=d.Evented.extend({uri:null,useCredentialedRequest:false,useCrossDomainCookies:false,userAgent:"Sage",userName:false,password:"",batchScope:null,timeout:0,cache:false,cacheParam:"_t",_etags:{},maxGetUriLength:2000,constructor:function(h,i,g){this.base.call(this,h);this.setUri(h);if(b(h.includeContent)){this.uri.setIncludeContent(h.includeContent)}if(b(h.version)){this.uri.setVersion(h.version)}if(b(h.cache)){this.cache=h.cache}if(b(h.cacheParam)){this.cacheParam=h.cacheParam}if(b(h.compact)){this.uri.setCompact(h.compact)}if(b(h.userName)){this.userName=h.userName}if(b(h.password)){this.password=h.password}if(b(i)){this.userName=i}if(b(g)){this.password=g}if(b(h.json)){this.json=h.json}if(b(h.maxGetUriLength)){this.maxGetUriLength=h.maxGetUriLength}if(b(h.timeout)){this.timeout=h.timeout}if(b(h.useCredentialedRequest)){this.useCredentialedRequest=h.useCredentialedRequest}if(b(h.useCrossDomainCookies)){this.useCrossDomainCookies=h.useCrossDomainCookies}this.addEvents("beforerequest","requestcomplete","requestexception","requestaborted","requesttimeout")},setUri:function(h){if(b(h.uri)){this.uri=new d.SData.Client.SDataUri(h.uri)}else{this.uri=new d.SData.Client.SDataUri();var g=this.parseUri(h);if(b(g.serverName)){this.uri.setHost(g.serverName)}if(b(g.virtualDirectory)){this.uri.setServer(g.virtualDirectory)}if(b(g.applicationName)){this.uri.setProduct(g.applicationName)}if(b(g.contractName)){this.uri.setContract(g.contractName)}if(b(g.dataSet)){this.uri.setCompanyDataset(g.dataSet)}if(b(g.port)){this.uri.setPort(g.port)}if(b(g.protocol)){this.uri.setScheme(g.protocol)}}return this},parseUri:function(j){var g={},i=typeof j==="object"?j.url:j;var h=(typeof window.parseUri==="function")&&window.parseUri(i);if(h){if(h.host){g.serverName=h.host}var k=h.path.split("/").slice(1);if(k[0]){g.virtualDirectory=k[0]}if(k[1]){g.applicationName=k[1]}if(k[2]){g.contractName=k[2]}if(k[3]){g.dataSet=k[3]}if(h.port){g.port=parseInt(h.port)}if(h.protocol){g.protocol=h.protocol}}if(typeof j==="object"){c.apply(g,j)}return g},isJsonEnabled:function(){return this.json},enableJson:function(){this.json=true;return this},disableJson:function(){this.json=false;return this},getVersion:function(){return this.uri.getVersion()},setVersion:function(g){this.uri.setVersion(g);return this},getUri:function(){return this.uri},getUserName:function(){return this.userName},setUserName:function(g){this.userName=g;return this},getPassword:function(){return this.password},setPassword:function(g){this.password=g;return this},getProtocol:function(){return this.uri.getScheme()},setProtocol:function(g){this.uri.setScheme(g);return this},getServerName:function(){return this.uri.getHost()},setServerName:function(g){this.uri.setHost(g);return this},getPort:function(){return this.uri.getPort()},setPort:function(g){this.uri.setPort(g);return this},getVirtualDirectory:function(){return this.uri.getServer()},setVirtualDirectory:function(g){this.uri.setServer(g);return this},getApplicationName:function(){return this.uri.getProduct()},setApplicationName:function(g){this.uri.setProduct(g);return this},getContractName:function(){return this.uri.getContract()},setContractName:function(g){this.uri.setContract(g);return this},getDataSet:function(){return this.uri.getCompanyDataset()},setDataSet:function(g){this.uri.setCompanyDataset(g);return this},getIncludeContent:function(){return this.uri.getIncludeContent()},setIncludeContent:function(g){this.uri.setIncludeContent(g);return this},getCompact:function(){return this.uri.getCompact()},setCompact:function(g){this.uri.setCompact(g);return this},setMaxGetUriLength:function(g){this.maxGetUriLength=g;return this},getMaxGetUriLength:function(){return this.maxGetUriLength},getUserAgent:function(){return this.userAgent},setUserAgent:function(g){this.userAgent=g;return this},registerBatchScope:function(g){this.batchScope=g},clearBatchScope:function(g){this.batchScope=null},createBasicAuthToken:function(){return"Basic "+Base64.encode(this.userName+":"+this.password)},createHeadersForRequest:function(g){var h={"X-Authorization-Mode":"no-challenge"};if(this.userName&&!this.useCredentialedRequest){h.Authorization=h["X-Authorization"]=this.createBasicAuthToken()}return h},extendAcceptRequestHeader:function(g,h){if(g){return g.split(/\s*,\s*/).join(";"+h+",")+";"+h}return g},executeRequest:function(i,h,j){if(this.json){i.setQueryArg("format","json")}var g=i.build();var k=c.apply({async:h.async,headers:{},method:"GET",url:g,cache:h.cache||this.cache,cacheParam:h.cacheParam||this.cacheParam,etagCache:this._etags[g]},{scope:this,success:function(l,m){var p=l.responseText;if(l.status===304){p=this._etags[g].responseText}var q=l.getResponseHeader&&l.getResponseHeader("Content-Type");var o=this.processFeed(p,q);var n=l.getResponseHeader&&l.getResponseHeader("etag");this._etags[g]={etag:n,responseText:p};this.fireEvent("requestcomplete",i,m,o);if(h.success){h.success.call(h.scope||this,o)}},failure:function(l,m){this.fireEvent("requestexception",i,m,l);if(h.failure){h.failure.call(h.scope||this,l,m)}},aborted:function(l,m){this.fireEvent("requestaborted",i,m,l);if(h.aborted){h.aborted.call(h.scope||this,l,m)}},timeout:function(l,m){this.fireEvent("requesttimeout",i,m,l);if(h.timeout){h.timeout.call(h.scope||this,l,m)}}},j);c.apply(k.headers,this.createHeadersForRequest(i),i.completeHeaders);if(typeof this.timeout==="number"){k.requestTimeout=this.timeout}if(i.extendedHeaders.Accept){k.headers.Accept=this.extendAcceptRequestHeader(k.headers.Accept,i.extendedHeaders.Accept)}if(this.useCredentialedRequest||this.useCrossDomainCookies){k.withCredentials=true}if(this.useCredentialedRequest&&this.userName){k.user=this.userName;k.password=this.password}this.fireEvent("beforerequest",i,k);if(typeof k.result!=="undefined"){if(h.success){h.success.call(h.scope||this,k.result)}return}return f.Ajax.request(k)},abortRequest:function(g){f.Ajax.cancel(g)},readFeed:function(i,g){g=g||{};if(this.batchScope){this.batchScope.add({url:i.build(),method:"GET"});return}var j={headers:{Accept:this.json?"application/json,*/*":"application/atom+xml;type=feed,*/*"}};var h=i.build();if(g.httpMethodOverride||(typeof h==="string"&&h.length>this.maxGetUriLength)){if(this.json){i.setQueryArg("format","json")}j.headers["X-HTTP-Method-Override"]="GET";j.method="POST";j.body=i.build();j.url=i.build(true)}return this.executeRequest(i,g,j)},readEntry:function(j,g){g=g||{};if(this.batchScope){var i={url:j.build(),method:"GET"};var h=j.getResourceKey();if(typeof h==="string"&&h.length>0){i.key=h}this.batchScope.add(i);return}var k=c.apply({},{success:function(m){var l=m["$resources"][0]||false;if(g.success){g.success.call(g.scope||this,l)}}},g);return this.executeRequest(j,k,{headers:{Accept:this.json?"application/json,*/*":"application/atom+xml;type=entry,*/*"}})},createEntry:function(j,i,h){h=h||{};if(this.batchScope){this.batchScope.add({url:j.build(),entry:i,method:"POST"});return}var l=c.apply({},{success:function(n){var m=n["$resources"][0]||false;if(h.success){h.success.call(h.scope||this,m)}}},h);var k=c.apply({},{method:"POST"});if(this.isJsonEnabled()){c.apply(k,{body:JSON.stringify(i),headers:{"Content-Type":"application/json"}})}else{var g=new XML.ObjTree();g.attr_prefix="@";c.apply(k,{body:g.writeXML(this.formatEntry(i)),headers:{"Content-Type":"application/atom+xml;type=entry",Accept:"application/atom+xml;type=entry,*/*"}})}return this.executeRequest(j,l,k)},updateEntry:function(j,i,h){h=h||{};if(this.batchScope){this.batchScope.add({url:j.build(),entry:i,method:"PUT",etag:i["$etag"]});return}var m=c.apply({},{success:function(o){var n=o["$resources"][0]||false;if(h.success){h.success.call(h.scope||this,n)}}},h);var l={},k={method:"PUT",headers:l};if(i["$etag"]&&!(h&&h.ignoreETag)){l["If-Match"]=i["$etag"]}if(this.isJsonEnabled()){l["Content-Type"]="application/json";k.body=JSON.stringify(i)}else{var g=new XML.ObjTree();g.attr_prefix="@";l["Content-Type"]="application/atom+xml;type=entry";l.Accept="application/atom+xml;type=entry,*/*";k.body=g.writeXML(this.formatEntry(i))}return this.executeRequest(j,m,k)},deleteEntry:function(i,h,g){g=g||{};if(this.batchScope){this.batchScope.add({url:i.build(),method:"DELETE",etag:!(g&&g.ignoreETag)&&h["$etag"]});return}var k={},j={method:"DELETE",headers:k};if(h["$etag"]&&!(g&&g.ignoreETag)){k["If-Match"]=h["$etag"]}return this.executeRequest(i,g,j)},executeServiceOperation:function(j,i,h){var l=c.apply({},{success:function(o){var n=o["$resources"][0]||false,m=n&&n.response,q=m&&m["$resources"],p=q&&q[0];if(p&&p["$name"]){n.response={};n.response[p["$name"]]=p}if(h.success){h.success.call(h.scope||this,n)}}},h);var k=c.apply({},{method:"POST"});if(this.isJsonEnabled()){c.apply(k,{body:JSON.stringify(i),headers:{"Content-Type":"application/json"}})}else{var g=new XML.ObjTree();g.attr_prefix="@";c.apply(k,{body:g.writeXML(this.formatEntry(i)),headers:{"Content-Type":"application/atom+xml;type=entry",Accept:"application/atom+xml;type=entry,*/*"}})}return this.executeRequest(j,l,k)},commitBatch:function(g,p){p=p||{};var k=g.getItems(),o,m,n={"$resources":[]};for(var h=0;h=200&&j<300)||j===304)};var c=function(n,m){if(n.readyState==4){if(f(n.status)){if(m.success){m.success.call(m.scope||this,n,m)}}else{if(n.status===0){var l=false;try{l=(n.statusText==="")}catch(j){l=true}if(l){var k=m.aborted||m.failure;if(k){k.call(m.scope||this,n,m)}}else{if(m.failure){m.failure.call(m.scope||this,n,m)}}}else{if(m.failure){m.failure.call(m.scope||this,n,m)}}}}};var g=function(l,k){var j=k.timeout||k.failure;if(j){j.call(k.scope||this,l,k)}};var d=function(k,j){k.ontimeout=function(){g.call(k,k,j)}};var i=function(k,j){k.onreadystatechange=function(){c.call(k,k,j)}};var h=function(k){var j=[];for(var l in k){j.push(encodeURIComponent(l)+"="+encodeURIComponent(k[l]))}return j.join("&")};b.apply(b.SData.Client.Ajax,{request:function(p){p=e.apply({},p);p.params=e.apply({},p.params);p.headers=e.apply({},p.headers);if(p.cache!==true){p.params[p.cacheParam||"_t"]=(new Date()).getTime()}p.method=p.method||"GET";var k=h(p.params);if(k){p.url=p.url+(/\?/.test(p.url)?"&":"?")+k}var m=new XMLHttpRequest();if(p.user){m.open(p.method,p.url,p.async!==false,p.user,p.password)}else{m.open(p.method,p.url,p.async!==false)}if(p.withCredentials){m.withCredentials=true}try{m.setRequestHeader("Accept",p.accept||"*/*");m.setRequestHeader("X-Requested-With","XMLHttpRequest");if(p.contentType){m.setRequestHeader("Content-Type",p.contentType)}for(var q in p.headers){m.setRequestHeader(q,p.headers[q])}var j=p.etagCache;if(p.cache&&j&&j.etag){m.setRequestHeader("If-None-Match",j.etag)}}catch(l){}if(p.async!==false){if(typeof p.requestTimeout==="number"&&p.requestTimeout>=0&&typeof m.timeout==="number"){m.timeout=p.requestTimeout;d(m,p)}i(m,p);m.send(p.body||null)}else{m.send(p.body||null);c(m,p)}return m},cancel:function(j){j.abort()}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataBaseRequest=b.Class.define({service:null,uri:null,completeHeaders:null,extendedHeaders:null,constructor:function(d){this.base.apply(this,arguments);this.service=d;this.completeHeaders={};this.extendedHeaders={};this.uri=new b.SData.Client.SDataUri();var f,e;if(this.service){this.uri.setVersion(this.service.getVersion());f=this.service.getIncludeContent();if(typeof f!=="undefined"){this.uri.setIncludeContent(f)}this.uri.setServer(this.service.getVirtualDirectory()?this.service.getVirtualDirectory():"sdata");this.uri.setScheme(this.service.getProtocol());this.uri.setHost(this.service.getServerName());this.uri.setPort(this.service.getPort());e=this.service.getCompact();if(typeof e!=="undefined"){this.uri.setCompact(e)}}},clone:function(){return new b.SData.Client.SDataBaseRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},setRequestHeader:function(d,e){this.completeHeaders[d]=e},extendRequestHeader:function(d,e){this.extendedHeaders[d]=e},clearRequestHeader:function(d){delete this.completeHeaders[d];delete this.extendedHeaders[d]},getAccept:function(){return this.extendedHeaders.Accept},setAccept:function(d){this.extendRequestHeader("Accept",d);return this},getService:function(){return this.service},getUri:function(){return this.uri},setUri:function(d){this.uri=d;return this},getServerName:function(){return this.uri.getHost()},setServerName:function(d){this.uri.setHost(d);return this},getVirtualDirectory:function(){return this.uri.getServer()},setVirtualDirectory:function(d){this.uri.setServer(d);return this},getProtocol:function(){return this.uri.getScheme()},setProtocol:function(d){this.uri.setScheme(d);return this},getPort:function(){return this.uri.getPort()},setPort:function(d){this.uri.setPort(d);return this},getQueryArgs:function(){return this.uri.getQueryArgs()},setQueryArgs:function(e,d){this.uri.setQueryArgs(e,d);return this},getQueryArg:function(d){return this.uri.getQueryArg(d)},setQueryArg:function(d,e){this.uri.setQueryArg(d,e);return this},build:function(d){return this.uri.build(d)},toString:function(d){return this.build(d)}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataApplicationRequest=b.SData.Client.SDataBaseRequest.extend({constructor:function(){this.base.apply(this,arguments);if(this.service){this.uri.setProduct(this.service.getApplicationName()?this.service.getApplicationName():"-");this.uri.setContract(this.service.getContractName()?this.service.getContractName():"-");this.uri.setCompanyDataset(this.service.getDataSet()?this.service.getDataSet():"-")}},clone:function(){return new b.SData.Client.SDataApplicationRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},getApplicationName:function(){return this.uri.getProduct()},setApplicationName:function(d){this.uri.setProduct(d);return this},getContractName:function(){return this.uri.getContract()},setContractName:function(d){this.uri.setContract(d);return this},getDataSet:function(){return this.uri.getCompanyDataset()},setDataSet:function(d){this.uri.setCompanyDataset(d);return this},getResourceKind:function(){return this.uri.getCollectionType()},setResourceKind:function(d){this.uri.setCollectionType(d);return this}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataResourceCollectionRequest=b.SData.Client.SDataApplicationRequest.extend({constructor:function(){this.base.apply(this,arguments)},clone:function(){return new b.SData.Client.SDataResourceCollectionRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},getCount:function(){return this.uri.getCount()},setCount:function(d){this.uri.setCount(d);return this},getStartIndex:function(){return this.uri.getStartIndex()},setStartIndex:function(d){this.uri.setStartIndex(d);return this},read:function(d){return this.service.readFeed(this,d)}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataNamedQueryRequest=b.SData.Client.SDataResourceCollectionRequest.extend({constructor:function(){this.base.apply(this,arguments);this.uri.setPathSegment(c.SDataUri.ResourcePropertyIndex,c.SDataUri.NamedQuerySegment)},clone:function(){return new b.SData.Client.SDataNamedQueryRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},getQueryName:function(){return this.uri.getPathSegment(c.SDataUri.ResourcePropertyIndex+1)},setQueryName:function(d){this.uri.setPathSegment(c.SDataUri.ResourcePropertyIndex+1,d);return this}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataSingleResourceRequest=b.SData.Client.SDataApplicationRequest.extend({key:"",constructor:function(){this.base.apply(this,arguments)},clone:function(){return new b.SData.Client.SDataSingleResourceRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},read:function(d){return this.service.readEntry(this,d)},update:function(e,d){return this.service.updateEntry(this,e,d)},create:function(e,d){return this.service.createEntry(this,e,d)},"delete":function(e,d){return this.service.deleteEntry(this,e,d)},getResourceSelector:function(){return this.uri.getCollectionPredicate()},setResourceSelector:function(d){this.uri.setCollectionPredicate(d);return this},setResourceKey:function(d){this.key=d;this.setResourceSelector("'"+this.key+"'");return this},getResourceKey:function(){return this.key}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataResourcePropertyRequest=b.SData.Client.SDataSingleResourceRequest.extend({constructor:function(){this.base.apply(this,arguments)},clone:function(){return new b.SData.Client.SDataResourcePropertyRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},readFeed:function(d){return this.service.readFeed(this,d)},getResourceProperty:function(){return this.uri.getPathSegment(b.SData.Client.SDataUri.ResourcePropertyIndex)},setResourceProperty:function(d){this.uri.setPathSegment(b.SData.Client.SDataUri.ResourcePropertyIndex,d);return this}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataSystemRequest=b.SData.Client.SDataBaseRequest.extend({constructor:function(){this.base.apply(this,arguments);this.uri.setPathSegment(b.SData.Client.SDataUri.ProductPathIndex,b.SData.Client.SDataUri.SystemSegment)},clone:function(){return new b.SData.Client.SDataSystemRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},getCategory:function(){this.uri.getPathSegment(b.SData.Client.SDataUri.ContractTypePathIndex)},setCategory:function(d){this.uri.setPathSegment(b.SData.Client.SDataUri.ContractTypePathIndex,d);return this},read:function(d){return this.service.readFeed(this,d)}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataTemplateResourceRequest=b.SData.Client.SDataApplicationRequest.extend({constructor:function(){this.base.apply(this,arguments);this.uri.setPathSegment(b.SData.Client.SDataUri.ResourcePropertyIndex,b.SData.Client.SDataUri.TemplateSegment)},clone:function(){return new b.SData.Client.SDataTemplateResourceRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},read:function(d){return this.service.readEntry(this,d)}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataServiceOperationRequest=b.SData.Client.SDataApplicationRequest.extend({constructor:function(){this.base.apply(this,arguments);this.uri.setPathSegment(c.SDataUri.ResourcePropertyIndex,c.SDataUri.ServiceMethodSegment)},clone:function(){return new b.SData.Client.SDataServiceOperationRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri))},execute:function(e,d){return this.service.executeServiceOperation(this,e,d)},getOperationName:function(){return this.uri.getPathSegment(c.SDataUri.ResourcePropertyIndex+1)},setOperationName:function(d){this.uri.setPathSegment(c.SDataUri.ResourcePropertyIndex+1,d);return this}})})();(function(){var b=window.Sage,a=b,c=b.namespace("Sage.SData.Client");b.SData.Client.SDataBatchRequest=b.SData.Client.SDataApplicationRequest.extend({items:null,constructor:function(){this.base.apply(this,arguments);this.items=[];this.uri.setPathSegment(b.SData.Client.SDataUri.ResourcePropertyIndex,b.SData.Client.SDataUri.BatchSegment)},clone:function(){return new b.SData.Client.SDataBatchRequest(this.service).setUri(new b.SData.Client.SDataUri(this.uri)).setItems(this.items.slice(0))},getItems:function(){return this.items},setItems:function(d){this.items=d;return this},using:function(f,d){if(this.service){this.service.registerBatchScope(this)}else{throw"A service must be associated with the batch request."}try{f.call(d||this,this)}catch(g){this.service.clearBatchScope(this);throw g}this.service.clearBatchScope(this);return this},add:function(d){this.items.push(d)},commit:function(d){this.service.commitBatch(this,d)}})})();(function(){var b=window.Sage,a=b,d=b.namespace("Sage.SData.Client"),c=/^true$/i;b.SData.Client.SDataUri=b.Class.define({scheme:"http",host:"",server:"",port:-1,version:null,queryArgs:null,pathSegments:null,constructor:function(e){this.base.apply(this,arguments);a.apply(this,e);this.queryArgs=a.apply({},e&&e.queryArgs);this.pathSegments=(e&&e.pathSegments&&e.pathSegments.slice(0))||[];this.version=(e&&e.version&&a.apply({},e.version))||{major:1,minor:0}},clone:function(){return new b.SData.Client.SDataUri(this)},getVersion:function(){return this.version},setVersion:function(e){this.version=a.apply({major:0,minor:0},e);return this},getScheme:function(){return this.scheme},setScheme:function(e){this.scheme=e;return this},getHost:function(){return this.host},setHost:function(e){this.host=e;return this},getPort:function(){return this.port},setPort:function(e){this.port=e;return this},getServer:function(){return this.server},setServer:function(e){this.server=e;return this},getQueryArgs:function(){return this.queryArgs},setQueryArgs:function(f,e){this.queryArgs=e?f:a.apply(this.queryArgs,f);return this},getQueryArg:function(e){return this.queryArgs[e]},setQueryArg:function(e,f){this.queryArgs[e]=f;return this},getPathSegments:function(){return this.pathSegments},setPathSegments:function(e){this.pathSegments=e;return this},getPathSegment:function(e){return this.pathSegments.length>e?this.pathSegments[e]:false},setPathSegment:function(f,h,e){if(!h&&!e){this.pathSegments[f]=null}else{if(typeof h==="object"){this.pathSegments[f]=a.apply({},h,this.pathSegments[f])}else{var g={};if(h){g.text=h}if(e){g.predicate=e}this.pathSegments[f]=a.apply({},g,this.pathSegments[f])}}return this},getStartIndex:function(){return this.queryArgs[d.SDataUri.QueryArgNames.StartIndex]?parseInt(this.queryArgs[d.SDataUri.QueryArgNames.StartIndex]):-1},setStartIndex:function(e){this.queryArgs[d.SDataUri.QueryArgNames.StartIndex]=e;return this},getCount:function(){return this.queryArgs[d.SDataUri.QueryArgNames.Count]?parseInt(this.queryArgs[d.SDataUri.QueryArgNames.Count]):-1},setCount:function(e){this.queryArgs[d.SDataUri.QueryArgNames.Count]=e;return this},getIncludeContent:function(){var e,f;e=this.version.major>=1?d.SDataUri.QueryArgNames.IncludeContent:d.SDataUri.QueryArgNames.LegacyIncludeContent;f=this.queryArgs[e];if(typeof f!=="undefined"){return c.test(f)}else{return f}},setCompact:function(e){this.queryArgs[d.SDataUri.QueryArgNames.Compact]=e;return this},getCompact:function(){return this.queryArgs[d.SDataUri.QueryArgNames.Compact]},setIncludeContent:function(f){var e=this.version.major>=1?d.SDataUri.QueryArgNames.IncludeContent:d.SDataUri.QueryArgNames.LegacyIncludeContent;this.queryArgs[e]=""+f;return this},appendPath:function(f){var e=typeof f==="string"?{text:f}:f;this.pathSegments.push(e);return this},toString:function(e){return this.build(e)},build:function(f){var e=[];e.push(this.getScheme()||d.SDataUri.Http);e.push(d.SDataUri.SchemeSuffix);e.push(d.SDataUri.PathSegmentPrefix);e.push(d.SDataUri.PathSegmentPrefix);e.push(this.getHost());if(this.getPort()>0){e.push(d.SDataUri.PortPrefix,this.getPort())}e.push(d.SDataUri.PathSegmentPrefix);var k=this.getPathSegments();var o=[];var h=this.getServer();if(h&&h.length>0){o=o.concat(h.split("/"))}for(var j=0;j0){e.push(d.SDataUri.QueryPrefix);e.push(m.join(d.SDataUri.QueryArgPrefix))}return e.join("")},getProduct:function(){return this.getPathSegment(d.SDataUri.ProductPathIndex)},setProduct:function(e){return this.setPathSegment(d.SDataUri.ProductPathIndex,e)},getContract:function(){return this.getPathSegment(d.SDataUri.ContractTypePathIndex)},setContract:function(e){return this.setPathSegment(d.SDataUri.ContractTypePathIndex,e)},getCompanyDataset:function(){return this.getPathSegment(d.SDataUri.CompanyDatasetPathIndex)},setCompanyDataset:function(e){return this.setPathSegment(d.SDataUri.CompanyDatasetPathIndex,e)},getCollectionType:function(){return this.getPathSegment(d.SDataUri.CollectionTypePathIndex)},setCollectionType:function(e){return this.setPathSegment(d.SDataUri.CollectionTypePathIndex,e)},getCollectionPredicate:function(){var e=this.getPathSegment(d.SDataUri.CollectionTypePathIndex);return(e&&e.predicate)||false},setCollectionPredicate:function(e){return this.setPathSegment(d.SDataUri.CollectionTypePathIndex,{predicate:e})}});b.apply(b.SData.Client.SDataUri,{Http:"http",Https:"https",PathSegmentPrefix:"/",PortPrefix:":",QueryArgPrefix:"&",QueryArgValuePrefix:"=",QueryPrefix:"?",SchemeSuffix:":",UnspecifiedPort:-1,UriName:"uri",QueryArgNames:{Compact:"_compact",Count:"count",Exclude:"exclude",Format:"format",Include:"include",IncludeContent:"_includeContent",LegacyIncludeContent:"includeContent",IncludeSchema:"includeSchema",Language:"language",OrderBy:"orderby",Precedence:"precedence",ReturnDelta:"returnDelta",Search:"search",Select:"select",StartIndex:"startIndex",Thumbnail:"thumbnail",TrackingID:"trackingID",Where:"where"},ProductPathIndex:0,ContractTypePathIndex:1,CompanyDatasetPathIndex:2,CollectionTypePathIndex:3,ResourcePropertyIndex:4,ServiceMethodSegment:"$service",TemplateSegment:"$template",SystemSegment:"$system",NamedQuerySegment:"$queries",BatchSegment:"$batch"})})();(function(){var d=window.Sage,c=d,f=d.namespace("Sage.SData.Client"),b=function(g){return typeof g!=="undefined"},a=function(g){return g&&g["#text"]?g["#text"]:g},e=/^(.+?):(.*)$/;d.SData.Client.SDataService=d.Evented.extend({uri:null,useCredentialedRequest:false,useCrossDomainCookies:false,userAgent:"Sage",userName:false,password:"",batchScope:null,timeout:0,cache:false,cacheParam:"_t",_etags:{},maxGetUriLength:2000,constructor:function(h,i,g){this.base.call(this,h);this.setUri(h);if(b(h.includeContent)){this.uri.setIncludeContent(h.includeContent)}if(b(h.version)){this.uri.setVersion(h.version)}if(b(h.cache)){this.cache=h.cache}if(b(h.cacheParam)){this.cacheParam=h.cacheParam}if(b(h.compact)){this.uri.setCompact(h.compact)}if(b(h.userName)){this.userName=h.userName}if(b(h.password)){this.password=h.password}if(b(i)){this.userName=i}if(b(g)){this.password=g}if(b(h.json)){this.json=h.json}if(b(h.maxGetUriLength)){this.maxGetUriLength=h.maxGetUriLength}if(b(h.timeout)){this.timeout=h.timeout}if(b(h.useCredentialedRequest)){this.useCredentialedRequest=h.useCredentialedRequest}if(b(h.useCrossDomainCookies)){this.useCrossDomainCookies=h.useCrossDomainCookies}this.addEvents("beforerequest","requestcomplete","requestexception","requestaborted","requesttimeout")},setUri:function(h){if(b(h.uri)){this.uri=new d.SData.Client.SDataUri(h.uri)}else{this.uri=new d.SData.Client.SDataUri();var g=this.parseUri(h);if(b(g.serverName)){this.uri.setHost(g.serverName)}if(b(g.virtualDirectory)){this.uri.setServer(g.virtualDirectory)}if(b(g.applicationName)){this.uri.setProduct(g.applicationName)}if(b(g.contractName)){this.uri.setContract(g.contractName)}if(b(g.dataSet)){this.uri.setCompanyDataset(g.dataSet)}if(b(g.port)){this.uri.setPort(g.port)}if(b(g.protocol)){this.uri.setScheme(g.protocol)}}return this},parseUri:function(j){var g={},i=typeof j==="object"?j.url:j;var h=(typeof window.parseUri==="function")&&window.parseUri(i);if(h){if(h.host){g.serverName=h.host}var k=h.path.split("/").slice(1);if(k[0]){g.virtualDirectory=k[0]}if(k[1]){g.applicationName=k[1]}if(k[2]){g.contractName=k[2]}if(k[3]){g.dataSet=k[3]}if(h.port){g.port=parseInt(h.port)}if(h.protocol){g.protocol=h.protocol}}if(typeof j==="object"){c.apply(g,j)}return g},isJsonEnabled:function(){return this.json},enableJson:function(){this.json=true;return this},disableJson:function(){this.json=false;return this},getVersion:function(){return this.uri.getVersion()},setVersion:function(g){this.uri.setVersion(g);return this},getUri:function(){return this.uri},getUserName:function(){return this.userName},setUserName:function(g){this.userName=g;return this},getPassword:function(){return this.password},setPassword:function(g){this.password=g;return this},getProtocol:function(){return this.uri.getScheme()},setProtocol:function(g){this.uri.setScheme(g);return this},getServerName:function(){return this.uri.getHost()},setServerName:function(g){this.uri.setHost(g);return this},getPort:function(){return this.uri.getPort()},setPort:function(g){this.uri.setPort(g);return this},getVirtualDirectory:function(){return this.uri.getServer()},setVirtualDirectory:function(g){this.uri.setServer(g);return this},getApplicationName:function(){return this.uri.getProduct()},setApplicationName:function(g){this.uri.setProduct(g);return this},getContractName:function(){return this.uri.getContract()},setContractName:function(g){this.uri.setContract(g);return this},getDataSet:function(){return this.uri.getCompanyDataset()},setDataSet:function(g){this.uri.setCompanyDataset(g);return this},getIncludeContent:function(){return this.uri.getIncludeContent()},setIncludeContent:function(g){this.uri.setIncludeContent(g);return this},getCompact:function(){return this.uri.getCompact()},setCompact:function(g){this.uri.setCompact(g);return this},setMaxGetUriLength:function(g){this.maxGetUriLength=g;return this},getMaxGetUriLength:function(){return this.maxGetUriLength},getUserAgent:function(){return this.userAgent},setUserAgent:function(g){this.userAgent=g;return this},registerBatchScope:function(g){this.batchScope=g},clearBatchScope:function(g){this.batchScope=null},createBasicAuthToken:function(){return"Basic "+Base64.encode(this.userName+":"+this.password)},createHeadersForRequest:function(g){var h={"X-Authorization-Mode":"no-challenge"};if(this.userName&&!this.useCredentialedRequest){h.Authorization=h["X-Authorization"]=this.createBasicAuthToken()}return h},extendAcceptRequestHeader:function(g,h){if(g){return g.split(/\s*,\s*/).join(";"+h+",")+";"+h}return g},executeRequest:function(i,h,j){if(this.json){i.setQueryArg("format","json")}var g=i.build();var k=c.apply({async:h.async,headers:{},method:"GET",url:g,cache:h.cache||this.cache,cacheParam:h.cacheParam||this.cacheParam,etagCache:this._etags[g]},{scope:this,success:function(l,m){var p=l.responseText;if(l.status===304){p=this._etags[g].responseText}var q=l.getResponseHeader&&l.getResponseHeader("Content-Type");var o=this.processFeed(p,q);var n=l.getResponseHeader&&l.getResponseHeader("etag");this._etags[g]={etag:n,responseText:p};this.fireEvent("requestcomplete",i,m,o);if(h.success){h.success.call(h.scope||this,o)}},failure:function(l,m){this.fireEvent("requestexception",i,m,l);if(h.failure){h.failure.call(h.scope||this,l,m)}},aborted:function(l,m){this.fireEvent("requestaborted",i,m,l);if(h.aborted){h.aborted.call(h.scope||this,l,m)}},timeout:function(l,m){this.fireEvent("requesttimeout",i,m,l);if(h.timeout){h.timeout.call(h.scope||this,l,m)}}},j);c.apply(k.headers,this.createHeadersForRequest(i),i.completeHeaders);if(typeof this.timeout==="number"){k.requestTimeout=this.timeout}if(i.extendedHeaders.Accept){k.headers.Accept=this.extendAcceptRequestHeader(k.headers.Accept,i.extendedHeaders.Accept)}if(this.useCredentialedRequest||this.useCrossDomainCookies){k.withCredentials=true}if(this.useCredentialedRequest&&this.userName){k.user=this.userName;k.password=this.password}this.fireEvent("beforerequest",i,k);if(typeof k.result!=="undefined"){if(h.success){h.success.call(h.scope||this,k.result)}return}return f.Ajax.request(k)},abortRequest:function(g){f.Ajax.cancel(g)},readFeed:function(i,g){g=g||{};if(this.batchScope){this.batchScope.add({url:i.build(),method:"GET"});return}var j={headers:{Accept:this.json?"application/json,*/*":"application/atom+xml;type=feed,*/*"}};var h=i.build();if(g.httpMethodOverride||(typeof h==="string"&&h.length>this.maxGetUriLength)){if(this.json){i.setQueryArg("format","json")}j.headers["X-HTTP-Method-Override"]="GET";j.method="POST";j.body=i.build();j.url=i.build(true)}return this.executeRequest(i,g,j)},readEntry:function(j,g){g=g||{};if(this.batchScope){var i={url:j.build(),method:"GET"};var h=j.getResourceKey();if(typeof h==="string"&&h.length>0){i.key=h}this.batchScope.add(i);return}var k=c.apply({},{success:function(m){var l=m["$resources"][0]||false;if(g.success){g.success.call(g.scope||this,l)}}},g);return this.executeRequest(j,k,{headers:{Accept:this.json?"application/json,*/*":"application/atom+xml;type=entry,*/*"}})},createEntry:function(j,i,h){h=h||{};if(this.batchScope){this.batchScope.add({url:j.build(),entry:i,method:"POST"});return}var l=c.apply({},{success:function(n){var m=n["$resources"][0]||false;if(h.success){h.success.call(h.scope||this,m)}}},h);var k=c.apply({},{method:"POST"});if(this.isJsonEnabled()){c.apply(k,{body:JSON.stringify(i),headers:{"Content-Type":"application/json"}})}else{var g=new XML.ObjTree();g.attr_prefix="@";c.apply(k,{body:g.writeXML(this.formatEntry(i)),headers:{"Content-Type":"application/atom+xml;type=entry",Accept:"application/atom+xml;type=entry,*/*"}})}return this.executeRequest(j,l,k)},updateEntry:function(j,i,h){h=h||{};if(this.batchScope){this.batchScope.add({url:j.build(),entry:i,method:"PUT",etag:i["$etag"]});return}var m=c.apply({},{success:function(o){var n=o["$resources"][0]||false;if(h.success){h.success.call(h.scope||this,n)}}},h);var l={},k={method:"PUT",headers:l};if(i["$etag"]&&!(h&&h.ignoreETag)){l["If-Match"]=i["$etag"]}if(this.isJsonEnabled()){l["Content-Type"]="application/json";k.body=JSON.stringify(i)}else{var g=new XML.ObjTree();g.attr_prefix="@";l["Content-Type"]="application/atom+xml;type=entry";l.Accept="application/atom+xml;type=entry,*/*";k.body=g.writeXML(this.formatEntry(i))}return this.executeRequest(j,m,k)},deleteEntry:function(i,h,g){g=g||{};if(this.batchScope){this.batchScope.add({url:i.build(),method:"DELETE",etag:!(g&&g.ignoreETag)&&h["$etag"]});return}var k={},j={method:"DELETE",headers:k};if(h["$etag"]&&!(g&&g.ignoreETag)){k["If-Match"]=h["$etag"]}return this.executeRequest(i,g,j)},executeServiceOperation:function(j,i,h){var l=c.apply({},{success:function(o){if(typeof o==="undefined"||o===null){o={}}var n=o.$resources&&o.$resources[0]||false,m=n&&n.response,q=m&&m["$resources"],p=q&&q[0];if(p&&p["$name"]){n.response={};n.response[p["$name"]]=p}if(h.success){h.success.call(h.scope||this,n)}}},h);var k=c.apply({},{method:"POST"});if(this.isJsonEnabled()){c.apply(k,{body:JSON.stringify(i),headers:{"Content-Type":"application/json"}})}else{var g=new XML.ObjTree();g.attr_prefix="@";c.apply(k,{body:g.writeXML(this.formatEntry(i)),headers:{"Content-Type":"application/atom+xml;type=entry",Accept:"application/atom+xml;type=entry,*/*"}})}return this.executeRequest(j,l,k)},commitBatch:function(g,p){p=p||{};var k=g.getItems(),o,m,n={"$resources":[]};for(var h=0;h