Changeset 224 for ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/services/DeleteService.as
- Timestamp:
- 03/09/10 17:37:10 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/services/DeleteService.as
r206 r224 1 1 package clarin.cmdi.componentregistry.services { 2 2 import clarin.cmdi.componentregistry.common.ItemDescription; 3 3 4 4 import com.adobe.net.URI; 5 5 import com.hurlant.util.Base64; 6 6 7 import flash.events.ErrorEvent; 7 8 import flash.events.Event; 8 9 import flash.events.EventDispatcher; 9 10 10 11 import mx.controls.Alert; 12 import mx.managers.CursorManager; 11 13 import mx.utils.StringUtil; 12 14 13 15 import org.httpclient.HttpClient; 14 import org.httpclient.events.HttpErrorEvent;15 16 import org.httpclient.events.HttpResponseEvent; 16 import org.httpclient.events.HttpStatusEvent;17 17 import org.httpclient.http.Delete; 18 18 … … 27 27 service.listener.onComplete = handleResult; 28 28 service.listener.onError = handleError; 29 service.listener.onStatus = handleStatus;30 29 } 31 30 … … 35 34 36 35 public function deleteItem(item:ItemDescription):void { 36 CursorManager.setBusyCursor(); 37 37 var uri:URI = new URI(item.dataUrl); 38 38 var httpDelete:Delete = new Delete(); … … 42 42 43 43 private function handleResult(resultEvent:HttpResponseEvent):void { 44 if (resultEvent.response.code == "200") { 44 CursorManager.removeBusyCursor(); 45 if (resultEvent.response.isSuccess) { 45 46 dispatchEvent(new Event(ITEM_DELETED)); 47 } else if (resultEvent.response.isClientError) { 48 Alert.show("Unauthorized to delete item, you are not the creator."); 49 } else if (resultEvent.response.isServerError) { 50 Alert.show("Unexpected error, server returned status: " + resultEvent.response.code); 46 51 } 47 52 } 48 53 49 public function handleError(faultEvent:HttpErrorEvent):void { 54 public function handleError(faultEvent:ErrorEvent):void { 55 CursorManager.removeBusyCursor(); 50 56 var errorMessage:String = StringUtil.substitute("Error in {0}: {1}", this, faultEvent.text); 51 throw new Error(errorMessage);57 Alert.show(errorMessage); 52 58 } 53 59 54 private function handleStatus(event:HttpStatusEvent):void {55 if (event.code != "200") {56 if (event.code == "401") {57 Alert.show("Unauthorized to delete item, you are not the creator.");58 }59 trace("(httpstatus code was: " + event.code + ")");60 }61 }62 60 } 63 61 }
Note: See TracChangeset
for help on using the changeset viewer.