|
18 | 18 |
|
19 | 19 | package org.wso2.carbon.apimgt.impl.restapi.publisher; |
20 | 20 |
|
21 | | -import org.wso2.carbon.apimgt.api.model.Backend; |
| 21 | +import org.wso2.carbon.apimgt.api.model.*; |
22 | 22 | import org.apache.http.client.HttpClient; |
23 | | -import org.wso2.carbon.apimgt.api.model.BackendOperation; |
24 | | -import org.wso2.carbon.apimgt.api.model.BackendOperationMapping; |
25 | 23 | import org.wso2.carbon.apimgt.impl.MCPInitializerAndToolFetcher; |
26 | 24 | import software.amazon.awssdk.core.exception.SdkClientException; |
27 | 25 | import com.fasterxml.jackson.core.type.TypeReference; |
|
53 | 51 | import org.wso2.carbon.apimgt.api.ExceptionCodes; |
54 | 52 | import org.wso2.carbon.apimgt.api.dto.APIEndpointValidationDTO; |
55 | 53 | import org.wso2.carbon.apimgt.api.dto.EnvironmentPropertiesDTO; |
56 | | -import org.wso2.carbon.apimgt.api.model.API; |
57 | | -import org.wso2.carbon.apimgt.api.model.APIIdentifier; |
58 | | -import org.wso2.carbon.apimgt.api.model.APIRevision; |
59 | | -import org.wso2.carbon.apimgt.api.model.APIRevisionDeployment; |
60 | | -import org.wso2.carbon.apimgt.api.model.Comment; |
61 | | -import org.wso2.carbon.apimgt.api.model.Environment; |
62 | | -import org.wso2.carbon.apimgt.api.model.ResourceFile; |
63 | | -import org.wso2.carbon.apimgt.api.model.Scope; |
64 | | -import org.wso2.carbon.apimgt.api.model.ServiceEntry; |
65 | | -import org.wso2.carbon.apimgt.api.model.SwaggerData; |
66 | | -import org.wso2.carbon.apimgt.api.model.Tier; |
67 | | -import org.wso2.carbon.apimgt.api.model.URITemplate; |
68 | | -import org.wso2.carbon.apimgt.api.model.VHost; |
69 | 54 | import org.wso2.carbon.apimgt.impl.APIConstants; |
70 | 55 | import org.wso2.carbon.apimgt.impl.dao.ApiMgtDAO; |
71 | 56 | import org.wso2.carbon.apimgt.impl.restapi.CommonUtils; |
@@ -1103,10 +1088,19 @@ public static APIRevisionDeployment mapAPIRevisionDeploymentWithValidation(Strin |
1103 | 1088 | String vhost, boolean mandatoryVHOST) |
1104 | 1089 | throws APIManagementException { |
1105 | 1090 |
|
1106 | | - if (environments.get(environment) == null) { |
| 1091 | + Environment env = environments.get(environment); |
| 1092 | + if (env == null) { |
1107 | 1093 | final String errorMessage = "Gateway environment not found: " + environment; |
1108 | 1094 | throw new APIManagementException(errorMessage, ExceptionCodes.from( |
1109 | 1095 | ExceptionCodes.INVALID_GATEWAY_ENVIRONMENT, String.format("name '%s'", environment))); |
| 1096 | + } else { |
| 1097 | + if (GatewayMode.READ_ONLY.getMode().equals(env.getMode())) { |
| 1098 | + final String errorMessage = "The mode of gateway environment : " + environment |
| 1099 | + + " is READ_ONLY. Cannot deploy revision"; |
| 1100 | + throw new APIManagementException(errorMessage, |
| 1101 | + ExceptionCodes.from(ExceptionCodes.READ_ONLY_MODE_GATEWAY_ENVIRONMENT, |
| 1102 | + String.format("name '%s'", environment))); |
| 1103 | + } |
1110 | 1104 | } |
1111 | 1105 |
|
1112 | 1106 | if (mandatoryVHOST && StringUtils.isEmpty(vhost)) { |
|
0 commit comments