Coverage Report - org.directdemocracyportal.democracy.web.controller.FrontController
 
Classes in this File Line Coverage Branch Coverage Complexity
FrontController
3%
7/180
0%
0/46
2.136
 
 1  
 /*
 2  
 Copyright 2010 James Pether Sörling Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 
 3  
         $Id
 4  
 */
 5  
 package org.directdemocracyportal.democracy.web.controller;
 6  
 
 7  
 import java.util.HashMap;
 8  
 import java.util.List;
 9  
 import java.util.Locale;
 10  
 import java.util.Map;
 11  
 
 12  
 import org.apache.commons.logging.Log;
 13  
 import org.apache.commons.logging.LogFactory;
 14  
 import org.directdemocracyportal.democracy.model.application.Event;
 15  
 import org.directdemocracyportal.democracy.model.application.OnlinePoliticalParty;
 16  
 import org.directdemocracyportal.democracy.model.application.User;
 17  
 import org.directdemocracyportal.democracy.model.world.Government;
 18  
 import org.directdemocracyportal.democracy.model.world.Organisation;
 19  
 import org.directdemocracyportal.democracy.model.world.Person;
 20  
 import org.directdemocracyportal.democracy.model.world.PoliticalParty;
 21  
 import org.directdemocracyportal.democracy.model.world.Vote;
 22  
 import org.directdemocracyportal.democracy.service.PartyAlreadyExistException;
 23  
 import org.directdemocracyportal.democracy.service.PortalService;
 24  
 import org.directdemocracyportal.democracy.service.UserAlreadyExistException;
 25  
 import org.directdemocracyportal.democracy.service.UserService;
 26  
 import org.directdemocracyportal.democracy.service.command.CreatePartyCommand;
 27  
 import org.directdemocracyportal.democracy.service.command.RegisterCommand;
 28  
 import org.directdemocracyportal.democracy.service.dao.AgentDAO;
 29  
 import org.directdemocracyportal.democracy.service.dao.DocumentDAO;
 30  
 import org.directdemocracyportal.democracy.web.ApplicationMessageHolder;
 31  
 import org.directdemocracyportal.democracy.web.BeanLocator;
 32  
 import org.directdemocracyportal.democracy.web.ImageConstants;
 33  
 import org.directdemocracyportal.democracy.web.StaticContextLoaderListener;
 34  
 import org.directdemocracyportal.democracy.web.UserState;
 35  
 import org.directdemocracyportal.democracy.web.ApplicationMessageHolder.MessageConstans;
 36  
 import org.directdemocracyportal.democracy.web.action.ControllerAction;
 37  
 import org.directdemocracyportal.democracy.web.action.CreatePoliticalPartyAction;
 38  
 import org.directdemocracyportal.democracy.web.action.JoinPoliticalPartyAction;
 39  
 import org.directdemocracyportal.democracy.web.action.LoginAction;
 40  
 import org.directdemocracyportal.democracy.web.action.LogoutAction;
 41  
 import org.directdemocracyportal.democracy.web.action.NewApplicationInstanceAction;
 42  
 import org.directdemocracyportal.democracy.web.action.RegisterAction;
 43  
 import org.directdemocracyportal.democracy.web.action.ShowAllEvents;
 44  
 import org.directdemocracyportal.democracy.web.action.ShowApplicationHome;
 45  
 import org.directdemocracyportal.democracy.web.action.ShowGovernmentAction;
 46  
 import org.directdemocracyportal.democracy.web.action.ShowGovernmentsAction;
 47  
 import org.directdemocracyportal.democracy.web.action.ShowMembersAction;
 48  
 import org.directdemocracyportal.democracy.web.action.ShowMyProfileAction;
 49  
 import org.directdemocracyportal.democracy.web.action.ShowOnlinePoliticalPartyAction;
 50  
 import org.directdemocracyportal.democracy.web.action.ShowOrganisationAction;
 51  
 import org.directdemocracyportal.democracy.web.action.ShowPersonAction;
 52  
 import org.directdemocracyportal.democracy.web.action.ShowPoliticalPartiesAction;
 53  
 import org.directdemocracyportal.democracy.web.action.ShowUserAction;
 54  
 import org.directdemocracyportal.democracy.web.views.ActiveUserView;
 55  
 import org.directdemocracyportal.democracy.web.views.EventsPanel;
 56  
 import org.directdemocracyportal.democracy.web.views.ExplorerPanel;
 57  
 import org.directdemocracyportal.democracy.web.views.FooterPanel;
 58  
 import org.directdemocracyportal.democracy.web.views.GovernmentOverviewPanel;
 59  
 import org.directdemocracyportal.democracy.web.views.GovernmentsPanel;
 60  
 import org.directdemocracyportal.democracy.web.views.HeaderPanel;
 61  
 import org.directdemocracyportal.democracy.web.views.MembersPanel;
 62  
 import org.directdemocracyportal.democracy.web.views.OnlinePoliticalPartyOverviewPanel;
 63  
 import org.directdemocracyportal.democracy.web.views.OrganisationOverviewPanel;
 64  
 import org.directdemocracyportal.democracy.web.views.PersonProfilePanel;
 65  
 import org.directdemocracyportal.democracy.web.views.PoliticalPartiesPanel;
 66  
 import org.directdemocracyportal.democracy.web.views.StartContentPanel;
 67  
 import org.directdemocracyportal.democracy.web.views.UserProfilePanel;
 68  
 import org.directdemocracyportal.democracy.web.views.dialogs.CreatePartyDialog;
 69  
 import org.directdemocracyportal.democracy.web.views.dialogs.LoginDialog;
 70  
 import org.directdemocracyportal.democracy.web.views.dialogs.RegisterUserDialog;
 71  
 import org.directdemocracyportal.democracy.web.views.dialogs.AbstractActionDialog.DialogResult;
 72  
 import org.directdemocracyportal.democracy.web.views.header.UserPanel;
 73  
 import org.directdemocracyportal.democracy.web.views.header.WelcomePanel;
 74  
 import org.springframework.context.i18n.LocaleContextHolder;
 75  
 import org.springframework.transaction.annotation.Propagation;
 76  
 import org.springframework.transaction.annotation.Transactional;
 77  
 
 78  
 import thinwire.ui.Component;
 79  
 import thinwire.ui.Frame;
 80  
 import thinwire.ui.Menu;
 81  
 import thinwire.ui.Panel;
 82  
 import thinwire.ui.layout.TableLayout;
 83  
 import thinwire.ui.style.Color;
 84  
 
 85  
 /**
 86  
  * The Class FrontController.
 87  
  */
 88  
 @Transactional(propagation = Propagation.REQUIRED)
 89  
 public class FrontController implements Controller
 90  
 {
 91  
 
 92  
     /** The log. */
 93  1
     private static Log log = LogFactory.getLog(FrontController.class);
 94  
 
 95  
     /** The user service. */
 96  
     private final UserService userService;
 97  
 
 98  
     /** The portal service. */
 99  
     private final PortalService portalService;
 100  
 
 101  
     /** The agent dao. */
 102  
     private final AgentDAO agentDAO;
 103  
 
 104  
     /** The document dao. */
 105  
     private final DocumentDAO documentDAO;
 106  
 
 107  
 
 108  
     /**
 109  
      * Instantiates a new front controller.
 110  
      *
 111  
      * @param userService the user service
 112  
      * @param portalService the portal service
 113  
      * @param agentDAO the agent dao
 114  
      * @param documentDAO the document dao
 115  
      */
 116  
     public FrontController(UserService userService,
 117  
             PortalService portalService, AgentDAO agentDAO,
 118  
             DocumentDAO documentDAO) {
 119  1
         super();
 120  1
         this.userService = userService;
 121  1
         this.portalService = portalService;
 122  1
         this.agentDAO = agentDAO;
 123  1
         this.documentDAO = documentDAO;
 124  1
     }
 125  
 
 126  
     /* (non-Javadoc)
 127  
      * @see org.directdemocracyportal.democracy.web.controller.Controller#handleAction(org.directdemocracyportal.democracy.web.action.ControllerAction)
 128  
      */
 129  
     public void handleAction(ControllerAction action) throws Exception {
 130  0
             if (action instanceof NewApplicationInstanceAction) {
 131  0
                 handleNewApplicationInstanceAction((NewApplicationInstanceAction) action);
 132  
             }
 133  0
             if (action instanceof LoginAction) {
 134  0
                 handleLoginAction((LoginAction) action);
 135  0
             } else if (action instanceof RegisterAction) {
 136  0
                 handleRegisterAction((RegisterAction) action);
 137  0
             }  else if (action instanceof LogoutAction) {
 138  0
                 handleLogoutAction((LogoutAction) action);
 139  0
             }  else if (action instanceof ShowMyProfileAction) {
 140  0
                 handleShowMyProfileAction((ShowMyProfileAction) action);
 141  0
             } else if (action instanceof ShowGovernmentAction) {
 142  0
                 handleShowGovernmentAction((ShowGovernmentAction) action);
 143  0
             }  else if (action instanceof ShowMembersAction) {
 144  0
                 handleShowMembersAction((ShowMembersAction) action);
 145  0
             }  else if (action instanceof ShowPoliticalPartiesAction) {
 146  0
                 handleShowPoliticalPartiesAction((ShowPoliticalPartiesAction) action);
 147  0
             } else if (action instanceof ShowGovernmentsAction) {
 148  0
                 handleShowGovernmentsAction((ShowGovernmentsAction) action);
 149  0
             } else if (action instanceof ShowApplicationHome) {
 150  0
                 handleShowApplicationHome((ShowApplicationHome) action);
 151  0
             } else if (action instanceof ShowAllEvents) {
 152  0
                 handleShowAllEvents((ShowAllEvents) action);
 153  0
             } else if (action instanceof CreatePoliticalPartyAction) {
 154  0
                 handleCreatePoliticalPartyAction((CreatePoliticalPartyAction) action);
 155  0
             }  else if (action instanceof JoinPoliticalPartyAction) {
 156  0
                 handleJoinPoliticalPartyAction((JoinPoliticalPartyAction) action);
 157  0
             } else if (action instanceof ShowOrganisationAction) {
 158  0
                 handleShowOrganisationAction((ShowOrganisationAction) action);
 159  0
             } else if (action instanceof ShowUserAction) {
 160  0
                 handleShowUserAction((ShowUserAction) action);
 161  0
             }  else if (action instanceof ShowOnlinePoliticalPartyAction) {
 162  0
                 handleShowOnlinePoliticalPartyAction((ShowOnlinePoliticalPartyAction) action);
 163  0
             } else if (action instanceof ShowPersonAction) {
 164  0
                 handleShowPersonAction((ShowPersonAction) action);
 165  
             }
 166  0
     }
 167  
 
 168  
     /**
 169  
      * Handle new application instance action.
 170  
      *
 171  
      * @param action the action
 172  
      */
 173  
     private void handleNewApplicationInstanceAction(
 174  
             NewApplicationInstanceAction action) {
 175  0
         Frame frame = action.getFrame();
 176  
 
 177  0
         setupUserSettings(action.getArgs());
 178  0
         frame.setTitle(ApplicationMessageHolder
 179  
                 .getMessage(MessageConstans.APPLICATION_NAME));
 180  0
         frame.setLayout(new TableLayout(new double[][] { { 150, 0 }, // Column
 181  
                 // Widths
 182  
                 { 0.1, 0.8, 0.1 } }, // Row Heights
 183  
                 1, // Margin around edge of container
 184  
                 0)); // Spacing between cells
 185  
 
 186  0
         Menu menu = createMenu();
 187  0
         frame.setMenu(menu);
 188  
 
 189  0
         HeaderPanel headerPanel = new HeaderPanel();
 190  0
         headerPanel.setLimit("0,0,2,1");
 191  0
         frame.getChildren().add(headerPanel);
 192  
 
 193  0
         ExplorerPanel explorerPanel = new ExplorerPanel();
 194  0
         explorerPanel.setLimit("0,1,1,1");
 195  0
         frame.getChildren().add(explorerPanel);
 196  
 
 197  0
         PortalService portalService = (PortalService) StaticContextLoaderListener.getWebApplicationContext().getBean("portalService");
 198  0
         Panel contentView = new StartContentPanel(portalService.getGlobalPortal());
 199  0
         contentView.setLimit("1,1,1,1");
 200  0
         frame.getChildren().add(contentView);
 201  0
         ActiveUserView.activeContentView.set(contentView);
 202  
 
 203  0
         FooterPanel footerPanel = new FooterPanel();
 204  0
         footerPanel.setLimit("0,2,2,1");
 205  0
         frame.getChildren().add(footerPanel);
 206  
 
 207  0
     }
 208  
 
 209  
     /**
 210  
      * Sets the up user settings.
 211  
      *
 212  
      * @param args the new up user settings
 213  
      */
 214  
     private void setupUserSettings(String[] args) {
 215  0
         UserState.userSettings.set(createUserSettingMap(args));
 216  
 
 217  0
         if (UserState.getAcceptLanguage().contains("sv")) {
 218  0
             UserState.locale.set(new Locale("sv"));
 219  
         } else {
 220  0
             UserState.locale.set(LocaleContextHolder.getLocale());
 221  
         }
 222  0
     }
 223  
 
 224  
     /**
 225  
      * Creates the user setting map.
 226  
      *
 227  
      * @param args the args
 228  
      * @return the map
 229  
      */
 230  
     private Map<String, String> createUserSettingMap(String[] args) {
 231  0
         Map<String, String> userSetting = new HashMap<String, String>();
 232  
 
 233  0
         for (String arg : args) {
 234  0
             String[] split = arg.split("=", 2);
 235  
 
 236  0
             String key = split[0];
 237  0
             String value = split[1];
 238  0
             userSetting.put(key, value);
 239  
         }
 240  0
         return userSetting;
 241  
     }
 242  
 
 243  
     /**
 244  
      * Creates the menu.
 245  
      *
 246  
      * @return the menu
 247  
      */
 248  
     private Menu createMenu() {
 249  0
         Menu menu = new Menu();
 250  0
         menu.getStyle().getFont().setColor(Color.WHITE);
 251  0
         menu.getStyle().getBackground().setColor(Color.valueOf("rgb(0,51,153)"));
 252  
 
 253  0
         Menu.Item mainPortalItem = new Menu.Item(ApplicationMessageHolder
 254  
                 .getMessage(MessageConstans.APPLICATION_NAME));
 255  0
         menu.getRootItem().getChildren().add(mainPortalItem);
 256  
 
 257  0
         Menu.Item membersPortalItem = new Menu.Item(ApplicationMessageHolder
 258  
                 .getMessage(MessageConstans.GROUPS));
 259  0
         membersPortalItem.setImage(ImageConstants.GROUP_HOME_ICON);
 260  0
         menu.getRootItem().getChildren().add(membersPortalItem);
 261  
 
 262  0
         Menu.Item portalItem = new Menu.Item(ApplicationMessageHolder
 263  
                 .getMessage(MessageConstans.RECENT_ACTIONS));
 264  0
         membersPortalItem.getChildren().add(portalItem);
 265  
 
 266  0
         Menu.Item showAllItem = new Menu.Item(ApplicationMessageHolder
 267  
                 .getMessage(MessageConstans.GROUPS));
 268  0
         showAllItem.setUserObject(new ShowAllEvents());
 269  0
         portalItem.getChildren().add(showAllItem);
 270  
 
 271  0
         Menu.Item partyItem = new Menu.Item(ApplicationMessageHolder
 272  
                 .getMessage(MessageConstans.POLITICAL_PARTY));
 273  0
         partyItem.setImage(ImageConstants.POLITICAL_PARTY_ICON);
 274  0
         menu.getRootItem().getChildren().add(partyItem);
 275  
 
 276  0
         Menu.Item createItem = new Menu.Item(ApplicationMessageHolder
 277  
                 .getMessage(MessageConstans.CREATE_POLITICAL_PARTY));
 278  0
         createItem.setUserObject(new CreatePoliticalPartyAction());
 279  
 
 280  0
         if (UserState.user.get() == null) {
 281  0
             createItem.setEnabled(false);
 282  
         }
 283  0
         partyItem.getChildren().add(createItem);
 284  
 
 285  0
         Menu.Item governmentPortalItem = new Menu.Item(ApplicationMessageHolder
 286  
                 .getMessage(MessageConstans.GOVERNMENTS));
 287  0
         governmentPortalItem.setImage(ImageConstants.GOVERNMENT_ICON);
 288  0
         menu.getRootItem().getChildren().add(governmentPortalItem);
 289  
 
 290  0
         menu.addActionListener(Component.ACTION_CLICK, BeanLocator
 291  
                 .getApplicationActionListener());
 292  0
         return menu;
 293  
     }
 294  
 
 295  
 
 296  
     /**
 297  
      * Handle show person action.
 298  
      *
 299  
      * @param action the action
 300  
      */
 301  
     private void handleShowPersonAction(ShowPersonAction action) {
 302  0
         Person person = (Person) agentDAO.load(action.getPersonId());
 303  
 
 304  0
         List<Vote> votes = documentDAO.getVotesForPerson(person);
 305  
 
 306  0
         ActiveUserView.changeContentView(new PersonProfilePanel(person,votes));
 307  0
     }
 308  
 
 309  
     /**
 310  
      * Handle show online political party action.
 311  
      *
 312  
      * @param action the action
 313  
      */
 314  
     private void handleShowOnlinePoliticalPartyAction(
 315  
             ShowOnlinePoliticalPartyAction action) {
 316  0
         Organisation organisation = (Organisation) portalService
 317  
         .getOrganisation(action.getPartyId());
 318  
 
 319  0
         ActiveUserView.changeContentView(new OnlinePoliticalPartyOverviewPanel(
 320  
         (OnlinePoliticalParty) organisation));
 321  0
     }
 322  
 
 323  
     /**
 324  
      * Handle show user action.
 325  
      *
 326  
      * @param action the action
 327  
      */
 328  
     private void handleShowUserAction(ShowUserAction action) {
 329  0
         User user = userService.getUser(action.getUserId());
 330  0
         ActiveUserView.changeContentView(new UserProfilePanel(user,portalService.getPoliticalParties()));
 331  0
     }
 332  
 
 333  
     /**
 334  
      * Handle show organisation action.
 335  
      *
 336  
      * @param action the action
 337  
      */
 338  
     private void handleShowOrganisationAction(ShowOrganisationAction action) {
 339  0
         Organisation organisation = (Organisation) portalService
 340  
         .getOrganisation(action.getOrganisationId());
 341  
 
 342  0
         ActiveUserView.changeContentView(new OrganisationOverviewPanel(
 343  
         organisation));
 344  0
     }
 345  
 
 346  
     /**
 347  
      * Handle join political party action.
 348  
      *
 349  
      * @param action the action
 350  
      */
 351  
     private void handleJoinPoliticalPartyAction(JoinPoliticalPartyAction action) {
 352  0
         ActiveUserView.changeContentView(new OnlinePoliticalPartyOverviewPanel(
 353  
                 portalService.joinParty(action.getPartyId(),
 354  
                         UserState.user.get().getId())));
 355  0
     }
 356  
 
 357  
     /**
 358  
      * Handle create political party action.
 359  
      *
 360  
      * @param action the action
 361  
      */
 362  
     private void handleCreatePoliticalPartyAction(
 363  
             CreatePoliticalPartyAction action) {
 364  0
         CreatePartyDialog createPartyDialog = new CreatePartyDialog(portalService.getCountries());
 365  0
         DialogResult dialogResult = createPartyDialog
 366  
                 .getDialogResult();
 367  
 
 368  0
         if (dialogResult.equals(DialogResult.Do_Action)) {
 369  0
             CreatePartyCommand createPartyCommand = new CreatePartyCommand();
 370  0
             createPartyCommand.setName(createPartyDialog.getName());
 371  0
             createPartyCommand.setCountryId(createPartyDialog
 372  
                     .getCountryId());
 373  
             try {
 374  0
                 PoliticalParty politicalParty = portalService
 375  
                         .createParty(createPartyCommand,
 376  
                                 UserState.user.get().getId());
 377  0
                 ActiveUserView
 378  
                         .changeContentView(new OnlinePoliticalPartyOverviewPanel(
 379  
                                 (OnlinePoliticalParty) politicalParty));
 380  0
             } catch (PartyAlreadyExistException e) {
 381  
                 // TODO Auto-generated catch block
 382  0
                 e.printStackTrace();
 383  0
             }
 384  
         }
 385  0
     }
 386  
 
 387  
     /**
 388  
      * Handle show all events.
 389  
      *
 390  
      * @param action the action
 391  
      */
 392  
     private void handleShowAllEvents(ShowAllEvents action) {
 393  0
         List<Event> events = portalService.getEvents();
 394  0
         ActiveUserView.changeContentView(new EventsPanel(events));
 395  0
     }
 396  
 
 397  
     /**
 398  
      * Handle show application home.
 399  
      *
 400  
      * @param action the action
 401  
      */
 402  
     private void handleShowApplicationHome(ShowApplicationHome action) {
 403  0
         ActiveUserView.changeContentView(new StartContentPanel(portalService.getGlobalPortal()));
 404  0
     }
 405  
 
 406  
     /**
 407  
      * Handle show governments action.
 408  
      *
 409  
      * @param action the action
 410  
      */
 411  
     private void handleShowGovernmentsAction(ShowGovernmentsAction action) {
 412  0
       ActiveUserView.changeContentView(new GovernmentsPanel(portalService.getGovernments()));
 413  0
     }
 414  
 
 415  
     /**
 416  
      * Handle show political parties action.
 417  
      *
 418  
      * @param action the action
 419  
      */
 420  
     private void handleShowPoliticalPartiesAction(ShowPoliticalPartiesAction action) {
 421  0
       ActiveUserView.changeContentView(new PoliticalPartiesPanel(portalService.getOnlinePoliticalParties()));
 422  0
     }
 423  
 
 424  
     /**
 425  
      * Handle show members action.
 426  
      *
 427  
      * @param action the action
 428  
      */
 429  
     private void handleShowMembersAction(ShowMembersAction action) {
 430  0
           ActiveUserView.changeContentView(new MembersPanel(portalService.getUsers()));
 431  0
     }
 432  
 
 433  
   /**
 434  
    * Handle show government action.
 435  
    *
 436  
    * @param action the action
 437  
    */
 438  
   private void handleShowGovernmentAction(ShowGovernmentAction action) {
 439  0
       Government government = portalService.getGovernment(action.getGovernmentId());
 440  0
       ActiveUserView.changeContentView(new GovernmentOverviewPanel(government,portalService.getPoliticalParties()));
 441  0
     }
 442  
 
 443  
   /**
 444  
    * Handle show my profile action.
 445  
    *
 446  
    * @param action the action
 447  
    */
 448  
   private void handleShowMyProfileAction(ShowMyProfileAction action) {
 449  0
       ActiveUserView.changeContentView(new UserProfilePanel(UserState.user
 450  
               .get(),portalService.getPoliticalParties()));
 451  0
     }
 452  
 
 453  
   /**
 454  
    * Handle logout action.
 455  
    *
 456  
    * @param action the action
 457  
    */
 458  
   private void handleLogoutAction(LogoutAction action) {
 459  0
       userService.logout(UserState.user.get());
 460  0
       UserState.user.set(null);
 461  0
       ActiveUserView.changeRightHeaderPanel(new WelcomePanel());
 462  0
       ActiveUserView.changeContentView(new StartContentPanel(portalService.getGlobalPortal()));
 463  0
       ActiveUserView.changeActiveMenu(createMenu());
 464  0
   }
 465  
 
 466  
   /**
 467  
    * Handle register action.
 468  
    *
 469  
    * @param action the action
 470  
    */
 471  
   private void handleRegisterAction(RegisterAction action) {
 472  0
         RegisterUserDialog registerDlg = new RegisterUserDialog(portalService.getPortals());
 473  0
         DialogResult dialogResult = registerDlg.getDialogResult();
 474  
 
 475  0
         while (DialogResult.Do_Action.equals(dialogResult)) {
 476  0
             RegisterCommand registerCommand = new RegisterCommand();
 477  0
             registerCommand.setName(registerDlg.getName());
 478  0
             registerCommand.setEmail(registerDlg.getEmail());
 479  0
             registerCommand.setUsername(registerDlg.getUsername());
 480  0
             registerCommand.setPassword(registerDlg.getPassword());
 481  
 
 482  0
             registerCommand.setPortalId(registerDlg.getPortalId());
 483  
 
 484  
             try {
 485  0
                 User user = userService.register(registerCommand, UserState.getSessionId());
 486  0
                 UserState.user.set(user);
 487  0
                 ActiveUserView.changeContentView(new UserProfilePanel(user,portalService.getPoliticalParties()));
 488  0
                 ActiveUserView.changeRightHeaderPanel(new UserPanel(user));
 489  0
                 ActiveUserView.changeActiveMenu(createMenu());
 490  0
                 dialogResult = null;
 491  0
             } catch (UserAlreadyExistException e) {
 492  0
                 registerDlg.setErrorMessage(ApplicationMessageHolder.getMessage(MessageConstans.USER_EXIST_CHOOSE_DIFFERENT));
 493  0
                 dialogResult = registerDlg.getDialogResult();
 494  0
             }
 495  0
         }
 496  0
    }
 497  
 
 498  
     /**
 499  
      * Handle login action.
 500  
      *
 501  
      * @param loginAction the login action
 502  
      * @throws Exception the exception
 503  
      */
 504  
     public void handleLoginAction(LoginAction loginAction) throws Exception {
 505  0
         LoginDialog loginDialog = new LoginDialog();
 506  0
         DialogResult dialogResult = loginDialog.getDialogResult();
 507  0
         if (dialogResult.equals(DialogResult.Do_Action)) {
 508  0
             User user = userService.login(
 509  
                     loginDialog.getName(), loginDialog.getPassword(),
 510  
                     UserState.getSessionId());
 511  0
             UserState.user.set(user);
 512  0
             ActiveUserView.changeContentView(new UserProfilePanel(user,portalService.getPoliticalParties()));
 513  0
             ActiveUserView.changeRightHeaderPanel(new UserPanel(user));
 514  0
             ActiveUserView.changeActiveMenu(createMenu());
 515  
         }
 516  0
     }
 517  
 }