21 #include "kinetic/status_code.h"
25 using com::seagate::kinetic::client::proto::Command_Status_StatusCode;
26 using com::seagate::kinetic::client::proto::Command_Status_StatusCode_INVALID_STATUS_CODE;
27 using com::seagate::kinetic::client::proto::Command_Status_StatusCode_HMAC_FAILURE;
28 using com::seagate::kinetic::client::proto::Command_Status_StatusCode_NOT_AUTHORIZED;
29 using com::seagate::kinetic::client::proto::Command_Status_StatusCode_NOT_FOUND;
30 using com::seagate::kinetic::client::proto::Command_Status_StatusCode_INTERNAL_ERROR;
31 using com::seagate::kinetic::client::proto::Command_Status_StatusCode_HEADER_REQUIRED;
32 using com::seagate::kinetic::client::proto::Command_Status_StatusCode_SUCCESS;
33 using com::seagate::kinetic::client::proto::Command_Status_StatusCode_VERSION_FAILURE;
34 using com::seagate::kinetic::client::proto::Command_Status_StatusCode_VERSION_MISMATCH;
35 using com::seagate::kinetic::client::proto::Command_Status_StatusCode_SERVICE_BUSY;
36 using com::seagate::kinetic::client::proto::Command_Status_StatusCode_EXPIRED;
37 using com::seagate::kinetic::client::proto::Command_Status_StatusCode_DATA_ERROR;
38 using com::seagate::kinetic::client::proto::Command_Status_StatusCode_PERM_DATA_ERROR;
39 using com::seagate::kinetic::client::proto::Command_Status_StatusCode_REMOTE_CONNECTION_ERROR;
40 using com::seagate::kinetic::client::proto::Command_Status_StatusCode_NO_SPACE;
41 using com::seagate::kinetic::client::proto::Command_Status_StatusCode_NO_SUCH_HMAC_ALGORITHM;
42 using com::seagate::kinetic::client::proto::Command_Status_StatusCode_INVALID_REQUEST;
43 using com::seagate::kinetic::client::proto::Command_Status_StatusCode_NESTED_OPERATION_ERRORS;
45 StatusCode ConvertFromProtoStatus(Command_Status_StatusCode status) {
47 case Command_Status_StatusCode_SUCCESS:
48 return StatusCode::OK;
49 case Command_Status_StatusCode_HMAC_FAILURE:
50 return StatusCode::REMOTE_HMAC_ERROR;
51 case Command_Status_StatusCode_NOT_AUTHORIZED:
52 return StatusCode::REMOTE_NOT_AUTHORIZED;
53 case Command_Status_StatusCode_VERSION_FAILURE:
54 return StatusCode::REMOTE_CLUSTER_VERSION_MISMATCH;
55 case Command_Status_StatusCode_INTERNAL_ERROR:
56 return StatusCode::REMOTE_INTERNAL_ERROR;
57 case Command_Status_StatusCode_HEADER_REQUIRED:
58 return StatusCode::REMOTE_HEADER_REQUIRED;
59 case Command_Status_StatusCode_NOT_FOUND:
60 return StatusCode::REMOTE_NOT_FOUND;
61 case Command_Status_StatusCode_VERSION_MISMATCH:
62 return StatusCode::REMOTE_VERSION_MISMATCH;
63 case Command_Status_StatusCode_SERVICE_BUSY:
64 return StatusCode::REMOTE_SERVICE_BUSY;
65 case Command_Status_StatusCode_EXPIRED:
66 return StatusCode::REMOTE_EXPIRED;
67 case Command_Status_StatusCode_DATA_ERROR:
68 return StatusCode::REMOTE_DATA_ERROR;
69 case Command_Status_StatusCode_PERM_DATA_ERROR:
70 return StatusCode::REMOTE_PERM_DATA_ERROR;
71 case Command_Status_StatusCode_REMOTE_CONNECTION_ERROR:
72 return StatusCode::REMOTE_REMOTE_CONNECTION_ERROR;
73 case Command_Status_StatusCode_NO_SPACE:
74 return StatusCode::REMOTE_NO_SPACE;
75 case Command_Status_StatusCode_NO_SUCH_HMAC_ALGORITHM:
76 return StatusCode::REMOTE_NO_SUCH_HMAC_ALGORITHM;
77 case Command_Status_StatusCode_INVALID_REQUEST:
78 return StatusCode::REMOTE_INVALID_REQUEST;
79 case Command_Status_StatusCode_INVALID_STATUS_CODE:
80 return StatusCode::CLIENT_INTERNAL_ERROR;
81 case Command_Status_StatusCode_NESTED_OPERATION_ERRORS:
82 return StatusCode::REMOTE_NESTED_OPERATION_ERRORS;
84 return StatusCode::REMOTE_OTHER_ERROR;
88 Command_Status_StatusCode ConvertToProtoStatus(StatusCode status) {
91 return Command_Status_StatusCode_SUCCESS;
92 case StatusCode::REMOTE_HMAC_ERROR:
93 return Command_Status_StatusCode_HMAC_FAILURE;
94 case StatusCode::REMOTE_NOT_AUTHORIZED:
95 return Command_Status_StatusCode_NOT_AUTHORIZED;
96 case StatusCode::REMOTE_CLUSTER_VERSION_MISMATCH:
97 return Command_Status_StatusCode_VERSION_FAILURE;
98 case StatusCode::REMOTE_INTERNAL_ERROR:
99 return Command_Status_StatusCode_INTERNAL_ERROR;
100 case StatusCode::REMOTE_HEADER_REQUIRED:
101 return Command_Status_StatusCode_HEADER_REQUIRED;
102 case StatusCode::REMOTE_NOT_FOUND:
103 return Command_Status_StatusCode_NOT_FOUND;
104 case StatusCode::REMOTE_VERSION_MISMATCH:
105 return Command_Status_StatusCode_VERSION_MISMATCH;
106 case StatusCode::REMOTE_SERVICE_BUSY:
107 return Command_Status_StatusCode_SERVICE_BUSY;
108 case StatusCode::REMOTE_EXPIRED:
109 return Command_Status_StatusCode_EXPIRED;
110 case StatusCode::REMOTE_DATA_ERROR:
111 return Command_Status_StatusCode_DATA_ERROR;
112 case StatusCode::REMOTE_PERM_DATA_ERROR:
113 return Command_Status_StatusCode_PERM_DATA_ERROR;
114 case StatusCode::REMOTE_REMOTE_CONNECTION_ERROR:
115 return Command_Status_StatusCode_REMOTE_CONNECTION_ERROR;
116 case StatusCode::REMOTE_NO_SPACE:
117 return Command_Status_StatusCode_NO_SPACE;
118 case StatusCode::REMOTE_NO_SUCH_HMAC_ALGORITHM:
119 return Command_Status_StatusCode_NO_SUCH_HMAC_ALGORITHM;
120 case StatusCode::REMOTE_INVALID_REQUEST:
121 return Command_Status_StatusCode_INVALID_REQUEST;
122 case StatusCode::REMOTE_NESTED_OPERATION_ERRORS:
123 return Command_Status_StatusCode_NESTED_OPERATION_ERRORS;
125 return Command_Status_StatusCode_INTERNAL_ERROR;