use of com.aidanwhiteley.books.domain.User in project books by aidanwhiteley.
the class LimitDataVisibilityAspect method limitPageOfBookDataImpl.
@SuppressWarnings("unchecked")
@Around("limitPageBookData()")
public Object limitPageOfBookDataImpl(ProceedingJoinPoint joinPoint) throws Throwable {
Object retVal = joinPoint.proceed();
Principal principal = getPrincipal(joinPoint);
Optional<User> user = authUtils.extractUserFromPrincipal(principal, true);
if (retVal instanceof Page) {
if (LOGGER.isInfoEnabled()) {
LOGGER.info("About to call setPermissionsAndContentForUser for {}", joinPoint.getSignature());
}
User theUser = user.orElse(null);
((Page<Book>) retVal).getContent().forEach(s -> s.setPermissionsAndContentForUser(theUser));
} else {
LOGGER.error("Unexpected return type found by aspect");
}
return retVal;
}
Aggregations