/**
  * Return if user exists.
  *
  * @param userId The user id
  * @param session The {@link Session}.
  * @return if user exists
  */
 private boolean userExists(final String userId, final Session session) {
   UserManager userManager;
   try {
     userManager = userManagerFactory.createUserManager(session);
     return userManager.hasAuthorizable(userId);
   } catch (final Exception e) {
     log.debug(e.getMessage(), e);
     return false;
   }
 }
 /**
  * Return if user has permission.
  *
  * @param userIdentifier The user id
  * @param requestSession The {@link Session}.
  * @param adminSession The administrator {@link Session}.
  * @return if user has permission.
  */
 private boolean hasPermissions(
     final String userIdentifier, final Session requestSession, final Session adminSession) {
   try {
     if (StringUtils.isNotBlank(userIdentifier)) {
       final UserManager um = userManagerFactory.createUserManager(adminSession);
       if (um != null) {
         final Profile profile = um.get(userIdentifier).getProfile();
         if (profile != null) {
           if (requestSession != null) {
             return requestSession.hasPermission(profile.getPath(), Session.ACTION_READ);
           }
         }
       }
     }
     return false;
   } catch (final RepositoryException e) {
     return false;
   } catch (final NoSuchAuthorizableException e) {
     return false;
   }
 }