Skip to content

Commit 4d2406d

Browse files
Resolve review comments
1 parent f5e4f0c commit 4d2406d

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

Diff for: components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/ExceptionCodes.java

+1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ public enum ExceptionCodes implements ErrorHandler {
122122
CANNOT_CREATE_API_VERSION(900362, "New API Version cannot be created from a different provider", 409, "Initial provider of an API must be preserved in all versions of that API"),
123123
INTERNAL_ERROR_WHILE_UPDATING_API(900363, "Internal Server Error occurred while updating the API", 500, "Internal Server Error. '%s'"),
124124
ERROR_WHILE_UPDATING_MANDATORY_PROPERTIES(903010, "Error while updating required properties", 400, "Error while updating required properties."),
125+
ERROR_WHILE_VALIDATING_MANDATORY_PROPERTIES(903015, "Error while validating required properties", 400, "Error while validating required properties."),
125126

126127
//Lifecycle related codes
127128
API_UPDATE_FORBIDDEN_PER_LC(900380, "Insufficient permission to update the API", 403,

Diff for: components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIProviderImpl.java

+13-15
Original file line numberDiff line numberDiff line change
@@ -3342,21 +3342,6 @@ public APIStateChangeResponse changeLifeCycleStatus(String orgId, ApiTypeWrapper
33423342
boolean isApiProduct = apiTypeWrapper.isAPIProduct();
33433343
String workflowType;
33443344

3345-
if (!apiTypeWrapper.isAPIProduct()){
3346-
// validate custom API properties
3347-
if (StringUtils.equals(action, APIConstants.LC_PUBLISH_LC_STATE)) {
3348-
org.json.simple.JSONArray customProperties = APIUtil.getCustomProperties(this.tenantDomain);
3349-
List<String> errorProperties = APIUtil.validateMandatoryProperties(customProperties,
3350-
apiTypeWrapper.getApi().getAdditionalProperties());
3351-
3352-
if (!errorProperties.isEmpty()) {
3353-
String errorString = " : " + String.join(", ", errorProperties);
3354-
throw new APIManagementException(errorString, ExceptionCodes.from(ExceptionCodes
3355-
.ERROR_WHILE_UPDATING_MANDATORY_PROPERTIES));
3356-
}
3357-
}
3358-
}
3359-
33603345
if (isApiProduct) {
33613346
APIProduct apiProduct = apiTypeWrapper.getApiProduct();
33623347
providerName = apiProduct.getId().getProviderName();
@@ -3369,6 +3354,19 @@ public APIStateChangeResponse changeLifeCycleStatus(String orgId, ApiTypeWrapper
33693354
apiOrApiProductId = apiMgtDAO.getAPIProductId(apiTypeWrapper.getApiProduct().getId());
33703355
workflowType = WorkflowConstants.WF_TYPE_AM_API_PRODUCT_STATE;
33713356
} else {
3357+
// validate mandatory API properties
3358+
if (StringUtils.equals(action, APIConstants.LC_PUBLISH_LC_STATE)) {
3359+
org.json.simple.JSONArray customProperties = APIUtil.getCustomProperties(this.tenantDomain);
3360+
List<String> errorProperties = APIUtil.validateMandatoryProperties(customProperties,
3361+
apiTypeWrapper.getApi().getAdditionalProperties());
3362+
3363+
if (!errorProperties.isEmpty()) {
3364+
String errorString = " : " + String.join(", ", errorProperties);
3365+
throw new APIManagementException(errorString, ExceptionCodes.from(ExceptionCodes
3366+
.ERROR_WHILE_VALIDATING_MANDATORY_PROPERTIES));
3367+
}
3368+
}
3369+
33723370
API api = apiTypeWrapper.getApi();
33733371
providerName = api.getId().getProviderName();
33743372
apiName = api.getId().getApiName();

Diff for: components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils/APIUtil.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -11606,7 +11606,7 @@ public static void validateApiWithFederatedGateway(API api) throws APIManagement
1160611606
/**
1160711607
* This method is used to validate the mandatory custom properties of an API
1160811608
*
11609-
* @param customProperties custom properties of the API
11609+
* @param customProperties custom properties of the API
1161011610
* @param additionalPropertiesMap additional properties to validate
1161111611
* @return list of erroneous property names. returns an empty array if there are no errors.
1161211612
*/

0 commit comments

Comments
 (0)