PageRenderTime 61ms CodeModel.GetById 33ms RepoModel.GetById 1ms app.codeStats 0ms

/WebApps/ServerII/src/com/dimdim/conference/action/common/GetWebAppRootAction.java

https://github.com/MarcosBL/DimSim
Java | 226 lines | 65 code | 7 blank | 154 comment | 6 complexity | 45145f971a9d94407b2c6b5e91cb8538 MD5 | raw file
  1. /*
  2. **************************************************************************
  3. * *
  4. * DDDDD iii DDDDD iii *
  5. * DD DD mm mm mmmm DD DD mm mm mmmm *
  6. * DD DD iii mmm mm mm DD DD iii mmm mm mm *
  7. * DD DD iii mmm mm mm DD DD iii mmm mm mm *
  8. * DDDDDD iii mmm mm mm DDDDDD iii mmm mm mm *
  9. * *
  10. **************************************************************************
  11. **************************************************************************
  12. * *
  13. * Part of the DimDim V 1.0 Codebase (http://www.dimdim.com) *
  14. * *
  15. * Copyright (c) 2006 Communiva Inc. All Rights Reserved. *
  16. * *
  17. * *
  18. * This code is licensed under the DimDim License *
  19. * For details please visit http://www.dimdim.com/license *
  20. * *
  21. **************************************************************************
  22. */
  23. package com.dimdim.conference.action.common;
  24. import javax.servlet.http.HttpServletRequest;
  25. import com.dimdim.conference.action.CommonDimDimAction;
  26. import com.dimdim.conference.ConferenceConsoleConstants;
  27. import com.dimdim.conference.UtilMethods;
  28. import com.opensymphony.webwork.interceptor.ServletRequestAware;
  29. /**
  30. * @author Jayant Pandit
  31. * @email Jayant.Pandit@communiva.com
  32. *
  33. * This action is the first one executed for all interactive use. Identifying
  34. * the browser type is required primarily for active x control access. The
  35. * server needs to know about the browser type because the html Object tag
  36. * and embed tag code is different for msie and firefox. Appropriate code
  37. * section will be added based on the browser type.
  38. */
  39. public class GetWebAppRootAction extends CommonDimDimAction
  40. implements ServletRequestAware
  41. {
  42. protected HttpServletRequest servletRequest;
  43. protected String browserType;
  44. protected String token;
  45. public GetWebAppRootAction()
  46. {
  47. }
  48. public String execute() throws Exception
  49. {
  50. // if (this.browserType != null)
  51. // {
  52. // this.getSession().put(ConferenceConsoleConstants.BROWSER_TYPE,browserType);
  53. // }
  54. // Analyze the user agent and set the browser type.
  55. browserType = (String)this.getSession().get(ConferenceConsoleConstants.BROWSER_TYPE);
  56. if (browserType == null)
  57. {
  58. String userAgent = this.servletRequest.getHeader("user-agent");
  59. if (userAgent != null)
  60. {
  61. userAgent = userAgent.toLowerCase();
  62. }
  63. else
  64. {
  65. userAgent = UtilMethods.findUserAgent(this.servletRequest);
  66. }
  67. if (userAgent != null)
  68. {
  69. UtilMethods.setSessionParameters(getSession(),userAgent);
  70. }
  71. else
  72. {
  73. System.out.println("ERROR: user agent header not available to interpret os and browser");
  74. }
  75. /*
  76. int indexSafariWindows = userAgent.indexOf("windows");
  77. int indexIEBrowserCheckVersion6 = userAgent.indexOf("msie 6");
  78. int indexIEBrowserCheckVersion7 = userAgent.indexOf("msie 7");
  79. System.out.println("User agent is ---------"+userAgent+"--------");
  80. System.out.println("-----------@!#!@#----------");
  81. System.out.println(browserType);
  82. System.out.println(userAgent.indexOf("firefox"));
  83. System.out.println(userAgent.indexOf("gecko"));
  84. System.out.println(userAgent.indexOf("khtml"));
  85. System.out.println(userAgent.indexOf("safari"));
  86. System.out.println("-----------@!#!@#----------");
  87. boolean is_opera = (userAgent.indexOf("opera") != -1);
  88. boolean is_firefox = ((userAgent.indexOf("firefox")!=-1) && (userAgent.indexOf("gecko")!=-1));
  89. boolean is_safari_win = ((userAgent.indexOf("safari") != -1) && (userAgent.indexOf("gecko") != -1));
  90. boolean is_safari = ((userAgent.indexOf("safari")!=-1)&&(userAgent.indexOf("mac")!=-1))?true:false;
  91. System.out.println(is_safari);
  92. System.out.println("Test GetWebAppRootAction Mac safari recognition...");
  93. System.out.println("GetWebApRootAction safari windows..." + is_safari_win);
  94. System.out.println("valuse of user agent are as follows:" + " " + userAgent.indexOf("safari/419"));
  95. System.out.println("valuse of user agent are as follows:" + " " + userAgent.indexOf("safari/522"));
  96. if(is_safari_win)
  97. {
  98. // navigator.appVersion.indexOf("Win")
  99. System.out.println("Before the version check loop...");
  100. System.out.println("Check for windows safari... " + userAgent.indexOf("Windows"));
  101. if(indexSafariWindows > 0)
  102. {
  103. System.out.println("Windows safari not supported for now... ");
  104. return SUCCESS;
  105. }
  106. else
  107. {
  108. this.getSession().put(ConferenceConsoleConstants.BROWSER_TYPE,
  109. ConferenceConsoleConstants.BROWSER_TYPE_SAFARI);
  110. this.getSession().put(ConferenceConsoleConstants.BROWSER_TYPE,
  111. ConferenceConsoleConstants.BROWSER_TYPE_SAFARI);
  112. if (userAgent.indexOf("safari/522") != -1)
  113. {
  114. System.out.println("Inside the version check loop...");
  115. this.getSession().put(ConferenceConsoleConstants.BROWSER_VERSION,
  116. ConferenceConsoleConstants.BROWSER_VERSION_SAFARI_3);
  117. }
  118. else if(userAgent.indexOf("safari/419") != -1)
  119. {
  120. System.out.println("Inside the version check loop...");
  121. this.getSession().put(ConferenceConsoleConstants.BROWSER_VERSION,
  122. ConferenceConsoleConstants.BROWSER_VERSION_SAFARI_2);
  123. }
  124. }
  125. }
  126. else if (is_firefox)
  127. {
  128. if (userAgent.indexOf("firefox/1.5") != -1 || userAgent.indexOf("firefox/2") != -1){
  129. // if (userAgent.indexOf("firefox/2") != -1){
  130. this.getSession().put(ConferenceConsoleConstants.BROWSER_TYPE,
  131. ConferenceConsoleConstants.BROWSER_TYPE_FIREFOX);
  132. if (userAgent.indexOf("firefox/2") != -1)
  133. {
  134. this.getSession().put(ConferenceConsoleConstants.BROWSER_VERSION,
  135. ConferenceConsoleConstants.BROWSER_VERSION_FIREFOX_2);
  136. }
  137. else if (userAgent.indexOf("firefox/1.5") != -1)
  138. {
  139. System.out.println("FF 1.5 detected..." + userAgent.indexOf("firefox/1.5"));
  140. this.getSession().put(ConferenceConsoleConstants.BROWSER_VERSION,
  141. ConferenceConsoleConstants.BROWSER_VERSION_FIREFOX_15_OR_LOWER);
  142. }
  143. }
  144. else
  145. {
  146. System.out.println("Less than FF 1.5 is not supported");
  147. return SUCCESS;
  148. }
  149. }
  150. else
  151. {
  152. int iePos = userAgent.indexOf("msie");
  153. int kqPos = userAgent.indexOf("konqueror");
  154. boolean is_konq = false;
  155. if (kqPos != -1)
  156. {
  157. is_konq = true;
  158. }
  159. // boolean is_safari = ((userAgent.indexOf("safari")!=-1)&&(userAgent.indexOf("mac")!=-1))?true:false;
  160. boolean is_khtml = (is_safari || is_konq);
  161. boolean is_ie = ((iePos!=-1) && (!is_opera) && (!is_khtml));
  162. if (is_ie)
  163. {
  164. System.out.println("msie 7: " + userAgent.indexOf("msie 7"));
  165. System.out.println("msie 6: " + userAgent.indexOf("msie 6"));
  166. if(indexIEBrowserCheckVersion6 > 0 || indexIEBrowserCheckVersion7 > 0)
  167. {
  168. this.getSession().put(ConferenceConsoleConstants.BROWSER_TYPE,
  169. ConferenceConsoleConstants.BROWSER_TYPE_IE);
  170. if (userAgent.indexOf("msie 7") != -1)
  171. {
  172. this.getSession().put(ConferenceConsoleConstants.BROWSER_VERSION,
  173. ConferenceConsoleConstants.BROWSER_VERSION_IE_7);
  174. }
  175. else if (userAgent.indexOf("msie 6") != -1)
  176. {
  177. this.getSession().put(ConferenceConsoleConstants.BROWSER_VERSION,
  178. ConferenceConsoleConstants.BROWSER_VERSION_IE_7);
  179. }
  180. }
  181. else
  182. {
  183. System.out.println("Less than IE 6 is not supported");
  184. return SUCCESS;
  185. }
  186. }
  187. }
  188. */
  189. }
  190. return SUCCESS;
  191. }
  192. public String getToken()
  193. {
  194. return this.token;
  195. }
  196. public void setToken(String token)
  197. {
  198. this.token = token;
  199. }
  200. public String getBrowserType()
  201. {
  202. return browserType;
  203. }
  204. public void setBrowserType(String browserType)
  205. {
  206. this.browserType = browserType;
  207. }
  208. public HttpServletRequest getServletRequest()
  209. {
  210. return servletRequest;
  211. }
  212. public void setServletRequest(HttpServletRequest servletRequest)
  213. {
  214. this.servletRequest = servletRequest;
  215. }
  216. }