CSIT Fix for SDC-2585
[sdc.git] / catalog-dao / src / main / java / org / openecomp / sdc / be / dao / neo4j / Neo4jOperationStatus.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.dao.neo4j;
22
23 public enum Neo4jOperationStatus {
24
25         OK, NOT_CONNECTED, NOT_AUTHORIZED, HTTP_PROTOCOL_ERROR, DB_NOT_AVAILABLE, DB_READ_ONLY, BAD_REQUEST, LEGACY_INDEX_ERROR, SCHEMA_ERROR, TRANSACTION_ERROR, EXECUTION_FAILED, ENTITY_ALREADY_EXIST,
26
27         WRONG_INPUT, GENERAL_ERROR, NOT_SUPPORTED, NOT_FOUND;
28
29         private String originError;
30         private String message;
31         private String helpErrorMsg;
32
33         private static final String NA = "NA";
34
35         Neo4jOperationStatus() {
36                 originError = NA;
37                 message = NA;
38                 helpErrorMsg = NA;
39         }
40
41         public Neo4jOperationStatus setOriginError(String originError) {
42                 this.originError = originError;
43                 return this;
44         }
45
46         public Neo4jOperationStatus setMessage(String message) {
47                 if (message != null && !message.isEmpty()) {
48                         this.message = message;
49                 }
50                 return this;
51         }
52
53         public Neo4jOperationStatus setHelpErrorMsg(String helpErrorMsg) {
54                 this.helpErrorMsg = helpErrorMsg;
55                 return this;
56         }
57
58         public String getOriginError() {
59                 return originError;
60         }
61
62         public String getMessage() {
63                 return message;
64         }
65
66         public String getHelpErrorMsg() {
67                 return helpErrorMsg;
68         }
69
70         public String printError() {
71                 StringBuilder sb = new StringBuilder();
72                 sb.append("[").append(toString()).append("-").append(originError).append("-").append(helpErrorMsg).append("-")
73                                 .append(message).append("]");
74                 return sb.toString();
75         }
76
77 }