Catalog alignment
[sdc.git] / common-app-api / src / main / java / org / openecomp / sdc / be / config / BeEcompErrorManager.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
21 package org.openecomp.sdc.be.config;
22
23 import org.openecomp.sdc.common.config.AbsEcompErrorManager;
24 import org.openecomp.sdc.common.config.EcompErrorEnum;
25 import org.openecomp.sdc.common.config.IEcompConfigurationManager;
26
27 public class BeEcompErrorManager extends AbsEcompErrorManager {
28
29         public enum ComponentName {
30                 SERVICE, PRODUCT, VF
31         }
32
33         public enum ErrorSeverity {
34                 INFO, WARNING, ERROR, FATAL
35         }
36
37         private static volatile BeEcompErrorManager instance;
38         private static ConfigurationManager configurationManager;
39
40         private BeEcompErrorManager() {
41         };
42
43         public static BeEcompErrorManager getInstance() {
44                 if (instance == null) {
45                         synchronized (BeEcompErrorManager.class){
46                                 if (instance == null)
47                                         instance = init();
48                         }
49                 }
50                 return instance;
51         }
52
53         private static synchronized BeEcompErrorManager init() {
54                 if (instance == null) {
55                         instance = new BeEcompErrorManager();
56                         configurationManager = ConfigurationManager.getConfigurationManager();
57                 }
58                 return instance;
59         }
60
61         @Override
62         public IEcompConfigurationManager getConfigurationManager() {
63                 return configurationManager;
64         }
65
66         public void logBeUebAuthenticationError(String context, String reason) {
67                 processEcompError(context, EcompErrorEnum.BeUebAuthenticationError, reason);
68         }
69
70         public void logBeHealthCheckRecovery(String context) {
71                 processEcompError(context, EcompErrorEnum.BeHealthCheckRecovery);
72         }
73
74         public void logBeHealthCheckJanusGraphRecovery(String context) {
75                 processEcompError(context, EcompErrorEnum.BeHealthCheckJanusGraphRecovery);
76         }
77
78         public void logBeHealthCheckUebClusterRecovery(String context) {
79                 processEcompError(context, EcompErrorEnum.BeHealthCheckUebClusterRecovery);
80         }
81
82         public void logDmaapHealthCheckError(String context) {
83                 processEcompError(context, EcompErrorEnum.DmaapHealthCheckError);
84         }
85
86         public void logUserSessionExpiredError(String context) {
87                 processEcompError(context, EcompErrorEnum.SessionExpiredAuthenticationError);
88         }
89
90         public void logDmaapHealthCheckRecovery(String context) {
91                 processEcompError(context, EcompErrorEnum.DmaapHealthCheckRecovery);
92         }
93
94         public void logFeHealthCheckRecovery(String context) {
95                 processEcompError(context, EcompErrorEnum.FeHealthCheckRecovery);
96         }
97
98         public void logBeHealthCheckError(String context) {
99                 processEcompError(context, EcompErrorEnum.BeHealthCheckError);
100         }
101
102         public void logBeHealthCheckJanusGraphError(String context) {
103                 processEcompError(context, EcompErrorEnum.BeHealthCheckJanusGraphError);
104         }
105
106         public void logBeHealthCheckUebClusterError(String context) {
107                 processEcompError(context, EcompErrorEnum.BeHealthCheckUebClusterError);
108         }
109
110         public void logFeHealthCheckError(String context) {
111                 processEcompError(context, EcompErrorEnum.FeHealthCheckError);
112         }
113
114         /**
115          * @param context
116          * @param reason
117          */
118         public void logBeUebConnectionError(String context, String reason) {
119                 processEcompError(context, EcompErrorEnum.BeUebConnectionError, reason);
120         }
121
122         public void logBeUebUnkownHostError(String context, String host) {
123                 processEcompError(context, EcompErrorEnum.BeUebUnkownHostError, host);
124         }
125
126         public void logBeComponentMissingError(String context, String componentType, String name) {
127                 processEcompError(context, EcompErrorEnum.BeComponentMissingError, componentType, name);
128         }
129
130         public void logBeIncorrectComponentError(String context, String componentType, String name) {
131                 processEcompError(context, EcompErrorEnum.BeIncorrectComponentError, componentType, name);
132         }
133
134         public void logBeInvalidConfigurationError(String context, String parameterName, String parameterValue) {
135                 processEcompError(context, EcompErrorEnum.BeInvalidConfigurationError, parameterName, parameterValue);
136         }
137
138         public void logBeUebObjectNotFoundError(String context, String notFoundObjectName) {
139                 processEcompError(context, EcompErrorEnum.BeUebObjectNotFoundError, notFoundObjectName);
140         }
141
142         public void logBeDistributionEngineInvalidArtifactType(String context, String artifactType,
143                         String validArtifactTypes) {
144                 processEcompError(context, EcompErrorEnum.BeDistributionEngineInvalidArtifactType, artifactType,
145                                 validArtifactTypes);
146         }
147
148         public void logBeMissingConfigurationError(String context, String parameterName) {
149                 processEcompError(context, EcompErrorEnum.BeMissingConfigurationError, parameterName);
150         }
151
152         public void logBeConfigurationInvalidListSizeError(String context, String parameterName, int listMinimumSize) {
153                 processEcompError(context, EcompErrorEnum.BeConfigurationInvalidListSizeError, parameterName,
154                                 String.valueOf(listMinimumSize));
155         }
156
157         public void logErrorConfigFileFormat(String context, String description) {
158                 processEcompError(context, EcompErrorEnum.ErrorConfigFileFormat, description);
159         }
160
161         public void logBeMissingArtifactInformationError(String context, String missingInfo) {
162                 processEcompError(context, EcompErrorEnum.BeMissingArtifactInformationError, missingInfo);
163         }
164
165         public void logBeArtifactMissingError(String context, String artifactName) {
166                 processEcompError(context, EcompErrorEnum.BeArtifactMissingError, artifactName);
167         }
168
169         public void logBeUserMissingError(String context, String userId) {
170                 processEcompError(context, EcompErrorEnum.BeUserMissingError, userId);
171         }
172
173         public void logBeInvalidTypeError(String context, String type, String name) {
174                 processEcompError(context, EcompErrorEnum.BeInvalidTypeError, type, name);
175         }
176
177         public void logBeInvalidValueError(String context, String value, String name, String type) {
178                 processEcompError(context, EcompErrorEnum.BeInvalidValueError, value, name, type);
179         }
180
181         public void logBeArtifactPayloadInvalid(String context) {
182                 processEcompError(context, EcompErrorEnum.BeArtifactPayloadInvalid);
183         }
184
185         public void logBeArtifactInformationInvalidError(String context) {
186                 processEcompError(context, EcompErrorEnum.BeArtifactInformationInvalidError);
187         }
188
189         public void logBeDistributionMissingError(String context, String distributionName) {
190                 processEcompError(context, EcompErrorEnum.BeDistributionMissingError, "Distribution", distributionName);
191         }
192
193         public void logBeGraphObjectMissingError(String context, String objectType, String objectName) {
194                 processEcompError(context, EcompErrorEnum.BeGraphObjectMissingError, objectType, objectName);
195         }
196
197         public void logBeInvalidJsonInput(String context) {
198                 processEcompError(context, EcompErrorEnum.BeInvalidJsonInput);
199         }
200
201         public void logBeInitializationError(String context) {
202                 processEcompError(context, EcompErrorEnum.BeInitializationError);
203         }
204
205         public void logBeFailedAddingResourceInstanceError(String context, String resourceName, String serviceId) {
206                 processEcompError(context, EcompErrorEnum.BeFailedAddingResourceInstanceError, resourceName, serviceId);
207         }
208
209         public void logBeUebSystemError(String context, String operation) {
210                 processEcompError(context, EcompErrorEnum.BeUebSystemError, operation);
211         }
212
213         public void logBeDistributionEngineSystemError(String context, String operation) {
214                 processEcompError(context, EcompErrorEnum.BeDistributionEngineSystemError, operation);
215         }
216
217         public void logBeFailedAddingNodeTypeError(String context, String nodeType) {
218                 processEcompError(context, EcompErrorEnum.BeFailedAddingNodeTypeError, nodeType);
219         }
220
221         public void logBeDaoSystemError(String context) {
222                 processEcompError(context, EcompErrorEnum.BeDaoSystemError);
223         }
224
225         public void logBeSystemError(String context) {
226                 processEcompError(context, EcompErrorEnum.BeSystemError);
227         }
228
229         public void logBeExecuteRollbackError(String context) {
230                 processEcompError(context, EcompErrorEnum.BeExecuteRollbackError);
231         }
232
233         public void logBeFailedLockObjectError(String context, String type, String id) {
234                 processEcompError(context, EcompErrorEnum.BeFailedLockObjectError, type, id);
235         }
236
237         public void logBeFailedCreateNodeError(String context, String nodeName, String status) {
238                 processEcompError(context, EcompErrorEnum.BeFailedCreateNodeError, nodeName, status);
239         }
240
241         public void logBeFailedUpdateNodeError(String context, String nodeName, String status) {
242                 processEcompError(context, EcompErrorEnum.BeFailedUpdateNodeError, nodeName, status);
243         }
244
245         public void logBeFailedDeleteNodeError(String context, String nodeName, String status) {
246                 processEcompError(context, EcompErrorEnum.BeFailedDeleteNodeError, nodeName, status);
247         }
248
249         public void logBeFailedRetrieveNodeError(String context, String nodeName, String status) {
250                 processEcompError(context, EcompErrorEnum.BeFailedRetrieveNodeError, nodeName, status);
251         }
252
253         public void logBeFailedFindParentError(String context, String node, String status) {
254                 processEcompError(context, EcompErrorEnum.BeFailedFindParentError, node, status);
255         }
256
257         public void logBeFailedFindAllNodesError(String context, String nodeType, String parentNode, String status) {
258                 processEcompError(context, EcompErrorEnum.BeFailedFindAllNodesError, nodeType, parentNode, status);
259         }
260
261         public void logBeFailedFindAssociationError(String context, String nodeType, String fromNode, String status) {
262                 processEcompError(context, EcompErrorEnum.BeFailedFindAssociationError, nodeType, fromNode, status);
263         }
264
265         public void logBeComponentCleanerSystemError(String context, String operation) {
266                 processEcompError(context, EcompErrorEnum.BeComponentCleanerSystemError, operation);
267         }
268
269         public void logBeRestApiGeneralError(String context) {
270                 processEcompError(context, EcompErrorEnum.BeRestApiGeneralError);
271         }
272
273         public void logFqdnResolveError(String context, String description) {
274                 processEcompError(context, EcompErrorEnum.FqdnResolveError, description);
275         }
276
277         public void logSiteSwitchoverInfo(String context, String description) {
278                 processEcompError(context, EcompErrorEnum.SiteSwitchoverInfo, description);
279         }
280
281         public void logInternalAuthenticationError(String context, String description, ErrorSeverity severity) {
282
283                 if (severity == null) {
284                         processEcompError(context, EcompErrorEnum.InternalAuthenticationError, description);
285                 } else {
286                         switch (severity) {
287                         case INFO:
288                                 processEcompError(context, EcompErrorEnum.InternalAuthenticationInfo, description);
289                                 break;
290                         case WARNING:
291                                 processEcompError(context, EcompErrorEnum.InternalAuthenticationWarning, description);
292                                 break;
293                         case ERROR:
294                                 processEcompError(context, EcompErrorEnum.InternalAuthenticationError, description);
295                                 break;
296                         case FATAL:
297                                 processEcompError(context, EcompErrorEnum.InternalAuthenticationFatal, description);
298                                 break;
299
300                         default:
301                                 break;
302                         }
303                 }
304
305         }
306
307         public void logInternalConnectionError(String context, String description, ErrorSeverity severity) {
308
309                 if (severity == null) {
310                         processEcompError(context, EcompErrorEnum.InternalConnectionError, description);
311                 } else {
312                         switch (severity) {
313                         case INFO:
314                                 processEcompError(context, EcompErrorEnum.InternalConnectionInfo, description);
315                                 break;
316                         case WARNING:
317                                 processEcompError(context, EcompErrorEnum.InternalConnectionWarning, description);
318                                 break;
319                         case ERROR:
320                                 processEcompError(context, EcompErrorEnum.InternalConnectionError, description);
321                                 break;
322                         case FATAL:
323                                 processEcompError(context, EcompErrorEnum.InternalConnectionFatal, description);
324                                 break;
325
326                         default:
327                                 break;
328                         }
329                 }
330
331         }
332
333         public void logInternalDataError(String context, String description, ErrorSeverity severity) {
334
335                 if (severity == null) {
336                         processEcompError(context, EcompErrorEnum.InternalDataError, description);
337                 } else {
338                         switch (severity) {
339                         case INFO:
340                                 processEcompError(context, EcompErrorEnum.InternalDataInfo, description);
341                                 break;
342                         case WARNING:
343                                 processEcompError(context, EcompErrorEnum.InternalDataWarning, description);
344                                 break;
345                         case ERROR:
346                                 processEcompError(context, EcompErrorEnum.InternalDataError, description);
347                                 break;
348                         case FATAL:
349                                 processEcompError(context, EcompErrorEnum.InternalDataFatal, description);
350                                 break;
351
352                         default:
353                                 break;
354                         }
355                 }
356
357         }
358
359         public void logInvalidInputError(String context, String description, ErrorSeverity severity) {
360
361                 if (severity == null) {
362                         processEcompError(context, EcompErrorEnum.InvalidInputError, description);
363                 } else {
364                         switch (severity) {
365                         case INFO:
366                                 processEcompError(context, EcompErrorEnum.InvalidInputWarning, description);
367                                 break;
368                         case WARNING:
369                                 processEcompError(context, EcompErrorEnum.InvalidInputInfo, description);
370                                 break;
371                         case ERROR:
372                                 processEcompError(context, EcompErrorEnum.InvalidInputError, description);
373                                 break;
374                         case FATAL:
375                                 processEcompError(context, EcompErrorEnum.InvalidInputFatal, description);
376                                 break;
377
378                         default:
379                                 break;
380                         }
381                 }
382
383         }
384
385         public void logInternalFlowError(String context, String description, ErrorSeverity severity) {
386
387                 if (severity == null) {
388                         processEcompError(context, EcompErrorEnum.InternalFlowError, description);
389                 } else {
390                         switch (severity) {
391                         case INFO:
392                                 processEcompError(context, EcompErrorEnum.InternalFlowInfo, description);
393                                 break;
394                         case WARNING:
395                                 processEcompError(context, EcompErrorEnum.InternalFlowWarning, description);
396                                 break;
397                         case ERROR:
398                                 processEcompError(context, EcompErrorEnum.InternalFlowError, description);
399                                 break;
400                         case FATAL:
401                                 processEcompError(context, EcompErrorEnum.InternalFlowFatal, description);
402                                 break;
403
404                         default:
405                                 break;
406                         }
407                 }
408
409         }
410
411         public void logInternalUnexpectedError(String context, String description, ErrorSeverity severity) {
412
413                 if (severity == null) {
414                         processEcompError(context, EcompErrorEnum.InternalUnexpectedError, description);
415                 } else {
416                         switch (severity) {
417                         case INFO:
418                                 processEcompError(context, EcompErrorEnum.InternalUnexpectedInfo, description);
419                                 break;
420                         case WARNING:
421                                 processEcompError(context, EcompErrorEnum.InternalUnexpectedWarning, description);
422                                 break;
423                         case ERROR:
424                                 processEcompError(context, EcompErrorEnum.InternalUnexpectedError, description);
425                                 break;
426                         case FATAL:
427                                 processEcompError(context, EcompErrorEnum.InternalUnexpectedFatal, description);
428                                 break;
429
430                         default:
431                                 break;
432                         }
433                 }
434
435         }
436
437 }