UpdateApplicationConfigurationClickListener.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.admin.UpdateApplicationConfigurationRequest;
  23. import com.hack23.cia.service.api.action.common.ServiceResponse;
  24. import com.hack23.cia.service.api.action.common.ServiceResponse.ServiceResult;
  25. import com.hack23.cia.web.impl.ui.application.views.common.viewnames.AdminViews;
  26. import com.vaadin.ui.Button.ClickEvent;
  27. import com.vaadin.ui.Button.ClickListener;
  28. import com.vaadin.ui.Notification;
  29. import com.vaadin.ui.UI;

  30. /**
  31.  * The Class UpdateApplicationConfigurationClickListener.
  32.  *
  33.  * @see UpdateApplicationConfigurationClickEvent
  34.  */
  35. public class UpdateApplicationConfigurationClickListener extends AbstractClickListener implements ClickListener {

  36.     /** The Constant ERROR_MESSAGE. */
  37.     private static final String ERROR_MESSAGE = "Error message";

  38.     /** The Constant LOG_MSG_UPDATE_APPLICATION_CONFIGURATION_FAILURE. */
  39.     private static final String LOG_MSG_UPDATE_APPLICATION_CONFIGURATION_FAILURE = "UpdateApplicationConfiguration {} failure";

  40.     /** The Constant LOG_UPDATE_APPLICATION_CONFIGURATION. */
  41.     private static final String LOG_UPDATE_APPLICATION_CONFIGURATION = "UpdateApplicationConfiguration {}";

  42.     /** The Constant LOGGER. */
  43.     private static final Logger LOGGER = LoggerFactory.getLogger(UpdateApplicationConfigurationClickListener.class);

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

  46.     /** The Constant UPDATE_APPLICATION_CONFIGURATION_FAILED. */
  47.     private static final String UPDATE_APPLICATION_CONFIGURATION_FAILED = "Update Application Configuration failed";


  48.     /** The request. */
  49.     private final UpdateApplicationConfigurationRequest request;

  50.     /**
  51.      * Instantiates a new update application configuration click listener.
  52.      *
  53.      * @param request
  54.      *            the request
  55.      */
  56.     public UpdateApplicationConfigurationClickListener(final UpdateApplicationConfigurationRequest request) {
  57.         this.request = request;
  58.     }

  59.     @Override
  60.     public final void buttonClick(final ClickEvent event) {
  61.         final ServiceResponse response = getApplicationManager().service(request);
  62.         if (ServiceResult.SUCCESS == response.getResult()) {
  63.             LOGGER.info(LOG_UPDATE_APPLICATION_CONFIGURATION,request.getApplicationConfigurationId());

  64.             UI.getCurrent().getNavigator().navigateTo(AdminViews.ADMIN_APPLICATIONS_CONFIGURATION_VIEW_NAME + "/" + request.getApplicationConfigurationId());

  65.         } else {
  66.             showNotification(UPDATE_APPLICATION_CONFIGURATION_FAILED,
  67.                       ERROR_MESSAGE,
  68.                       Notification.Type.WARNING_MESSAGE);
  69.             LOGGER.info(LOG_MSG_UPDATE_APPLICATION_CONFIGURATION_FAILURE,request.getApplicationConfigurationId());
  70.         }
  71.     }
  72. }