Merge branch 'refactor' into snapshotserver
[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             inlineStatus = true;
12         }
13
14         /** Send a "complete" call to the server, and remove it from the current layer */
15         public function markComplete(entity:Entity):void {
16             if (entity is Node) {
17               var node:Node = Node(entity);
18               if (node == getNode(node.id)) { // confirm it's from this connection
19                   var urlReq:URLRequest = new URLRequest(apiBaseURL+"node/"+node.id+"/complete");
20                   urlReq.method = "POST";
21                   urlReq.data = '   ';
22                   urlReq.contentType = "application/xml";
23                   urlReq.requestHeaders = [ new URLRequestHeader("X_HTTP_METHOD_OVERRIDE", "PUT"),
24                                             new URLRequestHeader("X-Error-Format", "XML") ];
25                   var loader:URLLoader = new URLLoader();
26                   loader.addEventListener(Event.COMPLETE, function(e:Event):void { killNode(node.id) });
27                   loader.load(urlReq);
28               }
29
30             } else if (entity is Way) {
31               var way:Way = Way(entity);
32               trace("not implemented");
33             }
34         }
35
36     }
37 }