a:21:{s:9:"#provides";s:18:"dojox.rpc.JsonRest";s:9:"#resource";s:15:"rpc/JsonRest.js";s:9:"#requires";a:2:{i:0;a:2:{i:0;s:6:"common";i:1;s:14:"dojox.json.ref";}i:1;a:2:{i:0;s:6:"common";i:1;s:14:"dojox.rpc.Rest";}}s:37:"dojox.rpc.JsonRest.conflictDateHeader";a:1:{s:7:"summary";s:0:"";}s:25:"dojox.rpc.JsonRest.commit";a:4:{s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:6:"kwArgs";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:1793:" kwArgs = kwArgs || {}; var actions = []; var alreadyRecorded = {}; var savingObjects = []; for(var i = 0; i < dirtyObjects.length; i++){ var dirty = dirtyObjects[i]; var object = dirty.object; var old = dirty.old; var append = false; if(!(kwArgs.service && (object || old) && (object || old).__id.indexOf(kwArgs.service.servicePath)) && dirty.save){ delete object.__isDirty; if(object){ if(old){ // changed object var pathParts; if((pathParts = object.__id.match(/(.*)#.*/))){ // it is a path reference // this means it is a sub object, we must go to the parent object and save it object = Rest._index[pathParts[1]]; } if(!(object.__id in alreadyRecorded)){// if it has already been saved, we don't want to repeat it // record that we are saving alreadyRecorded[object.__id] = object; actions.push({method:"put",target:object,content:object}); } }else{ // new object actions.push({method:"post",target:{__id:jr.getServiceAndId(object.__id).service.servicePath}, content:object}); } }else if(old){ // deleted object actions.push({method:"delete",target:old}); }//else{ this would happen if an object is created and then deleted, don't do anything savingObjects.push(dirty); dirtyObjects.splice(i--,1); } } dojo.connect(kwArgs,"onError",function(){ var postCommitDirtyObjects = dirtyObjects; dirtyObjects = savingObjects; var numDirty = 0; // make sure this does't do anything if it is called again jr.revert(); // revert if there was an error dirtyObjects = postCommitDirtyObjects; }); jr.sendToServer(actions, kwArgs); return actions;";s:7:"summary";s:44:"Saves the dirty data using REST Ajax methods";}s:31:"dojox.rpc.JsonRest.sendToServer";a:5:{s:4:"type";s:8:"Function";s:10:"parameters";a:2:{s:7:"actions";a:1:{s:4:"type";s:0:"";}s:6:"kwArgs";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:3150:" var xhrSendId; var plainXhr = dojo.xhr; var left = actions.length;// this is how many changes are remaining to be received from the server var i, contentLocation; var timeStamp; var conflictDateHeader = this.conflictDateHeader; // add headers for extra information dojo.xhr = function(method,args){ // keep the transaction open as we send requests args.headers = args.headers || {}; // the last one should commit the transaction args.headers['Transaction'] = actions.length - 1 == i ? "commit" : "open"; if(conflictDateHeader && timeStamp){ args.headers[conflictDateHeader] = timeStamp; } if(contentLocation){ args.headers['Content-ID'] = '<' + contentLocation + '>'; } return plainXhr.apply(dojo,arguments); }; for(i =0; i < actions.length;i++){ // iterate through the actions to execute var action = actions[i]; dojox.rpc.JsonRest._contentId = action.content && action.content.__id; // this is used by OfflineRest var isPost = action.method == 'post'; timeStamp = action.method == 'put' && Rest._timeStamps[action.content.__id]; if(timeStamp){ // update it now Rest._timeStamps[action.content.__id] = (new Date()) + ''; } // send the content location to the server contentLocation = isPost && dojox.rpc.JsonRest._contentId; var serviceAndId = jr.getServiceAndId(action.target.__id); var service = serviceAndId.service; var dfd = action.deferred = service[action.method]( serviceAndId.id.replace(/#/,''), // if we are using references, we need eliminate # dojox.json.ref.toJson(action.content, false, service.servicePath, true) ); (function(object, dfd, service){ dfd.addCallback(function(value){ try{ // Implements id assignment per the HTTP specification var newId = dfd.ioArgs.xhr && dfd.ioArgs.xhr.getResponseHeader("Location"); //TODO: match URLs if the servicePath is relative... if(newId){ // if the path starts in the middle of an absolute URL for Location, we will use the just the path part var startIndex = newId.match(/(^\w+:\/\/)/) && newId.indexOf(service.servicePath); newId = startIndex > 0 ? newId.substring(startIndex) : (service.servicePath + newId). // now do simple relative URL resolution in case of a relative URL. replace(/^(.*\/)?(\w+:\/\/)|[^\/\.]+\/\.\.\/|^.*\/(\/)/,'$2$3'); object.__id = newId; Rest._index[newId] = object; } value = resolveJson(service, dfd, value, object && object.__id); }catch(e){} if(!(--left)){ if(kwArgs.onComplete){ kwArgs.onComplete.call(kwArgs.scope); } } return value; }); })(action.content, dfd, service); dfd.addErrback(function(value){ // on an error we want to revert, first we want to separate any changes that were made since the commit left = -1; // first make sure that success isn't called kwArgs.onError.call(kwArgs.scope, value); }); } // revert back to the normal XHR handler dojo.xhr = plainXhr;";s:6:"chains";a:1:{s:4:"call";a:4:{i:0;s:17:"kwArgs.onComplete";i:1;s:14:"kwArgs.onError";i:2;s:17:"kwArgs.onComplete";i:3;s:14:"kwArgs.onError";}}s:7:"summary";s:0:"";}s:34:"dojox.rpc.JsonRest.getDirtyObjects";a:3:{s:4:"type";s:8:"Function";s:6:"source";s:23:" return dirtyObjects;";s:7:"summary";s:0:"";}s:25:"dojox.rpc.JsonRest.revert";a:4:{s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:7:"service";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:608:" for(var i = dirtyObjects.length; i > 0;){ i--; var dirty = dirtyObjects[i]; var object = dirty.object; var old = dirty.old; if(!(service && (object || old) && (object || old).__id.indexOf(service.servicePath))){ // if we are in the specified store or if this is a global revert if(object && old){ // changed for(var j in old){ if(old.hasOwnProperty(j)){ object[j] = old[j]; } } for(j in object){ if(!old.hasOwnProperty(j)){ delete object[j]; } } } dirtyObjects.splice(i, 1); } }";s:7:"summary";s:46:"Reverts all the changes made to JSON/REST data";}s:27:"dojox.rpc.JsonRest.changing";a:4:{s:4:"type";s:8:"Function";s:10:"parameters";a:2:{s:6:"object";a:1:{s:4:"type";s:0:"";}s:9:"_deleting";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:748:" if(!object.__id){ return; } object.__isDirty = true; //if an object is already in the list of dirty objects, don't add it again //or it will overwrite the premodification data set. for(var i=0; i