String yearAsStriing = request.getParameter("year");
String monthAsString = request.getParameter("month");
Calendar cal = blog.getCalendar();
LogSummary logSummary;
View view;
if (yearAsStriing != null && yearAsStriing.length() > 0 &&
monthAsString != null && monthAsString.length() > 0) {
int year = Integer.parseInt(yearAsStriing);
int month = Integer.parseInt(monthAsString)-1;
cal.set(Calendar.YEAR, year);
cal.set(Calendar.MONTH, month);
logSummary = blog.getLogger().getLogSummary(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH)+1);
view = new LogSummaryByMonthView();
registerObjectsForNavigation(blog, blog.getBlogForMonth(year, month+1));
} else if (yearAsStriing != null && yearAsStriing.length() > 0) {
cal.set(Calendar.YEAR, Integer.parseInt(yearAsStriing));
logSummary = blog.getLogger().getLogSummary(cal.get(Calendar.YEAR));
view = new LogSummaryByYearView();
} else {
// get the log for this monthAsString
logSummary = blog.getLogger().getLogSummary(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH)+1);
view = new LogSummaryByMonthView();
registerObjectsForNavigation(blog, blog.getBlogForThisMonth());
}
SimpleDateFormat yearFormatter = new SimpleDateFormat("yyyy", Locale.ENGLISH);
yearFormatter.setTimeZone(blog.getTimeZone());
SimpleDateFormat monthFormatter = new SimpleDateFormat("MM", Locale.ENGLISH);
monthFormatter.setTimeZone(blog.getTimeZone());
SimpleDateFormat dayFormatter = new SimpleDateFormat("dd", Locale.ENGLISH);
dayFormatter.setTimeZone(blog.getTimeZone());
getModel().put("year", yearFormatter.format(logSummary.getDate()));
getModel().put("month", monthFormatter.format(logSummary.getDate()));
getModel().put("logAction", "viewLogSummary");
getModel().put("logSummary", logSummary);
return view;