use of nl.basjes.parse.core.ParsedField in project logparser by nielsbasjes.
the class UrlClassDissector method dissect.
@Override
public void dissect(final Parsable<?> parsable, final String inputname) throws DissectionFailure {
final ParsedField field = parsable.getParsableField(INPUT_TYPE, inputname);
String fieldValue = field.getValue().getString();
if (fieldValue == null || fieldValue.isEmpty()) {
// Nothing to do here
return;
}
parsable.addDissection(inputname, "HTTP.PATH.CLASS", "class", calculateClass(fieldValue));
}
use of nl.basjes.parse.core.ParsedField in project logparser by nielsbasjes.
the class ModUniqueIdDissector method dissect.
// --------------------------------------------
@Override
public void dissect(final Parsable<?> parsable, final String inputname) throws DissectionFailure {
final ParsedField field = parsable.getParsableField(INPUT_TYPE, inputname);
String fieldValue = field.getValue().getString();
if (fieldValue == null || fieldValue.isEmpty()) {
// Nothing to do here
return;
}
UniqueIdRec record = decode(fieldValue);
if (record == null) {
return;
}
if (wantTime) {
parsable.addDissection(inputname, "TIME.EPOCH", "epoch", record.timestamp);
}
if (wantIp) {
parsable.addDissection(inputname, "IP", "ip", record.ipaddrStr);
}
if (wantProcessId) {
parsable.addDissection(inputname, "PROCESSID", "processid", record.pid);
}
if (wantCounter) {
parsable.addDissection(inputname, "COUNTER", "counter", record.counter);
}
if (wantThreadIndex) {
parsable.addDissection(inputname, "THREAD_INDEX", "threadindex", record.threadIndex);
}
}
use of nl.basjes.parse.core.ParsedField in project logparser by nielsbasjes.
the class QueryStringFieldDissector method dissect.
// --------------------------------------------
@Override
public void dissect(final Parsable<?> parsable, final String inputname) throws DissectionFailure {
final ParsedField field = parsable.getParsableField(INPUT_TYPE, inputname);
String fieldValue = field.getValue().getString();
if (fieldValue == null || fieldValue.isEmpty()) {
// Nothing to do here
return;
}
String[] allValues = fieldValue.split("&");
for (String value : allValues) {
int equalPos = value.indexOf('=');
if (equalPos == -1) {
if (!"".equals(value)) {
String name = value.toLowerCase();
if (wantAllFields || requestedParameters.contains(name)) {
parsable.addDissection(inputname, "STRING", name, "");
}
}
} else {
String name = value.substring(0, equalPos).toLowerCase();
if (wantAllFields || requestedParameters.contains(name)) {
try {
parsable.addDissection(inputname, "STRING", name, resilientUrlDecode(value.substring(equalPos + 1, value.length())));
} catch (IllegalArgumentException e) {
// This usually means that there was invalid encoding in the line
throw new DissectionFailure(e.getMessage());
}
}
}
}
}
use of nl.basjes.parse.core.ParsedField in project logparser by nielsbasjes.
the class ResponseSetCookieDissector method dissect.
// --------------------------------------------
@Override
public void dissect(final Parsable<?> parsable, final String inputname) throws DissectionFailure {
final ParsedField field = parsable.getParsableField(INPUT_TYPE, inputname);
final String fieldValue = field.getValue().getString();
if (fieldValue == null || fieldValue.isEmpty()) {
// Nothing to do here
return;
}
String[] parts = fieldValue.split(";");
for (int i = 0; i < parts.length; i++) {
String part = parts[i].trim();
String[] keyValue = part.split("=", 2);
String key = keyValue[0].trim();
String value = "";
if (keyValue.length == 2) {
value = keyValue[1].trim();
}
if (i == 0) {
parsable.addDissection(inputname, "STRING", "value", value);
} else {
switch(key) {
// We ignore the max-age field because that is unsupported by IE anyway.
case "expires":
Long expires = parseExpire(value);
// Backwards compatibility: STRING version is in seconds
parsable.addDissection(inputname, "STRING", "expires", expires / 1000);
parsable.addDissection(inputname, "TIME.EPOCH", "expires", expires);
break;
case "domain":
parsable.addDissection(inputname, "STRING", "domain", value);
break;
case "comment":
parsable.addDissection(inputname, "STRING", "comment", value);
break;
case "path":
parsable.addDissection(inputname, "STRING", "path", value);
break;
// Ignore anything else
default:
}
}
}
}
use of nl.basjes.parse.core.ParsedField in project logparser by nielsbasjes.
the class ScreenResolutionDissector method dissect.
@Override
public void dissect(Parsable<?> parsable, String inputname) throws DissectionFailure {
final ParsedField field = parsable.getParsableField(SCREENRESOLUTION, inputname);
final String fieldValue = field.getValue().getString();
if (fieldValue == null || fieldValue.isEmpty()) {
// Nothing to do here
return;
}
if (fieldValue.contains(separator)) {
String[] parts = fieldValue.split(separator);
if (wantWidth) {
parsable.addDissection(inputname, "SCREENWIDTH", "width", parts[0]);
}
if (wantHeight) {
parsable.addDissection(inputname, "SCREENHEIGHT", "height", parts[1]);
}
}
}
Aggregations