<commit_before>/*******************************************************************************
 * Copyright  (c) 2015-2016, WSO2.Telco Inc. (http://www.wso2telco.com) All Rights Reserved.
 * 
 * WSO2.Telco Inc. licences this file to you under  the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package com.wso2telco.dep.oneapivalidation.service.impl.payment;


import org.json.JSONObject;

import com.wso2telco.dep.oneapivalidation.exceptions.CustomException;
import com.wso2telco.dep.oneapivalidation.service.IServiceValidate;
import com.wso2telco.dep.oneapivalidation.util.UrlValidator;
import com.wso2telco.dep.oneapivalidation.util.Validation;
import com.wso2telco.dep.oneapivalidation.util.ValidationRule;

 
// TODO: Auto-generated Javadoc
/**
 * The Class ValidateRefund.
 */
public class ValidateRefund implements IServiceValidate {

    /** The validation rules. */
    private final String[] validationRules = {"*", "transactions", "amount"};

    /* (non-Javadoc)
     * @see com.wso2telco.oneapivalidation.service.IServiceValidate#validate(java.lang.String)
     */
    public void validate(String json) throws CustomException {

        String clientCorrelator = null;
        String endUserId = null;
        Double amount = null;
        String currency = null;
        String description = null;
        String code = null;
        String onBehalfOf = null;
        String purchaseCategoryCode = null;
        String channel = null;
        Double taxAmount = null;
        String mandateId = null;
        String productId = null;
        String serviceId = null;
        String callbackData = null;
        String notifyURL = null;
        String referenceCode = null;
        String notificationFormat = null;
        String originalServerReferenceCode = null;
        String transactionOperationStatus = null;

        try {
            JSONObject objJSONObject = new JSONObject(json);
            JSONObject objAmountTransaction = (JSONObject) objJSONObject.get("amountTransaction");

            if (!objAmountTransaction.isNull("clientCorrelator") ) {
                clientCorrelator = nullOrTrimmed(objAmountTransaction.get("clientCorrelator").toString());
            }
            if (!objAmountTransaction.isNull("endUserId") ) {
                endUserId = nullOrTrimmed(objAmountTransaction.get("endUserId").toString());
            }
            if (!objAmountTransaction.isNull("callbackData") ) {
                callbackData = nullOrTrimmed(objAmountTransaction.get("callbackData").toString());
            }
            if (!objAmountTransaction.isNull("notifyURL") ) {
                notifyURL = nullOrTrimmed(objAmountTransaction.get("notifyURL").toString());
            }
            if (!objAmountTransaction.isNull("notificationFormat")) {
                notificationFormat = nullOrTrimmed(objAmountTransaction.get("notificationFormat").toString());
            }
            if (!objAmountTransaction.isNull("referenceCode") ) {
                referenceCode = nullOrTrimmed(objAmountTransaction.get("referenceCode").toString());
            }
            if (!objAmountTransaction.isNull("originalServerReferenceCode")) {
                originalServerReferenceCode = nullOrTrimmed(objAmountTransaction.get("originalServerReferenceCode").toString());
            }
            if (!objAmountTransaction.isNull("transactionOperationStatus") ) {
                transactionOperationStatus = nullOrTrimmed(objAmountTransaction.get("transactionOperationStatus").toString());
            }

            JSONObject objPaymentAmount = (JSONObject) objAmountTransaction.get("paymentAmount");
            JSONObject objChargingInformation = (JSONObject) objPaymentAmount.get("chargingInformation");

            if (!objChargingInformation.isNull("amount") ) {
                amount = Double.parseDouble(nullOrTrimmed(objChargingInformation.get("amount").toString()));
            }
            if (!objChargingInformation.isNull("currency")) {
                currency = nullOrTrimmed(objChargingInformation.get("currency").toString());
            }
            if (!objChargingInformation.isNull("description") ) {
                description = nullOrTrimmed(objChargingInformation.get("description").toString());
            }
            if (!objChargingInformation.isNull("code")) {
                code = nullOrTrimmed(objChargingInformation.get("code").toString());
            }

            JSONObject objChargingMetaData = (JSONObject) objPaymentAmount.get("chargingMetaData");
<commit_msg>bug fix for EXGW-20<commit_after>/*******************************************************************************
 * Copyright  (c) 2015-2016, WSO2.Telco Inc. (http://www.wso2telco.com) All Rights Reserved.
 * 
 * WSO2.Telco Inc. licences this file to you under  the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package com.wso2telco.dep.oneapivalidation.service.impl.payment;


import org.json.JSONObject;

import com.wso2telco.dep.oneapivalidation.exceptions.CustomException;
import com.wso2telco.dep.oneapivalidation.service.IServiceValidate;
import com.wso2telco.dep.oneapivalidation.util.UrlValidator;
import com.wso2telco.dep.oneapivalidation.util.Validation;
import com.wso2telco.dep.oneapivalidation.util.ValidationRule;

 
// TODO: Auto-generated Javadoc
/**
 * The Class ValidateRefund.
 */
public class ValidateRefund implements IServiceValidate {

    /** The validation rules. */
    private final String[] validationRules = {"*", "transactions", "amount"};

    /* (non-Javadoc)
     * @see com.wso2telco.oneapivalidation.service.IServiceValidate#validate(java.lang.String)
     */
    public void validate(String json) throws CustomException {

        String clientCorrelator = null;
        String endUserId = null;
        Double amount = null;
        String currency = null;
        String description = null;
        String code = null;
        String onBehalfOf = null;
        String purchaseCategoryCode = null;
        String channel = null;
        Double taxAmount = null;
        String mandateId = null;
        String productId = null;
        String serviceId = null;
        String callbackData = null;
        String notifyURL = null;
        String referenceCode = null;
        String notificationFormat = null;
        String originalServerReferenceCode = null;
        String transactionOperationStatus = null;

        try {
            JSONObject objJSONObject = new JSONObject(json);
            JSONObject objAmountTransaction = (JSONObject) objJSONObject.get("amountTransaction");

            if (!objAmountTransaction.isNull("clientCorrelator") ) {
                clientCorrelator = nullOrTrimmed(objAmountTransaction.get("clientCorrelator").toString());
            }
            if (!objAmountTransaction.isNull("endUserId") ) {
                endUserId = nullOrTrimmed(objAmountTransaction.get("endUserId").toString());
            }
            if (!objAmountTransaction.isNull("callbackData") ) {
                callbackData = nullOrTrimmed(objAmountTransaction.get("callbackData").toString());
            }
            if (!objAmountTransaction.isNull("notifyURL") ) {
                notifyURL = nullOrTrimmed(objAmountTransaction.get("notifyURL").toString());
            }
            if (!objAmountTransaction.isNull("notificationFormat")) {
                notificationFormat = nullOrTrimmed(objAmountTransaction.get("notificationFormat").toString());
            }
            if (!objAmountTransaction.isNull("referenceCode") ) {
                referenceCode = nullOrTrimmed(objAmountTransaction.get("referenceCode").toString());
            }
            if (!objAmountTransaction.isNull("originalServerReferenceCode")) {
                originalServerReferenceCode = nullOrTrimmed(objAmountTransaction.get("originalServerReferenceCode").toString());
            }
            if (!objAmountTransaction.isNull("transactionOperationStatus") ) {
                transactionOperationStatus = nullOrTrimmed(objAmountTransaction.get("transactionOperationStatus").toString());
            }

            JSONObject objPaymentAmount = (JSONObject) objAmountTransaction.get("paymentAmount");
            JSONObject objChargingInformation = (JSONObject) objPaymentAmount.get("chargingInformation");

            if (!objChargingInformation.isNull("amount") ) {
                if(nullOrTrimmed(objChargingInformation.get("amount").toString()) != null){
                    amount = Double.parseDouble(nullOrTrimmed(objChargingInformation.get("amount").toString()));
                }

            }
            if (!objChargingInformation.isNull("currency")) {
                currency = nullOrTrimmed(objChargingInformation.get("currency").toString());
            }
            if (!objChargingInformation.isNull("description") ) {
                description = nullOrTrimmed(objChargingInformation.get("description").toString());
            }
            if (!objChargingInformation.isNull("code")) {
                code = nullOrTrimmed(objChargingInformation.get("code").toString());
            }

            JSONObject objChargingMetaData = (JSONObject) objPaymentAmount.get("chargingMetaData");

{'fraction_non_alphanumeric': 0.12839864537977747, 'fraction_numerical': 0.004450895016932753, 'mean_word_length': 3.0950871632329635, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6083544', 'n_tokens_mistral': 2636, 'n_tokens_neox': 2503, 'n_words': 531}