* @param userKey
* @return a calendar, null if authentication fails
*/
private Calendar createCal(final Map<String, String> params, final Integer userId, final String authKey, final String timesheetUserParam)
{
final UserDao userDao = Registry.instance().getDao(UserDao.class);
final PFUserDO loggedInUser = userDao.getUserByAuthenticationToken(userId, authKey);
if (loggedInUser == null) {
return null;
}
PFUserDO timesheetUser = null;
if (StringUtils.isNotBlank(timesheetUserParam) == true) {
final Integer timesheetUserId = NumberHelper.parseInteger(timesheetUserParam);
if (timesheetUserId != null) {
if (timesheetUserId.equals(loggedInUser.getId()) == false) {
log.error("Not yet allowed: all users are only allowed to download their own time-sheets.");
return null;
}
timesheetUser = userDao.getUserGroupCache().getUser(timesheetUserId);
if (timesheetUser == null) {
log.error("Time-sheet user with id '" + timesheetUserParam + "' not found.");
return null;
}
}