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);
}
}
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;
}
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;
}
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;
}
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;
}
Aggregations