private List<VerifiableEmail> getEmailIdentities(EntityParam recipient, SqlSession sql)
     throws EngineException {
   List<VerifiableEmail> emailIds = new ArrayList<>();
   long entityId = idResolver.getEntityId(recipient, sql);
   Identity[] identities = dbIdentities.getIdentitiesForEntityNoContext(entityId, sql);
   for (Identity id : identities)
     if (id.getTypeId().equals(EmailIdentity.ID))
       emailIds.add(EmailIdentity.fromIdentityParam(id));
   return emailIds;
 }
 private void cleanScheduledRemoval(long loggedEntity) {
   SqlSession sqlMap = db.getSqlSession(true);
   try {
     dbIdentities.clearScheduledRemovalStatus(loggedEntity, sqlMap);
     sqlMap.commit();
   } catch (EngineException e) {
     log.error("Can not clear automatic removal (if any) from the user being logged in", e);
   } finally {
     db.releaseSqlSession(sqlMap);
   }
 }
  /** {@inheritDoc} */
  @Override
  public ConfirmationStatus processConfirmation(String state, SqlSession sql)
      throws EngineException {
    T idState = parseState(state);
    EntityState entityState = null;
    try {
      entityState = dbIdentities.getEntityStatus(idState.getOwnerEntityId(), sql);
    } catch (Exception e) {
      return new ConfirmationStatus(
          false, idState.getRedirectUrl(), "ConfirmationStatus.entityRemoved");
    }

    if (!entityState.equals(EntityState.valid)) {
      return new ConfirmationStatus(
          false, idState.getRedirectUrl(), "ConfirmationStatus.entityInvalid");
    }

    return confirmElements(idState, sql);
  }