Changeset 3366


Ignore:
Timestamp:
08/13/13 11:06:15 (11 years ago)
Author:
g.georgovassilis@mpi.nl
Message:

#269 BaseRemoteService? abstracts HTTP communication away for XML services, added facility for mocking services in unit tests, moved tests into src/test

Location:
ComponentRegistry/branches/ggeorgovassilis_workspace/ComponentBrowserGui
Files:
24 added
5 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • ComponentRegistry/branches/ggeorgovassilis_workspace/ComponentBrowserGui

    • Property svn:ignore
      •  

        old new  
        88.flexConfig.xml
        99.metadata
         10
         11libs
         12
         13.FlexUnitSettings
  • ComponentRegistry/branches/ggeorgovassilis_workspace/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/common/components/HelpLabelButton.as

    r2515 r3366  
    11package clarin.cmdi.componentregistry.common.components
    22{
    3         import clarin.cmdi.componentregistry.services.Config;
    4        
    5         import com.adobe.net.URI;
    6        
    73        import flash.events.MouseEvent;
    84        import flash.net.URLRequest;
  • ComponentRegistry/branches/ggeorgovassilis_workspace/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/common/components/LoginLabelButton.as

    r2515 r3366  
    88        import flash.net.navigateToURL;
    99
    10         import mx.controls.Label;
    1110
    1211        public class LoginLabelButton extends LabelButton {
     
    2726                        var req:URLRequest = new URLRequest();
    2827
    29                         var uri:URI = new URI(Config.instance.serviceRootUrl);
     28                        var uri:URI  = new URI(Config.instance.serviceRootUrl);
    3029                        uri.setQueryValue("shhaaDo", "lI");
    3130                        if (viewType) {
  • ComponentRegistry/branches/ggeorgovassilis_workspace/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/importer/FileLoadedEvent.as

    r1255 r3366  
    11package clarin.cmdi.componentregistry.importer {
    2         import clarin.cmdi.componentregistry.common.ItemDescription;
    32       
    43        import flash.events.Event;
  • ComponentRegistry/branches/ggeorgovassilis_workspace/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/services/BaseRemoteService.as

    r3363 r3366  
    1414        import mx.utils.StringUtil;
    1515       
     16        import clarin.cmdi.componentregistry.services.remote.HttpServiceFactory;
     17        import clarin.cmdi.componentregistry.services.remote.RemoteService;
     18       
    1619/**
    1720 * Handles communication with any arbitrary XML backend service, implements error handling and dispatching of success events.
     
    2225
    2326                protected var successEventName:String;
    24                 protected var readService:HTTPService;
     27                protected var readService:RemoteService;
    2528               
    2629                /**
     
    2932                 */
    3033                public function BaseRemoteService(successEventName:String) {
    31                         readService = new HTTPService();
    32                         readService.method = HTTPRequestMessage.GET_METHOD;
    33                         readService.resultFormat = HTTPService.RESULT_FORMAT_E4X;
     34                        readService = HttpServiceFactory.createRemoteService();
     35                        readService.setMethod(HTTPRequestMessage.GET_METHOD);
     36                        readService.setResultFormat(HTTPService.RESULT_FORMAT_E4X);
    3437                        this.successEventName = successEventName;
    3538                }
     
    4144                protected function dispatchRequest(url:URI):void {
    4245                        trace(url);
    43                         readService.url = url.toString();
     46                        readService.setUrl(url);
    4447                        var token:AsyncToken = readService.send();
    4548                        token.addResponder(new Responder(this.requestCallbackOk, this.requestCallbackFailed));
  • ComponentRegistry/branches/ggeorgovassilis_workspace/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/services/ComponentInfoService.as

    r3363 r3366  
    22
    33        import com.adobe.net.URI;
     4       
     5        import mx.controls.Alert;
    46       
    57        import clarin.cmdi.componentregistry.common.Component;
  • ComponentRegistry/branches/ggeorgovassilis_workspace/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/services/IsocatService.as

    r1591 r3366  
    22        import com.adobe.net.URI;
    33       
    4         import flash.events.EventDispatcher;
    5        
    6         import mx.controls.Alert;
    74        import mx.managers.CursorManager;
    8         import mx.messaging.messages.HTTPRequestMessage;
    9         import mx.rpc.events.FaultEvent;
    10         import mx.rpc.events.ResultEvent;
    115        import mx.rpc.http.HTTPService;
    12         import mx.utils.StringUtil;
    136
    14         public class IsocatService extends EventDispatcher {
     7        public class IsocatService extends BaseRemoteService {
    158                public static const PROFILE_LOADED:String = "ProfileLoaded";
    169                public static const TYPE_SIMPLE:String = "simple";
     
    2720
    2821                public function IsocatService() {
     22                        super(PROFILE_LOADED);
    2923                }
    3024
     
    3529                public function load(keyword:String, type:String):void {
    3630                        if (keyword) {
    37                                 createClient();
    3831                                CursorManager.setBusyCursor();
    3932                                var uri:URI = new URI(Config.instance.isocatSearchUrl);
     
    4134                                if (type)
    4235                                    uri.setQueryValue("type", type);
    43                                 service.url = uri.toString();
    44                                 service.send();
     36                                dispatchRequest(uri);
    4537                        }
    4638                }
     
    5345                }
    5446
    55                 private function createClient():void {
    56                         service = new HTTPService();
    57                         service.method = HTTPRequestMessage.GET_METHOD;
    58                         service.resultFormat = HTTPService.RESULT_FORMAT_E4X;
    59                         service.addEventListener(ResultEvent.RESULT, handleResult);
    60                         service.addEventListener(FaultEvent.FAULT, handleError);
    61                 }
    62 
    63 
    64                 private function handleResult(resultEvent:ResultEvent):void {
     47                override protected function handleXmlResult(result:XML):void {
    6548                        CursorManager.removeBusyCursor();
    66                         if (resultEvent.statusCode >= 200 && resultEvent.statusCode < 300) {
    67                                 var data:XML = new XML(resultEvent.result);
    68                                 searchResults = data.dcif::dataCategory;
    69                         } else {
    70                                 Alert.show("Unexpected error, server returned status: " + resultEvent.statusCode + "\n Message = ");
    71                         }
    72                 }
    73 
    74                 private function handleError(faultEvent:FaultEvent):void {
    75                         CursorManager.removeBusyCursor();
    76                         var errorMessage:String = StringUtil.substitute("Error in {0} status {1}: {2}", this, faultEvent.statusCode, faultEvent.fault.faultString);
    77                         Alert.show(errorMessage);
     49                        searchResults = result.dcif::dataCategory;
    7850                }
    7951
  • ComponentRegistry/branches/ggeorgovassilis_workspace/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/services/SaveItemDialog.as

    r1088 r3366  
    11package clarin.cmdi.componentregistry.services {
    2         import clarin.cmdi.componentregistry.common.ItemDescription;
    3 
    4         import com.adobe.net.URI;
    52
    63        import flash.net.URLRequest;
    74        import flash.net.navigateToURL;
     5        import clarin.cmdi.componentregistry.common.ItemDescription;
     6        import com.adobe.net.URI;
    87
    98        public class SaveItemDialog {
  • ComponentRegistry/branches/ggeorgovassilis_workspace/ComponentBrowserGui/src/main/flex/main.mxml

    r2515 r3366  
    99        <mx:Script>
    1010                <![CDATA[
     11                        import com.flexspy.FlexSpy;
     12                       
     13                        import mx.controls.Button;
     14                        import mx.managers.PopUpManager;
     15                       
    1116                        import clarin.cmdi.componentregistry.common.AboutPopup;
    1217                        import clarin.cmdi.componentregistry.common.Credentials;
     
    1419                        import clarin.cmdi.componentregistry.services.Config;
    1520                        import clarin.cmdi.componentregistry.services.PingSessionService;
    16                        
    17                         import com.flexspy.FlexSpy;
    18                        
    19                         import mx.controls.Button;
    20                         import mx.managers.PopUpManager;
     21                        import clarin.cmdi.componentregistry.services.remote.ClientServiceFactoryImpl;
    2122                       
    2223                        import org.hasseg.externalMouseWheel.ExternalMouseWheelSupport;
Note: See TracChangeset for help on using the changeset viewer.