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.model.operations.impl;
23 import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus;
24 import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
25 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
27 public class DaoStatusConverter {
29 public static StorageOperationStatus convertTitanStatusToStorageStatus(TitanOperationStatus titanStatus) {
31 if (titanStatus == null) {
32 return StorageOperationStatus.GENERAL_ERROR;
35 switch (titanStatus) {
38 return StorageOperationStatus.OK;
41 return StorageOperationStatus.CONNECTION_FAILURE;
44 return StorageOperationStatus.NOT_FOUND;
47 return StorageOperationStatus.SCHEMA_ERROR;
49 case INDEX_CANNOT_BE_CHANGED:
50 return StorageOperationStatus.SCHEMA_ERROR;
52 case MISSING_UNIQUE_ID:
53 return StorageOperationStatus.BAD_REQUEST;
55 return StorageOperationStatus.FAILED_TO_LOCK_ELEMENT;
57 case TITAN_SCHEMA_VIOLATION:
58 return StorageOperationStatus.SCHEMA_VIOLATION;
61 return StorageOperationStatus.INVALID_ID;
63 return StorageOperationStatus.MATCH_NOT_FOUND;
65 case ILLEGAL_ARGUMENT:
66 return StorageOperationStatus.BAD_REQUEST;
68 return StorageOperationStatus.ENTITY_ALREADY_EXISTS;
69 case PROPERTY_NAME_ALREADY_EXISTS:
70 return StorageOperationStatus.PROPERTY_NAME_ALREADY_EXISTS;
71 case INVALID_PROPERTY:
72 return StorageOperationStatus.INVALID_PROPERTY;
74 return StorageOperationStatus.GENERAL_ERROR;
79 public static StorageOperationStatus convertCassandraStatusToStorageStatus(CassandraOperationStatus status) {
81 return StorageOperationStatus.GENERAL_ERROR;
85 return StorageOperationStatus.OK;
86 case CLUSTER_NOT_CONNECTED:
87 return StorageOperationStatus.CONNECTION_FAILURE;
88 case KEYSPACE_NOT_CONNECTED:
89 return StorageOperationStatus.STORAGE_NOT_AVAILABLE;
91 return StorageOperationStatus.NOT_FOUND;
94 return StorageOperationStatus.GENERAL_ERROR;