use of org.apache.synapse.debug.constructs.SynapseSequenceType in project wso2-synapse by wso2.
the class APIDebugUtil method registerAPISequenceMediationFlowBreakPoint.
/**
* Registers/Un-registers a breakpoint, point where mediation flow get suspended
*
* @param synCfg Synapse configuration
* @param mapping either resource url-mapping or uri-template
* @param method resource http method
* @param sequenceType Synapse sequence type
* @param apiKey name of the API
* @param position array of integers that uniquely specifies a point in mediation route
* @param registerMode specify whether register or un register
*/
public static void registerAPISequenceMediationFlowBreakPoint(SynapseConfiguration synCfg, String mapping, String method, String sequenceType, String apiKey, int[] position, boolean registerMode) {
SynapseSequenceType synapseSequenceType = SynapseSequenceType.valueOf(sequenceType.toUpperCase());
APIMediationFlowPoint breakPoint = new APIMediationFlowPoint();
breakPoint.setSynapseMediationComponent(SynapseMediationComponent.SEQUENCE);
breakPoint.setKey(apiKey);
breakPoint.setMediatorPosition(position);
breakPoint.setSynapseSequenceType(synapseSequenceType);
breakPoint.setSequenceBaseType(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE_API);
breakPoint.setResourceMapping(mapping);
breakPoint.setResourceHTTPMethod(method);
Mediator seqMediator = null;
Resource api_resource = null;
API api = synCfg.getAPI(apiKey);
if (api == null) {
if (log.isDebugEnabled()) {
log.debug("Non existing API for the key " + breakPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_API_NOT_FOUND).toString());
return;
}
Resource[] resource_array = api.getResources();
for (int counter = 0; counter < resource_array.length; counter++) {
if (resource_array[counter].getDispatcherHelper() != null && mapping != null) {
if (mapping.equals(resource_array[counter].getDispatcherHelper().getString())) {
for (String m1 : resource_array[counter].getMethods()) {
if (m1.equals(method)) {
api_resource = resource_array[counter];
break;
}
}
if (api_resource != null) {
break;
}
}
} else if (resource_array[counter].getDispatcherHelper() == null && mapping == null) {
for (String m1 : resource_array[counter].getMethods()) {
if (m1.equals(method)) {
api_resource = resource_array[counter];
break;
}
}
if (api_resource != null) {
break;
}
}
}
if (api_resource != null) {
if (synapseSequenceType.equals(SynapseSequenceType.API_INSEQ)) {
seqMediator = api_resource.getInSequence();
} else if (synapseSequenceType.equals(SynapseSequenceType.API_OUTSEQ)) {
seqMediator = api_resource.getOutSequence();
} else if (synapseSequenceType.equals(SynapseSequenceType.API_FAULTSEQ)) {
seqMediator = api_resource.getFaultSequence();
}
} else {
if (log.isDebugEnabled()) {
log.debug("Resource not found for the API key " + breakPoint.getKey() + " resource mapping " + breakPoint.getResourceMapping() + " resource HTTP method " + breakPoint.getResourceHTTPMethod());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_API_RESOURCE_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.info("Registered breakpoint at mediator position " + logMediatorPosition(breakPoint) + " for API key " + breakPoint.getKey() + " resource mapping " + breakPoint.getResourceMapping() + " resource HTTP method " + breakPoint.getResourceHTTPMethod() + " sequence type " + 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 API key " + breakPoint.getKey() + " resource mapping " + breakPoint.getResourceMapping() + " resource HTTP method " + breakPoint.getResourceHTTPMethod() + " sequence type " + 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 API key " + breakPoint.getKey() + " resource mapping " + breakPoint.getResourceMapping() + " resource HTTP method " + breakPoint.getResourceHTTPMethod() + " sequence type " + 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 API key " + breakPoint.getKey() + " resource mapping " + breakPoint.getResourceMapping() + " resource HTTP method " + breakPoint.getResourceHTTPMethod() + " sequence type " + 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 API key " + breakPoint.getKey() + " resource mapping " + breakPoint.getResourceMapping() + " resource HTTP method " + breakPoint.getResourceHTTPMethod() + " sequence type " + 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 API key " + breakPoint.getKey() + " resource mapping " + breakPoint.getResourceMapping() + " resource HTTP method " + breakPoint.getResourceHTTPMethod() + " sequence type " + 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 API key " + breakPoint.getKey() + " resource mapping " + breakPoint.getResourceMapping() + " resource HTTP method " + breakPoint.getResourceHTTPMethod());
}
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 API key " + breakPoint.getKey() + " resource mapping " + breakPoint.getResourceMapping() + " resource HTTP method " + breakPoint.getResourceHTTPMethod());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_SEQUENCE).toString());
}
}
}
use of org.apache.synapse.debug.constructs.SynapseSequenceType 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());
}
}
}
use of org.apache.synapse.debug.constructs.SynapseSequenceType 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());
}
}
}
use of org.apache.synapse.debug.constructs.SynapseSequenceType 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());
}
}
}
use of org.apache.synapse.debug.constructs.SynapseSequenceType in project wso2-synapse by wso2.
the class SequenceDebugUtil method registerSequenceMediationFlowBreakPoint.
/**
* Registers/Un-registers a skip, point where mediator disables from mediation flow
*
* @param synCfg Synapse configuration
* @param sequenceType Synapse sequence type
* @param seqKey name of the Sequence
* @param position array of integers that uniquely specifies a point in mediation route
* @param registerMode specify whether register or un register
*/
public static void registerSequenceMediationFlowBreakPoint(SynapseConfiguration synCfg, String sequenceType, String seqKey, int[] position, boolean registerMode) {
SynapseSequenceType synapseSequenceType = SynapseSequenceType.valueOf(sequenceType.toUpperCase());
SynapseMediationFlowPoint breakPoint = new SequenceMediationFlowPoint();
breakPoint.setSynapseMediationComponent(SynapseMediationComponent.SEQUENCE);
breakPoint.setKey(seqKey);
breakPoint.setMediatorPosition(position);
((SequenceMediationFlowPoint) breakPoint).setSynapseSequenceType(synapseSequenceType);
((SequenceMediationFlowPoint) breakPoint).setSequenceBaseType(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE);
Mediator seqMediator = null;
if (synapseSequenceType.equals(SynapseSequenceType.NAMED)) {
seqMediator = synCfg.getSequence(seqKey);
}
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 Sequence " + breakPoint.getKey());
}
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 Sequence " + breakPoint.getKey());
}
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 Sequence " + breakPoint.getKey());
}
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 Sequence " + breakPoint.getKey());
}
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 Sequence " + breakPoint.getKey());
}
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 Sequence " + breakPoint.getKey());
}
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 for 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 for key " + breakPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_SEQUENCE).toString());
}
}
}
Aggregations