//>>built
define("dojox/atom/io/Connection",["dojo/_base/declare","dojo/_base/kernel","dojo/_base/xhr","./model"],function(v,t,r,q){return v("dojox.atom.io.Connection",null,{constructor:function(a,b){this.sync=a;this.preventCache=b},preventCache:!1,alertsEnabled:!1,getFeed:function(a,b,f,m){this._getXmlDoc(a,"feed",new q.Feed,q._Constants.ATOM_NS,b,f,m)},getService:function(a,b,f,m){this._getXmlDoc(a,"service",new q.Service(a),q._Constants.APP_NS,b,f,m)},getEntry:function(a,b,f,m){this._getXmlDoc(a,"entry",
new q.Entry,q._Constants.ATOM_NS,b,f,m)},_getXmlDoc:function(a,b,f,m,c,g,h){h||(h=t.global);var p=this.alertsEnabled;a={url:a,handleAs:"xml",sync:this.sync,preventCache:this.preventCache,load:function(d,e){var k=null,l;if(d){if("undefined"!=typeof d.getElementsByTagNameNS)(l=d.getElementsByTagNameNS(m,b))&&0<l.length?k=l.item(0):d.lastChild&&(k=d.lastChild);else if("undefined"!=typeof d.getElementsByTagName)if((l=d.getElementsByTagName(b))&&0<l.length)for(var n=0;n<l.length;n++){if(l[n].namespaceURI==
m){k=l[n];break}}else d.lastChild&&(k=d.lastChild);else if(d.lastChild)k=d.lastChild;else{c.call(h,null,null,e);return}f.buildFromDom(k);if(c)c.call(h,f,d,e);else if(p)throw Error("The callback value does not exist.");}else c.call(h,null,null,e)}};this.user&&null!==this.user&&(a.user=this.user);this.password&&null!==this.password&&(a.password=this.password);a.error=g?function(d,e){g.call(h,d,e)}:function(){throw Error("The URL requested cannot be accessed");};r.get(a)},updateEntry:function(a,b,f,
m,c,g){g||(g=t.global);a.updated=new Date;var h=a.getEditHref();if(!h)throw Error("A URL has not been specified for editing this entry.");var p=this,d=this.alertsEnabled,e={url:h,handleAs:"text",contentType:"text/xml",sync:this.sync,preventCache:this.preventCache,load:function(k,l){var n=null;if(m)(n=l.xhr.getResponseHeader("Location"))||(n=h),p.getEntry(n,function(u,x,w){if(b)b.call(g,u,n,w);else if(d)throw Error("The callback value does not exist.");});else if(b)b.call(g,a,l.xhr.getResponseHeader("Location"),
l);else if(d)throw Error("The callback value does not exist.");return k}};this.user&&null!==this.user&&(e.user=this.user);this.password&&null!==this.password&&(e.password=this.password);e.error=f?function(k,l){f.call(g,k,l)}:function(){throw Error("The URL requested cannot be accessed");};c?(e.postData=a.toString(!0),e.headers={"X-Method-Override":"PUT"},r.post(e)):(e.putData=a.toString(!0),r.put(e))},addEntry:function(a,b,f,m,c,g){g||(g=t.global);a.published=new Date;a.updated=new Date;c=a.feedUrl;
var h=this.alertsEnabled;!b&&c&&(b=c);if(b){var p=this;c={url:b,handleAs:"text",contentType:"text/xml",sync:this.sync,preventCache:this.preventCache,postData:a.toString(!0),load:function(d,e){var k=e.xhr.getResponseHeader("Location");k||(k=b);if(e.retrieveEntry)p.getEntry(k,function(l,n,u){if(f)f.call(g,l,k,u);else if(h)throw Error("The callback value does not exist.");});else if(f)f.call(g,a,k,e);else if(h)throw Error("The callback value does not exist.");return d}};this.user&&null!==this.user&&
(c.user=this.user);this.password&&null!==this.password&&(c.password=this.password);c.error=m?function(d,e){m.call(g,d,e)}:function(){throw Error("The URL requested cannot be accessed");};r.post(c)}else if(h)throw Error("The request cannot be processed because the URL parameter is missing.");},deleteEntry:function(a,b,f,m,c){c||(c=t.global);var g=null;g="string"==typeof a?a:a.getEditHref();if(!g)throw b.call(c,!1,null),Error("The request cannot be processed because the URL parameter is missing.");
a={url:g,handleAs:"text",sync:this.sync,preventCache:this.preventCache,load:function(h,p){b.call(c,p);return h}};this.user&&null!==this.user&&(a.user=this.user);this.password&&null!==this.password&&(a.password=this.password);a.error=f?function(h,p){f.call(c,h,p)}:function(){throw Error("The URL requested cannot be accessed");};m?(a.headers={"X-Method-Override":"DELETE"},dhxr.post(a)):r.del(a)}})});