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.log.wrappers.Logger;
25 public class ErrorInfo {
28 private String message;
29 private String messageId;
30 private ErrorInfoType errorInfoType;
32 private static final String SVC_PREFIX = "SVC";
33 private static final String POL_PREFIX = "POL";
35 private static Logger log = Logger.getLogger(ErrorInfo.class.getName());
38 this.errorInfoType = ErrorInfoType.OK;
41 public Integer getCode() {
45 public void setCode(Integer code) {
49 public String getMessage() {
53 public void setMessage(String message) {
54 this.message = message;
57 public String getMessageId() {
61 public void setMessageId(String messageId) {
62 // Determining the type of error
63 if (messageId == null) {
64 this.errorInfoType = ErrorInfoType.OK;
65 } else if (messageId.startsWith(SVC_PREFIX)) {
66 this.errorInfoType = ErrorInfoType.SERVICE_EXCEPTION;
67 } else if (messageId.startsWith(POL_PREFIX)) {
68 this.errorInfoType = ErrorInfoType.POLICY_EXCEPTION;
70 // unexpected - should it fail the startup?
71 BeEcompErrorManager.getInstance().logErrorConfigFileFormat("Error Info",
72 "Could not set error info type for message id " + messageId);
73 log.debug("Error: unexpected error message ID {}, should start with {} or {}", messageId, SVC_PREFIX,
76 this.messageId = messageId;
79 public ErrorInfoType getErrorInfoType() {
80 return this.errorInfoType;
83 public void cloneData(ErrorInfo other) {
84 this.code = other.getCode();
85 this.message = other.getMessage();
86 this.messageId = other.getMessageId();
87 this.errorInfoType = other.errorInfoType;
91 public String toString() {
92 return "ErrorInfo [code=" + code + ", messageId=" + messageId + ", message=" + message + "]";
95 public enum ErrorInfoType {
96 OK, POLICY_EXCEPTION, SERVICE_EXCEPTION