use of org.wso2.ei.dashboard.core.rest.model.LogList in project product-mi-tooling by wso2.
the class GroupsApi method getLogFilesByNodeIds.
@GET
@Path("/{group-id}/logs")
@Produces({ "application/json" })
@Operation(summary = "Get log files by node ids", description = "", tags = { "logFiles" })
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "List of log files of provided nodes", content = @Content(schema = @Schema(implementation = LogList.class))), @ApiResponse(responseCode = "200", description = "Unexpected error", content = @Content(schema = @Schema(implementation = Error.class))) })
public Response getLogFilesByNodeIds(@PathParam("group-id") @Parameter(description = "Group ID of the node") String groupId, @NotNull @QueryParam("nodes") @Parameter(description = "ID/IDs of the nodes") List<String> nodes) throws ManagementApiException {
LogsDelegate logsDelegate = new LogsDelegate();
LogList logList = logsDelegate.getLogsList(groupId, nodes);
Response.ResponseBuilder responseBuilder = Response.ok().entity(logList);
HttpUtils.setHeaders(responseBuilder);
return responseBuilder.build();
}
use of org.wso2.ei.dashboard.core.rest.model.LogList in project product-mi-tooling by wso2.
the class LogsDelegate method getLogsList.
public LogList getLogsList(String groupId, List<String> nodeList) throws ManagementApiException {
log.debug("Fetching logs via management api.");
LogList logList = new LogList();
for (String nodeId : nodeList) {
JsonArray logsArray = getLogsArray(groupId, nodeId);
for (JsonElement jsonElement : logsArray) {
JsonObject logObject = jsonElement.getAsJsonObject();
String fileName = logObject.get("FileName").getAsString();
String fileSize = logObject.get("Size").getAsString();
AtomicBoolean isRecordExist = new AtomicBoolean(false);
logList.stream().filter(o -> o.getName().equals(fileName)).forEach(o -> {
LogDetail logDetail = new LogDetail();
logDetail.setNodeId(nodeId);
logDetail.setLogSize(fileSize);
o.getNodes().add(logDetail);
isRecordExist.set(true);
});
if (!isRecordExist.get()) {
LogListInner logListInner = new LogListInner();
logListInner.setName(fileName);
List<LogDetail> logDetailList = new ArrayList<>();
LogDetail logDetail = new LogDetail();
logDetail.setNodeId(nodeId);
logDetail.setLogSize(fileSize);
logDetailList.add(logDetail);
logListInner.setNodes(logDetailList);
logList.add(logListInner);
}
}
}
return logList;
}
Aggregations