use of com.jeanchampemont.wtfdyum.dto.Principal in project WTFDYUM by jchampemont.
the class AuthenticationInterceptor method preHandle.
@Override
public boolean preHandle(final HttpServletRequest request, final HttpServletResponse response, final Object handler) throws Exception {
final Long currentUserId = authenticationService.getCurrentUserId();
if (currentUserId != null) {
final Principal principal = principalService.get(currentUserId);
SessionManager.setPrincipal(principal);
}
return super.preHandle(request, response, handler);
}
use of com.jeanchampemont.wtfdyum.dto.Principal in project WTFDYUM by jchampemont.
the class NotifyUnfollowFeatureStrategy method completeCron.
@Override
public void completeCron(final Long userId) throws WTFDYUMException {
final Principal principal = principalService.get(userId);
final Set<Long> followers = twitterService.getFollowers(userId, Optional.ofNullable(principal));
followersService.saveFollowers(userId, followers);
}
use of com.jeanchampemont.wtfdyum.dto.Principal in project WTFDYUM by jchampemont.
the class TweetUnfollowFeatureStrategy method completeCron.
@Override
public void completeCron(final Long userId) throws WTFDYUMException {
final Principal principal = principalService.get(userId);
final Set<Long> followers = twitterService.getFollowers(userId, Optional.ofNullable(principal));
followersService.saveFollowers(userId, followers);
}
use of com.jeanchampemont.wtfdyum.dto.Principal in project WTFDYUM by jchampemont.
the class TweetUnfollowFeatureStrategy method cron.
@Override
public Set<Event> cron(final Long userId) throws WTFDYUMException {
final Set<Event> result = new HashSet<>();
final Principal principal = principalService.get(userId);
final Set<Long> followers = twitterService.getFollowers(userId, Optional.ofNullable(principal));
final Set<Long> unfollowersId = followersService.getUnfollowers(userId, followers);
final List<User> unfollowers = twitterService.getUsers(principal, Longs.toArray(unfollowersId));
for (final User unfollower : unfollowers) {
result.add(new Event(EventType.UNFOLLOW, unfollower.getScreenName()));
twitterService.tweet(principal, String.format(unfollowTweetText, unfollower.getScreenName()));
}
return result;
}
use of com.jeanchampemont.wtfdyum.dto.Principal in project WTFDYUM by jchampemont.
the class AuthenticationServiceTest method authenticateTest.
@Test
public void authenticateTest() {
sut.authenticate(new Principal(120L, "tok", "secret"));
verify(session, times(1)).setAttribute(anyString(), eq(120L));
}
Aggregations