* launched
* @throws Exception
*/
public Request launchApplication(LaunchSession launchSession) throws Exception {
ApplicationShortcut shortcut = (ApplicationShortcut) launchSession.getResource();
ByteArrayWriter msg = new ByteArrayWriter();
// If this is a service side application launcher then launch now and inform the agent not to go any further
ExtensionDescriptor descriptor = ExtensionStore.getInstance().getExtensionDescriptor(shortcut.getApplication());
if(((ApplicationLauncherType)descriptor.getExtensionType()).isServerSide()) {
msg.writeBoolean(true);
// Do the launch
try {
if(descriptor.getApplicationBundle().getStatus() != ExtensionBundleStatus.ACTIVATED) {
throw new Exception("Extension bundle " + descriptor.getApplicationBundle().getId() +" is not activated, cannot launch applicaiton.");
}
((ApplicationLauncherType) descriptor.getExtensionType()).launch(new HashMap<String, String>(),
descriptor,
shortcut,
null,
launchSession,
null,
null);
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()));
} 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;
}
}
else {
msg.writeBoolean(false);
msg.writeString(shortcut.getApplication());
msg.writeInt(shortcut.getResourceId());
msg.writeString(launchSession.getId());
msg.writeString(ExtensionParser.processApplicationParameters(launchSession,
new Properties(),
shortcut.getParameters(),
shortcut.getApplication()));
}
return new Request("launchApplication", msg.toByteArray());
}