| 1 |  |   | 
  | 2 |  |   | 
  | 3 |  |   | 
  | 4 |  |   | 
  | 5 |  |   | 
  | 6 |  |   | 
  | 7 |  |   | 
  | 8 |  |   | 
  | 9 |  |   | 
  | 10 |  |   | 
  | 11 |  |   | 
  | 12 |  |   | 
  | 13 |  |   | 
  | 14 |  |   | 
  | 15 |  |   | 
  | 16 |  |   | 
  | 17 |  |   | 
  | 18 |  |   | 
  | 19 |  |   | 
  | 20 |  |   | 
  | 21 |  |   | 
  | 22 |  |   | 
  | 23 |  |   | 
  | 24 |  |   | 
  | 25 |  |   | 
  | 26 |  |   | 
  | 27 |  |   | 
  | 28 |  |   | 
  | 29 | 1 |  package org.vostokframework.application.monitoring.monitors.dispatchers | 
  | 30 |  |  { | 
  | 31 |  |          import org.as3collections.IList; | 
  | 32 |  |          import org.as3utils.StringUtil; | 
  | 33 |  |          import org.vostokframework.application.events.AssetLoadingErrorEvent; | 
  | 34 |  |          import org.vostokframework.application.events.AssetLoadingEvent; | 
  | 35 |  |          import org.vostokframework.application.monitoring.LoadingMonitoring; | 
  | 36 |  |          import org.vostokframework.application.monitoring.monitors.LoadingMonitorDispatcher; | 
  | 37 |  |          import org.vostokframework.domain.assets.AssetType; | 
  | 38 |  |   | 
  | 39 |  |           | 
  | 40 |  |   | 
  | 41 |  |   | 
  | 42 |  |   | 
  | 43 |  |   | 
  | 44 |  |          public class AssetLoadingMonitorDispatcher extends LoadingMonitorDispatcher | 
  | 45 |  |          { | 
  | 46 |  |                   | 
  | 47 |  |   | 
  | 48 |  |   | 
  | 49 |  |                  private var _assetId:String; | 
  | 50 |  |                  private var _assetLocale:String; | 
  | 51 |  |                  private var _assetType:AssetType; | 
  | 52 |  |                   | 
  | 53 |  |                   | 
  | 54 |  |   | 
  | 55 |  |   | 
  | 56 |  |                  public function AssetLoadingMonitorDispatcher(assetId:String, assetLocale:String, assetType:AssetType) | 
  | 57 | 1 |                  { | 
  | 58 | 1 |                          if (StringUtil.isBlank(assetId)) throw new ArgumentError("Argument <assetId> must not be null nor an empty String."); | 
  | 59 | 1 |                          if (StringUtil.isBlank(assetLocale)) throw new ArgumentError("Argument <assetLocale> must not be null nor an empty String."); | 
  | 60 | 1 |                          if (!assetType) throw new ArgumentError("Argument <assetType> must not be null."); | 
  | 61 |  |                           | 
  | 62 | 1 |                          _assetId = assetId; | 
  | 63 | 1 |                          _assetLocale = assetLocale; | 
  | 64 | 1 |                          _assetType = assetType; | 
  | 65 | 1 |                  } | 
  | 66 |  |                   | 
  | 67 |  |                  override public function dispatchCanceledEvent(monitoring:LoadingMonitoring):void | 
  | 68 |  |                  { | 
  | 69 | 1 |                          dispatchEvent(createEvent(AssetLoadingEvent.CANCELED, monitoring)); | 
  | 70 | 1 |                  } | 
  | 71 |  |                   | 
  | 72 |  |                  override public function dispatchCompleteEvent(monitoring:LoadingMonitoring, data:* = null):void | 
  | 73 |  |                  { | 
  | 74 | 1 |                          dispatchEvent(createEvent(AssetLoadingEvent.COMPLETE, monitoring, data)); | 
  | 75 | 1 |                  } | 
  | 76 |  |                   | 
  | 77 |  |                  override public function dispatchFailedEvent(monitoring:LoadingMonitoring, errors:IList):void | 
  | 78 |  |                  { | 
  | 79 | 0 |                          dispatchEvent(createErrorEvent(AssetLoadingErrorEvent.FAILED, monitoring, errors)); | 
  | 80 | 0 |                  } | 
  | 81 |  |                   | 
  | 82 |  |                  override public function dispatchHttpStatusEvent(monitoring:LoadingMonitoring, status:int):void | 
  | 83 |  |                  { | 
  | 84 | 0 |                          var event:AssetLoadingEvent = createEvent(AssetLoadingEvent.HTTP_STATUS, monitoring); | 
  | 85 | 0 |                          event.httpStatus = status; | 
  | 86 | 0 |                          dispatchEvent(event); | 
  | 87 | 0 |                  } | 
  | 88 |  |                   | 
  | 89 |  |                  override public function dispatchInitEvent(monitoring:LoadingMonitoring, data:* = null):void | 
  | 90 |  |                  { | 
  | 91 | 0 |                          dispatchEvent(createEvent(AssetLoadingEvent.INIT, monitoring, data)); | 
  | 92 | 0 |                  } | 
  | 93 |  |                   | 
  | 94 |  |                  override public function dispatchOpenEvent(monitoring:LoadingMonitoring, data:* = null):void | 
  | 95 |  |                  { | 
  | 96 | 1 |                          dispatchEvent(createEvent(AssetLoadingEvent.OPEN, monitoring, data)); | 
  | 97 | 1 |                  } | 
  | 98 |  |                   | 
  | 99 |  |                  override public function dispatchProgressEvent(monitoring:LoadingMonitoring):void | 
  | 100 |  |                  { | 
  | 101 | 1 |                          dispatchEvent(createEvent(AssetLoadingEvent.PROGRESS, monitoring)); | 
  | 102 | 1 |                  } | 
  | 103 |  |                   | 
  | 104 |  |                  override public function dispatchStoppedEvent(monitoring:LoadingMonitoring):void | 
  | 105 |  |                  { | 
  | 106 | 1 |                          dispatchEvent(createEvent(AssetLoadingEvent.STOPPED, monitoring)); | 
  | 107 | 1 |                  } | 
  | 108 |  |                   | 
  | 109 |  |                  override public function typeBelongs(type:String):Boolean | 
  | 110 |  |                  { | 
  | 111 | 0 |                          return AssetLoadingEvent.typeBelongs(type); | 
  | 112 |  |                  } | 
  | 113 |  |                   | 
  | 114 |  |                  private function createEvent(type:String, monitoring:LoadingMonitoring, data:* = null):AssetLoadingEvent | 
  | 115 |  |                  { | 
  | 116 | 1 |                          return new AssetLoadingEvent(type, _assetId, _assetLocale, _assetType, monitoring, data); | 
  | 117 |  |                  } | 
  | 118 |  |                   | 
  | 119 |  |                  private function createErrorEvent(type:String, monitoring:LoadingMonitoring, errors:IList):AssetLoadingErrorEvent | 
  | 120 |  |                  { | 
  | 121 | 0 |                          return new AssetLoadingErrorEvent(type, _assetId, _assetLocale, _assetType, errors, monitoring); | 
  | 122 |  |                  } | 
  | 123 |  |                   | 
  | 124 |  |          } | 
  | 125 |  |   | 
  | 126 |  |  } |