KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openi > web > controller > SplashController


1 /*********************************************************************************
2  * The contents of this file are subject to the OpenI Public License Version 1.0
3  * ("License"); You may not use this file except in compliance with the
4  * License. You may obtain a copy of the License at
5  * http://www.openi.org/docs/LICENSE.txt
6  *
7  * Software distributed under the License is distributed on an "AS IS" basis,
8  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
9  * the specific language governing rights and limitations under the License.
10  *
11  * The Original Code is: OpenI Open Source
12  *
13  * The Initial Developer of the Original Code is Loyalty Matrix, Inc.
14  * Portions created by Loyalty Matrix, Inc. are
15  * Copyright (C) 2005 Loyalty Matrix, Inc.; All Rights Reserved.
16  *
17  * Contributor(s): ______________________________________.
18  *
19  ********************************************************************************/

20 package org.openi.web.controller;
21
22 import org.apache.log4j.Logger;
23 import org.openi.project.Project;
24 import org.openi.project.ProjectContext;
25 import org.springframework.web.servlet.ModelAndView;
26 import org.springframework.web.servlet.mvc.AbstractController;
27 import java.util.HashMap JavaDoc;
28 import java.util.Map JavaDoc;
29 import javax.servlet.http.HttpServletRequest JavaDoc;
30 import javax.servlet.http.HttpServletResponse JavaDoc;
31
32
33 /**
34  * @author Uddhab Pant <br>
35  * @version $Revision: 1.6 $ $Date: 2006/04/12 00:39:12 $ <br>
36  *
37  * Controller for splash page.
38  *
39  */

40 public class SplashController extends AbstractController {
41     private static Logger logger = Logger.getLogger(SplashController.class);
42
43     /**
44      * Process the request and return a ModelAndView object which the DispatcherServlet will render.
45      *
46      * @param httpServletRequest HttpServletRequest
47      * @param httpServletResponse HttpServletResponse
48      * @return ModelAndView
49      * @throws Exception
50      */

51     protected ModelAndView handleRequestInternal(HttpServletRequest JavaDoc request,
52         HttpServletResponse JavaDoc response) throws Exception JavaDoc {
53         String JavaDoc splashUrl = "";
54         boolean isSplashPage = false;
55
56         Map JavaDoc model;
57
58         try {
59             model = new HashMap JavaDoc();
60
61             ProjectContext projectContext = (ProjectContext) request.getSession()
62                                                                     .getAttribute("projectContext");
63
64             // if project context is not null, get splash url.
65
if (projectContext != null) {
66                 Project project = projectContext.getProject();
67
68                 // splash page
69
String JavaDoc splashPage = project.getSplashPage();
70
71                 //splash image
72
String JavaDoc splashImageUrl = project.getSplashImageUrl();
73
74                 //if splash page is available, use splash page url
75
/*
76                 if ((splashPage != null) && !splashPage.trim().equals("")) {
77                     splashUrl = "../" + request.getContextPath() + "-projects/"
78                         + project.getProjectId() + "/" + splashPage.trim();
79                     isSplashPage = true;
80
81                     //if splash page is not available, use splash image url.
82                 } else {
83                 */

84                     if ((splashImageUrl != null)
85                             && !splashImageUrl.trim().equals("")) {
86                         splashUrl = "../" + request.getContextPath()
87                             + "-projects/" + project.getProjectId() + "/"
88                             + splashImageUrl.trim();
89                     }
90                 //}
91
}
92
93             model.put("isSplashPage", new Boolean JavaDoc(isSplashPage));
94             model.put("splashUrl", splashUrl);
95
96             return new ModelAndView("splashView", "model", model);
97         } catch (Exception JavaDoc e) {
98             logger.error("Exception:", e);
99             throw e;
100         }
101     }
102 }
103
Popular Tags