2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
23 var PropertyService = function($location, $http) {
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";
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;
46 getAaiBaseUrl : function() {
47 return _this.aaiBaseUrl;
49 setAaiBaseUrl : function(aaiBaseUrl) {
50 _this.aaiBaseUrl = aaiBaseUrl;
52 getAsdcBaseUrl : function() {
53 return _this.asdcBaseUrl;
55 setAsdcBaseUrl : function(asdcBaseUrl) {
56 _this.asdcBaseUrl = asdcBaseUrl;
58 retrieveMsoMaxPollingIntervalMsec : function(defaultvalue) {
59 _this.msoMaxPollingIntervalMsec = defaultvalue;
60 $http.get( _this.aaiBaseUrl + "/get_property/" + MSO_POLLING_INTERVAL_MSECS + "/" + defaultvalue, {
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) );
73 return _this.msoMaxPollingIntervalMsec;
75 getMsoMaxPollingIntervalMsec : function() {
76 return _this.msoMaxPollingIntervalMsec;
78 setMsoMaxPollingIntervalMsec : function(msoMaxPollingIntervalMsec) {
79 _this.msoMaxPollingIntervalMsec = msoMaxPollingIntervalMsec;
81 retrieveMsoMaxPolls : function(defaultvalue) {
82 _this.msoMaxPolls = defaultvalue;
83 $http.get( _this.aaiBaseUrl + "/get_property/" + MSO_MAX_POLLS + "/" + defaultvalue, {
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);
93 return _this.msoMaxPolls;
95 getMsoMaxPolls : function() {
96 return _this.msoMaxPolls;
98 setMsoMaxPolls : function(msoMaxPolls) {
99 _this.msoMaxPolls = msoMaxPolls;
101 getMsoBaseUrl : function() {
102 return _this.msoBaseUrl;
104 setMsoBaseUrl : function(msoBaseUrl) {
105 _this.msoBaseUrl = msoBaseUrl;
107 getServerResponseTimeoutMsec : function() {
108 return _this.serverResponseTimeoutMsec;
110 setServerResponseTimeoutMsec : function(serverResponseTimeoutMsec) {
111 _this.serverResponseTimeoutMsec = serverResponseTimeoutMsec;
116 app.factory("PropertyService", PropertyService);