Ignore:
Timestamp:
03/09/10 17:37:10 (14 years ago)
Author:
patdui
Message:
  • reimplemented my drag and drop editor
  • created search functionality for isocat conceptLinks.
  • added some flexUnit tests and cleanup error handling
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/services/DeleteService.as

    r206 r224  
    11package clarin.cmdi.componentregistry.services {
    22        import clarin.cmdi.componentregistry.common.ItemDescription;
    3 
     3       
    44        import com.adobe.net.URI;
    55        import com.hurlant.util.Base64;
    6 
     6       
     7        import flash.events.ErrorEvent;
    78        import flash.events.Event;
    89        import flash.events.EventDispatcher;
    9 
     10       
    1011        import mx.controls.Alert;
     12        import mx.managers.CursorManager;
    1113        import mx.utils.StringUtil;
    12 
     14       
    1315        import org.httpclient.HttpClient;
    14         import org.httpclient.events.HttpErrorEvent;
    1516        import org.httpclient.events.HttpResponseEvent;
    16         import org.httpclient.events.HttpStatusEvent;
    1717        import org.httpclient.http.Delete;
    1818
     
    2727                        service.listener.onComplete = handleResult;
    2828                        service.listener.onError = handleError;
    29                         service.listener.onStatus = handleStatus;
    3029                }
    3130
     
    3534
    3635                public function deleteItem(item:ItemDescription):void {
     36                        CursorManager.setBusyCursor();
    3737                        var uri:URI = new URI(item.dataUrl);
    3838                        var httpDelete:Delete = new Delete();
     
    4242
    4343                private function handleResult(resultEvent:HttpResponseEvent):void {
    44                         if (resultEvent.response.code == "200") {
     44                        CursorManager.removeBusyCursor();
     45                        if (resultEvent.response.isSuccess) {
    4546                                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);
    4651                        }
    4752                }
    4853
    49                 public function handleError(faultEvent:HttpErrorEvent):void {
     54                public function handleError(faultEvent:ErrorEvent):void {
     55                        CursorManager.removeBusyCursor();
    5056                        var errorMessage:String = StringUtil.substitute("Error in {0}: {1}", this, faultEvent.text);
    51                         throw new Error(errorMessage);
     57                    Alert.show(errorMessage);
    5258                }
    5359
    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                 }
    6260        }
    6361}
Note: See TracChangeset for help on using the changeset viewer.