Untitled
unknown
java
3 years ago
4.2 kB
12
Indexable
private void process() throws IOException, InstantiationException, ClassNotFoundException,
IllegalAccessException, NoSuchMethodException, IllegalArgumentException, InvocationTargetException {
try ( LineIterator it = FileUtils.lineIterator(log, "UTF-8")) {
while (it.hasNext()) {
String originalLine = it.nextLine();
String[] lineSplited = originalLine.split("\\|-\\|");
if (lineSplited.length > 1) {
String temp_1 = lineSplited[1].trim();
String[] temp_2 = temp_1.split("&&", 2);
if (temp_2.length > 1) {
String tipoTransaccion = temp_2[0];
String[] temp_3 = temp_2[1].split(" ", 4);
if (temp_3.length > 3) {
// En muy raras ocasiones, en ves de que el string sea así [BV00010615], está así [BV00010615 ]
// probablemente sea algun error en el logger. Este workaround soluciona esto
if (!isJSONValid(temp_3[3])) {
temp_3 = temp_2[1].split(" ", 6);
if (temp_3.length > 5) {
temp_3[3] = temp_3[5];
}
}
String transaccion = temp_3[2].replaceAll("[\\[\\](){}]", "");
String jsonString = temp_3[3];
switch (tipoTransaccion) {
case "IN": {
ObjectMapper jsonMapper = new ObjectMapper();
JsonNode jsonNode = jsonMapper.readTree(jsonString);
((ObjectNode) jsonNode.get("requestHeader")).removeAll();
jsonString = jsonNode.toString();
jsonString = jsonString.replaceAll("\"requestHeader\":\\{\\},", "");
break;
}
case "OUT": {
ObjectMapper jsonMapper = new ObjectMapper();
JsonNode jsonNode = jsonMapper.readTree(jsonString);
((ObjectNode) jsonNode.get("responseHeader")).removeAll();
jsonString = jsonNode.toString();
jsonString = jsonString.replaceAll("\"responseHeader\":\\{\\},", "");
break;
}
}
jsonString = jsonString.replace(",\"__hashCodeCalc\":false", "");
System.out.println("==========================================================================================================");
System.out.println("Tipo transaccion: " + tipoTransaccion);
System.out.println("Transaccion: " + transaccion);
System.out.println("JSON string: " + jsonString);
System.out.println("==========================================================================================================");
ObjectMapper mapper = new ObjectMapper();
String clsName = transactions_two.get(transaccion + tipoTransaccion);
if (clsName != null) {
Class cls = Class.forName("com.debug.grupobbva.saexreadlog.beans." + clsName);
Object bean = mapper.readValue(jsonString, cls);
System.out.println("=====");
System.out.println("Bean: ");
System.out.println(bean);
System.out.println("=====");
}
}
}
}
}
}
}Editor is loading...