| 1 5 6 package com.raptus.owxv3.api; 7 8 import java.io.IOException ; 9 import java.util.Locale ; 10 11 import javax.servlet.ServletException ; 12 import javax.servlet.http.*; 13 14 import org.apache.struts.action.*; 15 import org.apache.struts.util.MessageResources; 16 17 import com.raptus.owxv3.*; 18 import com.raptus.owxv3.api.securitymgr.*; 19 20 42 public class VModuleRoleAction extends OmniaWebAction 43 { 44 59 public ActionForward perform(ActionMapping mapping, 60 ActionForm form, 61 HttpServletRequest request, 62 HttpServletResponse response) 63 throws IOException , ServletException  64 { 65 SecurityMgrIF securityManager = SecurityMgrFactory.getInstance().createSecurityManager(request); 67 68 String vmid = getSelectedVModule(form, request); 69 if(vmid == null || vmid.length() == 0) 70 { 71 LoggingManager.log("Parameter <vmodule> not specified. Displaying error screen.", this); 72 return mapping.findForward(Constants.SCREEN_ERROR_UNKNOWNVMODULE); 73 } 74 75 String element = getSelectedElement(form, request); 76 if(element == null || element.length() == 0) 77 { 78 LoggingManager.log("Parameter <element> not specified. Displaying " + 79 "error screen.", this); 80 81 System.out.println("Parameter <element> not specified. Displaying " + 82 "error screen."); 83 84 return mapping.findForward(Constants.SCREEN_ERROR_UNKNOWNELEMENT); 85 } 86 87 88 String section = getSelectedSection(form, request); 89 if(section == null || section.length() == 0) 90 { 91 LoggingManager.log("Parameter <section> not specified. Displaying " + 92 "error screen.", this); 93 System.out.println("Parameter <section> not specified. Displaying " + 94 "error screen."); 95 96 return mapping.findForward(Constants.SCREEN_ERROR_UNKNOWNSECTION); 97 } 98 99 VModule vm = null; 100 101 vm = cachedVModuleAccess(request.getSession(), vmid); 102 if(vm == null) 103 { 104 LoggingManager.log("FAILED to retrieve a valid virtual module from session.", this); 105 System.out.println("FAILED to retrieve a valid virtual module from session."); 106 return mapping.findForward(Constants.SCREEN_ERROR_UNKNOWNVMODULE); 107 } 108 109 VModuleSection sect = vm.getSection(section); 110 if(sect == null) 111 { 112 LoggingManager.log("Unknown section "+section+". Displaying " + 113 "error screen.", this); 114 System.out.println("Unknown section "+section+". Displaying " + 115 "error screen."); 116 return mapping.findForward(Constants.SCREEN_ERROR_UNKNOWNSECTION); 117 } 118 119 VModuleSectionElement elem = sect.getElement(element); 120 if(elem == null) 121 { 122 LoggingManager.log("Unknown element "+element+". Displaying " + 123 "error screen.", this); 124 System.out.println("Unknown element "+element+". Displaying " + 125 "error screen."); 126 127 return mapping.findForward(Constants.SCREEN_ERROR_UNKNOWNELEMENT); 128 } 129 130 if(!securityManager.hasAccess(elem)) 132 { 133 if(!securityManager.needLogin(elem)) 134 { 135 LoggingManager.log("User has no access!!!!!",this); 136 return mapping.findForward(Constants.SCREEN_ERROR_ACCESSDENIED); 137 } 138 else 139 { 140 LoggingManager.log("User must log in, section="+section+" !!!!!!!!!!",this); 141 142 if("eadmin".equals(section)) 144 { 145 return mapping.findForward(Constants.SCREEN_LOGIN); 146 } 147 else 148 { 149 return mapping.findForward(Constants.SCREEN_PUBLIC_LOGIN); 150 } 151 } 152 } 153 154 MessageResources msgRes = MessageResources.getMessageResources(Constants.OWXRESOURCES); 156 if(msgRes != null) 157 { 158 String bid = "base"; if(vm.isVirtual()) 160 bid = vm.getIdentification(); 161 162 String key = "module" + bid + Constants.VMODULE_SECTION_ELEMENT_PREFIX + 163 element + ".titletag"; 165 String titleTag = msgRes.getMessage(securityManager.getLocale(),key); 166 if(titleTag != null) 167 request.setAttribute(Constants.SESSIONKEY_TITLETAG, titleTag); 168 } 169 170 com.raptus.owxv3.api.usermgr.User user = (com.raptus.owxv3.api.usermgr.User) 173 request.getSession().getAttribute(Constants.SESSIONKEY_USER); 174 LoggingManager.log("vmoduleroleaction vmodule="+vmid+",section="+section+",element="+element,this); 182 String fwdTo = dispatchVModuleElement(request, element, form, vm, user); 183 if(fwdTo == null) 184 { 185 fwdTo = dispatchVModuleElement(request, element, form, vm, securityManager.getLocale()); 186 if(fwdTo == null) 187 { 188 LoggingManager.log("Dispatcher wasn't able to dispatch element " + element, this); 189 return mapping.findForward(Constants.SCREEN_ERROR_UNKNOWNELEMENT); 190 } 191 } 192 193 return mapping.findForward(vm.getIdentification() + Constants.DEFAULT_SPACER + fwdTo); 194 } 195 196 197 198 201 public String dispatchVModuleElement(HttpServletRequest request, 202 String element, 203 ActionForm form, 204 VModule vm, 205 com.raptus.owxv3.api.usermgr.User user) 206 { 207 return null; 208 } 209 210 213 protected String dispatchVModuleElement(HttpServletRequest request, 214 String element, 215 ActionForm form, 216 VModule vm, 217 Locale locale) 218 { 219 return null; 220 } 221 } 222 223 224 | Popular Tags |