[VID-3] Setting docker image tag
[vid.git] / vid / src / main / webapp / app / vid / scripts / services / propertyService.js
1 /*-
2  * ============LICENSE_START=======================================================
3  * VID
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 "use strict";
22
23 var PropertyService = function($location, $http) {
24
25     var RE = /.*?:\/\/.*?:.*?\/(.*?)\//g;
26     var BASE_PATH = RE.exec($location.absUrl())[1];
27     var DEFAULT_AAI_BASE_URL = "/" + BASE_PATH;
28     var DEFAULT_ASDC_BASE_URL = "asdc";
29     var DEFAULT_MSO_MAX_POLLING_INTERVAL_MSEC = 60000;
30     var DEFAULT_MSO_MAX_POLLS = 10;
31     var DEFAULT_MSO_BASE_URL = "/" + BASE_PATH + "/mso";
32     var DEFAULT_SERVER_RESPONSE_TIMEOUT_MSEC = 60000;
33     var MSO_POLLING_INTERVAL_MSECS = "mso_polling_interval_msecs";
34     var MSO_MAX_POLLS = "mso_max_polls";
35
36     var _this = this;
37
38     _this.asdcBaseUrl = DEFAULT_ASDC_BASE_URL;
39     _this.aaiBaseUrl = DEFAULT_AAI_BASE_URL;
40     _this.msoMaxPollingIntervalMsec = DEFAULT_MSO_MAX_POLLING_INTERVAL_MSEC;
41     _this.msoMaxPolls = DEFAULT_MSO_MAX_POLLS;
42     _this.msoBaseUrl = DEFAULT_MSO_BASE_URL;
43     _this.serverResponseTimeoutMsec = DEFAULT_SERVER_RESPONSE_TIMEOUT_MSEC;
44
45     return {
46         getAaiBaseUrl : function() {
47             return _this.aaiBaseUrl;
48         },
49         setAaiBaseUrl : function(aaiBaseUrl) {
50             _this.aaiBaseUrl = aaiBaseUrl;
51         },
52         getAsdcBaseUrl : function() {
53             return _this.asdcBaseUrl;
54         },
55         setAsdcBaseUrl : function(asdcBaseUrl) {
56             _this.asdcBaseUrl = asdcBaseUrl;
57         },
58         retrieveMsoMaxPollingIntervalMsec : function(defaultvalue) {
59                 _this.msoMaxPollingIntervalMsec = defaultvalue;
60                 $http.get( _this.aaiBaseUrl + "/get_property/" + MSO_POLLING_INTERVAL_MSECS + "/" + defaultvalue, {
61
62                 },{
63                         timeout: _this.serverResponseTimeoutMsec
64                 }).then(function(response) {
65                         //console.log ( "retrieveMsoMaxPollingIntervalMsec: " ); console.log ( JSON.stringify(response) );
66                         //console.log ( "retrieveMsoMaxPollingIntervalMsec: " + response.data );
67                         _this.msoMaxPollingIntervalMsec = response.data;
68                 console.log ("retrieveMsoMaxPollingIntervalMsec: " + _this.msoMaxPollingIntervalMsec);
69             },function errorCallback(response) {
70                 console.log ( "retrieveMsoMaxPollingIntervalMsec: " + response.status );
71                 //console.log ( "retrieveMsoMaxPollingIntervalMsec: " ); console.log ( JSON.stringify(response) );
72               });
73             return _this.msoMaxPollingIntervalMsec;
74         },
75         getMsoMaxPollingIntervalMsec : function() {
76             return _this.msoMaxPollingIntervalMsec;
77         },
78         setMsoMaxPollingIntervalMsec : function(msoMaxPollingIntervalMsec) {
79             _this.msoMaxPollingIntervalMsec = msoMaxPollingIntervalMsec;
80         },
81         retrieveMsoMaxPolls : function(defaultvalue) {
82                 _this.msoMaxPolls = defaultvalue;
83                 $http.get( _this.aaiBaseUrl + "/get_property/" + MSO_MAX_POLLS + "/" + defaultvalue, {
84
85                 },{
86                         timeout: _this.serverResponseTimeoutMsec
87                 }).then(function(response) {
88                         //console.log ( "retrieveMsoMaxPolls: " ); console.log ( JSON.stringify(response) );
89                         //console.log ( "retrieveMsoMaxPolls: " + response.data.entity );
90                         _this.msoMaxPolls = response.data;
91                 console.log ("retrieveMsoMaxPolls: " + _this.msoMaxPolls);
92             });
93             return _this.msoMaxPolls;
94         },
95         getMsoMaxPolls : function() {
96             return _this.msoMaxPolls;
97         },
98         setMsoMaxPolls : function(msoMaxPolls) {
99             _this.msoMaxPolls = msoMaxPolls;
100         },
101         getMsoBaseUrl : function() {
102             return _this.msoBaseUrl;
103         },
104         setMsoBaseUrl : function(msoBaseUrl) {
105             _this.msoBaseUrl = msoBaseUrl;
106         },
107         getServerResponseTimeoutMsec : function() {
108             return _this.serverResponseTimeoutMsec;
109         },
110         setServerResponseTimeoutMsec : function(serverResponseTimeoutMsec) {
111             _this.serverResponseTimeoutMsec = serverResponseTimeoutMsec;
112         }
113     };
114 }
115
116 app.factory("PropertyService", PropertyService);