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=========================================================
21 package org.openecomp.sdc.be.config;
23 import org.openecomp.sdc.common.config.EcompErrorName;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
27 public class ErrorInfo {
30 private String message;
31 private String messageId;
32 private ErrorInfoType errorInfoType;
34 private static final String SVC_PREFIX = "SVC";
35 private static final String POL_PREFIX = "POL";
37 private static Logger log = LoggerFactory.getLogger(ErrorInfo.class.getName());
40 this.errorInfoType = ErrorInfoType.OK;
43 public Integer getCode() {
47 public void setCode(Integer code) {
51 public String getMessage() {
55 public void setMessage(String message) {
56 this.message = message;
59 public String getMessageId() {
63 public void setMessageId(String messageId) {
64 // Determining the type of error
65 if (messageId == null) {
66 this.errorInfoType = ErrorInfoType.OK;
67 } else if (messageId.startsWith(SVC_PREFIX)) {
68 this.errorInfoType = ErrorInfoType.SERVICE_EXCEPTION;
69 } else if (messageId.startsWith(POL_PREFIX)) {
70 this.errorInfoType = ErrorInfoType.POLICY_EXCEPTION;
72 // unexpected - should it fail the startup?
73 BeEcompErrorManager.getInstance().logErrorConfigFileFormat("Error Info",
74 "Could not set error info type for message id " + messageId);
75 log.debug("Error: unexpected error message ID {}, should start with {} or {}", messageId, SVC_PREFIX,
78 this.messageId = messageId;
81 public ErrorInfoType getErrorInfoType() {
82 return this.errorInfoType;
85 public void cloneData(ErrorInfo other) {
86 this.code = other.getCode();
87 this.message = other.getMessage();
88 this.messageId = other.getMessageId();
89 this.errorInfoType = other.errorInfoType;
93 public String toString() {
94 return "ErrorInfo [code=" + code + ", messageId=" + messageId + ", message=" + message + "]";
97 public enum ErrorInfoType {
98 OK, POLICY_EXCEPTION, SERVICE_EXCEPTION