@Nonnull public PhotonSessionStatePerApp stateLastAppID () { return state (getLastApplicationID ()); }
public PhotonRequestState (@Nonnull final PhotonSessionStatePerApp aState) { this (aState.getMenuTree (), aState.getMenuItem (), aState.getDisplayLocale ()); }
@Nonnull public static IMenuTree getMenuTree (@Nonnull final IRequestWebScopeWithoutResponse aRequestScope) { final IMenuTree aMenuTree = getRequestState (aRequestScope).getMenuTree (); if (aMenuTree == null) throw new IllegalStateException ("No menu tree is present!"); return aMenuTree; }
@Nonnull public static PhotonGlobalStatePerApp state (@Nonnull @Nonempty final String sAppID) { ValueEnforcer.notEmpty (sAppID, "AppID"); final PhotonGlobalState aGlobalState = getInstance (); return aGlobalState.m_aStateMap.computeIfAbsent (sAppID, k -> { // By default set first app ID as default if (!aGlobalState.hasDefaultApplicationID ()) aGlobalState.setDefaultApplicationID (sAppID); return new PhotonGlobalStatePerApp (); }); }
public static void clear () { final PhotonGlobalState aGlobalState = getInstance (); aGlobalState.m_aStateMap.clear (); aGlobalState.setDefaultApplicationID (null); }
@Nonnull public SimpleURL getLinkToMenuItem (@Nonnull @Nonempty final String sAppID, @Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final Locale aDisplayLocale, @Nonnull final String sMenuItemID) { // Get the servlet path from the app ID final String sServletPath = PhotonGlobalState.state (sAppID).getServletPath (); // Prepend the context path final String sBasePath = aRequestScope.getContextPath () + sServletPath; return m_aRequestParamHdl.buildURL (aRequestScope, sBasePath, aDisplayLocale, sMenuItemID); }
public static boolean containsAnyApplicationServletPathMapping () { return getInstance ().m_aStateMap.containsAnyValue (x -> x.internalGetServletPath () != null); }
@Nonnull @ReturnsMutableCopy public static ICommonsMap <String, String> getAppIDToServletPathMap () { final ICommonsMap <String, String> ret = new CommonsHashMap <> (); getInstance ().m_aStateMap.forEach ( (sAppID, aState) -> ret.put (sAppID, aState.getServletPath ())); return ret; } }
public static boolean containsNoState () { return getInstance ().m_aStateMap.isEmpty (); }
@Nonnull public static String getDisplayLanguage (@Nonnull final IRequestWebScopeWithoutResponse aRequestScope) { return getDisplayLocale (aRequestScope).getLanguage (); }
@Nonnull public static IMenuItemPage getMenuItem (@Nonnull final IRequestWebScopeWithoutResponse aRequestScope) { final IMenuItemPage aMenuItem = getRequestState (aRequestScope).getMenuItem (); if (aMenuItem == null) throw new IllegalStateException ("No menu item is present!"); return aMenuItem; }
@Nonnull public static Locale getDisplayLocale (@Nonnull final IRequestWebScopeWithoutResponse aRequestScope) { final Locale aLocale = getRequestState (aRequestScope).getDisplayLocale (); if (aLocale == null) throw new IllegalStateException ("No locale is available"); return aLocale; }
@Nonnull public static PhotonGlobalState getInstance () { return getGlobalSingleton (PhotonGlobalState.class); }
/** * @return The one and only instance for the current session. Never * <code>null</code>. * @see #getInstanceIfInstantiated() */ @Nonnull public static PhotonSessionState getInstance () { return getSessionSingleton (PhotonSessionState.class); }
/** * @return The one and only instance for the current session. It may be * <code>null</code> if this singleton was not yet instantiated. * @see #getInstance() */ @Nullable public static PhotonSessionState getInstanceIfInstantiated () { return getSessionSingletonIfInstantiated (PhotonSessionState.class); }
public void beforeRequest (@Nonnull final IRequestWebScope aRequestScope) { setStatePerApp (aRequestScope, m_sAppID); }
public void beforeRequest (@Nonnull final IRequestWebScope aRequestScope) { setStatePerApp (aRequestScope); }
/** * @return <code>true</code> if a default application ID is present, * <code>false</code> otherwise. * @since 8.0.3 */ public boolean hasDefaultApplicationID () { return StringHelper.hasText (getDefaultApplicationID ()); }
public static void removeAllApplicationServletPathMappings () { getInstance ().m_aStateMap.forEachValue (PhotonGlobalStatePerApp::removeServletPath); }
@Nonnull public static Locale getDisplayCountry (@Nonnull final IRequestWebScopeWithoutResponse aRequestScope) { return CountryCache.getInstance ().getCountry (getDisplayLocale (aRequestScope)); }