[PORTAL-7] Rebase
[portal.git] / ecomp-portal-FE-common / client / app / services / be-property-reader / be-property-reader.service.js
1 /*-\r
2  * ================================================================================\r
3  * ECOMP Portal\r
4  * ================================================================================\r
5  * Copyright (C) 2017 AT&T Intellectual Property\r
6  * ================================================================================\r
7  * Licensed under the Apache License, Version 2.0 (the "License");\r
8  * you may not use this file except in compliance with the License.\r
9  * You may obtain a copy of the License at\r
10  * \r
11  *      http://www.apache.org/licenses/LICENSE-2.0\r
12  * \r
13  * Unless required by applicable law or agreed to in writing, software\r
14  * distributed under the License is distributed on an "AS IS" BASIS,\r
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  * See the License for the specific language governing permissions and\r
17  * limitations under the License.\r
18  * ================================================================================\r
19  */\r
20 /**\r
21  * Created by nnaffar on 11/22/2015.\r
22  */\r
23 'use strict';\r
24 \r
25 (function () {\r
26     class BeReaderService {\r
27         constructor($q, $log, $http, conf, uuid, utilsService) {\r
28             this.$q = $q;\r
29             this.$log = $log;\r
30             this.$http = $http;\r
31             this.conf = conf;\r
32             this.uuid = uuid;\r
33             this.utilsService = utilsService;\r
34         }\r
35 \r
36         getProperty(property) {\r
37             let deferred = this.$q.defer();\r
38             //this.$log.info('BeReaderService::get all applications admins list');\r
39             \r
40             let url = this.conf.api.beProperty + "?key=" + property;\r
41             this.$http({\r
42                     method: "GET",\r
43                     cache: false,\r
44                     url: url,\r
45                     headers: {\r
46                         'X-ECOMP-RequestID':this.uuid.generate()\r
47                     }\r
48                 })\r
49                 .then( res => {\r
50                     // If response comes back as a redirected HTML page which IS NOT a success\r
51                     //if (this.utilsService.isValidJSON(res)=== false) {\r
52                     //  this.$log.error('BeReaderService::getAccountAdmins Failed');\r
53                     //    deferred.reject("BeReaderService::getAccountAdmins Failed");\r
54                     //} else {\r
55                         // this.$log.info('BeReaderService::getAccountAdmins Succeeded');\r
56                     deferred.resolve(res.data);\r
57                     //}\r
58                 })\r
59                 .catch( status => {\r
60                         this.$log.error('BeReaderService::getAccountAdmins Failed', status);\r
61                     deferred.reject(status);\r
62                 });\r
63            \r
64             return deferred.promise;\r
65 \r
66         }\r
67     }\r
68     BeReaderService.$inject = ['$q', '$log', '$http', 'conf','uuid4', 'utilsService'];\r
69     angular.module('ecompApp').service('beReaderService', BeReaderService)\r
70 })();\r