@Override public I18nHelper getI18nBean() { return getI18nHelper(); }
@Override public boolean isLoggedInUser() { return getLoggedInUser() != null; }
public Map<String, Object> getRequestCache() { return JiraAuthenticationContextImpl.getRequestCache(); }
/** * This should be called <strong>before</strong> any "runnable code" is called. * This will setup a clean {@code ThreadLocal} environment for the runnable * code to execute in. */ public static void preCall() { JiraAuthenticationContextImpl.clearRequestCache(); RequestCacheController.startContext(); ThreadLocalQueryProfiler.start(); }
@Override public Locale getLocale() { return I18nBean.getLocaleFromUser(getUser()); }
@Override public void clearLoggedInUser() { setLoggedInUserImpl(null); }
@Override public ApplicationUser getLoggedInUser() { final Principal principal = authenticationContext.getUser(); if (principal == null) { return null; } if (principal instanceof ApplicationUser) { return (ApplicationUser) principal; } return getUserManager().getUserByName(principal.getName()); }
@Override public OutlookDate getOutlookDate() { return ComponentAccessor.getComponent(OutlookDateManager.class).getOutlookDate(getLocale()); }
@Override public FilterCallContext beforeDoFilter(FilterCallContext callContext) { // clear the old request cache JiraAuthenticationContextImpl.clearRequestCache(); // start a request context for the new Request Cache RequestCacheController.startContext(); // insert a velocity request context. Fixes JRA-11038 DefaultVelocityRequestContextFactory.cacheVelocityRequestContext(callContext.getHttpServletRequest()); ThreadLocalErrorCollection.clear(); return callContext; }
@Override public I18nHelper getI18nHelper() { return i18n.getInstance(getUser()); }
@Override public void setLoggedInUser(final ApplicationUser user) { setLoggedInUserImpl(user); }
private Boolean getEnabledCachedWrapperFlag() { final Boolean flag = (Boolean) JiraAuthenticationContextImpl.getRequestCache().get(RequestCacheKeys.WRAP_PERMISSION_FILTER_IN_CACHED_WRAPPER_CACHE); return (flag == null) ? Boolean.FALSE : flag; } }
JiraAuthenticationContextImpl.clearRequestCache();
@Override public String getText(final String key) { return getI18nHelper().getText(key); }
@Override public ApplicationUser getUser() { return getLoggedInUser(); }
@VisibleForTesting Map<String, Object> getRequestCache() { return JiraAuthenticationContextImpl.getRequestCache(); }
private static void clearStatics() { ComponentAccessor.initialiseWorker(null); DefaultOfBizConnectionFactory.getInstance().resetInstance(); JiraAuthenticationContextImpl.clearRequestCache(); while (RequestCacheController.isInContext()) { RequestCacheController.closeContext(); } DefaultIndexManager.flushThreadLocalSearchers(); JiraKeyUtils.resetKeyMatcher(); try { final Field field = Configuration.class.getDeclaredField("configurationImpl"); field.setAccessible(true); field.set(Configuration.class, null); } catch (NoSuchFieldException e) { throw new AssertionError(e); } catch (IllegalAccessException e) { throw new AssertionError(e); } }
private void flushCustomFieldValueCache() { // TODO This is a horrible hack to stop the field values cache growing out of control during a reindex. Find a better way! final Map<?, ?> customFieldValueCache = (Map<?, ?>) JiraAuthenticationContextImpl.getRequestCache().get(RequestCacheKeys.CUSTOMFIELD_VALUES_CACHE); if (customFieldValueCache != null) { customFieldValueCache.clear(); } // TODO:end }
static <K, V> Map<K, V> getCache(final String key) { final Map<String, Object> requestCache = JiraAuthenticationContextImpl.getRequestCache(); @SuppressWarnings("unchecked") Map<K, V> result = (Map<K, V>) requestCache.get(key); if (result == null) { result = new HashMap<K, V>(); requestCache.put(key, result); } return result; }
@Override public boolean shouldSectionBeLazy(final String section) { final LoadingCache<String, Boolean> cache = getRequestCache(LAZY_SECTION_KEY, () -> CacheBuilder.newBuilder().build(new CacheLoader<String, Boolean>() { @Override public Boolean load(@Nonnull final String key) throws Exception { return ThreadLocalCachingSimpleLinkManager.super.shouldSectionBeLazy(key); } })); return cache.getUnchecked(section); }