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.PortalRequest;
8   import com.hack23.cia.service.api.admin.PortalResponse;
9   import com.hack23.cia.service.api.application.ApplicationManager;
10  import com.hack23.cia.web.action.admin.PortalAction;
11  import com.hack23.cia.web.viewfactory.api.admin.AgencyModelAndView;
12  import com.hack23.cia.web.viewfactory.api.admin.PortalModelAndView;
13  import com.hack23.cia.web.viewfactory.api.admin.AgencyModelAndView.AgencyViewSpecification;
14  import com.hack23.cia.web.viewfactory.api.admin.PortalModelAndView.PortalViewSpecification;
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 PortalActionHandler.
20   */
21  public class PortalActionHandler extends
22          AbstractAdminActionHandler<PortalAction, PortalRequest, PortalResponse> {
23  
24      /***
25       * Instantiates a new portal action handler.
26       *
27       * @param viewFactoryService the view factory service
28       * @param applicationManager the application manager
29       */
30      public PortalActionHandler(final ViewFactoryService viewFactoryService,
31              final ApplicationManager applicationManager) {
32          super(viewFactoryService, applicationManager);
33      }
34  
35      /*
36       * (non-Javadoc)
37       * 
38       * @seecom.hack23.cia.web.controller.common.AbstractGenericHandler#
39       * createServiceRequest(com.hack23.cia.web.action.common.AbstractAction)
40       */
41      @Override
42      public final PortalRequest createServiceRequest(final PortalAction action) {
43          return new PortalRequest(getUserStateService().getUserSessionId(),
44                  action.getOperation(), action.getPortal());
45      }
46  
47      /*
48       * (non-Javadoc)
49       * 
50       * @see com.hack23.cia.web.controller.ActionHandler#getSupportedAction()
51       */
52      @SuppressWarnings("unchecked")
53      @Override
54      public final Class getSupportedAction() {
55          return PortalAction.class;
56      }
57  
58      /*
59       * (non-Javadoc)
60       * 
61       * @seecom.hack23.cia.web.controller.common.AbstractGenericHandler#
62       * handleSuccessResponse(com.hack23.cia.web.action.common.AbstractAction,
63       * com.hack23.cia.service.api.common.AbstractServiceResponse)
64       */
65      @Override
66      public final ModelAndView handleSuccessResponse(final PortalAction action,
67              final PortalResponse response) {
68          ModelAndView modelAndView = null;
69          switch (action.getOperation()) {
70          case Update:
71              modelAndView = new PortalModelAndView(response.getUserSessionDTO(),
72                      action, PortalViewSpecification.ConfigurePortalView,
73                      response.getPortal());
74              break;
75          case Delete:
76              modelAndView = new AgencyModelAndView(response.getUserSessionDTO(),
77                      action, AgencyViewSpecification.ConfigureAgencyView,
78                      response.getAgency());
79              break;
80          default:
81              break;
82          }
83          return modelAndView;
84      }
85  
86  }