}
}
}
private History historyFromSQLResult(ResultSet result, boolean withResponseData, Script[] scripts) throws Exception {
History history = new History();
history.setId(result.getInt(Constants.GENERIC_ID));
history.setProfileId(result.getInt(Constants.GENERIC_PROFILE_ID));
history.setClientUUID(result.getString(Constants.GENERIC_CLIENT_UUID));
history.setCreatedAt(result.getString(Constants.HISTORY_CREATED_AT));
history.setRequestType(result.getString(Constants.GENERIC_REQUEST_TYPE));
history.setRequestURL(result.getString(Constants.HISTORY_REQUEST_URL));
history.setRequestParams(result.getString(Constants.HISTORY_REQUEST_PARAMS));
history.setRequestPostData(result.getString(Constants.HISTORY_REQUEST_POST_DATA));
history.setRequestHeaders(result.getString(Constants.HISTORY_REQUEST_HEADERS));
history.setResponseCode(result.getString(Constants.HISTORY_RESPONSE_CODE));
history.setResponseContentType(result.getString(Constants.HISTORY_RESPONSE_CONTENT_TYPE));
history.setResponseHeaders(result.getString(Constants.HISTORY_RESPONSE_HEADERS));
history.setOriginalRequestHeaders(result.getString(Constants.HISTORY_ORIGINAL_REQUEST_HEADERS));
history.setOriginalRequestParams(result.getString(Constants.HISTORY_ORIGINAL_REQUEST_PARAMS));
history.setOriginalRequestPostData(result.getString(Constants.HISTORY_ORIGINAL_REQUEST_POST_DATA));
history.setOriginalRequestURL(result.getString(Constants.HISTORY_ORIGINAL_REQUEST_URL));
history.setOriginalResponseCode(result.getString(Constants.HISTORY_ORIGINAL_RESPONSE_CODE));
history.setOriginalResponseContentType(result.getString(Constants.HISTORY_ORIGINAL_RESPONSE_CONTENT_TYPE));
history.setOriginalResponseHeaders(result.getString(Constants.HISTORY_ORIGINAL_RESPONSE_HEADERS));
history.setModified(result.getBoolean(Constants.HISTORY_MODIFIED));
history.setRequestSent(result.getBoolean(Constants.HISTORY_REQUEST_SENT));
history.setRequestBodyDecoded(result.getBoolean(Constants.HISTORY_REQUEST_BODY_DECODED));
history.setResponseBodyDecoded(result.getBoolean(Constants.HISTORY_RESPONSE_BODY_DECODED));
if (withResponseData) {
history.setResponseData(result.getString(Constants.HISTORY_RESPONSE_DATA));
history.setOriginalResponseData(result.getString(Constants.HISTORY_ORIGINAL_RESPONSE_DATA));
} else {
history.setResponseData(null);
history.setOriginalResponseData(null);
}
// evaluate all scripts
for (Script script : scripts) {
try {
List<?> gresult = GroovyService.getInstance().runGroovy(script.getScript(), history.getRequestType(),
history.getRequestURL(),
history.getRequestParams(),
history.getRequestPostData(),
history.getRequestHeaders(),
history.getResponseCode(),
history.getResponseContentType(),
history.getResponseHeaders(),
history.getOriginalRequestURL(),
history.getOriginalRequestParams(),
history.getOriginalRequestPostData(),
history.getOriginalRequestHeaders(),
history.getOriginalResponseData(),
history.getOriginalResponseContentType(),
history.getOriginalResponseHeaders(),
history.isModified());
// this returns a list where [0] is the status
// and the rest is messages
if (Integer.parseInt(gresult.get(0).toString()) == 1) {
history.setValid(false);
String validString = history.getValidationMessage();
for (int x = 1; x < gresult.size(); x++) {
if (!validString.equals(""))
validString += "\n";
validString += gresult.get(x);
}
history.setValidationMessage(validString);
}
} catch (Exception e) {
}
}