c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
Guest guest = guestService.getGuest(username);
if (AuthHelper.getGuest().getId()!=guest.getId())
throw new RuntimeException("Attempt to access another user's photos");
DecimalFormat datePartFormat = new DecimalFormat("00");
DayMetadata dayMetaStart = metadataService.getDayMetadata(guest.getId(), year + "-" + datePartFormat.format(c.get(Calendar.MONTH) + 1) +
"-" + datePartFormat.format(c.get(Calendar.DAY_OF_MONTH)));
int newDay = c.get(Calendar.DAY_OF_YEAR) + 6;
if (newDay > (isLeapYear(year) ? 366 : 365)){
newDay -= isLeapYear(year) ? 366 : 365;
year += 1;
c.set(Calendar.YEAR,year);
}
c.set(Calendar.DAY_OF_YEAR,newDay);
DayMetadata dayMetaEnd = metadataService.getDayMetadata(guest.getId(), year + "-" + datePartFormat.format(c.get(Calendar.MONTH) + 1) +
"-" + datePartFormat.format(c.get(Calendar.DAY_OF_MONTH)));
return Response.ok(gson.toJson(getPhotos(guest, new SimpleTimeInterval(dayMetaStart.start,dayMetaEnd.end,TimeUnit.WEEK,dayMetaStart.getTimeInterval().getMainTimeZone())))).build();
} catch (Exception e){
return Response.serverError().entity("Could not get photos: " + e.getMessage()).build();
}