1 | package clarin.cmdi.componentregistry.services { |
---|
2 | import mx.core.Application; |
---|
3 | |
---|
4 | public final class Config { |
---|
5 | private static const COMPONENT_LIST_URL:String = "/rest/registry/components"; |
---|
6 | private static const PROFILE_LIST_URL:String = "/rest/registry/profiles"; |
---|
7 | private static const UPLOAD_PROFILE_SERVICE_URL:String = "/rest/registry/profiles"; |
---|
8 | private static const UPLOAD_COMPONENT_SERVICE_URL:String = "/rest/registry/components"; |
---|
9 | private static const PROFILE_INFO_URL:String = "/rest/registry/profiles/"; |
---|
10 | private static const COMPONENT_INFO_URL:String = "/rest/registry/components/"; |
---|
11 | |
---|
12 | private static var _instance:Config = new Config(); |
---|
13 | |
---|
14 | private var _serviceRootUrl:String = "http://localhost:8080/ComponentRegistry"; |
---|
15 | //Default _serviceRootUrl value can be useful for testing. Set the proper value in your (index.)html that embeds the flash object. |
---|
16 | //Like this: "FlashVars", "serviceRootUrl=http://localhost:8080/ComponentRegistry" |
---|
17 | |
---|
18 | |
---|
19 | public function Config() { |
---|
20 | if (_instance != null) { |
---|
21 | throw new Error("Config can only be accessed through Config.instance"); |
---|
22 | } |
---|
23 | var serviceRootUrl:String = Application.application.parameters.serviceRootUrl; |
---|
24 | if (serviceRootUrl != null) { |
---|
25 | _serviceRootUrl = serviceRootUrl; |
---|
26 | } |
---|
27 | } |
---|
28 | |
---|
29 | public function get profileListUrl():String { |
---|
30 | return _serviceRootUrl + PROFILE_LIST_URL; |
---|
31 | } |
---|
32 | |
---|
33 | public function get componentListUrl():String { |
---|
34 | return _serviceRootUrl + COMPONENT_LIST_URL; |
---|
35 | } |
---|
36 | |
---|
37 | public function get profileInfoUrl():String { |
---|
38 | return _serviceRootUrl + PROFILE_INFO_URL; |
---|
39 | } |
---|
40 | |
---|
41 | public function get componentInfoUrl():String { |
---|
42 | return _serviceRootUrl + COMPONENT_INFO_URL; |
---|
43 | } |
---|
44 | |
---|
45 | public function get uploadProfileUrl():String { |
---|
46 | return _serviceRootUrl + UPLOAD_PROFILE_SERVICE_URL; |
---|
47 | } |
---|
48 | |
---|
49 | public function get uploadComponentUrl():String { |
---|
50 | return _serviceRootUrl + UPLOAD_COMPONENT_SERVICE_URL; |
---|
51 | } |
---|
52 | |
---|
53 | public static function get instance():Config { |
---|
54 | return _instance; |
---|
55 | } |
---|
56 | |
---|
57 | } |
---|
58 | } |
---|