diff --git a/components/apimgt/org.wso2.carbon.apimgt.common.analytics/src/main/java/org/wso2/carbon/apimgt/common/analytics/publishers/dto/enums/FaultSubCategories.java b/components/apimgt/org.wso2.carbon.apimgt.common.analytics/src/main/java/org/wso2/carbon/apimgt/common/analytics/publishers/dto/enums/FaultSubCategories.java index 9f001019becb..9ae16ab0ca3b 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.common.analytics/src/main/java/org/wso2/carbon/apimgt/common/analytics/publishers/dto/enums/FaultSubCategories.java +++ b/components/apimgt/org.wso2.carbon.apimgt.common.analytics/src/main/java/org/wso2/carbon/apimgt/common/analytics/publishers/dto/enums/FaultSubCategories.java @@ -28,6 +28,8 @@ public enum Other implements FaultSubCategory { MEDIATION_ERROR, RESOURCE_NOT_FOUND, METHOD_NOT_ALLOWED, + INVALID_REQUEST_SCHEMA, + INVALID_RESPONSE_SCHEMA, UNCLASSIFIED } diff --git a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/analytics/FaultCodeClassifier.java b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/analytics/FaultCodeClassifier.java index 7cbeed25a635..174d2d327e55 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/analytics/FaultCodeClassifier.java +++ b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/analytics/FaultCodeClassifier.java @@ -17,6 +17,7 @@ package org.wso2.carbon.apimgt.gateway.handlers.analytics; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.synapse.MessageContext; @@ -127,6 +128,10 @@ protected FaultSubCategory getOtherFaultSubCategory(int errorCode) { return FaultSubCategories.Other.METHOD_NOT_ALLOWED; } else if (isResourceNotFound()) { return FaultSubCategories.Other.RESOURCE_NOT_FOUND; + } else if (isRequestSchemaInvalid()) { + return FaultSubCategories.Other.INVALID_REQUEST_SCHEMA; + } else if (isResponseSchemaInvalid()) { + return FaultSubCategories.Other.INVALID_RESPONSE_SCHEMA; } else { return FaultSubCategories.Other.UNCLASSIFIED; } @@ -149,4 +154,24 @@ public boolean isMethodNotAllowed() { } return false; } + + private boolean isRequestSchemaInvalid() { + if (messageContext.getPropertyKeySet().contains(SynapseConstants.ERROR_DETAIL)) { + String errorDetail = (String) messageContext.getProperty(SynapseConstants.ERROR_DETAIL); + String errorMessage = "Schema validation failed in the Request: "; + return messageContext.getPropertyKeySet().contains(RESTConstants.PROCESSED_API) + && StringUtils.isNotEmpty(errorDetail) && errorDetail.contains(errorMessage); + } + return false; + } + + private boolean isResponseSchemaInvalid() { + if (messageContext.getPropertyKeySet().contains(SynapseConstants.ERROR_DETAIL)) { + String errorDetail = (String) messageContext.getProperty(SynapseConstants.ERROR_DETAIL); + String errorMessage = "Schema validation failed in the Response: "; + return messageContext.getPropertyKeySet().contains(RESTConstants.PROCESSED_API) + && StringUtils.isNotEmpty(errorDetail) && errorDetail.contains(errorMessage); + } + return false; + } } diff --git a/features/apimgt/org.wso2.carbon.apimgt.rest.api.service.catalog.feature/src/main/resources/runtimes/cxf3/snakeyaml-2.0.jar b/features/apimgt/org.wso2.carbon.apimgt.rest.api.service.catalog.feature/src/main/resources/runtimes/cxf3/snakeyaml-2.0.jar new file mode 100644 index 000000000000..469b0430e4bd Binary files /dev/null and b/features/apimgt/org.wso2.carbon.apimgt.rest.api.service.catalog.feature/src/main/resources/runtimes/cxf3/snakeyaml-2.0.jar differ