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.service.impl.user;
6   
7   import java.util.Date;
8   
9   import com.hack23.cia.model.application.dto.common.UserSessionDTO;
10  import com.hack23.cia.model.application.impl.common.ActionEvent;
11  import com.hack23.cia.model.application.impl.common.Agency;
12  import com.hack23.cia.model.application.impl.common.UserSession;
13  import com.hack23.cia.model.application.impl.user.ExternalUrlActionEvent;
14  import com.hack23.cia.service.api.common.ServiceResponse;
15  import com.hack23.cia.service.api.user.ExternalUrlRequest;
16  import com.hack23.cia.service.api.user.ExternalUrlResponse;
17  import com.hack23.cia.service.impl.common.UserSessionService;
18  
19  /***
20   * The Class ExternalUrlRequestService.
21   */
22  public class ExternalUrlRequestService extends
23          AbstractUserRequestService<ExternalUrlRequest> {
24  
25      /***
26       * Instantiates a new external url request service.
27       *
28       * @param userSessionService the user session service
29       */
30      public ExternalUrlRequestService(final UserSessionService userSessionService) {
31          super(userSessionService);
32      }
33  
34      /*
35       * (non-Javadoc)
36       * 
37       * @see
38       * com.hack23.cia.service.impl.common.AbstractGenericService#createActionEvent
39       * (com.hack23.cia.service.api.common.AbstractServiceRequest,
40       * com.hack23.cia.model.application.UserSession)
41       */
42      @Override
43      public final ActionEvent createActionEvent(
44              final ExternalUrlRequest request, final UserSession userSession) {
45          return new ExternalUrlActionEvent(new Date(), userSession, request
46                  .getOperation());
47      }
48  
49      /*
50       * (non-Javadoc)
51       * 
52       * @see com.hack23.cia.service.common.ServiceHandler#getSupportedService()
53       */
54      @SuppressWarnings("unchecked")
55      @Override
56      public final Class getSupportedService() {
57          return ExternalUrlRequest.class;
58      }
59  
60      /*
61       * (non-Javadoc)
62       * 
63       * @seecom.hack23.cia.service.common.AbstractGenericServiceHandler#
64       * handleServiceRequest(com.hack23.cia.service.api.AbstractServiceRequest)
65       */
66      @Override
67      public final ServiceResponse handleServiceRequest(
68              final ExternalUrlRequest request, final UserSessionDTO userSessionDTO) {
69          ExternalUrlResponse externalUrlResponse = null;
70  
71          switch (request.getOperation()) {
72          case ShowProjectInformation:
73              externalUrlResponse = new ExternalUrlResponse(userSessionDTO,
74                      userSessionDTO.getLanguageResource(Agency.LanguageContentKey.PROJECT_INFORMATION), "http://cia.sourceforge.net/");
75              break;
76          case ShowDonateToProject:
77             	externalUrlResponse = new ExternalUrlResponse(
78  				        userSessionDTO,
79  				        userSessionDTO.getLanguageResource(Agency.LanguageContentKey.DONATE_TO_PROJECT), "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6760739");
80              break;
81          case ShowWikiLeaks:
82              externalUrlResponse = new ExternalUrlResponse(userSessionDTO,
83                      "WikiLeaks : Be careful, Big Brother is watching you!",
84                      "http://wikileaks.org");
85              break;
86          default:
87              break;
88          }
89          return externalUrlResponse;
90      }
91  }