e30f5f32fc914f971fa08adb11bfa0c749e3dcad
[sdc.git] / common-app-api / src / main / java / org / openecomp / sdc / be / config / Configuration.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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 package org.openecomp.sdc.be.config;
21
22 import static java.lang.String.format;
23 import static java.util.Collections.emptyMap;
24
25 import java.util.Collections;
26 import java.util.Date;
27 import java.util.List;
28 import java.util.Map;
29 import java.util.Set;
30 import lombok.Getter;
31 import lombok.NoArgsConstructor;
32 import lombok.Setter;
33 import lombok.ToString;
34 import org.apache.commons.collections.CollectionUtils;
35 import org.apache.commons.collections.map.CaseInsensitiveMap;
36 import org.openecomp.sdc.common.api.BasicConfiguration;
37
38 @Getter
39 @Setter
40 @NoArgsConstructor
41 public class Configuration extends BasicConfiguration {
42
43     private List<String> identificationHeaderFields;
44     /**
45      * Requests from these Urls will not be logged by org.openecomp.sdc.be.filters.BeServletFilter.<br>
46      **/
47     private List<String> unLoggedUrls;
48     /**
49      * backend host
50      */
51     private String beFqdn;
52     /**
53      * backend http port
54      */
55     private Integer beHttpPort;
56     /**
57      * backend http secured port
58      */
59     private Integer beSslPort;
60     /**
61      * be http context
62      */
63     private String beContext;
64     /**
65      * backend protocol. http | https
66      */
67     private String beProtocol = "http";
68     private Date released;
69     private String version = "1111";
70     private String toscaConformanceLevel = "3.0";
71     private String minToscaConformanceLevel = "3.0";
72     private List<String> protocols;
73     private Map<String, String> users;
74     private Map<String, Object> neo4j;
75     private String janusGraphCfgFile;
76     private String janusGraphMigrationKeySpaceCfgFile;
77     private Boolean janusGraphInMemoryGraph;
78     private int startMigrationFrom;
79     private Long janusGraphLockTimeout;
80     private Long janusGraphReconnectIntervalInSeconds;
81     private List<String> healthStatusExclude;
82     private Long janusGraphHealthCheckReadTimeout;
83     private Long uebHealthCheckReconnectIntervalInSeconds;
84     private Long uebHealthCheckReadTimeout;
85     private List<Map<String, Map<String, String>>> defaultImports;
86     private List<String> globalCsarImports;
87     private List<String> resourceTypes;
88     private List<String> excludeResourceCategory;
89     private List<String> excludeResourceType;
90     private Map<String, Set<String>> excludedPolicyTypesMapping;
91     private Map<String, Set<String>> excludedGroupTypesMapping;
92     private Map<String, Object> deploymentResourceArtifacts;
93     private Map<String, Object> deploymentResourceInstanceArtifacts;
94     private Map<String, Object> toscaArtifacts;
95     private Map<String, Object> informationalResourceArtifacts;
96     private Map<String, Object> informationalServiceArtifacts;
97     private Map<String, Object> serviceApiArtifacts;
98     private List<String> excludeServiceCategory;
99     private List<String> licenseTypes;
100     private List<String> definedResourceNamespace;
101     private List<String> directives;
102     private Integer additionalInformationMaxNumberOfKeys;
103     private HeatDeploymentArtifactTimeout heatArtifactDeploymentTimeout;
104     private BeMonitoringConfig systemMonitoring;
105     private CleanComponentsConfiguration cleanComponentsConfiguration;
106     private String artifactsIndex;
107     private String heatEnvArtifactHeader;
108     private String heatEnvArtifactFooter;
109     private String toscaFilesDir;
110     private String heatTranslatorPath;
111     private OnboardingConfig onboarding;
112     private BasicAuthConfig basicAuth;
113     private CassandrConfig cassandraConfig;
114     private SwitchoverDetectorConfig switchoverDetector;
115     private ApplicationL1CacheConfig applicationL1Cache;
116     private ApplicationL2CacheConfig applicationL2Cache;
117     private ToscaValidatorsConfig toscaValidators;
118     private boolean disableAudit;
119     private Boolean consumerBusinessLogic;
120     private Map<String, VfModuleProperty> vfModuleProperties;
121     private Map<String, String> genericAssetNodeTypes;
122     private Map<String, String> serviceNodeTypes;
123     private Map<String, Map<String, String>> resourceNodeTypes;
124     private String appVersion;
125     private String artifactGeneratorConfig;
126     private CadiFilterParams cadiFilterParams;
127     private Boolean aafAuthNeeded = false;
128     private String autoHealingOwner;
129     private boolean enableAutoHealing;
130     private Map<String, List<String>> resourcesForUpgrade;
131     private DmaapConsumerConfiguration dmaapConsumerConfiguration;
132     private DmaapProducerConfiguration dmaapProducerConfiguration;
133     private boolean skipUpgradeFailedVfs;
134     private boolean skipUpgradeVSPs;
135     private DmeConfiguration dmeConfiguration;
136     private boolean supportAllottedResourcesAndProxy;
137     private Integer deleteLockTimeoutInSeconds;
138     private Integer maxDeleteComponents;
139     private CookieConfig authCookie;
140     private String aafNamespace;
141     private String workloadContext;
142     private EnvironmentContext environmentContext;
143     private List<GabConfig> gabConfig;
144     private EcompPortalConfig ecompPortal;
145     private List<ArtifactConfiguration> artifacts;
146     private Map<String, Map<String, List<String>>> componentAllowedInstanceTypes;
147
148     @SuppressWarnings("unchecked")
149     private <K, V> Map<K, V> safeGetCapsInsensitiveMap(Map<K, V> map) {
150         return map == null ? emptyMap() : new CaseInsensitiveMap(map);
151     }
152
153     public Long getJanusGraphHealthCheckReadTimeout(long defaultVal) {
154         return janusGraphHealthCheckReadTimeout == null ? defaultVal : janusGraphHealthCheckReadTimeout;
155     }
156
157     public Long getJanusGraphReconnectIntervalInSeconds(long defaultVal) {
158         return janusGraphReconnectIntervalInSeconds == null ? defaultVal : janusGraphReconnectIntervalInSeconds;
159     }
160
161     public Map<String, Set<String>> getExcludedPolicyTypesMapping() {
162         return safeGetCapsInsensitiveMap(excludedPolicyTypesMapping);
163     }
164
165     public Map<String, Set<String>> getExcludedGroupTypesMapping() {
166         return safeGetCapsInsensitiveMap(excludedGroupTypesMapping);
167     }
168
169     @Override
170     public String toString() {
171         return new StringBuilder().append(format("backend host: %s%n", beFqdn)).append(format("backend http port: %s%n", beHttpPort))
172             .append(format("backend ssl port: %s%n", beSslPort)).append(format("backend context: %s%n", beContext))
173             .append(format("backend protocol: %s%n", beProtocol)).append(format("Version: %s%n", version)).append(format("Released: %s%n", released))
174             .append(format("Supported protocols: %s%n", protocols)).append(format("Users: %s%n", users)).append(format("Neo4j: %s%n", neo4j))
175             .append(format("JanusGraph Cfg File: %s%n", janusGraphCfgFile)).append(format("JanusGraph In memory: %s%n", janusGraphInMemoryGraph))
176             .append(format("JanusGraph lock timeout: %s%n", janusGraphLockTimeout))
177             .append(format("JanusGraph reconnect interval seconds: %s%n", janusGraphReconnectIntervalInSeconds))
178             .append(format("excludeResourceCategory: %s%n", excludeResourceCategory))
179             .append(format("informationalResourceArtifacts: %s%n", informationalResourceArtifacts))
180             .append(format("deploymentResourceArtifacts: %s%n", deploymentResourceArtifacts))
181             .append(format("informationalServiceArtifacts: %s%n", informationalServiceArtifacts))
182             .append(format("Supported artifacts types: %s%n", artifacts)).append(format("Supported license types: %s%n", licenseTypes))
183             .append(format("Additional information Maximum number of preoperties: %s%n", additionalInformationMaxNumberOfKeys))
184             .append(format("Heat Artifact Timeout in Minutes: %s%n", heatArtifactDeploymentTimeout))
185             .append(format("URLs For HTTP Requests that will not be automatically logged : %s%n", unLoggedUrls))
186             .append(format("Service Api Artifacts: %s%n", serviceApiArtifacts))
187             .append(format("heat env artifact header: %s%n", heatEnvArtifactHeader))
188             .append(format("heat env artifact footer: %s%n", heatEnvArtifactFooter)).append(format("onboarding: %s%n", onboarding)).toString();
189     }
190
191     public List<String> getGlobalCsarImports() {
192         if (CollectionUtils.isEmpty(globalCsarImports)) {
193             return Collections.emptyList();
194         }
195         return globalCsarImports;
196     }
197
198     @Getter
199     @Setter
200     @NoArgsConstructor
201     public static class CookieConfig {
202
203         private String securityKey = "";
204         private long maxSessionTimeOut = 600 * 1000L;
205         private long sessionIdleTimeOut = 30 * 1000L;
206         private String cookieName = "AuthenticationCookie";
207         private String redirectURL = "https://www.e-access.att.com/ecomp_portal_ist/ecompportal/process_csp";
208         private List<String> excludedUrls;
209         private List<String> onboardingExcludedUrls;
210         private String domain = "";
211         private String path = "";
212         private boolean isHttpOnly = true;
213
214         public boolean isHttpOnly() {
215             return isHttpOnly;
216         }
217
218         public void setIsHttpOnly(final boolean isHttpOnly) {
219             this.isHttpOnly = isHttpOnly;
220         }
221     }
222
223     @Getter
224     @Setter
225     @NoArgsConstructor
226     public static class CassandrConfig {
227
228         private static final Integer CASSANDRA_DEFAULT_PORT = 9042;
229         private List<String> cassandraHosts;
230         private Integer cassandraPort;
231         private String localDataCenter;
232         private Long reconnectTimeout;
233         private Integer socketReadTimeout;
234         private Integer socketConnectTimeout;
235         private List<KeyspaceConfig> keySpaces;
236         private boolean authenticate;
237         private String username;
238         private String password;
239         private boolean ssl;
240         private String truststorePath;
241         private String truststorePassword;
242         private int maxWaitSeconds = 120;
243
244         public Integer getCassandraPort() {
245             return cassandraPort != null ? cassandraPort : Configuration.CassandrConfig.CASSANDRA_DEFAULT_PORT;
246         }
247
248         @Getter
249         @Setter
250         @NoArgsConstructor
251         public static class KeyspaceConfig {
252
253             private String name;
254             private String replicationStrategy;
255             private List<String> replicationInfo;
256         }
257     }
258
259     @Getter
260     @Setter
261     @NoArgsConstructor
262     public static class SwitchoverDetectorConfig {
263
264         private String gBeFqdn;
265         private String gFeFqdn;
266         private String beVip;
267         private String feVip;
268         private int beResolveAttempts;
269         private int feResolveAttempts;
270         private Boolean enabled;
271         private long interval;
272         private String changePriorityUser;
273         private String changePriorityPassword;
274         private String publishNetworkUrl;
275         private String publishNetworkBody;
276         private Map<String, GroupInfo> groups;
277
278         public String getgBeFqdn() {
279             return gBeFqdn;
280         }
281
282         public void setgBeFqdn(String gBeFqdn) {
283             this.gBeFqdn = gBeFqdn;
284         }
285
286         public String getgFeFqdn() {
287             return gFeFqdn;
288         }
289
290         public void setgFeFqdn(String gFeFqdn) {
291             this.gFeFqdn = gFeFqdn;
292         }
293
294         @Getter
295         @Setter
296         @NoArgsConstructor
297         public static class GroupInfo {
298
299             String changePriorityUrl;
300             String changePriorityBody;
301         }
302     }
303
304     @Getter
305     @Setter
306     @NoArgsConstructor
307     @ToString
308     public static class HeatDeploymentArtifactTimeout {
309
310         private Integer defaultMinutes;
311         private Integer minMinutes;
312         private Integer maxMinutes;
313     }
314
315     @Getter
316     @Setter
317     @NoArgsConstructor
318     public static class BeMonitoringConfig {
319
320         private Boolean enabled;
321         private Boolean isProxy;
322         private Integer probeIntervalInSeconds;
323
324         public Integer getProbeIntervalInSeconds(int defaultVal) {
325             return probeIntervalInSeconds == null ? defaultVal : probeIntervalInSeconds;
326         }
327     }
328
329     @Getter
330     @Setter
331     @NoArgsConstructor
332     public static class ArtifactTypeConfig {
333
334         private List<String> acceptedTypes;
335         private List<String> validForResourceTypes;
336     }
337
338     @Getter
339     @Setter
340     @NoArgsConstructor
341     @ToString
342     public static class OnboardingConfig {
343
344         private String protocol = "http";
345         private String host;
346         private Integer port;
347         private String downloadCsarUri;
348         @ToString.Exclude
349         private String healthCheckUri;
350     }
351
352     @Getter
353     @Setter
354     @NoArgsConstructor
355     public static class BasicAuthConfig {
356
357         private boolean enabled;
358         private String userName;
359         private String userPass;
360         private String excludedUrls;
361     }
362
363     @Getter
364     @Setter
365     @NoArgsConstructor
366     @ToString(onlyExplicitlyIncluded = true)
367     public static class EcompPortalConfig {
368
369         private String protocol = "https";
370         private String host;
371         private Integer port;
372         private String healthCheckUri;
373         @ToString.Include
374         private String defaultFunctionalMenu;
375         private Integer pollingInterval;
376         private Integer timeoutMs;
377     }
378
379     @Getter
380     @Setter
381     @NoArgsConstructor
382     @ToString
383     public static class ApplicationL1CacheConfig {
384
385         private ApplicationL1CacheInfo datatypes;
386     }
387
388     @Getter
389     @Setter
390     @NoArgsConstructor
391     @ToString
392     public static class ApplicationL2CacheConfig {
393
394         private boolean enabled;
395         private ApplicationL1CacheCatalogInfo catalogL1Cache;
396         @ToString.Exclude
397         private QueueInfo queue;
398     }
399
400     @Getter
401     @Setter
402     @NoArgsConstructor
403     @ToString
404     public static class ToscaValidatorsConfig {
405
406         private Integer stringMaxLength;
407     }
408
409     @Getter
410     @Setter
411     @NoArgsConstructor
412     @ToString
413     public static class ApplicationL1CacheInfo {
414
415         private Boolean enabled;
416         private Integer firstRunDelay;
417         private Integer pollIntervalInSec;
418     }
419
420     @Getter
421     @Setter
422     @NoArgsConstructor
423     @ToString
424     public static class ApplicationL1CacheCatalogInfo {
425
426         private Boolean enabled;
427         private Integer resourcesSizeInCache;
428         private Integer servicesSizeInCache;
429         private Integer productsSizeInCache;
430     }
431
432     @Getter
433     @Setter
434     @NoArgsConstructor
435     @ToString
436     public static class QueueInfo {
437
438         private Integer waitOnShutDownInMinutes;
439         private Integer syncIntervalInSecondes;
440         private Integer numberOfCacheWorkers;
441     }
442
443     @Getter
444     @Setter
445     @NoArgsConstructor
446     public static class EnvironmentContext {
447
448         private String defaultValue;
449         private List<String> validValues;
450     }
451
452     @Getter
453     @Setter
454     @NoArgsConstructor
455     public static class VfModuleProperty {
456
457         private String forBaseModule;
458         private String forNonBaseModule;
459     }
460
461     @Getter
462     @Setter
463     @NoArgsConstructor
464     public static class PathsAndNamesDefinition {
465
466         private String friendlyName;
467         private String path;
468         private Boolean searchable;
469     }
470
471     @Getter
472     @Setter
473     @NoArgsConstructor
474     public static class GabConfig {
475
476         private String artifactType;
477         private List<PathsAndNamesDefinition> pathsAndNamesDefinitions;
478     }
479 }