org.apache.axis2.context.MessageContext - java examples

Here are the examples of the java api org.apache.axis2.context.MessageContext taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

155 Examples 7

19 View Complete Implementation : JMSUtils.java
Copyright Apache License 2.0
Author : wso2
private static boolean isHyphenDeleteMode(MessageContext msgContext) {
    if (msgContext == null) {
        return false;
    }
    String hyphenSupport = (String) msgContext.getProperty(JMSConstants.PARAM_JMS_HYPHEN_MODE);
    if (hyphenSupport != null && hyphenSupport.equals(JMSConstants.HYPHEN_MODE_DELETE)) {
        return true;
    }
    return false;
}

19 View Complete Implementation : LoadbalanceFailoverClient.java
Copyright Apache License 2.0
Author : wso2
protected String getSetCookieHeader(MessageContext axis2MessageContext) {
    Object o = axis2MessageContext.getProperty(MessageContext.TRANSPORT_HEADERS);
    if (o != null && o instanceof Map) {
        Map headerMap = (Map) o;
        return (String) headerMap.get(SET_COOKIE);
    }
    return null;
}

19 View Complete Implementation : LoadbalanceFailoverClient.java
Copyright Apache License 2.0
Author : wso2
protected String getSetCookieHeader(MessageContext axis2MessageContext) {
    Object o = axis2MessageContext.getProperty(MessageContext.TRANSPORT_HEADERS);
    if (o != null && o instanceof Map) {
        Map headerMap = (Map) o;
        return (String) headerMap.get(SET_COOKIE);
    }
    return null;
}

19 View Complete Implementation : RabbitMQUtils.java
Copyright Apache License 2.0
Author : wso2
public static String getProperty(MessageContext mc, String key) {
    return (String) mc.getProperty(key);
}

19 View Complete Implementation : AbstractAuthorizationProvider.java
Copyright Apache License 2.0
Author : wso2
/**
 * Default implementation to get user name from message context.
 *
 * @param msgContext
 * @return username.
 */
public String getUsername(MessageContext msgContext) {
    String userName = (String) msgContext.getProperty(DBConstants.MSG_CONTEXT_USERNAME_PROPERTY);
    return userName;
}

19 View Complete Implementation : LoadbalanceFailoverClient.java
Copyright Apache License 2.0
Author : wso2
protected String extractSessionID(MessageContext axis2MessageContext) {
    Object o = axis2MessageContext.getProperty(MessageContext.TRANSPORT_HEADERS);
    if (o != null && o instanceof Map) {
        Map headerMap = (Map) o;
        String cookie = (String) headerMap.get(SET_COOKIE);
        if (cookie == null) {
            cookie = (String) headerMap.get(COOKIE);
        } else {
            cookie = cookie.split(";")[0];
        }
        return cookie;
    }
    return null;
}

19 View Complete Implementation : LoadbalanceFailoverClient.java
Copyright Apache License 2.0
Author : wso2
protected String extractSessionID(MessageContext axis2MessageContext) {
    Object o = axis2MessageContext.getProperty(MessageContext.TRANSPORT_HEADERS);
    if (o != null && o instanceof Map) {
        Map headerMap = (Map) o;
        String cookie = (String) headerMap.get(SET_COOKIE);
        if (cookie == null) {
            cookie = (String) headerMap.get(COOKIE);
        } else {
            cookie = cookie.split(";")[0];
        }
        return cookie;
    }
    return null;
}

19 View Complete Implementation : JMSUtils.java
Copyright Apache License 2.0
Author : wso2
private static boolean isHyphenReplaceMode(MessageContext msgContext) {
    if (msgContext == null) {
        return false;
    }
    String hyphenSupport = (String) msgContext.getProperty(JMSConstants.PARAM_JMS_HYPHEN_MODE);
    if (hyphenSupport != null && hyphenSupport.equals(JMSConstants.HYPHEN_MODE_REPLACE)) {
        return true;
    }
    return false;
}

18 View Complete Implementation : LoadBalanceSessionFullClient.java
Copyright Apache License 2.0
Author : wso2
protected String getSetCookieHeader(MessageContext axis2MessageContext) {
    Object o = axis2MessageContext.getProperty(MessageContext.TRANSPORT_HEADERS);
    if (o instanceof Map) {
        Map headerMap = (Map) o;
        return (String) headerMap.get(SET_COOKIE);
    }
    return null;
}

18 View Complete Implementation : LoadbalanceFailoverClient.java
Copyright Apache License 2.0
Author : wso2
protected String extractSessionID(MessageContext axis2MessageContext) {
    Object o = axis2MessageContext.getProperty(MessageContext.TRANSPORT_HEADERS);
    if (o != null && o instanceof Map) {
        Map headerMap = (Map) o;
        String cookie = (String) headerMap.get(SET_COOKIE);
        if (cookie == null) {
            cookie = (String) headerMap.get(COOKIE);
        } else {
            cookie = cookie.split(";")[0];
        }
        return cookie;
    }
    return null;
}

18 View Complete Implementation : LoadbalanceFailoverClient.java
Copyright Apache License 2.0
Author : wso2
protected String getSetCookieHeader(MessageContext axis2MessageContext) {
    Object o = axis2MessageContext.getProperty(MessageContext.TRANSPORT_HEADERS);
    if (o != null && o instanceof Map) {
        Map headerMap = (Map) o;
        return (String) headerMap.get(SET_COOKIE);
    }
    return null;
}

18 View Complete Implementation : JWTAuthorizationProvider.java
Copyright Apache License 2.0
Author : wso2
@Override
public String[] getUserRoles(MessageContext msgContext) throws DataServiceFault {
    // need to retrieve from msgcontext
    return DBUtils.getUserRoles(getUsername(msgContext));
}

18 View Complete Implementation : AbstractAdmin.java
Copyright Apache License 2.0
Author : wso2
private void checkAdminService() {
    MessageContext msgCtx = MessageContext.getCurrentMessageContext();
    if (msgCtx == null) {
        return;
    }
    AxisService axisService = msgCtx.getAxisService();
    if (axisService.getParameter(Constants.ADMIN_SERVICE_PARAM_NAME) == null) {
        throw new RuntimeException("AbstractAdmin can only be extended by Carbon admin services. " + getClreplaced().getName() + " is not an admin service. Service name " + axisService.getName() + ". The service should have defined the " + Constants.ADMIN_SERVICE_PARAM_NAME + " parameter");
    }
}

18 View Complete Implementation : SMTPFaultHandler.java
Copyright Apache License 2.0
Author : wso2
public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
    return InvocationResponse.CONTINUE;
}

18 View Complete Implementation : UserStoreAuthorizationProvider.java
Copyright Apache License 2.0
Author : wso2
@Override
public String[] getUserRoles(MessageContext msgContext) throws DataServiceFault {
    return DBUtils.getUserRoles(getUsername(msgContext));
}

18 View Complete Implementation : POXSecurityHandler.java
Copyright Apache License 2.0
Author : wso2
/**
 * Utility method to return basic auth transport headers if present
 *
 * @return
 */
private String getBasicAuthHeaders(MessageContext msgCtx) {
    Map map = (Map) msgCtx.getProperty(MessageContext.TRANSPORT_HEADERS);
    if (map == null) {
        return null;
    }
    String tmp = (String) map.get("Authorization");
    if (tmp == null) {
        tmp = (String) map.get("authorization");
    }
    if (tmp != null && tmp.trim().startsWith("Basic ")) {
        return tmp;
    } else {
        return null;
    }
}

18 View Complete Implementation : LoadbalanceFailoverClient.java
Copyright Apache License 2.0
Author : wso2
protected void setSessionID(MessageContext axis2MessageContext, String value) {
    if (value == null) {
        return;
    }
    Map map = (Map) axis2MessageContext.getProperty(HTTPConstants.HTTP_HEADERS);
    if (map == null) {
        map = new HashMap();
        axis2MessageContext.setProperty(HTTPConstants.HTTP_HEADERS, map);
    }
    map.put(COOKIE, value);
}

18 View Complete Implementation : IntegratorStatefulHandler.java
Copyright Apache License 2.0
Author : wso2
@Override
public AxisService findService(MessageContext messageContext) throws AxisFault {
    return this.rubsd.findService(messageContext);
}

18 View Complete Implementation : POXSecurityHandler.java
Copyright Apache License 2.0
Author : wso2
@Override
public void flowComplete(MessageContext msgContext) {
// Do Nothing
}

18 View Complete Implementation : PublisherUtil.java
Copyright Apache License 2.0
Author : wso2
public static int getTenantId(MessageContext msgContext) {
    return Constants.SUPER_TENANT_ID;
}

18 View Complete Implementation : CallQuery.java
Copyright Apache License 2.0
Author : wso2
/**
 * This method returns the system variable's value given the property name.
 */
private Object evaluateGetProperty(String propName) throws DataServiceFault {
    /* so far we only evaluate the "USERNAME" value */
    if ("USERNAME".equals(propName)) {
        MessageContext context = MessageContext.getCurrentMessageContext();
        if (context != null) {
            // todo change this to use role retriever
            return this.getDataService().getAuthorizationProvider().getUsername(context);
        }
    } else if ("TENANT_ID".equals(propName)) {
        // PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId());
        return String.valueOf(Constants.SUPER_TENANT_ID);
    } else if ("USER_ROLES".equals(propName)) {
        MessageContext context = MessageContext.getCurrentMessageContext();
        if (context != null) {
            return this.getDataService().getAuthorizationProvider().getUserRoles(context);
        }
    } else if ("NULL".equals(propName)) {
        /* represent the special null value (not empty string) */
        return null;
    }
    return null;
}

18 View Complete Implementation : SystemStatistics.java
Copyright Apache License 2.0
Author : wso2
/* This method use by data publishers to get update about current invocation. we need to use message context instead of
    AxisConfiguration, because in concurrent execution if we save values as axis parameters these values might get overwrite
    by another thread. */
public void update(MessageContext messageContext) throws AxisFault {
    try {
        currentInvocationResponseTime = statService.getCurrentSystemResponseTime(messageContext);
        currentInvocationResponseCount = statService.getCurrentSystemResponseCount(messageContext);
        currentInvocationRequestCount = statService.getCurrentSystemRequestCount(messageContext);
        currentInvocationFaultCount = statService.getCurrentSystemFaultCount(messageContext);
    } catch (Exception e) {
        throw AxisFault.makeFault(e);
    }
}

18 View Complete Implementation : LoadBalanceSessionFullClient.java
Copyright Apache License 2.0
Author : wso2
protected String extractSessionID(MessageContext axis2MessageContext) {
    Object o = axis2MessageContext.getProperty(MessageContext.TRANSPORT_HEADERS);
    if (o instanceof Map) {
        Map headerMap = (Map) o;
        String cookie = (String) headerMap.get(SET_COOKIE);
        if (cookie == null) {
            cookie = (String) headerMap.get(COOKIE);
        } else {
            cookie = cookie.split(";")[0];
        }
        return cookie;
    }
    return null;
}

18 View Complete Implementation : DOMHASHGenerator.java
Copyright Apache License 2.0
Author : wso2
/**
 * This is the implementation of the getDigest method and will implement the DOMHASH algorithm based XML node
 * identifications. This will consider only the SOAP payload and this does not consider the SOAP headers in
 * generating the digets. So, in effect this will uniquely identify the SOAP messages with the same payload.
 *
 * @param msgContext - MessageContext on which the XML node identifier will be generated
 * @return Object representing the DOMHASH value of the normalized XML node
 * @throws CachingException if there is an error in generating the digest key
 *                          <p>
 *                          #getDigest(org.apache.axis2.context.MessageContext)
 */
public String getDigest(MessageContext msgContext) throws CachingException {
    OMNode request = msgContext.getEnvelope().getBody();
    if (request != null) {
        byte[] digest = getDigest(request, MD5_DIGEST_ALGORITHM);
        return digest != null ? getStringRepresentation(digest) : null;
    } else {
        return null;
    }
}

18 View Complete Implementation : RoleRetriever.java
Copyright Apache License 2.0
Author : wso2
@Override
public String getUsername(MessageContext messageContext) throws DataServiceFault {
    return userName;
}

18 View Complete Implementation : LoadbalanceFailoverClient.java
Copyright Apache License 2.0
Author : wso2
protected void setSessionID(MessageContext axis2MessageContext, String value) {
    if (value == null) {
        return;
    }
    Map map = (Map) axis2MessageContext.getProperty(HTTPConstants.HTTP_HEADERS);
    if (map == null) {
        map = new HashMap();
        axis2MessageContext.setProperty(HTTPConstants.HTTP_HEADERS, map);
    }
    map.put(COOKIE, value);
}

17 View Complete Implementation : JWTAuthorizationProvider.java
Copyright Apache License 2.0
Author : wso2
/**
 * This method gets the JWT token from the transport header, and extracts the user name from the JWT and
 * sets it to the message context.
 * Example Usage - is to enable user name token security in DSS and use the JWT token sent from APIM to
 * get the roles of the user in order to utilize the content filtering feature of DSS.
 * @param msgContext
 */
private String extractUsernameFromJWT(MessageContext msgContext) throws UnsupportedEncodingException, AxisFault {
    if (endUserClaim == null || endUserClaim.isEmpty()) {
        endUserClaim = ENDUSER_CLAIM;
    }
    HttpServletRequest obj = (HttpServletRequest) msgContext.getProperty(HTTP_SERVLET_REQUEST);
    if (obj != null) {
        // Get the JWT token from the header.
        String jwt = obj.getHeader(JWT_TOKEN_HEADER_NAME);
        if (jwt != null && validateSignature(jwt)) {
            String jwtToken = null;
            // Decode the JWT token.
            jwtToken = new String(org.apache.axiom.om.util.Base64.decode(jwt), UTF_8_ENCODING);
            if (jwtToken != null) {
                // Extract the end user claim.
                String[] tempStr4 = jwtToken.split(endUserClaim + CLAIM_VALUE_SEPARATOR);
                String[] decoded = tempStr4[1].split(ESCAPED_DOUBLE_QUOTATION);
                System.out.println("tempStr4= " + tempStr4.toString());
                System.out.println("decoded=" + decoded.toString());
                // Set username to message context.
                return decoded[0];
            }
        }
    }
    return null;
}

17 View Complete Implementation : JsonStreamBuilder.java
Copyright Apache License 2.0
Author : wso2
public OMElement processDoreplacedent(InputStream inputStream, String s, MessageContext messageContext) throws AxisFault {
    try {
        if (MicroIntegratorBaseUtils.isDataService(messageContext)) {
            return (OMElement) axis2GsonBuilderProcessDoreplacedentMethod.invoke(axis2GsonBuilder, inputStream, s, messageContext);
        } else {
            return (OMElement) synapseBuilderProcessDoreplacedentMethod.invoke(synapseBuilder, inputStream, s, messageContext);
        }
    } catch (InvocationTargetException | IllegalAccessException e) {
        logger.error("Error occurred while processing doreplacedent for application/json", e);
        throw new AxisFault(e.getMessage());
    }
}

17 View Complete Implementation : LoadBalanceSessionFullClient.java
Copyright Apache License 2.0
Author : wso2
protected void setSessionID(MessageContext axis2MessageContext, String value) {
    if (value == null) {
        return;
    }
    Map map = (Map) axis2MessageContext.getProperty(HTTPConstants.HTTP_HEADERS);
    if (map == null) {
        map = new HashMap();
        axis2MessageContext.setProperty(HTTPConstants.HTTP_HEADERS, map);
    }
    map.put(COOKIE, value);
}

17 View Complete Implementation : TracingInPostDispatchHandler.java
Copyright Apache License 2.0
Author : wso2
/**
 * Store the received message
 *
 * @param operationName operationName
 * @param serviceName   serviceName
 * @param msgCtxt       msgCtxt
 * @return the sequence of the message stored with respect to the operation
 *         in the service
 */
protected long storeMessage(String serviceName, String operationName, MessageContext msgCtxt) {
    TracePersister tracePersister = (TracePersister) msgCtxt.getConfigurationContext().getAxisConfiguration().getParameter(TracerConstants.TRACE_PERSISTER_IMPL).getValue();
    return tracePersister.saveMessage(serviceName, operationName, msgCtxt.getFLOW(), msgCtxt, (OMElement) msgCtxt.getProperty(TracerConstants.TEMP_IN_ENVELOPE), // Use the temp envelope
    -1);
}

17 View Complete Implementation : SystemStatisticsUtil.java
Copyright Apache License 2.0
Author : wso2
public int getCurrentSystemResponseCount(MessageContext messageContext) {
    Object currentSystemResponseCount = messageContext.getProperty(StatisticsConstants.GLOBAL_CURRENT_RESPONSE_COUNTER);
    if (currentSystemResponseCount != null) {
        Object value = currentSystemResponseCount;
        if (value instanceof Integer) {
            return ((Integer) value);
        }
    }
    return 0;
}

17 View Complete Implementation : JWTAuthorizationProvider.java
Copyright Apache License 2.0
Author : wso2
@Override
public String getUsername(MessageContext msgContext) throws DataServiceFault {
    try {
        return extractUsernameFromJWT(msgContext);
    } catch (UnsupportedEncodingException e) {
        log.debug("Error in retrieving user name from message context - " + e.getMessage(), e);
        throw new DataServiceFault(e, "Error in retrieving user name from message context - " + e.getMessage());
    } catch (AxisFault axisFault) {
        log.debug("Error in retrieving user name from message context - " + axisFault.getMessage(), axisFault);
        throw new DataServiceFault(axisFault, "Error in retrieving user name from message context - " + axisFault.getMessage());
    }
}

17 View Complete Implementation : AbstractTracingHandler.java
Copyright Apache License 2.0
Author : wso2
/**
 * Store the received message
 *
 * @param operationName operationName
 * @param serviceName   serviceName
 * @param msgCtxt       msgCtxt
 * @return the sequence of the message stored with respect to the operation
 *         in the service
 */
protected long storeMessage(String serviceName, String operationName, MessageContext msgCtxt, long msgSequenceNumber) {
    TracePersister tracePersister = (TracePersister) msgCtxt.getConfigurationContext().getAxisConfiguration().getParameter(TracerConstants.TRACE_PERSISTER_IMPL).getValue();
    return tracePersister.saveMessage(serviceName, operationName, msgCtxt.getFLOW(), msgCtxt, msgCtxt.getEnvelope().cloneOMElement(), msgSequenceNumber);
}

17 View Complete Implementation : SystemStatisticsUtil.java
Copyright Apache License 2.0
Author : wso2
public int getCurrentSystemFaultCount(MessageContext messageContext) {
    Object currentSystemFaultCount = messageContext.getProperty(StatisticsConstants.GLOBAL_CURRENT_FAULT_COUNTER);
    if (currentSystemFaultCount != null) {
        Object value = currentSystemFaultCount;
        if (value instanceof Integer) {
            return ((Integer) value);
        }
    }
    return 0;
}

17 View Complete Implementation : IntegratorStatefulHandler.java
Copyright Apache License 2.0
Author : wso2
@Override
public AxisOperation findOperation(AxisService axisService, MessageContext messageContext) throws AxisFault {
    return null;
}

17 View Complete Implementation : SystemStatisticsUtil.java
Copyright Apache License 2.0
Author : wso2
public int getCurrentSystemRequestCount(MessageContext messageContext) {
    Object currentSystemRequestCount = messageContext.getProperty(StatisticsConstants.GLOBAL_CURRENT_REQUEST_COUNTER);
    if (currentSystemRequestCount != null) {
        Object value = currentSystemRequestCount;
        if (value instanceof Integer) {
            return ((Integer) value);
        }
    }
    return 0;
}

17 View Complete Implementation : DataServiceRequest.java
Copyright Apache License 2.0
Author : wso2
/**
 * Set the current session user's name, user roles etc..
 * @param dataService data service
 * @param dsRequest Current data service request
 * @param msgContext Incoming message's message context
 * @throws DataServiceFault
 */
private static void populateUserInfo(DataService dataService, DataServiceRequest dsRequest, MessageContext msgContext) throws DataServiceFault {
    /* set request username */
    String username = dataService.getAuthorizationProvider().getUsername(msgContext);
    dsRequest.setUser(username);
    /* if only there's a user .. */
    if (username != null) {
        /* set user roles */
        try {
            dsRequest.setUserRoles(dataService.getAuthorizationProvider().getUserRoles(msgContext));
        } catch (Exception e) {
            throw new DataServiceFault(e, "Error setting user roles");
        }
    }
}

17 View Complete Implementation : RoleRetriever.java
Copyright Apache License 2.0
Author : wso2
@Override
public String[] getUserRoles(MessageContext messageContext) throws DataServiceFault {
    log.info("External role retriever invoked returning roles");
    String[] roleArray = { "admin", "sampleRole1", "sampleRole2", userRole };
    return roleArray;
}

17 View Complete Implementation : REQUESTHASHGenerator.java
Copyright Apache License 2.0
Author : wso2
/**
 * This is the implementation of the getDigest method and will implement the Extended DOMHASH algorithm based HTTP
 * request identifications. This will consider To address of the request, HTTP headers and XML Payload in generating
 * the digets. So, in effect this will uniquely identify the HTTP request with the same To address, Headers and
 * Payload.
 *
 * @param msgContext - MessageContext on which the XML node identifier will be generated
 * @return Object representing the DOMHASH value of the normalized XML node
 * @throws CachingException if there is an error in generating the digest key
 * @see org.wso2.caching.digest.DigestGenerator #getDigest(org.apache.axis2.context.MessageContext)
 */
public String getDigest(MessageContext msgContext) throws CachingException {
    OMNode body = msgContext.getEnvelope().getBody();
    String toAddress = null;
    if (msgContext.getTo() != null) {
        toAddress = msgContext.getTo().getAddress();
    }
    Map<String, String> headers = (Map) msgContext.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);
    if (body != null) {
        byte[] digest = null;
        if (toAddress != null) {
            digest = getDigest(body, toAddress, headers, MD5_DIGEST_ALGORITHM);
        } else {
            digest = getDigest(body, MD5_DIGEST_ALGORITHM);
        }
        return digest != null ? getStringRepresentation(digest) : null;
    } else {
        return null;
    }
}

17 View Complete Implementation : ODataServletResponse.java
Copyright Apache License 2.0
Author : wso2
public clreplaced ODataServletResponse implements HttpServletResponse {

    private MessageContext axis2MessageContext;

    private final ByteArrayOutputStream content = new ByteArrayOutputStream(1024);

    private final ServletOutputStream outputStream = new ResponseServletOutputStream(this.content);

    private long contentLength = 0;

    private String contentType;

    private String characterEncoding = StandardCharsets.UTF_8.name();

    private int bufferSize = 4096;

    private int statusCode;

    private boolean committed;

    ODataServletResponse(MessageContext messageContext) {
        this.axis2MessageContext = messageContext;
    }

    @Override
    public void addCookie(Cookie cookie) {
        throw new UnsupportedOperationException();
    }

    @Override
    public boolean containsHeader(String s) {
        throw new UnsupportedOperationException();
    }

    @Override
    public String encodeURL(String s) {
        throw new UnsupportedOperationException();
    }

    @Override
    public String encodeRedirectURL(String s) {
        throw new UnsupportedOperationException();
    }

    @Override
    public String encodeUrl(String s) {
        throw new UnsupportedOperationException();
    }

    @Override
    public String encodeRedirectUrl(String s) {
        throw new UnsupportedOperationException();
    }

    @Override
    public void sendError(int i, String s) throws IOException {
        throw new UnsupportedOperationException();
    }

    @Override
    public void sendError(int i) throws IOException {
        throw new UnsupportedOperationException();
    }

    @Override
    public void sendRedirect(String s) throws IOException {
        throw new UnsupportedOperationException();
    }

    @Override
    public void setDateHeader(String s, long l) {
        throw new UnsupportedOperationException();
    }

    @Override
    public void addDateHeader(String s, long l) {
        throw new UnsupportedOperationException();
    }

    @Override
    public void setHeader(String headerName, String headerValue) {
        Object o = axis2MessageContext.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);
        Map headers = (Map) o;
        if (headers != null) {
            headers.put(headerName, headerValue);
        }
    }

    @Override
    public void addHeader(String headerName, String headerValue) {
        Object o = axis2MessageContext.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);
        Map headers = (Map) o;
        if (headers != null) {
            headers.put(headerName, headerValue);
        }
        if (HTTP.CONTENT_TYPE.equals(headerName)) {
            contentType = headerValue;
        }
        if (HTTP.CONTENT_LEN.equals(headerName)) {
            contentLength = Long.parseLong(headerValue);
        }
    }

    @Override
    public void setIntHeader(String s, int i) {
        throw new UnsupportedOperationException();
    }

    @Override
    public void addIntHeader(String s, int i) {
        throw new UnsupportedOperationException();
    }

    @Override
    public void setStatus(int i) {
        axis2MessageContext.setProperty(PreplacedThroughConstants.HTTP_SC, i);
        statusCode = i;
    }

    @Override
    public void setStatus(int i, String s) {
        throw new UnsupportedOperationException();
    }

    @Override
    public int getStatus() {
        return statusCode;
    }

    @Override
    public String getHeader(String s) {
        throw new UnsupportedOperationException();
    }

    @Override
    public Collection<String> getHeaders(String s) {
        throw new UnsupportedOperationException();
    }

    @Override
    public Collection<String> getHeaderNames() {
        throw new UnsupportedOperationException();
    }

    @Override
    public String getCharacterEncoding() {
        return characterEncoding;
    }

    @Override
    public String getContentType() {
        return contentType;
    }

    @Override
    public ServletOutputStream getOutputStream() throws IOException {
        return this.outputStream;
    }

    private void setCommittedIfBufferSizeExceeded() {
        int bufSize = getBufferSize();
        if (bufSize > 0 && this.content.size() > bufSize) {
            setCommitted(true);
        }
    }

    public void setCommitted(boolean committed) {
        this.committed = committed;
    }

    private clreplaced ResponseServletOutputStream extends ServletOutputStream {

        private final OutputStream targetStream;

        ResponseServletOutputStream(OutputStream out) {
            targetStream = out;
        }

        @Override
        public void write(int b) throws IOException {
            targetStream.write(b);
            super.flush();
            targetStream.flush();
            setCommittedIfBufferSizeExceeded();
        }

        @Override
        public void flush() throws IOException {
            super.flush();
            setCommitted(true);
        }

        @Override
        public void close() throws IOException {
            super.close();
            this.targetStream.close();
        }
    }

    @Override
    public PrintWriter getWriter() {
        throw new UnsupportedOperationException();
    }

    @Override
    public void setCharacterEncoding(String s) {
        this.characterEncoding = characterEncoding;
    }

    @Override
    public void setContentLength(int i) {
        contentLength = i;
    }

    public int getContentLength() {
        return (int) this.contentLength;
    }

    public String getContentreplacedtring() throws UnsupportedEncodingException {
        return (this.characterEncoding != null ? this.content.toString(this.characterEncoding) : this.content.toString());
    }

    @Override
    public void setContentType(String s) {
        contentType = s;
    }

    @Override
    public void setBufferSize(int bufferSize) {
        this.bufferSize = bufferSize;
    }

    @Override
    public int getBufferSize() {
        return this.bufferSize;
    }

    @Override
    public void flushBuffer() {
        setCommitted(true);
    }

    @Override
    public void resetBuffer() {
        this.content.reset();
    }

    @Override
    public boolean isCommitted() {
        return this.committed;
    }

    @Override
    public void reset() {
        resetBuffer();
        this.characterEncoding = null;
        this.contentLength = 0;
        this.contentType = null;
    }

    @Override
    public void setLocale(Locale locale) {
        throw new UnsupportedOperationException();
    }

    @Override
    public Locale getLocale() {
        throw new UnsupportedOperationException();
    }
}

17 View Complete Implementation : SMTPFaultHandler.java
Copyright Apache License 2.0
Author : wso2
public void flowComplete(MessageContext msgContext) {
    String protocol = msgContext.getIncomingTransportName();
    if (protocol == null) {
        return;
    }
    if (protocol.equalsIgnoreCase(Constants.TRANSPORT_MAIL) && msgContext.isServerSide()) {
        // This will allow the faults to go out.
        msgContext.setServerSide(false);
    }
}

17 View Complete Implementation : InboundHttpServerWorker.java
Copyright Apache License 2.0
Author : wso2
/**
 * Creates synapse message context from axis2 context
 *
 * @param inboundSourceRequest Source Request of inbound
 * @param axis2Context         Axis2 message context of message
 * @return Synapse Message Context instance
 * @throws AxisFault
 */
private org.apache.synapse.MessageContext createSynapseMessageContext(SourceRequest inboundSourceRequest, MessageContext axis2Context) throws AxisFault {
    return MessageContextCreatorForAxis2.getSynapseMessageContext(axis2Context);
}

17 View Complete Implementation : LoadbalanceFailoverClient.java
Copyright Apache License 2.0
Author : wso2
protected void setSessionID(MessageContext axis2MessageContext, String value) {
    if (value == null) {
        return;
    }
    Map map = (Map) axis2MessageContext.getProperty(HTTPConstants.HTTP_HEADERS);
    if (map == null) {
        map = new HashMap();
        axis2MessageContext.setProperty(HTTPConstants.HTTP_HEADERS, map);
    }
    map.put(COOKIE, value);
}

17 View Complete Implementation : InboundHttpServerWorker.java
Copyright Apache License 2.0
Author : wso2
/**
 * Set Inbound Related Properties for Axis2 Message Context
 *
 * @param axis2Context Axis2 Message Context of incoming request
 */
private void setInboundProperties(MessageContext axis2Context) {
    axis2Context.setProperty(SynapseConstants.IS_INBOUND, true);
}

16 View Complete Implementation : AbstractAdmin.java
Copyright Apache License 2.0
Author : wso2
protected ConfigurationContext getConfigContext() {
    checkAdminService();
    if (configurationContext != null) {
        return configurationContext;
    }
    MessageContext msgContext = MessageContext.getCurrentMessageContext();
    if (msgContext != null) {
        ConfigurationContext mainConfigContext = msgContext.getConfigurationContext();
        return mainConfigContext;
    } else {
        return CarbonConfigurationContextFactory.getConfigurationContext();
    }
}

16 View Complete Implementation : JsonStreamFormatter.java
Copyright Apache License 2.0
Author : wso2
public String formatSOAPAction(MessageContext messageContext, OMOutputFormat omOutputFormat, String s) {
    try {
        if (MicroIntegratorBaseUtils.isDataService(messageContext)) {
            return (String) axis2GsonFormatterFormatSOAPActionMethod.invoke(axis2GsonFormatter, messageContext, omOutputFormat, s);
        } else {
            return (String) synapseFormatterFormatSOAPActionMethod.invoke(synapseFormatter, messageContext, omOutputFormat, s);
        }
    } catch (InvocationTargetException | IllegalAccessException | AxisFault e) {
        logger.error(e.getMessage());
        throw new RuntimeException(e.getMessage());
    }
}

16 View Complete Implementation : AbstractAdmin.java
Copyright Apache License 2.0
Author : wso2
protected HttpSession getHttpSession() {
    checkAdminService();
    MessageContext msgCtx = MessageContext.getCurrentMessageContext();
    HttpSession httpSession = null;
    if (msgCtx != null) {
        HttpServletRequest request = (HttpServletRequest) msgCtx.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
        httpSession = request.getSession();
    }
    return httpSession;
}

16 View Complete Implementation : JsonStreamFormatter.java
Copyright Apache License 2.0
Author : wso2
public String getContentType(MessageContext messageContext, OMOutputFormat omOutputFormat, String s) {
    try {
        if (MicroIntegratorBaseUtils.isDataService(messageContext)) {
            return (String) axis2GsonFormatterGetContentTypeMethod.invoke(axis2GsonFormatter, messageContext, omOutputFormat, s);
        } else {
            return (String) synapseFormatterGetContentTypeMethod.invoke(synapseFormatter, messageContext, omOutputFormat, s);
        }
    } catch (InvocationTargetException | IllegalAccessException | AxisFault e) {
        logger.error(e.getMessage());
        throw new RuntimeException(e.getMessage());
    }
}

16 View Complete Implementation : JsonStreamFormatter.java
Copyright Apache License 2.0
Author : wso2
public byte[] getBytes(MessageContext messageContext, OMOutputFormat omOutputFormat) throws AxisFault {
    try {
        if (MicroIntegratorBaseUtils.isDataService(messageContext)) {
            return (byte[]) axis2GsonFormatterGetBytesMethod.invoke(axis2GsonFormatter, messageContext, omOutputFormat);
        } else {
            return (byte[]) synapseFormatterGetBytesMethod.invoke(synapseFormatter, messageContext, omOutputFormat);
        }
    } catch (InvocationTargetException | IllegalAccessException e) {
        logger.error("Error occurred while generating bytes for application/json", e);
        throw new AxisFault(e.getMessage());
    }
}

16 View Complete Implementation : ParallelRequestHelper.java
Copyright Apache License 2.0
Author : wso2
/**
 * helper method to send begin boxcar request and return the session
 *
 * @return cookie
 * @throws org.apache.axis2.AxisFault
 */
public String beginBoxcarReturningSession() throws AxisFault {
    sender.sendReceive(payload);
    MessageContext msgCtx = sender.getLastOperationContext().getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
    CommonsTransportHeaders commonsTransportHeaders = (CommonsTransportHeaders) msgCtx.getProperty(MessageContext.TRANSPORT_HEADERS);
    String cookie = (String) commonsTransportHeaders.get("Set-Cookie");
    return cookie;
}