Search in sources :

Example 66 with Axis2MessageContext

use of org.apache.synapse.core.axis2.Axis2MessageContext in project wso2-synapse by wso2.

the class LoadbalanceEndpoint method sendToApplicationMember.

private void sendToApplicationMember(MessageContext synCtx, EndpointReference to, LoadbalanceFaultHandler faultHandler) {
    org.apache.axis2.context.MessageContext axis2MsgCtx = ((Axis2MessageContext) synCtx).getAxis2MessageContext();
    String transport = axis2MsgCtx.getTransportIn().getName();
    algorithm.setApplicationMembers(activeMembers);
    Member currentMember = algorithm.getNextApplicationMember(algorithmContext);
    faultHandler.setCurrentMember(currentMember);
    if (currentMember != null) {
        // URL rewrite
        if (transport.equals("http") || transport.equals("https")) {
            String address = to.getAddress();
            if (address.indexOf(":") != -1) {
                try {
                    address = new URL(address).getPath();
                } catch (MalformedURLException e) {
                    String msg = "URL " + address + " is malformed";
                    log.error(msg, e);
                    throw new SynapseException(msg, e);
                }
            }
            EndpointReference epr = new EndpointReference(transport + "://" + currentMember.getHostName() + ":" + ("http".equals(transport) ? currentMember.getHttpPort() : currentMember.getHttpsPort()) + address);
            synCtx.setTo(epr);
            if (failover) {
                synCtx.getEnvelope().build();
            }
            AddressEndpoint endpoint = new AddressEndpoint();
            EndpointDefinition definition = new EndpointDefinition();
            endpoint.setDefinition(definition);
            endpoint.init(synCtx.getEnvironment());
            endpoint.send(synCtx);
        } else {
            log.error("Cannot load balance for non-HTTP/S transport " + transport);
        }
    } else {
        // Remove the LoadbalanceFaultHandler
        synCtx.getFaultStack().pop();
        String msg = "No application members available";
        log.error(msg);
        throw new SynapseException(msg);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) SynapseException(org.apache.synapse.SynapseException) Member(org.apache.axis2.clustering.Member) URL(java.net.URL) Axis2MessageContext(org.apache.synapse.core.axis2.Axis2MessageContext) EndpointReference(org.apache.axis2.addressing.EndpointReference)

Example 67 with Axis2MessageContext

use of org.apache.synapse.core.axis2.Axis2MessageContext in project wso2-synapse by wso2.

the class RecipientListEndpoint method sendToEndpointList.

private void sendToEndpointList(MessageContext synCtx, List<Endpoint> children) {
    int i = 0;
    boolean foundEndpoint = false;
    // we should build the message, its should have the same behavior as clone mediator
    try {
        RelayUtils.buildMessage(((Axis2MessageContext) synCtx).getAxis2MessageContext(), false);
    } catch (Exception e) {
        handleException("Error while building message", e);
    }
    for (Endpoint childEndpoint : children) {
        if (childEndpoint.readyToSend()) {
            foundEndpoint = true;
            MessageContext newCtx = null;
            try {
                newCtx = MessageHelper.cloneMessageContext(synCtx);
            } catch (AxisFault e) {
                handleException("Error cloning the message context", e);
            }
            // Used when aggregating responses
            newCtx.setProperty(EIPConstants.MESSAGE_SEQUENCE, String.valueOf(i++) + EIPConstants.MESSAGE_SEQUENCE_DELEMITER + children.size());
            // evaluate the endpoint properties
            evaluateProperties(newCtx);
            newCtx.pushFaultHandler(this);
            try {
                childEndpoint.send(newCtx);
            } catch (SynapseException e) {
                String msg = "Child Endpoint " + (childEndpoint.getName() != null ? childEndpoint.getName() : SynapseConstants.ANONYMOUS_ENDPOINT) + " of Recipient List endpoint " + (getName() != null ? getName() : SynapseConstants.ANONYMOUS_ENDPOINT) + " encountered an error while sending the message";
                log.warn(msg);
                // continue sending message to rest of the child endpoints.
                continue;
            }
        }
    }
    if (!foundEndpoint) {
        String msg = "Recipient List endpoint : " + (getName() != null ? getName() : SynapseConstants.ANONYMOUS_ENDPOINT) + " - no ready child endpoints";
        log.warn(msg);
        informFailure(synCtx, SynapseConstants.ENDPOINT_RL_NONE_READY, msg);
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) SynapseException(org.apache.synapse.SynapseException) MessageContext(org.apache.synapse.MessageContext) Axis2MessageContext(org.apache.synapse.core.axis2.Axis2MessageContext) MalformedURLException(java.net.MalformedURLException) SynapseException(org.apache.synapse.SynapseException)

Example 68 with Axis2MessageContext

use of org.apache.synapse.core.axis2.Axis2MessageContext in project wso2-synapse by wso2.

the class RecipientListEndpoint method sendToApplicationMembers.

/**
 *<p>Iterates the <b>members</b> list, creates Address Endpoints
 * from each member element and routes cloned copies of the message
 * to each Address Endpoint.</p>
 * @param synCtx - The Original Message received by Synapse
 */
private void sendToApplicationMembers(MessageContext synCtx) {
    int i = 0;
    boolean foundEndpoint = false;
    for (Member member : members) {
        org.apache.axis2.context.MessageContext axis2MsgCtx = ((Axis2MessageContext) synCtx).getAxis2MessageContext();
        String transport = axis2MsgCtx.getTransportIn().getName();
        // If the transport is not HTTP nor HTTPS
        if (!transport.equals("http") && !transport.equals("https")) {
            // Skip member.
            log.error("Cannot deliver for non-HTTP/S transport " + transport);
            continue;
        }
        MessageContext newCtx = null;
        try {
            newCtx = MessageHelper.cloneMessageContext(synCtx);
        } catch (AxisFault e) {
            handleException("Error cloning the message context", e);
        }
        // Used when aggregating responses
        newCtx.setProperty(EIPConstants.MESSAGE_SEQUENCE, String.valueOf(i++) + EIPConstants.MESSAGE_SEQUENCE_DELEMITER + members.size());
        // evaluate the endpoint properties
        evaluateProperties(newCtx);
        // URL rewrite
        String address = newCtx.getTo().getAddress();
        if (address.indexOf(":") != -1) {
            try {
                address = new URL(address).getPath();
            } catch (MalformedURLException e) {
                String msg = "URL " + address + " is malformed";
                log.error(msg, e);
                throw new SynapseException(msg, e);
            }
        }
        EndpointReference epr = new EndpointReference(transport + "://" + member.getHostName() + ":" + ("http".equals(transport) ? member.getHttpPort() : member.getHttpsPort()) + address);
        newCtx.setTo(epr);
        newCtx.pushFaultHandler(this);
        AddressEndpoint endpoint = new AddressEndpoint();
        EndpointDefinition definition = new EndpointDefinition();
        endpoint.setDefinition(definition);
        endpoint.init(newCtx.getEnvironment());
        if (endpoint.readyToSend()) {
            foundEndpoint = true;
            endpoint.send(newCtx);
        }
    }
    if (!foundEndpoint) {
        String msg = "Recipient List endpoint : " + (getName() != null ? getName() : SynapseConstants.ANONYMOUS_ENDPOINT) + " - no ready child members";
        log.warn(msg);
        informFailure(synCtx, SynapseConstants.ENDPOINT_RL_NONE_READY, msg);
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) MalformedURLException(java.net.MalformedURLException) SynapseException(org.apache.synapse.SynapseException) URL(java.net.URL) EndpointReference(org.apache.axis2.addressing.EndpointReference) MessageContext(org.apache.synapse.MessageContext) Axis2MessageContext(org.apache.synapse.core.axis2.Axis2MessageContext) Member(org.apache.axis2.clustering.Member) Axis2MessageContext(org.apache.synapse.core.axis2.Axis2MessageContext)

Example 69 with Axis2MessageContext

use of org.apache.synapse.core.axis2.Axis2MessageContext in project wso2-synapse by wso2.

the class SynapseDebugManager method acquireMediationFlowPointProperties.

public void acquireMediationFlowPointProperties(String propertyOrProperties, String propertyContext, JSONObject property_arguments) throws IOException {
    if ((!(this.medFlowState == MediationFlowState.SUSPENDED)) & (propertyContext != null & !propertyContext.equals(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_CONTEXT_WIRE))) {
        this.advertiseCommandResponse(createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_UNABLE_TO_ACQUIRE_MESSAGE_CONTEXT_PROPERTIES).toString());
        return;
    }
    try {
        if (propertyOrProperties.equals(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTIES)) {
            if (propertyContext.equals(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_CONTEXT_ALL)) {
                JSONObject data_axis2 = getAxis2Properties();
                JSONObject data_synapse = new JSONObject(((Axis2MessageContext) synCtx).getProperties());
                JSONObject data_axis2_prop = new JSONObject();
                JSONObject data_synapse_prop = new JSONObject();
                data_axis2_prop.put(SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_PROPERTY_CONTEXT_AXIS2, data_axis2);
                data_synapse_prop.put(SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_PROPERTY_CONTEXT_SYNAPSE, data_synapse);
                JSONArray data_array = new JSONArray();
                data_array.put(data_axis2_prop);
                data_array.put(data_synapse_prop);
                debugInterface.getPortListenWriter().println(data_array.toString());
                debugInterface.getPortListenWriter().flush();
            } else if (propertyContext.equals(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_CONTEXT_AXIS2)) {
                JSONObject data_axis2 = getAxis2Properties();
                JSONObject data_axis2_prop = new JSONObject();
                data_axis2_prop.put(SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_PROPERTY_CONTEXT_AXIS2, data_axis2);
                debugInterface.getPortListenWriter().println(data_axis2_prop.toString());
                debugInterface.getPortListenWriter().flush();
            } else if (propertyContext.equals(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_CONTEXT_SYNAPSE) || propertyContext.equals(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_CONTEXT_DEFAULT)) {
                JSONObject data_synapse = new JSONObject(((Axis2MessageContext) synCtx).getProperties());
                JSONObject data_synapse_prop = new JSONObject();
                data_synapse_prop.put(SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_PROPERTY_CONTEXT_SYNAPSE, data_synapse);
                debugInterface.getPortListenWriter().println(data_synapse_prop.toString());
                debugInterface.getPortListenWriter().flush();
            } else if (propertyContext.equals(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_CONTEXT_AXIS2CLIENT)) {
                JSONObject data_axis2 = new JSONObject(((Axis2MessageContext) synCtx).getAxis2MessageContext().getOptions().getProperties());
                JSONObject data_axis2_prop = new JSONObject();
                data_axis2_prop.put(SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_PROPERTY_CONTEXT_AXIS2CLIENT, data_axis2);
                debugInterface.getPortListenWriter().println(data_axis2_prop.toString());
                debugInterface.getPortListenWriter().flush();
            } else if (propertyContext.equals(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_CONTEXT_TRANSPORT)) {
                JSONObject data_axis2 = new JSONObject((Map) ((Axis2MessageContext) synCtx).getAxis2MessageContext().getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS));
                JSONObject data_axis2_prop = new JSONObject();
                data_axis2_prop.put(SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_PROPERTY_CONTEXT_AXIS2TRANSPORT, data_axis2);
                debugInterface.getPortListenWriter().println(data_axis2_prop.toString());
                debugInterface.getPortListenWriter().flush();
            } else if (propertyContext.equals(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_CONTEXT_OPERATION)) {
                JSONObject data_axis2 = new JSONObject(((Axis2MessageContext) synCtx).getAxis2MessageContext().getOperationContext().getProperties());
                JSONObject data_axis2_prop = new JSONObject();
                data_axis2_prop.put(SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_PROPERTY_CONTEXT_AXIS2OPERATION, data_axis2);
                debugInterface.getPortListenWriter().println(data_axis2_prop.toString());
                debugInterface.getPortListenWriter().flush();
            }
        } else if (propertyOrProperties.equals(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY)) {
            if (propertyContext.equals(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_CONTEXT_AXIS2)) {
                JSONObject data_axis2 = getAxis2Properties();
                Object result = null;
                if (data_axis2.has(property_arguments.getString(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_NAME))) {
                    result = data_axis2.get(property_arguments.getString(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_NAME));
                }
                JSONObject json_result = new JSONObject();
                json_result.put(property_arguments.getString(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_NAME), result);
                debugInterface.getPortListenWriter().println(json_result.toString());
                debugInterface.getPortListenWriter().flush();
            } else if (propertyContext.equals(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_CONTEXT_SYNAPSE) || propertyContext.equals(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_CONTEXT_DEFAULT)) {
                JSONObject data_synapse = new JSONObject(((Axis2MessageContext) synCtx).getProperties());
                Object result = null;
                if (data_synapse.has(property_arguments.getString(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_NAME))) {
                    result = data_synapse.getJSONObject(property_arguments.getString(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_NAME));
                }
                JSONObject json_result = new JSONObject();
                json_result.put(property_arguments.getString(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_NAME), result);
                debugInterface.getPortListenWriter().println(json_result.toString());
                debugInterface.getPortListenWriter().flush();
            } else if (propertyContext.equals(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_CONTEXT_AXIS2CLIENT)) {
                JSONObject data_axis2 = new JSONObject(((Axis2MessageContext) synCtx).getAxis2MessageContext().getOptions().getProperties());
                Object result = null;
                if (data_axis2.has(property_arguments.getString(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_NAME))) {
                    result = data_axis2.get(property_arguments.getString(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_NAME));
                }
                JSONObject json_result = new JSONObject();
                json_result.put(property_arguments.getString(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_NAME), result);
                debugInterface.getPortListenWriter().println(json_result.toString());
                debugInterface.getPortListenWriter().flush();
            } else if (propertyContext.equals(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_CONTEXT_TRANSPORT)) {
                JSONObject data_axis2 = new JSONObject((Map) ((Axis2MessageContext) synCtx).getAxis2MessageContext().getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS));
                Object result = null;
                if (data_axis2.has(property_arguments.getString(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_NAME))) {
                    result = data_axis2.get(property_arguments.getString(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_NAME));
                }
                JSONObject json_result = new JSONObject();
                json_result.put(property_arguments.getString(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_NAME), result);
                debugInterface.getPortListenWriter().println(json_result.toString());
                debugInterface.getPortListenWriter().flush();
            } else if (propertyContext.equals(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_CONTEXT_OPERATION)) {
                JSONObject data_axis2 = new JSONObject(((Axis2MessageContext) synCtx).getAxis2MessageContext().getOperationContext().getProperties());
                Object result = null;
                if (data_axis2.has(property_arguments.getString(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_NAME))) {
                    result = data_axis2.get(property_arguments.getString(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_NAME));
                }
                JSONObject json_result = new JSONObject();
                json_result.put(property_arguments.getString(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_NAME), result);
                debugInterface.getPortListenWriter().println(json_result.toString());
                debugInterface.getPortListenWriter().flush();
            } else if (propertyContext.equals(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_CONTEXT_WIRE)) {
                SynapseWireLogHolder synapseWireLogHolder = (synCtx != null) ? (SynapseWireLogHolder) ((Axis2MessageContext) synCtx).getAxis2MessageContext().getProperty(SynapseDebugInfoHolder.SYNAPSE_WIRE_LOG_HOLDER_PROPERTY) : null;
                JSONObject wireLog = createWireLogResponse(synapseWireLogHolder);
                debugInterface.getPortListenWriter().println(wireLog.toString());
                debugInterface.getPortListenWriter().flush();
                log.debug("wirelog sent to devstudio - " + wireLog.toString());
            }
        }
    } catch (JSONException ex) {
        log.error("Failed to acquire property in the scope: " + propertyContext, ex);
    }
}
Also used : JSONObject(org.codehaus.jettison.json.JSONObject) SynapseWireLogHolder(org.apache.synapse.transport.http.conn.SynapseWireLogHolder) JSONArray(org.codehaus.jettison.json.JSONArray) JSONException(org.codehaus.jettison.json.JSONException) JSONObject(org.codehaus.jettison.json.JSONObject) Axis2MessageContext(org.apache.synapse.core.axis2.Axis2MessageContext)

Example 70 with Axis2MessageContext

use of org.apache.synapse.core.axis2.Axis2MessageContext in project wso2-synapse by wso2.

the class SynapseDebugManager method addMediationFlowPointProperty.

public void addMediationFlowPointProperty(String propertyContext, JSONObject property_arguments, boolean isActionSet) {
    try {
        String propertyKey = property_arguments.getString(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_NAME);
        if (isActionSet) {
            String propertyValue = property_arguments.getString(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_VALUE);
            if (propertyContext.equals(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_CONTEXT_DEFAULT) || propertyContext.equals(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_CONTEXT_SYNAPSE)) {
                synCtx.setProperty(propertyKey, propertyValue);
            } else if (propertyContext.equals(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_CONTEXT_AXIS2) && synCtx instanceof Axis2MessageContext) {
                Axis2MessageContext axis2smc = (Axis2MessageContext) synCtx;
                org.apache.axis2.context.MessageContext axis2MessageCtx = axis2smc.getAxis2MessageContext();
                setAxis2Property(propertyKey, propertyValue, axis2MessageCtx);
                if (org.apache.axis2.Constants.Configuration.MESSAGE_TYPE.equalsIgnoreCase(propertyKey)) {
                    setAxis2Property(org.apache.axis2.Constants.Configuration.CONTENT_TYPE, propertyValue, axis2MessageCtx);
                    Object o = axis2MessageCtx.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);
                    Map headers = (Map) o;
                    if (headers != null) {
                        headers.remove(HTTP.CONTENT_TYPE);
                        headers.put(HTTP.CONTENT_TYPE, propertyValue);
                    }
                }
            } else if (propertyContext.equals(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_CONTEXT_AXIS2CLIENT) && synCtx instanceof Axis2MessageContext) {
                Axis2MessageContext axis2smc = (Axis2MessageContext) synCtx;
                org.apache.axis2.context.MessageContext axis2MessageCtx = axis2smc.getAxis2MessageContext();
                axis2MessageCtx.getOptions().setProperty(propertyKey, propertyValue);
            } else if (propertyContext.equals(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_CONTEXT_TRANSPORT) && synCtx instanceof Axis2MessageContext) {
                Axis2MessageContext axis2smc = (Axis2MessageContext) synCtx;
                org.apache.axis2.context.MessageContext axis2MessageCtx = axis2smc.getAxis2MessageContext();
                Object headers = axis2MessageCtx.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);
                if (headers != null && headers instanceof Map) {
                    Map headersMap = (Map) headers;
                    headersMap.put(propertyKey, propertyValue);
                }
                if (headers == null) {
                    Map headersMap = new HashMap();
                    headersMap.put(propertyKey, propertyValue);
                    axis2MessageCtx.setProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS, headersMap);
                }
            } else if (propertyContext.equals(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_CONTEXT_OPERATION) && synCtx instanceof Axis2MessageContext) {
                Axis2MessageContext axis2smc = (Axis2MessageContext) synCtx;
                axis2smc.getAxis2MessageContext().getOperationContext().setProperty(propertyKey, propertyValue);
            }
        } else {
            if (propertyContext == null || SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_CONTEXT_DEFAULT.equals(propertyContext) || SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_CONTEXT_SYNAPSE.equals(propertyContext)) {
                Set pros = synCtx.getPropertyKeySet();
                if (pros != null) {
                    pros.remove(propertyKey);
                }
            } else if (propertyContext.equals(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_CONTEXT_AXIS2) && synCtx instanceof Axis2MessageContext) {
                Axis2MessageContext axis2smc = (Axis2MessageContext) synCtx;
                org.apache.axis2.context.MessageContext axis2MessageCtx = axis2smc.getAxis2MessageContext();
                axis2MessageCtx.removeProperty(propertyKey);
            } else if (propertyContext.equals(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_CONTEXT_AXIS2CLIENT) && synCtx instanceof Axis2MessageContext) {
                Axis2MessageContext axis2smc = (Axis2MessageContext) synCtx;
                org.apache.axis2.context.MessageContext axis2MessageCtx = axis2smc.getAxis2MessageContext();
                axis2MessageCtx.getOptions().setProperty(propertyKey, EMPTY_STRING);
            } else if (propertyContext.equals(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_CONTEXT_TRANSPORT) && synCtx instanceof Axis2MessageContext) {
                Axis2MessageContext axis2smc = (Axis2MessageContext) synCtx;
                org.apache.axis2.context.MessageContext axis2MessageCtx = axis2smc.getAxis2MessageContext();
                Object headers = axis2MessageCtx.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);
                if (headers != null && headers instanceof Map) {
                    Map headersMap = (Map) headers;
                    headersMap.remove(propertyKey);
                }
            } else if (propertyContext.equals(SynapseDebugCommandConstants.DEBUG_COMMAND_PROPERTY_CONTEXT_OPERATION) && synCtx instanceof Axis2MessageContext) {
                Axis2MessageContext axis2smc = (Axis2MessageContext) synCtx;
                axis2smc.getAxis2MessageContext().getOperationContext().removeProperty(propertyKey);
            } else {
                log.error("Failed to set or remove property in the scope " + propertyContext);
                this.advertiseCommandResponse(createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_UNABLE_TO_ALTER_MESSAGE_CONTEXT_PROPERTY).toString());
            }
        }
    } catch (JSONException e) {
        log.error("Failed to set or remove property in the scope " + propertyContext, e);
        this.advertiseCommandResponse(createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_UNABLE_TO_ALTER_MESSAGE_CONTEXT_PROPERTY).toString());
    }
    this.advertiseCommandResponse(createDebugCommandResponse(true, null).toString());
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) JSONException(org.codehaus.jettison.json.JSONException) JSONObject(org.codehaus.jettison.json.JSONObject) MessageContext(org.apache.synapse.MessageContext) Axis2MessageContext(org.apache.synapse.core.axis2.Axis2MessageContext) HashMap(java.util.HashMap) Map(java.util.Map) Axis2MessageContext(org.apache.synapse.core.axis2.Axis2MessageContext)

Aggregations

Axis2MessageContext (org.apache.synapse.core.axis2.Axis2MessageContext)92 MessageContext (org.apache.synapse.MessageContext)50 Axis2SynapseEnvironment (org.apache.synapse.core.axis2.Axis2SynapseEnvironment)24 Map (java.util.Map)23 HashMap (java.util.HashMap)20 SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)19 SynapseEnvironment (org.apache.synapse.core.SynapseEnvironment)18 Test (org.junit.Test)16 OMElement (org.apache.axiom.om.OMElement)15 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)14 SynapseException (org.apache.synapse.SynapseException)14 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)13 ArrayList (java.util.ArrayList)12 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)11 EndpointReference (org.apache.axis2.addressing.EndpointReference)10 SynapseLog (org.apache.synapse.SynapseLog)9 Endpoint (org.apache.synapse.endpoints.Endpoint)9 OperationContext (org.apache.axis2.context.OperationContext)8 AxisFault (org.apache.axis2.AxisFault)7 Entry (org.apache.synapse.config.Entry)7