Skip to content

Instantly share code, notes, and snippets.

@sandromancuso
Created July 17, 2011 10:05
Show Gist options
  • Save sandromancuso/1087417 to your computer and use it in GitHub Desktop.
Save sandromancuso/1087417 to your computer and use it in GitHub Desktop.
public class TripService {
public List<Trip> getTripsByUser(User user) throws UserNotLoggedInException {
List<Trip> tripList = new ArrayList<Trip>();
User loggedUser = loggedUser();
boolean isFriend = false;
if (loggedUser != null) {
for (User friend : user.getFriends()) {
if (friend.equals(loggedUser)) {
isFriend = true;
break;
}
}
if (isFriend) {
tripList = findTripsByUser(user);
}
return tripList;
} else {
throw new UserNotLoggedInException();
}
}
protected List<Trip> findTripsByUser(User user) {
return TripDAO.findTripsByUser(user);
}
protected User loggedUser() {
return UserSession.getInstance().getLoggedUser();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment