String dateStr = parameters.get("from");
if (dateStr != null) {
try {
fromDate = format.parse(dateStr);
} catch (ParseException e) {
return new EmptyResponseContext(400, "Bad 'from' date format '" + dateStr + "'");
}
}
dateStr = parameters.get("to");
if (dateStr != null) {
try {
toDate = format.parse(dateStr);
} catch (ParseException e) {
return new EmptyResponseContext(400, "Bad 'to' date format '" + dateStr + "'");
}
}
boolean recentFirst = recentParam == null || recentParam.equals("true");
int action = -1;
LogEntry[] logs;
try {
final Registry reg = getSecureRegistry(request);
logs = reg.getLogs(path, action, user, fromDate, toDate, recentFirst);
} catch (RegistryException e) {
return new StackTraceResponseContext(e);
}
String uri = request.getUri().toString();
int colonIdx = uri.indexOf(':');
if (colonIdx > -1 && uri.length() > colonIdx + 1) {
int entryIdx;
try {
entryIdx = Integer.parseInt(uri.substring(colonIdx + 1));
} catch (NumberFormatException e) {
return new EmptyResponseContext(400, "Bad log entry id '" +
uri.substring(colonIdx + 1) + "'");
}
if (entryIdx < 0 || entryIdx > logs.length - 1) {
return new EmptyResponseContext(400, "Bad log entry id '" + entryIdx + "'");
}
LogEntry logentry = logs[logs.length - 1 - entryIdx];
Entry entry = factory.newEntry();
entry.setUpdated(new Date());
entry.setId("http://wso2.org/jdbcregistry,2007:logs:" + entryIdx);