re base code
[sdc.git] / catalog-model / src / main / java / org / openecomp / sdc / be / model / operations / impl / Neo4jStatusConverter.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.model.operations.impl;
22
23 import org.openecomp.sdc.be.dao.neo4j.Neo4jOperationStatus;
24 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
25
26 public class Neo4jStatusConverter {
27
28     public static StorageOperationStatus convertNeo4jStatusToStorageStatus(Neo4jOperationStatus neo4jStatus) {
29
30         if (neo4jStatus == null) {
31             return StorageOperationStatus.GENERAL_ERROR;
32         }
33
34         switch (neo4jStatus) {
35
36         case OK:
37             return StorageOperationStatus.OK;
38
39         case NOT_CONNECTED:
40             return StorageOperationStatus.CONNECTION_FAILURE;
41
42         case NOT_AUTHORIZED:
43             return StorageOperationStatus.PERMISSION_ERROR;
44
45         case HTTP_PROTOCOL_ERROR:
46             return StorageOperationStatus.HTTP_PROTOCOL_ERROR;
47         case DB_NOT_AVAILABLE:
48             return StorageOperationStatus.STORAGE_NOT_AVAILABLE;
49         case DB_READ_ONLY:
50             return StorageOperationStatus.READ_ONLY_STORAGE;
51         case BAD_REQUEST:
52             return StorageOperationStatus.BAD_REQUEST;
53         case LEGACY_INDEX_ERROR:
54             return StorageOperationStatus.STORAGE_LEGACY_INDEX_ERROR;
55         case SCHEMA_ERROR:
56             return StorageOperationStatus.SCHEMA_ERROR;
57         case TRANSACTION_ERROR:
58             return StorageOperationStatus.TRANSACTION_ERROR;
59         case EXECUTION_FAILED:
60             return StorageOperationStatus.EXEUCTION_FAILED;
61         case ENTITY_ALREADY_EXIST:
62             return StorageOperationStatus.ENTITY_ALREADY_EXISTS;
63         case WRONG_INPUT:
64             return StorageOperationStatus.BAD_REQUEST;
65         case GENERAL_ERROR:
66             return StorageOperationStatus.GENERAL_ERROR;
67         case NOT_SUPPORTED:
68             return StorageOperationStatus.OPERATION_NOT_SUPPORTED;
69         case NOT_FOUND:
70             return StorageOperationStatus.NOT_FOUND;
71
72         default:
73             return StorageOperationStatus.GENERAL_ERROR;
74         }
75
76     }
77
78 }