/** Validate if password and confirm password field is equals */
  @Override
  public void validate(FacesContext context, UIComponent component, Object value) {

    String password = value.toString();

    UIInput uiInputConfirmPassword = (UIInput) component.getAttributes().get("confirmPassword");
    String confirmPassword = uiInputConfirmPassword.getSubmittedValue().toString();

    // Password and confirmPassword are required
    if (password == null
        || password.isEmpty()
        || confirmPassword == null
        || confirmPassword.isEmpty()) {
      return;
    }

    // If password and confirmPassword aren´t equal
    if (!password.equals(confirmPassword)) {
      uiInputConfirmPassword.setValid(false);
      FacesMessage msg =
          guiUtils.getFacesMessage(
              context, FacesMessage.SEVERITY_ERROR, "edit.user.passwordNotEqual");
      throw new ValidatorException(msg);
    }
  }
  public String doDelete() {
    FacesContext context = FacesContext.getCurrentInstance();
    FacesMessage message =
        guiUtils.getFacesMessage(
            FacesContext.getCurrentInstance(), FacesMessage.SEVERITY_ERROR, "album.delete.info");
    context.addMessage(null, message);

    albumService.delete(album);

    return "search.xhtml?faces-redirect=true";
  }
  public String init() {
    if (albumId > 0) {
      album = albumService.findById(albumId);

      if (album != null) {
        currentSongNumber = album.getSongs().size() + 1L;
        interpret = album.getInterpret();
        imageName = album.getImageFilename();
      } else {
        FacesContext context = FacesContext.getCurrentInstance();
        FacesMessage message =
            guiUtils.getFacesMessage(
                FacesContext.getCurrentInstance(),
                FacesMessage.SEVERITY_ERROR,
                "album.init.albumNotFoundError");
        context.addMessage(null, message);

        return "error";
      }
    }

    return null;
  }