work in progress for marking nodes as complete
[potlatch2.git] / net / systemeD / potlatch2 / utils / SnapshotConnection.as
1 package net.systemeD.potlatch2.utils {
2
3     import net.systemeD.halcyon.connection.*;
4     import flash.events.Event;
5     import flash.net.*;
6
7     public class SnapshotConnection extends XMLConnection {
8
9         public function SnapshotConnection(cname:String,api:String,policy:String,initparams:Object=null) {
10             super(cname,api,policy,initparams);
11         }
12
13         /** Send a "complete" call to the server, and remove it from the current layer */
14         public function markComplete(entity:Entity):void {
15             if (entity is Node) {
16               var node:Node = Node(entity);
17               if (node == getNode(node.id)) { // confirm it's from this connection
18                   var urlReq:URLRequest = new URLRequest(apiBaseURL+"node/"+node.id+"/complete");
19                   urlReq.method = "POST";
20                   urlReq.data = '   ';
21                   urlReq.contentType = "application/xml";
22                   urlReq.requestHeaders = [ new URLRequestHeader("X_HTTP_METHOD_OVERRIDE", "PUT"),
23                                             new URLRequestHeader("X-Error-Format", "XML") ];
24                   var loader:URLLoader = new URLLoader();
25                   loader.addEventListener(Event.COMPLETE, function(e:Event):void { killNode(node.id) });
26                   loader.load(urlReq);
27               }
28
29             } else if (entity is Way) {
30               var way:Way = Way(entity);
31               trace("not implemented");
32             }
33         }
34
35     }
36 }