Search in sources :

Example 1 with SequenceMediationFlowPoint

use of org.apache.synapse.debug.constructs.SequenceMediationFlowPoint in project wso2-synapse by wso2.

the class InboundEndpointDebugUtil method registerInboundSequenceMediationFlowBreakPoint.

/**
 * Registers/Un-registers a breakpoint, point where mediation flow get suspended
 *
 * @param synCfg Synapse configuration
 * @param sequenceType Synapse sequence type
 * @param inboundKey name of the Inbound Endpoint
 * @param position array of integers that uniquely specifies a point in mediation route
 * @param registerMode specify whether register or un register
 */
public static void registerInboundSequenceMediationFlowBreakPoint(SynapseConfiguration synCfg, String sequenceType, String inboundKey, int[] position, boolean registerMode) {
    SynapseSequenceType synapseSequenceType = SynapseSequenceType.valueOf(sequenceType.toUpperCase());
    SequenceMediationFlowPoint breakPoint = new SequenceMediationFlowPoint();
    breakPoint.setSynapseMediationComponent(SynapseMediationComponent.SEQUENCE);
    breakPoint.setKey(inboundKey);
    breakPoint.setMediatorPosition(position);
    breakPoint.setSequenceBaseType(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE_INBOUND);
    breakPoint.setSynapseSequenceType(synapseSequenceType);
    Mediator seqMediator = null;
    InboundEndpoint inbound = null;
    inbound = synCfg.getInboundEndpoint(inboundKey);
    if (inbound != null) {
        if (synapseSequenceType.equals(SynapseSequenceType.INBOUND_SEQ)) {
            seqMediator = synCfg.getSequence(inbound.getInjectingSeq());
        } else if (synapseSequenceType.equals(SynapseSequenceType.INBOUND_FAULTSEQ)) {
            seqMediator = synCfg.getSequence(inbound.getOnErrorSeq());
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("Non existing Inbound Endpoint for key " + breakPoint.getKey());
        }
        debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_INBOUND_NOT_FOUND).toString());
        return;
    }
    if (seqMediator != null) {
        Mediator current_mediator = null;
        current_mediator = MediatorTreeTraverseUtil.getMediatorReference(synCfg, seqMediator, position);
        if (current_mediator != null) {
            breakPoint.setMediatorReference(current_mediator);
            if (registerMode) {
                if (!((AbstractMediator) current_mediator).isBreakPoint()) {
                    ((AbstractMediator) current_mediator).setBreakPoint(true);
                    ((AbstractMediator) current_mediator).registerMediationFlowPoint(breakPoint);
                    if (log.isDebugEnabled()) {
                        log.debug("Registered breakpoint at mediator position " + logMediatorPosition(breakPoint) + " for Inbound Endpoint key " + breakPoint.getKey() + " sequence " + breakPoint.getSynapseSequenceType().toString());
                    }
                    debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(true, null).toString());
                } else {
                    if (log.isDebugEnabled()) {
                        log.debug("Failed register breakpoint. Already breakpoint enabled at mediator position " + logMediatorPosition(breakPoint) + " for Inbound Endpoint key " + breakPoint.getKey() + " sequence " + breakPoint.getSynapseSequenceType().toString());
                    }
                    debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_ALREADY_BREAKPOINT_ENABLED).toString());
                }
            } else {
                if (((AbstractMediator) current_mediator).isBreakPoint()) {
                    ((AbstractMediator) current_mediator).unregisterMediationFlowPoint();
                    ((AbstractMediator) current_mediator).setBreakPoint(false);
                    if (log.isDebugEnabled()) {
                        log.debug("Unregistered breakpoint at mediator position " + logMediatorPosition(breakPoint) + " for Inbound Endpoint key " + breakPoint.getKey() + " sequence " + breakPoint.getSynapseSequenceType().toString());
                    }
                    debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(true, null).toString());
                } else {
                    if (log.isDebugEnabled()) {
                        log.debug("Failed unregister breakpoint. Already breakpoint disabled at mediator position " + logMediatorPosition(breakPoint) + " for Inbound Endpoint key " + breakPoint.getKey() + " sequence " + breakPoint.getSynapseSequenceType().toString());
                    }
                    debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_ALREADY_BREAKPOINT_DISABLED).toString());
                }
            }
        } else {
            if (registerMode) {
                if (log.isDebugEnabled()) {
                    log.debug("Failed register breakpoint. Non existing mediator position at " + logMediatorPosition(breakPoint) + " for Inbound Endpoint key " + breakPoint.getKey() + " sequence " + breakPoint.getSynapseSequenceType().toString());
                }
                debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_MEDIATOR_POSITION).toString());
            } else {
                if (log.isDebugEnabled()) {
                    log.debug("Failed unregister breakpoint. Non existing mediator position at " + logMediatorPosition(breakPoint) + " for Inbound Endpoint key " + breakPoint.getKey() + " sequence " + breakPoint.getSynapseSequenceType().toString());
                }
                debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_MEDIATOR_POSITION).toString());
            }
        }
    } else {
        if (registerMode) {
            if (log.isDebugEnabled()) {
                log.debug("Failed register breakpoint. Non existing sequence " + breakPoint.getSynapseSequenceType().toString() + " for Inbound Endpoint key " + breakPoint.getKey());
            }
            debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_SEQUENCE).toString());
        } else {
            if (log.isDebugEnabled()) {
                log.debug("Failed unregister breakpoint. Non existing sequence " + breakPoint.getSynapseSequenceType().toString() + " for Inbound Endpoint key " + breakPoint.getKey());
            }
            debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_SEQUENCE).toString());
        }
    }
}
Also used : SequenceMediationFlowPoint(org.apache.synapse.debug.constructs.SequenceMediationFlowPoint) InboundEndpoint(org.apache.synapse.inbound.InboundEndpoint) SynapseSequenceType(org.apache.synapse.debug.constructs.SynapseSequenceType) AbstractMediator(org.apache.synapse.mediators.AbstractMediator) Mediator(org.apache.synapse.Mediator) AbstractMediator(org.apache.synapse.mediators.AbstractMediator)

Example 2 with SequenceMediationFlowPoint

use of org.apache.synapse.debug.constructs.SequenceMediationFlowPoint in project wso2-synapse by wso2.

the class ProxyDebugUtil method registerProxySequenceMediationFlowSkip.

/**
 * Registers/Un-registers a skip, point where mediator disables from medation flow
 *
 * @param synCfg Synapse configuration
 * @param seqType Synapse sequence type
 * @param proxyKey name of the Proxy Service
 * @param position array of integers that uniquely specifies a point in mediation route
 * @param registerMode specify whether register or un register
 */
public static void registerProxySequenceMediationFlowSkip(SynapseConfiguration synCfg, String seqType, String proxyKey, int[] position, boolean registerMode) {
    SynapseSequenceType synapseSequenceType = SynapseSequenceType.valueOf(seqType.toUpperCase());
    SequenceMediationFlowPoint skipPoint = new SequenceMediationFlowPoint();
    skipPoint.setSynapseMediationComponent(SynapseMediationComponent.SEQUENCE);
    skipPoint.setKey(proxyKey);
    skipPoint.setMediatorPosition(position);
    skipPoint.setSequenceBaseType(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE_PROXY);
    skipPoint.setSynapseSequenceType(synapseSequenceType);
    Mediator seqMediator = null;
    ProxyService proxy = null;
    proxy = synCfg.getProxyService(proxyKey);
    if (proxy != null) {
        if (synapseSequenceType.equals(SynapseSequenceType.PROXY_INSEQ)) {
            seqMediator = proxy.getTargetInLineInSequence();
        } else if (synapseSequenceType.equals(SynapseSequenceType.PROXY_OUTSEQ)) {
            seqMediator = proxy.getTargetInLineOutSequence();
        } else if (synapseSequenceType.equals(SynapseSequenceType.PROXY_FAULTSEQ)) {
            seqMediator = proxy.getTargetInLineFaultSequence();
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("Non existing Proxy for key " + skipPoint.getKey());
        }
        debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_PROXY_NOT_FOUND).toString());
        return;
    }
    if (seqMediator != null) {
        Mediator current_mediator = null;
        current_mediator = MediatorTreeTraverseUtil.getMediatorReference(synCfg, seqMediator, position);
        if (current_mediator != null) {
            skipPoint.setMediatorReference(current_mediator);
            if (registerMode) {
                if (!((AbstractMediator) current_mediator).isSkipEnabled()) {
                    ((AbstractMediator) current_mediator).setSkipEnabled(true);
                    ((AbstractMediator) current_mediator).registerMediationFlowPoint(skipPoint);
                    if (log.isDebugEnabled()) {
                        log.debug("Registered skip at mediator position " + logMediatorPosition(skipPoint) + " for Proxy key " + skipPoint.getKey() + " Sequence " + skipPoint.getSynapseSequenceType().toString());
                    }
                    debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(true, null).toString());
                } else {
                    if (log.isDebugEnabled()) {
                        log.debug("Failed register skip. Already skip enabled at mediator position " + logMediatorPosition(skipPoint) + " for Proxy key " + skipPoint.getKey() + " Sequence " + skipPoint.getSynapseSequenceType().toString());
                    }
                    debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_ALREADY_SKIP_ENABLED).toString());
                }
            } else {
                if (((AbstractMediator) current_mediator).isSkipEnabled()) {
                    ((AbstractMediator) current_mediator).unregisterMediationFlowPoint();
                    ((AbstractMediator) current_mediator).setSkipEnabled(false);
                    if (log.isDebugEnabled()) {
                        log.debug("Unregistered skip at mediator position " + logMediatorPosition(skipPoint) + " for Proxy key " + skipPoint.getKey() + " Sequence " + skipPoint.getSynapseSequenceType().toString());
                    }
                    debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(true, null).toString());
                } else {
                    if (log.isDebugEnabled()) {
                        log.debug("Failed unregister skip. Already skip disabled at mediator position " + logMediatorPosition(skipPoint) + " for Proxy key " + skipPoint.getKey() + " Sequence " + skipPoint.getSynapseSequenceType().toString());
                    }
                    debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_ALREADY_SKIP_DISABLED).toString());
                }
            }
        } else {
            if (registerMode) {
                if (log.isDebugEnabled()) {
                    log.debug("Failed register skip. Non existing mediator position at " + logMediatorPosition(skipPoint) + " for Proxy key " + skipPoint.getKey() + " Sequence " + skipPoint.getSynapseSequenceType().toString());
                }
                debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_MEDIATOR_POSITION).toString());
            } else {
                if (log.isDebugEnabled()) {
                    log.debug("Failed unregister skip. Non existing mediator position at " + logMediatorPosition(skipPoint) + " for Proxy key " + skipPoint.getKey() + " Sequence " + skipPoint.getSynapseSequenceType().toString());
                }
                debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_MEDIATOR_POSITION).toString());
            }
        }
    } else {
        if (registerMode) {
            if (log.isDebugEnabled()) {
                log.debug("Failed register skip. Non existing sequence " + skipPoint.getSynapseSequenceType().toString() + " for Proxy key " + skipPoint.getKey());
            }
            debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_SEQUENCE).toString());
        } else {
            if (log.isDebugEnabled()) {
                log.debug("Failed unregister skip. Non existing sequence " + skipPoint.getSynapseSequenceType().toString() + " for Proxy key " + skipPoint.getKey());
            }
            debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_SEQUENCE).toString());
        }
    }
}
Also used : SequenceMediationFlowPoint(org.apache.synapse.debug.constructs.SequenceMediationFlowPoint) SynapseSequenceType(org.apache.synapse.debug.constructs.SynapseSequenceType) ProxyService(org.apache.synapse.core.axis2.ProxyService) AbstractMediator(org.apache.synapse.mediators.AbstractMediator) Mediator(org.apache.synapse.Mediator) AbstractMediator(org.apache.synapse.mediators.AbstractMediator)

Example 3 with SequenceMediationFlowPoint

use of org.apache.synapse.debug.constructs.SequenceMediationFlowPoint in project wso2-synapse by wso2.

the class ProxyDebugUtil method registerProxySequenceMediationFlowBreakPoint.

/**
 * Registers/Un-registers a breakpoint, point where mediation flow get suspended
 *
 * @param synCfg Synapse configuration
 * @param sequenceType Synapse sequence type
 * @param proxyKey name of the Proxy Service
 * @param position array of integers that uniquely specifies a point in mediation route
 * @param registerMode specify whether register or un register
 */
public static void registerProxySequenceMediationFlowBreakPoint(SynapseConfiguration synCfg, String sequenceType, String proxyKey, int[] position, boolean registerMode) {
    SynapseSequenceType synapseSequenceType = SynapseSequenceType.valueOf(sequenceType.toUpperCase());
    SequenceMediationFlowPoint breakPoint = new SequenceMediationFlowPoint();
    breakPoint.setSynapseMediationComponent(SynapseMediationComponent.SEQUENCE);
    breakPoint.setKey(proxyKey);
    breakPoint.setMediatorPosition(position);
    breakPoint.setSequenceBaseType(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE_PROXY);
    breakPoint.setSynapseSequenceType(synapseSequenceType);
    Mediator seqMediator = null;
    ProxyService proxy = null;
    proxy = synCfg.getProxyService(proxyKey);
    if (proxy != null) {
        if (synapseSequenceType.equals(SynapseSequenceType.PROXY_INSEQ)) {
            seqMediator = proxy.getTargetInLineInSequence();
        } else if (synapseSequenceType.equals(SynapseSequenceType.PROXY_OUTSEQ)) {
            seqMediator = proxy.getTargetInLineOutSequence();
        } else if (synapseSequenceType.equals(SynapseSequenceType.PROXY_FAULTSEQ)) {
            seqMediator = proxy.getTargetInLineFaultSequence();
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("Non existing Proxy for the key " + breakPoint.getKey());
        }
        debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_PROXY_NOT_FOUND).toString());
        return;
    }
    if (seqMediator != null) {
        Mediator current_mediator = null;
        current_mediator = MediatorTreeTraverseUtil.getMediatorReference(synCfg, seqMediator, position);
        if (current_mediator != null) {
            breakPoint.setMediatorReference(current_mediator);
            if (registerMode) {
                if (!((AbstractMediator) current_mediator).isBreakPoint()) {
                    ((AbstractMediator) current_mediator).setBreakPoint(true);
                    ((AbstractMediator) current_mediator).registerMediationFlowPoint(breakPoint);
                    if (log.isDebugEnabled()) {
                        log.debug("Registered breakpoint at mediator position " + logMediatorPosition(breakPoint) + " for Proxy key " + breakPoint.getKey() + " Sequence " + breakPoint.getSynapseSequenceType().toString());
                    }
                    debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(true, null).toString());
                } else {
                    if (log.isDebugEnabled()) {
                        log.debug("Failed register breakpoint. Already breakpoint enabled at mediator position " + logMediatorPosition(breakPoint) + " for Proxy key " + breakPoint.getKey() + " Sequence " + breakPoint.getSynapseSequenceType().toString());
                    }
                    debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_ALREADY_BREAKPOINT_ENABLED).toString());
                }
            } else {
                if (((AbstractMediator) current_mediator).isBreakPoint()) {
                    ((AbstractMediator) current_mediator).unregisterMediationFlowPoint();
                    ((AbstractMediator) current_mediator).setBreakPoint(false);
                    if (log.isDebugEnabled()) {
                        log.debug("Unregistered breakpoint at mediator position " + logMediatorPosition(breakPoint) + " for Proxy key " + breakPoint.getKey() + " Sequence " + breakPoint.getSynapseSequenceType().toString());
                    }
                    debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(true, null).toString());
                } else {
                    if (log.isDebugEnabled()) {
                        log.debug("Failed unregister breakpoint. Already breakpoint disabled at mediator position " + logMediatorPosition(breakPoint) + " for Proxy key " + breakPoint.getKey() + " Sequence " + breakPoint.getSynapseSequenceType().toString());
                    }
                    debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_ALREADY_BREAKPOINT_DISABLED).toString());
                }
            }
        } else {
            if (registerMode) {
                if (log.isDebugEnabled()) {
                    log.debug("Failed register breakpoint. Non existing mediator position at " + logMediatorPosition(breakPoint) + " for Proxy key " + breakPoint.getKey() + " Sequence " + breakPoint.getSynapseSequenceType().toString());
                }
                debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_MEDIATOR_POSITION).toString());
            } else {
                if (log.isDebugEnabled()) {
                    log.debug("Failed unregister breakpoint. Non existing mediator position at " + logMediatorPosition(breakPoint) + " for Proxy key " + breakPoint.getKey() + " Sequence " + breakPoint.getSynapseSequenceType().toString());
                }
                debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_MEDIATOR_POSITION).toString());
            }
        }
    } else {
        if (registerMode) {
            if (log.isDebugEnabled()) {
                log.debug("Failed register breakpoint. Non existing sequence " + breakPoint.getSynapseSequenceType().toString() + " for Proxy key " + breakPoint.getKey());
            }
            debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_SEQUENCE).toString());
        } else {
            if (log.isDebugEnabled()) {
                log.debug("Failed unregister breakpoint. Non existing sequence " + breakPoint.getSynapseSequenceType().toString() + " for Proxy key " + breakPoint.getKey());
            }
            debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_SEQUENCE).toString());
        }
    }
}
Also used : SequenceMediationFlowPoint(org.apache.synapse.debug.constructs.SequenceMediationFlowPoint) SynapseSequenceType(org.apache.synapse.debug.constructs.SynapseSequenceType) ProxyService(org.apache.synapse.core.axis2.ProxyService) AbstractMediator(org.apache.synapse.mediators.AbstractMediator) Mediator(org.apache.synapse.Mediator) AbstractMediator(org.apache.synapse.mediators.AbstractMediator)

Example 4 with SequenceMediationFlowPoint

use of org.apache.synapse.debug.constructs.SequenceMediationFlowPoint in project wso2-synapse by wso2.

the class SynapseDebugManager method createDebugMediationFlowPointJSONForWireLogs.

/**
 * This method is to generate json string which can be used to identify mediator position for wire logs
 *
 * @param point
 * @return
 */
public JSONObject createDebugMediationFlowPointJSONForWireLogs(SynapseMediationFlowPoint point) {
    JSONObject flowPointJson = null;
    try {
        flowPointJson = new JSONObject();
        JSONObject parameters = new JSONObject();
        if (point.getSynapseMediationComponent().equals(SynapseMediationComponent.SEQUENCE)) {
            flowPointJson.put(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT, SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE);
            if (((SequenceMediationFlowPoint) point).getSequenceBaseType().equals(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE)) {
                parameters.put(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE_KEY, point.getKey());
                parameters.put(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE_TYPE, ((SequenceMediationFlowPoint) point).getSynapseSequenceType().toString().toLowerCase());
                parameters.put(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_MEDIATOR_POSITION, toString(point.getMediatorPosition()));
                flowPointJson.put(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE, parameters);
            } else if (((SequenceMediationFlowPoint) point).getSequenceBaseType().equals(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE_PROXY)) {
                JSONObject proxy_parameters = new JSONObject();
                proxy_parameters.put(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE_PROXY_KEY, point.getKey());
                proxy_parameters.put(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE_TYPE, ((SequenceMediationFlowPoint) point).getSynapseSequenceType().toString().toLowerCase());
                proxy_parameters.put(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_MEDIATOR_POSITION, toString(point.getMediatorPosition()));
                parameters.put(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE_PROXY, proxy_parameters);
                flowPointJson.put(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE, parameters);
            } else if (((SequenceMediationFlowPoint) point).getSequenceBaseType().equals(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE_INBOUND)) {
                JSONObject inbound_parameters = new JSONObject();
                inbound_parameters.put(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE_INBOUND_KEY, point.getKey());
                inbound_parameters.put(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE_TYPE, ((SequenceMediationFlowPoint) point).getSynapseSequenceType().toString().toLowerCase());
                inbound_parameters.put(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_MEDIATOR_POSITION, toString(point.getMediatorPosition()));
                parameters.put(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE_INBOUND, inbound_parameters);
                flowPointJson.put(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE, parameters);
            } else if (((SequenceMediationFlowPoint) point).getSequenceBaseType().equals(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE_API)) {
                JSONObject api_parameters = new JSONObject();
                api_parameters.put(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE_API_KEY, point.getKey());
                JSONObject resource = new JSONObject();
                resource.put(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE_API_RESOURCE_MAPPING, ((APIMediationFlowPoint) point).getResourceMapping());
                resource.put(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE_API_RESOURCE_METHOD, ((APIMediationFlowPoint) point).getResourceHTTPMethod());
                api_parameters.put(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE_API_RESOURCE, resource);
                api_parameters.put(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE_TYPE, ((SequenceMediationFlowPoint) point).getSynapseSequenceType().toString().toLowerCase());
                api_parameters.put(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_MEDIATOR_POSITION, toString(point.getMediatorPosition()));
                parameters.put(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE_API, api_parameters);
                flowPointJson.put(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE, parameters);
            }
        } else if (point.getSynapseMediationComponent().equals(SynapseMediationComponent.TEMPLATE)) {
            flowPointJson.put(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT, SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_TEMPLATE);
            parameters.put(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_TEMPLATE_KEY, point.getKey());
            parameters.put(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_MEDIATOR_POSITION, toString(point.getMediatorPosition()));
            flowPointJson.put(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_TEMPLATE, parameters);
        } else if (point.getSynapseMediationComponent().equals(SynapseMediationComponent.CONNECTOR)) {
            flowPointJson.put(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT, SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_CONNECTOR);
            parameters.put(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_CONNECTOR_KEY, point.getKey());
            parameters.put(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_CONNECTOR_METHOD, ((ConnectorMediationFlowPoint) point).getConnectorMediationComponentMethod());
            parameters.put(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_MEDIATOR_POSITION, toString(point.getMediatorPosition()));
            flowPointJson.put(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_CONNECTOR, parameters);
        }
    } catch (JSONException ex) {
        log.error("Failed to create debug flowPointJson in JSON format", ex);
    }
    return flowPointJson;
}
Also used : SequenceMediationFlowPoint(org.apache.synapse.debug.constructs.SequenceMediationFlowPoint) JSONObject(org.codehaus.jettison.json.JSONObject) APIMediationFlowPoint(org.apache.synapse.debug.constructs.APIMediationFlowPoint) JSONException(org.codehaus.jettison.json.JSONException)

Example 5 with SequenceMediationFlowPoint

use of org.apache.synapse.debug.constructs.SequenceMediationFlowPoint in project wso2-synapse by wso2.

the class SynapseDebugManager method logMediatorPosition.

protected String logMediatorPosition(SynapseMediationFlowPoint flowPoint) {
    String log = "";
    String position = "";
    for (int count = 0; count < flowPoint.getMediatorPosition().length; count++) {
        if (count != 0) {
            position = position.concat("-->");
        }
        position = position.concat("(" + String.valueOf(flowPoint.getMediatorPosition()[count]) + ")");
    }
    log = log.concat("mediator position " + position);
    if (flowPoint instanceof SequenceMediationFlowPoint) {
        log = log.concat(" " + ((SequenceMediationFlowPoint) flowPoint).getSequenceBaseType().toString() + " " + flowPoint.getKey());
        log = log.concat(" sequence " + ((SequenceMediationFlowPoint) flowPoint).getSynapseSequenceType().toString().toLowerCase());
    } else {
        log = log.concat(" " + flowPoint.getSynapseMediationComponent().toString().toLowerCase() + " " + flowPoint.getKey());
    }
    return log;
}
Also used : SequenceMediationFlowPoint(org.apache.synapse.debug.constructs.SequenceMediationFlowPoint) SequenceMediationFlowPoint(org.apache.synapse.debug.constructs.SequenceMediationFlowPoint) APIMediationFlowPoint(org.apache.synapse.debug.constructs.APIMediationFlowPoint) ConnectorMediationFlowPoint(org.apache.synapse.debug.constructs.ConnectorMediationFlowPoint) SynapseMediationFlowPoint(org.apache.synapse.debug.constructs.SynapseMediationFlowPoint)

Aggregations

SequenceMediationFlowPoint (org.apache.synapse.debug.constructs.SequenceMediationFlowPoint)9 Mediator (org.apache.synapse.Mediator)6 SynapseSequenceType (org.apache.synapse.debug.constructs.SynapseSequenceType)6 AbstractMediator (org.apache.synapse.mediators.AbstractMediator)6 APIMediationFlowPoint (org.apache.synapse.debug.constructs.APIMediationFlowPoint)3 ProxyService (org.apache.synapse.core.axis2.ProxyService)2 SynapseMediationFlowPoint (org.apache.synapse.debug.constructs.SynapseMediationFlowPoint)2 InboundEndpoint (org.apache.synapse.inbound.InboundEndpoint)2 JSONException (org.codehaus.jettison.json.JSONException)2 JSONObject (org.codehaus.jettison.json.JSONObject)2 ConnectorMediationFlowPoint (org.apache.synapse.debug.constructs.ConnectorMediationFlowPoint)1