1 5 6 package com.raptus.owxv3.api; 7 8 import java.util.*; 9 10 import javax.servlet.http.*; 11 12 import org.apache.struts.Globals; 13 import org.apache.struts.action.ActionForm; 14 15 import com.raptus.owxv3.*; 16 17 39 public class OmniaWebAction extends org.apache.struts.action.Action 40 { 41 45 protected String getSelectedElement(ActionForm form, HttpServletRequest request) 46 { 47 String element = request.getParameter(Constants.HTTPGET_PARAM_ELEMENT); 48 if(element == null || element.length() == 0) 49 element = ((OmniaWebBean) form).getElement(); 50 else 51 ((OmniaWebBean) form).setElement(element); 52 53 return element; 54 } 55 56 59 protected String getSelectedSection(ActionForm form, HttpServletRequest request) 60 { 61 String section = request.getParameter(Constants.HTTPGET_PARAM_SECTION); 62 if(section == null || section.length() == 0) 63 section = ((OmniaWebBean) form).getSection(); 64 else 65 ((OmniaWebBean) form).setSection(section); 66 67 return section; 68 } 69 70 74 protected String getSelectedVModule(ActionForm form, HttpServletRequest request) 75 { 76 String vmid = request.getParameter(Constants.HTTPGET_PARAM_VMODULE); 77 if(vmid == null || vmid.length() == 0) 78 vmid = ((OmniaWebBean) form).getVModule(); 79 else 80 ((OmniaWebBean) form).setVModule(vmid); 81 82 return vmid; 83 } 84 85 89 protected Locale getSelectedLocale(ActionForm form, HttpServletRequest request) 90 { 91 String l = request.getParameter(Constants.HTTPGET_PARAM_LOCALE); 92 if(l == null || l.length() == 0) 93 { 94 HttpSession session = request.getSession(); 97 return (Locale) session.getAttribute(Globals.LOCALE_KEY); 98 } 99 100 PairOfObjects po = LocaleManager.stripLocaleString(l); 101 return new Locale((String ) po.getObjectOne(), (String ) po.getObjectTwo()); 102 } 103 104 107 protected com.raptus.owxv3.api.usermgr.User checkForUserInSession(HttpSession session) 108 { 109 return (com.raptus.owxv3.api.usermgr.User) session.getAttribute(Constants.SESSIONKEY_USER); 110 } 111 112 113 119 protected VModule cachedVModuleAccess(HttpSession session, String vmid) 120 { 121 Hashtable vmcache = (Hashtable) session.getAttribute(Constants.SESSIONKEY_VMCACHE); 122 if(vmcache == null) 123 { 124 vmcache = new Hashtable(); 126 session.setAttribute(Constants.SESSIONKEY_VMCACHE, vmcache); 127 LoggingManager.log("Created virtual module cache for session " + 128 session.getId(), this); 129 } 130 131 VModule vm = (VModule) vmcache.get(vmid); 132 if(vm == null) 133 { 134 VModuleManager vmm = VModuleManager.getInstance(); 136 vm = vmm.getVModule(vmid); 137 if(vm != null) 138 { 139 vmcache.put(vmid, vm); 140 LoggingManager.log("Created virtual module (" + vmid + 141 "), and stored in the vmodule cache.", this); 142 } 143 } 144 145 return vm; 146 } 147 148 151 public static int convertToInteger(int defVal, String strValue) 152 { 153 int value = defVal; 154 if(strValue != null && strValue.length() > 0) 155 { 156 try 157 { 158 value = Integer.parseInt(strValue); 159 } 160 catch(NumberFormatException e) { 161 } 162 } 163 164 return value; 165 } 166 167 } 168 169 | Popular Tags |