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=========================================================
20 package org.openecomp.sdc.be.model.operations.impl;
22 import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus;
23 import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
24 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
26 public class DaoStatusConverter {
28 public static StorageOperationStatus convertJanusGraphStatusToStorageStatus(JanusGraphOperationStatus janusGraphStatus) {
29 if (janusGraphStatus == null) {
30 return StorageOperationStatus.GENERAL_ERROR;
32 switch (janusGraphStatus) {
34 return StorageOperationStatus.OK;
36 return StorageOperationStatus.CONNECTION_FAILURE;
38 return StorageOperationStatus.NOT_FOUND;
40 return StorageOperationStatus.SCHEMA_ERROR;
41 case INDEX_CANNOT_BE_CHANGED:
42 return StorageOperationStatus.SCHEMA_ERROR;
43 case MISSING_UNIQUE_ID:
44 return StorageOperationStatus.BAD_REQUEST;
46 return StorageOperationStatus.FAILED_TO_LOCK_ELEMENT;
47 case JANUSGRAPH_SCHEMA_VIOLATION:
48 return StorageOperationStatus.SCHEMA_VIOLATION;
50 return StorageOperationStatus.INVALID_ID;
52 return StorageOperationStatus.MATCH_NOT_FOUND;
53 case ILLEGAL_ARGUMENT:
54 return StorageOperationStatus.BAD_REQUEST;
56 return StorageOperationStatus.ENTITY_ALREADY_EXISTS;
57 case PROPERTY_NAME_ALREADY_EXISTS:
58 return StorageOperationStatus.PROPERTY_NAME_ALREADY_EXISTS;
59 case INVALID_PROPERTY:
60 return StorageOperationStatus.INVALID_PROPERTY;
62 return StorageOperationStatus.GENERAL_ERROR;
66 public static StorageOperationStatus convertCassandraStatusToStorageStatus(CassandraOperationStatus status) {
68 return StorageOperationStatus.GENERAL_ERROR;
72 return StorageOperationStatus.OK;
73 case CLUSTER_NOT_CONNECTED:
74 return StorageOperationStatus.CONNECTION_FAILURE;
75 case KEYSPACE_NOT_CONNECTED:
76 return StorageOperationStatus.STORAGE_NOT_AVAILABLE;
78 return StorageOperationStatus.NOT_FOUND;
80 return StorageOperationStatus.GENERAL_ERROR;