View Javadoc

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 com.hack23.cia.web.controller.admin;
6   
7   import com.hack23.cia.service.api.admin.LanguageContentRequest;
8   import com.hack23.cia.service.api.admin.LanguageContentResponse;
9   import com.hack23.cia.service.api.application.ApplicationManager;
10  import com.hack23.cia.web.action.admin.LanguageContentAction;
11  import com.hack23.cia.web.viewfactory.api.admin.LanguageAgencyModelAndView;
12  import com.hack23.cia.web.viewfactory.api.admin.LanguageContentModelAndView;
13  import com.hack23.cia.web.viewfactory.api.admin.LanguageAgencyModelAndView.LanguageAgencyViewSpecification;
14  import com.hack23.cia.web.viewfactory.api.admin.LanguageContentModelAndView.LanguageContentViewSpecification;
15  import com.hack23.cia.web.viewfactory.api.common.ModelAndView;
16  import com.hack23.cia.web.viewfactory.api.common.ViewFactoryService;
17  
18  /***
19   * The Class LanguageContentActionHandler.
20   */
21  public class LanguageContentActionHandler
22          extends
23          AbstractAdminActionHandler<LanguageContentAction, LanguageContentRequest, LanguageContentResponse> {
24  
25      /***
26       * Instantiates a new language content action handler.
27       *
28       * @param viewFactoryService the view factory service
29       * @param applicationManager the application manager
30       */
31      public LanguageContentActionHandler(
32              final ViewFactoryService viewFactoryService,
33              final ApplicationManager applicationManager) {
34          super(viewFactoryService, applicationManager);
35      }
36  
37      /*
38       * (non-Javadoc)
39       * 
40       * @seecom.hack23.cia.web.controller.common.AbstractGenericHandler#
41       * createServiceRequest(com.hack23.cia.web.action.common.AbstractAction)
42       */
43      @Override
44      public final LanguageContentRequest createServiceRequest(
45              final LanguageContentAction action) {
46          return new LanguageContentRequest(getUserStateService().getUserSessionId(),
47                  action.getOperation(), action.getAgency(),action.getLanguageContent());
48      }
49  
50      /*
51       * (non-Javadoc)
52       * 
53       * @see com.hack23.cia.web.controller.ActionHandler#getSupportedAction()
54       */
55      @SuppressWarnings("unchecked")
56      @Override
57      public final Class getSupportedAction() {
58          return LanguageContentAction.class;
59      }
60  
61      /*
62       * (non-Javadoc)
63       * 
64       * @seecom.hack23.cia.web.controller.common.AbstractGenericHandler#
65       * handleSuccessResponse(com.hack23.cia.web.action.common.AbstractAction,
66       * com.hack23.cia.service.api.common.AbstractServiceResponse)
67       */
68      @Override
69      public final ModelAndView handleSuccessResponse(
70              final LanguageContentAction action, final LanguageContentResponse response) {
71          ModelAndView modelAndView = null;
72  
73          switch (action.getOperation()) {
74          case Update:
75              modelAndView = new LanguageContentModelAndView(
76                      response.getUserSessionDTO(),
77                      action,
78                      LanguageContentViewSpecification.ConfigureLanguageContentView,
79                      response.getAgency(), response.getLanguageContent());
80              break;
81          case Delete:
82              modelAndView = new LanguageAgencyModelAndView(
83                      response.getUserSessionDTO(),
84                      action,
85                      LanguageAgencyViewSpecification.ConfigureAgencyLanguageView,
86                      response.getAgency(), response.getLanguage());
87              break;
88          default:
89              break;
90          }
91  
92          return modelAndView;
93      }
94  
95  }