PageRenderTime 76ms CodeModel.GetById 48ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://github.com/MarcosBL/DimSim
Java | 428 lines | 227 code | 10 blank | 191 comment | 43 complexity | 3c8ae28139891b3af5519ef315103b2b 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 java.text.DateFormat;
  25. import java.util.Date;
  26. //import java.util.Enumeration;
  27. //import java.util.Iterator;
  28. import java.util.Locale;
  29. import javax.servlet.http.HttpServletRequest;
  30. import javax.servlet.http.HttpServletResponse;
  31. import com.dimdim.locale.LocaleManager;
  32. //import com.dimdim.util.misc.IDGenerator;
  33. import com.dimdim.util.misc.StringGenerator;
  34. import com.dimdim.conference.action.CommonDimDimAction;
  35. //import com.dimdim.conference.application.ChildSession;
  36. //import com.dimdim.conference.application.UserSession;
  37. //import com.dimdim.conference.application.UserSessionManager;
  38. //import com.dimdim.conference.model.IConference;
  39. //import com.dimdim.conference.model.IConferenceParticipant;
  40. import com.dimdim.conference.ConferenceConsoleConstants;
  41. import com.dimdim.conference.ConferenceConstants;
  42. import com.dimdim.conference.UtilMethods;
  43. import com.opensymphony.webwork.interceptor.ServletRequestAware;
  44. import com.opensymphony.webwork.interceptor.ServletResponseAware;
  45. /**
  46. * @author Jayant Pandit
  47. * @email Jayant.Pandit@communiva.com
  48. *
  49. * This action is generic redirect to the forms page. It is a generic
  50. * return for all the forms page actions that do not forward the user
  51. * to the console.
  52. */
  53. public class GetSignInPageAction extends CommonDimDimAction
  54. implements ServletRequestAware, ServletResponseAware
  55. {
  56. private static StringGenerator idGen = new StringGenerator();
  57. protected HttpServletRequest servletRequest;
  58. protected HttpServletResponse servletResponse;
  59. protected String action;
  60. protected String email;
  61. protected String displayName;
  62. protected String confName;
  63. protected String confKey;
  64. protected String asPresenter = "off";
  65. protected String meetNow = "on";
  66. protected String message;
  67. protected String submitFormOnLoad;
  68. protected String lc;
  69. protected boolean publisherEnabled = true;
  70. String osType = null;
  71. public GetSignInPageAction()
  72. {
  73. }
  74. /**
  75. * Data provided by the user always overrides the data in the session object at
  76. * any given time.
  77. */
  78. public String execute() throws Exception
  79. {
  80. String userAgent = this.servletRequest.getHeader("user-agent");
  81. UtilMethods.setSessionParameters(this.getSession(), userAgent);
  82. /*
  83. if (userAgent != null)
  84. {
  85. userAgent = userAgent.toLowerCase();
  86. }
  87. else
  88. {
  89. userAgent = UtilMethods.findUserAgent(this.servletRequest);
  90. }
  91. int indexSafariWindows = userAgent.indexOf("windows");
  92. int indexIEBrowserCheckVersion6 = userAgent.indexOf("msie 6");
  93. int indexIEBrowserCheckVersion7 = userAgent.indexOf("msie 7");
  94. System.out.println("User agent is ---------"+userAgent+"--------");
  95. //if(null != osType && osType.length() > 0)
  96. //{
  97. if(userAgent.contains(ConferenceConsoleConstants.OS_MAC) ||
  98. userAgent.contains(ConferenceConsoleConstants.OS_LINUX) || userAgent.contains(ConferenceConsoleConstants.OS_UNIX))
  99. {
  100. System.out.println("the os that server knows is "+osType +" hence disabling publisher");
  101. publisherEnabled = false;
  102. }
  103. //}
  104. // Analyze the user agent and set the browser type.
  105. String browserType = (String)this.getSession().get(ConferenceConsoleConstants.BROWSER_TYPE);
  106. // System.out.println("-----------@!#!@#----------");
  107. // System.out.println(browserType);
  108. // System.out.println(userAgent.indexOf("firefox"));
  109. // System.out.println(userAgent.indexOf("gecko"));
  110. // System.out.println(userAgent.indexOf("KHTML"));
  111. // System.out.println(userAgent.indexOf("safari"));
  112. // System.out.println("-----------@!#!@#----------");
  113. if (browserType == null)
  114. {
  115. boolean is_opera = (userAgent.indexOf("opera") != -1);
  116. boolean is_firefox = ((userAgent.indexOf("firefox")!=-1) && (userAgent.indexOf("gecko")!=-1));
  117. boolean is_safari_win = ((userAgent.indexOf("safari") != -1) && (userAgent.indexOf("gecko") != -1));
  118. boolean is_safari = ((userAgent.indexOf("safari")!=-1)&&(userAgent.indexOf("mac")!=-1))?true:false;
  119. System.out.println(is_safari);
  120. System.out.println("Test GetWebAppRootAction Mac safari recognition...");
  121. System.out.println("GetWebApRootAction safari windows..." + is_safari_win);
  122. System.out.println("valuse of user agent are as follows:" + " " + userAgent.indexOf("safari/419"));
  123. System.out.println("valuse of user agent are as follows:" + " " + userAgent.indexOf("safari/522"));
  124. if(is_safari_win)
  125. {
  126. // navigator.appVersion.indexOf("Win")
  127. System.out.println("Before the version check loop...");
  128. System.out.println("Check for windows safari... " + userAgent.indexOf("Windows"));
  129. if(indexSafariWindows > 0)
  130. {
  131. System.out.println("Windows safari not supported for now... ");
  132. return SUCCESS;
  133. }
  134. else
  135. {
  136. this.getSession().put(ConferenceConsoleConstants.BROWSER_TYPE,
  137. ConferenceConsoleConstants.BROWSER_TYPE_SAFARI);
  138. this.getSession().put(ConferenceConsoleConstants.BROWSER_TYPE,
  139. ConferenceConsoleConstants.BROWSER_TYPE_SAFARI);
  140. if (userAgent.indexOf("safari/522") != -1)
  141. {
  142. System.out.println("Inside the version check loop...");
  143. this.getSession().put(ConferenceConsoleConstants.BROWSER_VERSION,
  144. ConferenceConsoleConstants.BROWSER_VERSION_SAFARI_3);
  145. }
  146. else if(userAgent.indexOf("safari/419") != -1)
  147. {
  148. System.out.println("Inside the version check loop...");
  149. this.getSession().put(ConferenceConsoleConstants.BROWSER_VERSION,
  150. ConferenceConsoleConstants.BROWSER_VERSION_SAFARI_2);
  151. }
  152. }
  153. }
  154. else if (is_firefox)
  155. {
  156. if (userAgent.indexOf("firefox/1.5") != -1 || userAgent.indexOf("firefox/2") != -1){
  157. // if (userAgent.indexOf("firefox/2") != -1){
  158. this.getSession().put(ConferenceConsoleConstants.BROWSER_TYPE,
  159. ConferenceConsoleConstants.BROWSER_TYPE_FIREFOX);
  160. if (userAgent.indexOf("firefox/2") != -1)
  161. {
  162. this.getSession().put(ConferenceConsoleConstants.BROWSER_VERSION,
  163. ConferenceConsoleConstants.BROWSER_VERSION_FIREFOX_2);
  164. }
  165. else if (userAgent.indexOf("firefox/1.5") != -1)
  166. {
  167. System.out.println("FF 1.5 detected..." + userAgent.indexOf("firefox/1.5"));
  168. this.getSession().put(ConferenceConsoleConstants.BROWSER_VERSION,
  169. ConferenceConsoleConstants.BROWSER_VERSION_FIREFOX_15_OR_LOWER);
  170. }
  171. }
  172. else
  173. {
  174. System.out.println("Less than FF 1.5 is not supported");
  175. return SUCCESS;
  176. }
  177. }
  178. else
  179. {
  180. int iePos = userAgent.indexOf("msie");
  181. int kqPos = userAgent.indexOf("konqueror");
  182. boolean is_konq = false;
  183. if (kqPos != -1)
  184. {
  185. is_konq = true;
  186. }
  187. // boolean is_safari = ((userAgent.indexOf("safari")!=-1)&&(userAgent.indexOf("mac")!=-1))?true:false;
  188. boolean is_khtml = (is_safari || is_konq);
  189. boolean is_ie = ((iePos!=-1) && (!is_opera) && (!is_khtml));
  190. if (is_ie)
  191. {
  192. System.out.println("msie 7: " + userAgent.indexOf("msie 7"));
  193. System.out.println("msie 6: " + userAgent.indexOf("msie 6"));
  194. if(indexIEBrowserCheckVersion6 > 0 || indexIEBrowserCheckVersion7 > 0)
  195. {
  196. this.getSession().put(ConferenceConsoleConstants.BROWSER_TYPE,
  197. ConferenceConsoleConstants.BROWSER_TYPE_IE);
  198. if (userAgent.indexOf("msie 7") != -1)
  199. {
  200. this.getSession().put(ConferenceConsoleConstants.BROWSER_VERSION,
  201. ConferenceConsoleConstants.BROWSER_VERSION_IE_7);
  202. }
  203. else if (userAgent.indexOf("msie 6") != -1)
  204. {
  205. this.getSession().put(ConferenceConsoleConstants.BROWSER_VERSION,
  206. ConferenceConsoleConstants.BROWSER_VERSION_IE_7);
  207. }
  208. }
  209. else
  210. {
  211. System.out.println("Less than IE 6 is not supported");
  212. return SUCCESS;
  213. }
  214. }
  215. }
  216. }
  217. */
  218. ActionRedirectData ard = (ActionRedirectData)this.servletRequest.getSession().
  219. getAttribute(ActionRedirectData.SESSION_ATTRIBUTE_NAME);
  220. if (ard == null)
  221. {
  222. System.out.println("Action redirect data not found *********** ");
  223. ard = new ActionRedirectData();
  224. this.servletRequest.getSession().setAttribute(ActionRedirectData.SESSION_ATTRIBUTE_NAME,ard);
  225. this.initializeActionData(ard);
  226. }
  227. else
  228. {
  229. System.out.println("Action redirect data:" +ard.toString());
  230. this.refreshActionData(ard);
  231. }
  232. this.servletRequest.setAttribute(ActionRedirectData.SESSION_ATTRIBUTE_NAME,ard);
  233. ard.setRequestAttributes(this.servletRequest);
  234. this.servletRequest.getSession().setAttribute("publisher_enabled", String.valueOf(publisherEnabled) );
  235. setSessionLocale();
  236. return SUCCESS;
  237. }
  238. /**
  239. * This method is intended for use only while creating the action data for the
  240. * first time.
  241. *
  242. * @param ard
  243. */
  244. protected void initializeActionData(ActionRedirectData ard)
  245. {
  246. if (action != null)
  247. {
  248. // Setup the default values for host meeting, if not provided. If this
  249. // url is coming from another page, then the values may be provided.
  250. if (this.action.equals(ConferenceConstants.ACTION_HOST_MEETING))
  251. {
  252. if (email == null)
  253. {
  254. email = "admin@dimdim.com"; // Move to config file
  255. }
  256. if (displayName == null)
  257. {
  258. displayName = "Admin"; // Move to config file
  259. }
  260. if (confName == null)
  261. {
  262. DateFormat dateFormater = DateFormat.getDateTimeInstance(DateFormat.SHORT,
  263. DateFormat.SHORT,Locale.US);
  264. confName = "Web Meeting "+dateFormater.format(new Date());
  265. }
  266. if (confKey == null)
  267. {
  268. confKey = GetSignInPageAction.idGen.generateRandomString(7,7);
  269. }
  270. }
  271. this.refreshActionData(ard);
  272. }
  273. }
  274. private void setSessionLocale()
  275. {
  276. //this loclae code is set when url comes from portal
  277. if(null != lc)
  278. {
  279. System.out.println("inside GetSigninPageACtion of conf server setting session locale to");
  280. LocaleManager lm = LocaleManager.getManager();
  281. Locale locale = lm.getSupportedLocale(lc);
  282. if(null != locale)
  283. {
  284. System.out.println("Changing over to locale:"+locale.toString());
  285. this.servletRequest.getSession().setAttribute(ConferenceConsoleConstants.USER_LOCALE,locale);
  286. }
  287. }
  288. }
  289. protected void refreshActionData(ActionRedirectData ard)
  290. {
  291. if (action != null) ard.setAction(action);
  292. if (email != null) ard.setEmail(email);
  293. if (message != null) ard.setMessage(message);
  294. if (displayName != null) ard.setDisplayName(displayName);
  295. if (action != null && (action.equals("host") || action.equals("start")))
  296. {
  297. if (ard.getDisplayName() == null || ard.getDisplayName().length() == 0)
  298. {
  299. ard.setDisplayName("Admin");
  300. }
  301. }
  302. if (confName != null) ard.setConfName(confName);
  303. if (confKey != null) ard.setConfKey(confKey);
  304. if (asPresenter != null) ard.setAsPresenter(asPresenter);
  305. if (meetNow != null) ard.setMeetNow(meetNow);
  306. if (submitFormOnLoad != null) ard.setSubmitFormOnLoad(submitFormOnLoad);
  307. }
  308. public HttpServletRequest getServletRequest()
  309. {
  310. return this.servletRequest;
  311. }
  312. public void setServletRequest(HttpServletRequest servletRequest)
  313. {
  314. this.servletRequest = servletRequest;
  315. }
  316. public HttpServletResponse getServletResponse()
  317. {
  318. return this.servletResponse;
  319. }
  320. public void setServletResponse(HttpServletResponse servletResponse)
  321. {
  322. this.servletResponse = servletResponse;
  323. }
  324. public String getAction()
  325. {
  326. return action;
  327. }
  328. public void setAction(String action)
  329. {
  330. this.action = action;
  331. }
  332. public String getAsPresenter()
  333. {
  334. return asPresenter;
  335. }
  336. public void setAsPresenter(String asPresenter)
  337. {
  338. this.asPresenter = asPresenter;
  339. }
  340. public String getConfKey()
  341. {
  342. return confKey;
  343. }
  344. public void setConfKey(String confKey)
  345. {
  346. this.confKey = confKey;
  347. }
  348. public String getConfName()
  349. {
  350. return confName;
  351. }
  352. public void setConfName(String confName)
  353. {
  354. this.confName = confName;
  355. }
  356. public String getDisplayName()
  357. {
  358. return displayName;
  359. }
  360. public void setDisplayName(String displayName)
  361. {
  362. this.displayName = displayName;
  363. }
  364. public String getEmail()
  365. {
  366. return email;
  367. }
  368. public void setEmail(String email)
  369. {
  370. this.email = email;
  371. }
  372. public String getMessage()
  373. {
  374. return message;
  375. }
  376. public void setMessage(String message)
  377. {
  378. this.message = message;
  379. }
  380. public String getMeetNow()
  381. {
  382. return meetNow;
  383. }
  384. public void setMeetNow(String meetNow)
  385. {
  386. this.meetNow = meetNow;
  387. }
  388. public String getSubmitFormOnLoad()
  389. {
  390. return submitFormOnLoad;
  391. }
  392. public void setSubmitFormOnLoad(String submitFormOnLoad)
  393. {
  394. this.submitFormOnLoad = submitFormOnLoad;
  395. }
  396. public String getLc() {
  397. return lc;
  398. }
  399. public void setLc(String lc) {
  400. this.lc = lc;
  401. }
  402. public boolean isPublisherEnabled() {
  403. return publisherEnabled;
  404. }
  405. public void setPublisherEnabled(boolean publisherEnabled) {
  406. this.publisherEnabled = publisherEnabled;
  407. }
  408. public String getOsType() {
  409. return osType;
  410. }
  411. public void setOsType(String osType) {
  412. this.osType = osType;
  413. }
  414. }