Search in sources :

Example 1 with Ack

use of org.wso2.ei.dashboard.core.rest.model.Ack in project wso2-synapse by wso2.

the class HttpRequestWorker method sendResponse.

private void sendResponse(int statusCode, HttpResponseStatus responseStatus, boolean disableKeepAlive, boolean contentAvailable, String content, String contentType) {
    HttpCarbonMessage clientRequest = (HttpCarbonRequest) this.msgContext.getProperty(BridgeConstants.HTTP_CLIENT_REQUEST_CARBON_MESSAGE);
    HttpCarbonMessage outboundResponse;
    try {
        outboundResponse = new HttpCarbonMessage(new DefaultHttpResponse(HttpVersion.HTTP_1_1, responseStatus));
        outboundResponse.setHttpStatusCode(statusCode);
        if (disableKeepAlive) {
            outboundResponse.setKeepAlive(false);
        }
        clientRequest.respond(outboundResponse);
    } catch (ServerConnectorException e) {
        LOG.error("Error occurred while submitting the Ack to the client", e);
        return;
    }
    if (!contentAvailable) {
        try {
            OutputStream messageOutputStream = HttpUtils.getHttpMessageDataStreamer(outboundResponse).getOutputStream();
            HttpUtils.writeEmptyBody(messageOutputStream);
        } catch (AxisFault e) {
            LOG.error("Error occurred while writing the Ack to the client", e);
        }
        return;
    }
    outboundResponse.setHeader(HTTP.CONTENT_TYPE, contentType);
    try (OutputStream outputStream = HttpUtils.getHttpMessageDataStreamer(outboundResponse).getOutputStream()) {
        outputStream.write(content.getBytes());
    } catch (IOException ioException) {
        LOG.error("Error occurred while writing the response body to the client", ioException);
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) HttpCarbonMessage(org.wso2.transport.http.netty.message.HttpCarbonMessage) DefaultHttpResponse(io.netty.handler.codec.http.DefaultHttpResponse) OutputStream(java.io.OutputStream) ServerConnectorException(org.wso2.transport.http.netty.contract.exceptions.ServerConnectorException) IOException(java.io.IOException) HttpCarbonRequest(org.wso2.transport.http.netty.message.HttpCarbonRequest)

Example 2 with Ack

use of org.wso2.ei.dashboard.core.rest.model.Ack in project product-mi-tooling by wso2.

the class EndpointsDelegate method updateArtifact.

@Override
public Ack updateArtifact(String groupId, ArtifactUpdateRequest request) throws ManagementApiException {
    logger.debug("Updating Endpoint " + request.getArtifactName() + " in node " + request.getNodeId() + " in group " + groupId);
    Ack ack = new Ack(Constants.FAIL_STATUS);
    boolean isSuccess = updateEndpoint(groupId, request);
    if (isSuccess) {
        ack.setStatus(Constants.SUCCESS_STATUS);
    }
    return ack;
}
Also used : Ack(org.wso2.ei.dashboard.core.rest.model.Ack)

Example 3 with Ack

use of org.wso2.ei.dashboard.core.rest.model.Ack in project product-mi-tooling by wso2.

the class InboundEndpointDelegate method updateArtifact.

@Override
public Ack updateArtifact(String groupId, ArtifactUpdateRequest request) throws ManagementApiException {
    logger.debug("Updating inbound endpoint " + request.getArtifactName() + " in node " + request.getNodeId() + " in group " + groupId);
    Ack ack = new Ack(Constants.FAIL_STATUS);
    boolean isSuccess = updateInboundEndpoint(groupId, request);
    if (isSuccess) {
        ack.setStatus(Constants.SUCCESS_STATUS);
    }
    return ack;
}
Also used : Ack(org.wso2.ei.dashboard.core.rest.model.Ack)

Example 4 with Ack

use of org.wso2.ei.dashboard.core.rest.model.Ack in project product-mi-tooling by wso2.

the class LogConfigDelegate method addLogger.

public Ack addLogger(String groupId, LogConfigAddRequest request) throws ManagementApiException {
    logger.debug("Adding new Logger " + request.getName() + " for all nodes in group " + groupId);
    Ack ack = new Ack(Constants.FAIL_STATUS);
    JsonObject payload = createAddLoggerPayload(request);
    NodeList nodeList = databaseManager.fetchNodes(groupId);
    for (NodeListInner node : nodeList) {
        String nodeId = node.getNodeId();
        String mgtApiUrl = ManagementApiUtils.getMgtApiUrl(groupId, nodeId);
        String accessToken = databaseManager.getAccessToken(groupId, nodeId);
        String addLoggerUrl = mgtApiUrl.concat("logging");
        logger.debug("Adding new logger on node " + nodeId);
        CloseableHttpResponse httpResponse = Utils.doPatch(groupId, nodeId, accessToken, addLoggerUrl, payload);
        if (httpResponse.getStatusLine().getStatusCode() != 200) {
            logger.error("Error occurred while adding logger on node " + nodeId + " in group " + groupId);
            String message = HttpUtils.getJsonResponse(httpResponse).get("Error").getAsString();
            ack.setMessage(message);
            return ack;
        }
    }
    ack.setStatus(Constants.SUCCESS_STATUS);
    return ack;
}
Also used : NodeListInner(org.wso2.ei.dashboard.core.rest.model.NodeListInner) NodeList(org.wso2.ei.dashboard.core.rest.model.NodeList) Ack(org.wso2.ei.dashboard.core.rest.model.Ack) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) JsonObject(com.google.gson.JsonObject)

Example 5 with Ack

use of org.wso2.ei.dashboard.core.rest.model.Ack in project product-mi-tooling by wso2.

the class LogConfigDelegate method updateLogLevel.

public Ack updateLogLevel(String groupId, LogConfigUpdateRequest request) throws ManagementApiException {
    logger.debug("Updating logger " + request.getName() + " for all nodes in group " + groupId);
    Ack ack = new Ack(Constants.FAIL_STATUS);
    JsonObject payload = createUpdateLoggerPayload(request);
    NodeList nodeList = databaseManager.fetchNodes(groupId);
    for (NodeListInner node : nodeList) {
        String nodeId = node.getNodeId();
        CloseableHttpResponse httpResponse = updateLogLevelByNodeId(groupId, nodeId, payload);
        if (httpResponse.getStatusLine().getStatusCode() != 200) {
            logger.error("Error occurred while updating logger on node " + nodeId + " in group " + groupId);
            String message = HttpUtils.getJsonResponse(httpResponse).get("Error").getAsString();
            ack.setMessage(message);
            return ack;
        }
    }
    ack.setStatus(Constants.SUCCESS_STATUS);
    return ack;
}
Also used : NodeListInner(org.wso2.ei.dashboard.core.rest.model.NodeListInner) NodeList(org.wso2.ei.dashboard.core.rest.model.NodeList) Ack(org.wso2.ei.dashboard.core.rest.model.Ack) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) JsonObject(com.google.gson.JsonObject)

Aggregations

Ack (org.wso2.ei.dashboard.core.rest.model.Ack)17 JsonObject (com.google.gson.JsonObject)5 Operation (io.swagger.v3.oas.annotations.Operation)5 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)5 ApiResponse (io.swagger.v3.oas.annotations.responses.ApiResponse)4 Response (javax.ws.rs.core.Response)4 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)4 NodeList (org.wso2.ei.dashboard.core.rest.model.NodeList)4 LogConfigDelegate (org.wso2.ei.dashboard.micro.integrator.delegates.LogConfigDelegate)3 NodeListInner (org.wso2.ei.dashboard.core.rest.model.NodeListInner)2 UsersDelegate (org.wso2.ei.dashboard.micro.integrator.delegates.UsersDelegate)2 HL7Exception (ca.uhn.hl7v2.HL7Exception)1 Message (ca.uhn.hl7v2.model.Message)1 DefaultHttpResponse (io.netty.handler.codec.http.DefaultHttpResponse)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 AxisFault (org.apache.axis2.AxisFault)1 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)1 MessageContext (org.apache.axis2.context.MessageContext)1 Parameter (org.apache.axis2.description.Parameter)1