try { Locale locale = LocaleUtils.toLocale(startCommand.getLanguage()); IFrontendController<RComponent, RIcon, RAction> controller = getFrontendController(); if (!dupSessionNotifiedOnce && isDupSessionDetectionEnabled() && controller != null && controller.isStarted()) { dupSessionNotifiedOnce = true; return handleDuplicateSession(locale, controller); setStartupLocale(locale); TimeZone serverTimeZone = TimeZone.getDefault(); int currentOffset = serverTimeZone.getOffset(System.currentTimeMillis()); setClientTimeZone(clientTz); start(); controller = getFrontendController(); if (startCommand.getVersion() != null && !isClientVersionCompatible(startCommand.getVersion())) { return handleVersionIncompatibility(startCommand, controller, locale); return handleCommands(Collections .singletonList((RemoteCommand) startCommand)); } catch (Throwable ex) { RemoteMessageCommand errorMessage = createErrorMessageCommand(); errorMessage .setMessage("An unexpected error occurred while starting the server. Please contact the application manager.");
/** * Delegates to the frontend controller. * <p> * {@inheritDoc} */ @Override public void registerCommand(RemoteCommand command) { ((IRemoteCommandHandler) getFrontendController()).registerCommand(command); }
/** * Handle duplicate session list. * * @param locale * the locale * @param controller * the controller * @return the list */ protected List<RemoteCommand> handleDuplicateSession(Locale locale, IFrontendController<RComponent, RIcon, RAction> controller) { RemoteMessageCommand errorMessage = createErrorMessageCommand(); errorMessage.setMessage(controller.getTranslation("session.dup", new Object[] { controller.getI18nName(controller, locale) }, locale)); // Do not return the singleton list directly since subclasses might add commands to it. return new ArrayList<>(Collections.singleton((RemoteCommand) errorMessage)); }
/** * Registers the controller in the http session. * <p> * {@inheritDoc} */ @Override public void start() { if (System.getProperty("java.security.auth.login.config") == null && HttpRequestHolder.isAvailable()) { System.setProperty("java.security.auth.login.config", ResourceProviderServlet.computeStaticUrl("conf/jaas.config")); } super.start(); if (HttpRequestHolder.isAvailable()) { HttpSession session = HttpRequestHolder.getServletRequest().getSession(); if (session != null) { session.setAttribute(RemotePeerRegistryServlet.PEER_REGISTRY, getFrontendController()); session.setAttribute(RemoteUtilServlet.REMOTE_STARTUP, this); } } }
/** * Handle version incompatibility list. * * @param startCommand * the start command * @param controller * the controller * @param locale * the locale * @return the list */ protected List<RemoteCommand> handleVersionIncompatibility(RemoteStartCommand startCommand, IFrontendController<RComponent, RIcon, RAction> controller, Locale locale) { RemoteMessageCommand errorMessage = createErrorMessageCommand(); assert controller != null; errorMessage.setMessage(controller.getTranslation( "incompatible.client.version", new Object[] { startCommand.getVersion(), Build.getJspressoVersion() }, locale)); // Do not return the singleton list directly since subclasses might add commands to it. return new ArrayList<>(Collections.singleton((RemoteCommand) errorMessage)); }
/** * Delegates to the frontend controller. * <p> * {@inheritDoc} */ @Override public List<RemoteCommand> handleCommands(List<RemoteCommand> commands) { IFrontendController<RComponent, RIcon, RAction> controller = getFrontendController(); if (controller == null || !controller.isStarted()) { // we are on a brand new session instance. return Collections .singletonList((RemoteCommand) new RemoteRestartCommand()); } try { return ((IRemoteCommandHandler) controller).handleCommands(commands); } catch (Throwable ex) { controller.traceUnexpectedException(ex); return Collections.emptyList(); } }
protected RemoteMessageCommand createErrorMessageCommand() { IIconFactory<RIcon> iconFactory = getFrontendController().getViewFactory() .getIconFactory(); RemoteMessageCommand messageCommand = new RemoteMessageCommand(); messageCommand.setTitle(getFrontendController().getTranslation("error", getFrontendController().getLocale())); messageCommand.setTitleIcon(iconFactory.getErrorIcon(iconFactory .getTinyIconSize())); messageCommand.setMessageIcon(iconFactory.getErrorIcon(iconFactory .getLargeIconSize())); return messageCommand; }