congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
ThreadLocalUserContext.getUserContext
Code IndexAdd Tabnine to your IDE (free)

How to use
getUserContext
method
in
org.projectforge.framework.persistence.user.api.ThreadLocalUserContext

Best Java code snippets using org.projectforge.framework.persistence.user.api.ThreadLocalUserContext.getUserContext (Showing top 7 results out of 315)

origin: micromata/projectforge

/**
 * @return The user of ThreadLocal if exists.
 */
public final static PFUserDO getUser()
{
 final UserContext userContext = getUserContext();
 if (userContext == null) {
  return null;
 }
 return userContext.getUser();
}
origin: micromata/projectforge

public TenantDO getCurrentTenant()
{
 final UserContext userContext = ThreadLocalUserContext.getUserContext();
 final TenantDO currentTenant = userContext != null ? userContext.getCurrentTenant()
   : tenantService.getDefaultTenant();
 return currentTenant;
}
origin: micromata/projectforge

private void initActualTenant()
{
 if (ThreadLocalUserContext.getUserContext() == null) {
  return;
 }
 UserContext userContext = ThreadLocalUserContext.getUserContext();
 TenantService tenantService = ApplicationContextProvider.getApplicationContext().getBean(TenantService.class);
 PFUserDO user = userContext.getUser();
 if (user.getId() != null && tenantService.isMultiTenancyAvailable() == true) {
  // Try to find the last used tenant of the user:
  final Integer currentTenantId = (Integer) UserPreferencesHelper.getEntry(USER_PREF_KEY_CURRENT_TENANT);
  if (currentTenantId != null) {
   setCurrentTenant(tenantService.getTenant(currentTenantId));
  } else {
   final Collection<TenantDO> tenants = tenantService.getTenantsOfUser(user.getId());
   if (CollectionUtils.isNotEmpty(tenants) == true) {
    setCurrentTenant(tenants.iterator().next());
   }
  }
 }
}
origin: micromata/projectforge

/**
 * Runs the update method of the given update entry.
 *
 * @param updateScript
 */
public void update(final UpdateEntry updateEntry)
{
 UserContext uc = ThreadLocalUserContext.getUserContext();
 exService.submit(() -> {
  setUpdating(true);
  try {
   ThreadLocalUserContext.setUserContext(uc);
   updateEntry.setRunningStatus(updateEntry.runUpdate());
   //getDatabaseUpdateDao().writeUpdateEntryLog(updateEntry);
   updateEntry.setPreCheckStatus(updateEntry.runPreCheckSafely());
   runAllPreChecks();
  } catch (Error e) {
   log.error("Error while updating entry: " + updateEntry.getVersion(), e);
  } finally {
   setUpdating(false);
  }
 });
}
origin: micromata/projectforge

/**
 * 
 * @param filter
 * @param ignoreTenant default is false.
 */
public QueryFilter(final BaseSearchFilter filter, final boolean ignoreTenant)
{
 if (filter == null) {
  this.filter = new BaseSearchFilter();
 } else {
  this.filter = filter;
 }
 TenantService tenantService = ApplicationContextProvider.getApplicationContext().getBean(TenantService.class);
 if (ignoreTenant == false && tenantService.isMultiTenancyAvailable() == true) {
  final UserContext userContext = ThreadLocalUserContext.getUserContext();
  final TenantDO currentTenant = userContext.getCurrentTenant();
  if (currentTenant != null) {
   if (currentTenant.isDefault() == true) {
    this.add(Restrictions.or(Restrictions.eq("tenant", userContext.getCurrentTenant()),
      Restrictions.isNull("tenant")));
   } else {
    this.add(Restrictions.eq("tenant", userContext.getCurrentTenant()));
   }
  }
 }
}
origin: micromata/projectforge

list = new LinkedList<PFUserDO>();
for (final PFUserDO user : origList) {
 if (tenantChecker.isPartOfTenant(ThreadLocalUserContext.getUserContext().getCurrentTenant(), user) == true) {
  list.add(user);
origin: micromata/projectforge

public MySession(final Request request)
{
 super(request);
 setLocale(request);
 final ClientInfo info = getClientInfo();
 if (info instanceof WebClientInfo) {
  clientProperties = ((WebClientInfo) clientInfo).getProperties();
  clientProperties.setTimeZone(ThreadLocalUserContext.getTimeZone());
  userAgent = ((WebClientInfo) info).getUserAgent();
  userAgentDevice = UserAgentDevice.getUserAgentDevice(userAgent);
  userAgentOS = UserAgentOS.getUserAgentOS(userAgent);
  mobileUserAgent = userAgentDevice.isMobile();
  final UserAgentDetection userAgentDetection = UserAgentDetection.browserDetect(userAgent);
  userAgentBrowser = userAgentDetection.getUserAgentBrowser();
  userAgentBrowserVersionString = userAgentDetection.getUserAgentBrowserVersion();
 } else {
  log.error("Oups, ClientInfo is not from type WebClientInfo: " + info);
 }
 setUserContext(ThreadLocalUserContext.getUserContext());
 initActualTenant();
 this.csrfToken = NumberHelper.getSecureRandomUrlSaveString(20);
}
org.projectforge.framework.persistence.user.apiThreadLocalUserContextgetUserContext

Popular methods of ThreadLocalUserContext

  • getUser
  • getLocalizedString
  • getTimeZone
  • getUserId
  • getLocale
    If context user's locale is null and the given defaultLocale is not null, then the context user's cl
  • getDateTimeZone
  • setUser
    If given user is null, #clear() is called.
  • clear
  • getLocalizedMessage
  • setUserContext
  • getCalendarFirstDayOfWeek
    The first day of the week, configured at the given user, if not configured ConfigXml#getFirstDayOfWe
  • getJodaFirstDayOfWeek
  • getCalendarFirstDayOfWeek,
  • getJodaFirstDayOfWeek

Popular in Java

  • Running tasks concurrently on multiple threads
  • getExternalFilesDir (Context)
  • getApplicationContext (Context)
  • addToBackStack (FragmentTransaction)
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • Top 15 Vim Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now