* javax.servlet.http.HttpServletRequest, java.lang.String)
*/
protected ActionForward launch(ActionMapping mapping, LaunchSession launchSession, HttpServletRequest request, String returnTo)
throws Exception {
ApplicationShortcut shortcut = (ApplicationShortcut) launchSession.getResource();
ExtensionDescriptor descriptor = ExtensionStore.getInstance().getExtensionDescriptor(shortcut.getApplication());
HashMap<String, String> parameters = new HashMap<String, String>();
Enumeration e = request.getParameterNames();
while (e.hasMoreElements()) {
String nameParam = (String) e.nextElement();
parameters.put(nameParam, request.getParameter(nameParam));
}
// Do the launch
try {
if(descriptor.getApplicationBundle().getStatus() != ExtensionBundleStatus.ACTIVATED) {
throw new Exception("Extension bundle " + descriptor.getApplicationBundle().getId() +" is not activated, cannot launch applicaiton.");
}
ActionForward fwd = ((ApplicationLauncherType) descriptor.getExtensionType()).launch(parameters,
descriptor,
shortcut,
mapping,
launchSession,
returnTo,
request);
CoreServlet.getServlet().fireCoreEvent(new ResourceAccessEvent(this,
ApplicationShortcutEventConstants.APPLICATION_SHORTCUT_LAUNCHED,
launchSession.getResource(),
launchSession.getPolicy(),
launchSession.getSession(),
CoreEvent.STATE_SUCCESSFUL).addAttribute(CoreAttributeConstants.EVENT_ATTR_APPLICATION_NAME,
descriptor.getName()).addAttribute(CoreAttributeConstants.EVENT_ATTR_APPLICATION_ID, descriptor.getId()));
/*
* If the launch implementation returns its own forward, it is
* reponsible for setting up its 'launched' message
*/
if (fwd == null) {
ActionMessages msgs = new ActionMessages();
msgs.add(Globals.MESSAGE_KEY, new BundleActionMessage(ApplicationsPlugin.MESSAGE_RESOURCES_KEY,
"launchApplication.launched",
shortcut.getResourceName()));
saveMessages(request, msgs);
return new RedirectWithMessages(returnTo, request);
}
return fwd;
} catch (Exception ex) {
CoreServlet.getServlet().fireCoreEvent(new ResourceAccessEvent(this,
ApplicationShortcutEventConstants.APPLICATION_SHORTCUT_LAUNCHED,
launchSession.getSession(),
ex).addAttribute(CoreAttributeConstants.EVENT_ATTR_APPLICATION_NAME, descriptor.getName())
.addAttribute(CoreAttributeConstants.EVENT_ATTR_APPLICATION_ID, descriptor.getId()));
throw ex;
}
}