use of nl.basjes.parse.core.exceptions.DissectionFailure 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());
}
}
}
}
}
Aggregations