DeleteAccountClickListener.java

  1. /*
  2.  * Copyright 2010-2025 James Pether Sörling
  3.  *
  4.  * Licensed under the Apache License, Version 2.0 (the "License");
  5.  * you may not use this file except in compliance with the License.
  6.  * You may obtain a copy of the License at
  7.  *
  8.  *   http://www.apache.org/licenses/LICENSE-2.0
  9.  *
  10.  * Unless required by applicable law or agreed to in writing, software
  11.  * distributed under the License is distributed on an "AS IS" BASIS,
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  * See the License for the specific language governing permissions and
  14.  * limitations under the License.
  15.  *
  16.  *  $Id$
  17.  *  $HeadURL$
  18. */
  19. package com.hack23.cia.web.impl.ui.application.views.pageclicklistener;

  20. import org.slf4j.Logger;
  21. import org.slf4j.LoggerFactory;

  22. import com.hack23.cia.service.api.action.common.ServiceResponse.ServiceResult;
  23. import com.hack23.cia.service.api.action.user.DeleteAccountRequest;
  24. import com.hack23.cia.service.api.action.user.DeleteAccountResponse;
  25. import com.vaadin.ui.Button.ClickEvent;
  26. import com.vaadin.ui.Button.ClickListener;
  27. import com.vaadin.ui.Notification;

  28. /**
  29.  * The Class DeleteAccountClickListener.
  30.  *
  31.  * @see DeleteAccountClickEvent
  32.  */
  33. public class DeleteAccountClickListener extends AbstractClickListener implements ClickListener {

  34.     /** The Constant ERROR_MESSAGE. */
  35.     private static final String ERROR_MESSAGE = "Error message";

  36.     /** The Constant LOGGER. */
  37.     private static final Logger LOGGER = LoggerFactory
  38.             .getLogger(DeleteAccountClickListener.class);

  39.     /** The Constant PROBLEM_DISABLE_GOOGLE_AUTHENTICATOR. */
  40.     private static final String PROBLEM_DELETE_ACCOUNT = "Problem deleting account";

  41.     /** The Constant PROBLEM_DISABLE_GOOGLE_AUTHENTICATOR_SESSIONID. */
  42.     private static final String PROBLEM_DELETE_ACCOUNT_SESSIONID = "Problem deleting account, sessionid{}";

  43.     /** The Constant serialVersionUID. */
  44.     private static final long serialVersionUID = 1L;

  45.     /** The google auth request. */
  46.     private final DeleteAccountRequest deleteAccountRequest;

  47.     /**
  48.      * Instantiates a new delete account click listener.
  49.      *
  50.      * @param deleteAccountRequest the delete account request
  51.      */
  52.     public DeleteAccountClickListener(final DeleteAccountRequest deleteAccountRequest) {
  53.         this.deleteAccountRequest = deleteAccountRequest;
  54.     }

  55.     /**
  56.      * Button click.
  57.      *
  58.      * @param event the event
  59.      */
  60.     @Override
  61.     public final void buttonClick(final ClickEvent event) {
  62.         final DeleteAccountResponse response = (DeleteAccountResponse) getApplicationManager().service(deleteAccountRequest);

  63.         if (ServiceResult.FAILURE == response.getResult()) {
  64.             showNotification(PROBLEM_DELETE_ACCOUNT, ERROR_MESSAGE, Notification.Type.WARNING_MESSAGE);
  65.             LOGGER.info(PROBLEM_DELETE_ACCOUNT_SESSIONID, deleteAccountRequest.getSessionId());
  66.         }
  67.     }
  68. }