Fix for Penetration test _ Session and cookie management
[vid.git] / vid-app-common / src / main / webapp / app / vid / scripts / services / asdcService.js
1 /*-\r
2  * ============LICENSE_START=======================================================\r
3  * VID\r
4  * ================================================================================\r
5  * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.\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  * ============LICENSE_END=========================================================\r
19  */\r
20 \r
21 "use strict";\r
22 \r
23 var AsdcService = function ($http, $log, PropertyService, UtilityService, VIDCONFIGURATION, COMPONENT, DataService, featureFlags) {\r
24     var shouldExcludeMacroFromAsyncInstantiationFlow = function(serviceModel){\r
25         if (DataService.getE2EService())\r
26             return true;\r
27         if (!_.isEmpty(serviceModel.pnfs) && !featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_EXTENDED_MACRO_PNF_CONFIG))\r
28             return true;\r
29         if (!_.isEmpty(serviceModel.collectionResources))\r
30             return true;\r
31         if (!_.isEmpty(serviceModel.networks) && !featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_NETWORK_TO_ASYNC_INSTANTIATION))\r
32             return true;\r
33         if(serviceModel.service.instantiationType === "ClientConfig")\r
34             return true;\r
35         return false;\r
36     };\r
37 \r
38     return {\r
39         getModel: function (modelId, successCallbackFunction) {\r
40             $log.debug("AsdcService:getModel: modelId: " + modelId);\r
41             $http.get(\r
42                 "asdc/getModel/" + modelId\r
43                 + "?r=" + Math.random(),\r
44                 {\r
45                     timeout: PropertyService\r
46                         .getServerResponseTimeoutMsec()\r
47                 }).then(successCallbackFunction)["catch"]\r
48             (UtilityService.runHttpErrorHandler);\r
49         },\r
50 \r
51         shouldTakeTheDrawingBoardViewEdit: function(serviceModel) {\r
52             if (this.enableWebpackModernUi()\r
53                 && serviceModel.service.vidNotions\r
54                 && serviceModel.service.vidNotions.viewEditUI\r
55                 && serviceModel.service.vidNotions.viewEditUI !== 'legacy'\r
56             ) return true;\r
57 \r
58             return false;\r
59         },\r
60 \r
61         enableWebpackModernUi: function(){\r
62             return featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_ENABLE_WEBPACK_MODERN_UI);\r
63         },\r
64 \r
65         shouldTakeTheAsyncInstantiationFlow: function(serviceModel) {\r
66             if (!(this.enableWebpackModernUi()))\r
67                 return false;\r
68             // Assuming positive flag - first of all, respect serviceModel.service.vidNotions.instantiationUI\r
69             if (serviceModel.service.vidNotions\r
70                 && serviceModel.service.vidNotions.instantiationUI\r
71                 && serviceModel.service.vidNotions.instantiationUI !== 'legacy'\r
72             ) return true;\r
73 \r
74             // If defined 'legacy' or not defined, other client-side\r
75             // logic still apply:\r
76 \r
77             if (this.isMacro(serviceModel)\r
78                 && !shouldExcludeMacroFromAsyncInstantiationFlow(serviceModel)\r
79             ) return true;\r
80 \r
81             // otherwise...\r
82             return false;\r
83         },\r
84 \r
85         isMacro: function (serviceModel) {\r
86             if (serviceModel && serviceModel.service) {\r
87                 switch (serviceModel.service.instantiationType) {\r
88                     case 'Macro':\r
89                     case 'Both':\r
90                         return true;\r
91                     case 'A-La-Carte':\r
92                         return false;\r
93                     case 'ClientConfig':\r
94                         console.debug("Looking for " + serviceModel.service.invariantUuid + " by Client Config");\r
95                         return UtilityService.arrayContains(VIDCONFIGURATION.MACRO_SERVICES, serviceModel.service.invariantUuid);\r
96                     default:\r
97                         console.debug("Unexpected serviceModel.service.instantiationType: " + serviceModel.service.instantiationType);\r
98                         return UtilityService.arrayContains(VIDCONFIGURATION.MACRO_SERVICES, serviceModel.service.invariantUuid);\r
99                 }\r
100             } else {\r
101                 $log.debug("isMscro=false, because serviceModel.service is undefined");\r
102                 return false;\r
103             }\r
104         }\r
105     };\r
106 };\r
107 \r
108 appDS2.factory("AsdcService", ["$http", "$log", "PropertyService",\r
109     "UtilityService", "VIDCONFIGURATION","COMPONENT", "DataService", "featureFlags", AsdcService]);\r