Created
July 17, 2011 10:05
-
-
Save sandromancuso/1087417 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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