ChangePasswordClickListener.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.ChangePasswordRequest;
  24. import com.hack23.cia.service.api.action.user.ChangePasswordResponse;
  25. import com.vaadin.ui.Button.ClickEvent;
  26. import com.vaadin.ui.Button.ClickListener;
  27. import com.vaadin.ui.Notification;

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

  34.     /** The Constant LOGGER. */
  35.     private static final Logger LOGGER = LoggerFactory
  36.             .getLogger(ChangePasswordClickListener.class);

  37.     /** The Constant PROBLEM_CHANGING_PASSWORD. */
  38.     public static final String PROBLEM_CHANGING_PASSWORD = "Problem changing password";

  39.     /** The Constant PROBLEM_CHANGING_PASSWORD_SESSIONID. */
  40.     private static final String PROBLEM_CHANGING_PASSWORD_SESSIONID = "Problem changing password, sessionid{}";

  41.     /** The Constant serialVersionUID. */
  42.     private static final long serialVersionUID = 1L;

  43.     /** The change password request. */
  44.     private final ChangePasswordRequest changePasswordRequest;

  45.     /**
  46.      * Instantiates a new change password click listener.
  47.      *
  48.      * @param changePasswordRequest the change password request
  49.      */
  50.     public ChangePasswordClickListener(
  51.             final ChangePasswordRequest changePasswordRequest) {
  52.         this.changePasswordRequest = changePasswordRequest;
  53.     }

  54.     @Override
  55.     public final void buttonClick(final ClickEvent event) {
  56.         final ChangePasswordResponse response = (ChangePasswordResponse) getApplicationManager().service(changePasswordRequest);

  57.         if (ServiceResult.FAILURE == response.getResult()) {
  58.             showNotification(PROBLEM_CHANGING_PASSWORD, response.getErrorMessage(), Notification.Type.WARNING_MESSAGE);
  59.             LOGGER.info(PROBLEM_CHANGING_PASSWORD_SESSIONID, changePasswordRequest.getSessionId());
  60.         }
  61.     }
  62. }