org.sakaiproject.tool.api.Session.getUserId()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(9.6k)|赞(0)|评价(0)|浏览(191)

本文整理了Java中org.sakaiproject.tool.api.Session.getUserId()方法的一些代码示例,展示了Session.getUserId()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Session.getUserId()方法的具体详情如下:
包路径:org.sakaiproject.tool.api.Session
类名称:Session
方法名:getUserId

Session.getUserId介绍

[英]Return the authenticated user id associated with this session.
[中]返回与此会话关联的经过身份验证的用户id。

代码示例

代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl

/**
 * @inheritDoc
 */
public String getUserId()
{
  return m_session.getUserId();
}

代码示例来源:origin: sakaiproject/sakai

public String getCurrentUserId() {
  Session session = sessionManager.getCurrentSession();
  String userId = session.getUserId();
  return userId;
}

代码示例来源:origin: sakaiproject/sakai

/**
 * @see org.sakaiproject.tool.gradebook.facades.Authn#getUserUid()
 */
public String getUserUid() {
  Session session = SessionManager.getCurrentSession();
  String userId = session.getUserId();
  if(log.isDebugEnabled()) log.debug("current user id is " + userId);
  return userId;
}

代码示例来源:origin: org.sakaiproject.edu-services.gradebook/gradebook-service-impl

/**
 * @see org.sakaiproject.tool.gradebook.facades.Authn#getUserUid()
 */
public String getUserUid() {
  Session session = SessionManager.getCurrentSession();
  String userId = session.getUserId();
  if(log.isDebugEnabled()) log.debug("current user id is " + userId);
  return userId;
}

代码示例来源:origin: org.sakaiproject.profile/profile-component-shared

/**
 * @return
 */
private String getCurrentUserId()
{
  LOG.debug("getCurrentUser()");
  return SessionManager.getCurrentSession().getUserId();
}

代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl

/**
 * @inheritDoc
 */
public String getCurrentSessionUserId()
{
  Session s = (Session) threadLocalManager().get(CURRENT_SESSION);
  if (s != null)
  {
    return s.getUserId();
  }
  return null;
}

代码示例来源:origin: sakaiproject/sakai

@Override
public int doGet(String[] parts, HttpServletRequest req,
    HttpServletResponse res, Session session)
    throws PortalHandlerException
{
  if ((parts.length == 3) && (parts[1].equals(URL_FRAGMENT)))
  {
    try {
      UserFavorites favorites = userFavorites(session.getUserId());
      res.getWriter().write(favorites.toJSON());
      return END;
    } catch (Exception e) {
      throw new PortalHandlerException(e);
    }
  }
  return NEXT;
}

代码示例来源:origin: org.sakaiproject.portal/sakai-portal-impl

@Override
public int doGet(String[] parts, HttpServletRequest req,
    HttpServletResponse res, Session session)
    throws PortalHandlerException
{
  if ((parts.length == 3) && (parts[1].equals(URL_FRAGMENT)))
  {
    try {
      UserFavorites favorites = userFavorites(session.getUserId());
      res.getWriter().write(favorites.toJSON());
      return END;
    } catch (Exception e) {
      throw new PortalHandlerException(e);
    }
  }
  return NEXT;
}

代码示例来源:origin: sakaiproject/sakai

private void refreshAutoFavorites(Session session) {
  Long lastRefreshTime = (Long)session.getAttribute(AUTO_FAVORITES_LAST_REFRESHED_TIME);
  if (lastRefreshTime == null) {
    lastRefreshTime = Long.valueOf(0);
  }
  long now = System.currentTimeMillis();
  if ((now - lastRefreshTime) > AUTO_FAVORITES_REFRESH_INTERVAL_MS) {
    // Fetch the list of favorites, which will in turn populate the auto favorites.
    try {
      new FavoritesHandler().userFavorites(session.getUserId());
    } catch (Exception e) {
      log.error(e.getMessage(), e);
    }
    session.setAttribute(AUTO_FAVORITES_LAST_REFRESHED_TIME, now);
  }
}

代码示例来源:origin: sakaiproject/sakai

@Override
public int doPost(String[] parts, HttpServletRequest req,
    HttpServletResponse res, Session session)
    throws PortalHandlerException {
  if ((parts.length == 3) && (parts[1].equals(URL_FRAGMENT)))
  {
    try {
      UserFavorites favorites = UserFavorites.fromJSON(req.getParameter("userFavorites"));
      synchronized (session) {
        saveUserFavorites(session.getUserId(), favorites);
      }
      return END;
    } catch (Exception e) {
      throw new PortalHandlerException(e);
    }
  }
  return NEXT;
}

代码示例来源:origin: sakaiproject/sakai

public CurrentSiteViewImpl(PortalSiteHelperImpl siteHelper,
    SiteNeighbourhoodService siteNeighbourhoodService,
    HttpServletRequest request, Session session, String currentSiteId,
    SiteService siteService,
    ServerConfigurationService serverConfigurationService,
    PreferencesService preferencesService)
{
  this.siteHelper = siteHelper;
  this.request = request;
  this.currentSiteId = currentSiteId;
  this.session = session;
  Site myWorkspaceSite = siteHelper.getMyWorkspace(session);
  loggedIn = session.getUserId() != null;
  if (myWorkspaceSite != null)
  {
    myWorkspaceSiteId = myWorkspaceSite.getId();
  }
  initDone = false;
}

代码示例来源:origin: org.sakaiproject.portal/sakai-portal-impl

private void refreshAutoFavorites(Session session) {
  Long lastRefreshTime = (Long)session.getAttribute(AUTO_FAVORITES_LAST_REFRESHED_TIME);
  if (lastRefreshTime == null) {
    lastRefreshTime = Long.valueOf(0);
  }
  long now = System.currentTimeMillis();
  if ((now - lastRefreshTime) > AUTO_FAVORITES_REFRESH_INTERVAL_MS) {
    // Fetch the list of favorites, which will in turn populate the auto favorites.
    try {
      new FavoritesHandler().userFavorites(session.getUserId());
    } catch (Exception e) {
      log.error(e.getMessage(), e);
    }
    session.setAttribute(AUTO_FAVORITES_LAST_REFRESHED_TIME, now);
  }
}

代码示例来源:origin: org.sakaiproject.portal/sakai-portal-impl

public CurrentSiteViewImpl(PortalSiteHelperImpl siteHelper,
    SiteNeighbourhoodService siteNeighbourhoodService,
    HttpServletRequest request, Session session, String currentSiteId,
    SiteService siteService,
    ServerConfigurationService serverConfigurationService,
    PreferencesService preferencesService)
{
  this.siteHelper = siteHelper;
  this.request = request;
  this.currentSiteId = currentSiteId;
  this.session = session;
  Site myWorkspaceSite = siteHelper.getMyWorkspace(session);
  loggedIn = session.getUserId() != null;
  if (myWorkspaceSite != null)
  {
    myWorkspaceSiteId = myWorkspaceSite.getId();
  }
  initDone = false;
}

代码示例来源:origin: org.sakaiproject.portal/sakai-portal-impl

@Override
public int doPost(String[] parts, HttpServletRequest req,
    HttpServletResponse res, Session session)
    throws PortalHandlerException {
  if ((parts.length == 3) && (parts[1].equals(URL_FRAGMENT)))
  {
    try {
      UserFavorites favorites = UserFavorites.fromJSON(req.getParameter("userFavorites"));
      synchronized (session) {
        saveUserFavorites(session.getUserId(), favorites);
      }
      return END;
    } catch (Exception e) {
      throw new PortalHandlerException(e);
    }
  }
  return NEXT;
}

代码示例来源:origin: sakaiproject/sakai

/**
 * @see org.sakaiproject.portal.api.PortalSiteHelper#getMyWorkspace(org.sakaiproject.tool.api.Session)
 */
public Site getMyWorkspace(Session session)
{
  String siteId = SiteService.getUserSiteId(session.getUserId());
  // Make sure we can visit
  Site site = null;
  try
  {
    site = getSiteVisit(siteId);
  }
  catch (IdUnusedException e)
  {
    site = null;
  }
  catch (PermissionException e)
  {
    site = null;
  }
  return site;
}

代码示例来源:origin: org.sakaiproject.scheduler/scheduler-component-shared

@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
  if (siteId == null) {
    siteId = UUID.randomUUID().toString();
  }
  log.info("Attempting to import: " + zip+ " into "+ siteId);
  Session currentSession = sessionManager.getCurrentSession();
  String oldId = currentSession.getUserId();
  String oldEid = currentSession.getUserEid();
  try {
    currentSession.setUserId("admin");
    currentSession.setUserEid("admin");
    archiveService.mergeFromZip(zip, siteId, null);
  } catch (Exception e) {
    log.warn("Failed to import " + zip + " to " + siteId + " " + e.getMessage());
  } finally {
    currentSession.setUserId(oldId);
    currentSession.setUserEid(oldEid);
  }
}

代码示例来源:origin: sakaiproject/sakai

@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
  if (siteId == null) {
    siteId = UUID.randomUUID().toString();
  }
  log.info("Attempting to import: " + zip+ " into "+ siteId);
  Session currentSession = sessionManager.getCurrentSession();
  String oldId = currentSession.getUserId();
  String oldEid = currentSession.getUserEid();
  try {
    currentSession.setUserId("admin");
    currentSession.setUserEid("admin");
    archiveService.mergeFromZip(zip, siteId, null);
  } catch (Exception e) {
    log.warn("Failed to import " + zip + " to " + siteId + " " + e.getMessage());
  } finally {
    currentSession.setUserId(oldId);
    currentSession.setUserEid(oldEid);
  }
}

代码示例来源:origin: sakaiproject/sakai

public AbstractSiteViewImpl(PortalSiteHelperImpl siteHelper, SiteNeighbourhoodService siteNeighbourhoodService, 
    HttpServletRequest request, Session session, String currentSiteId, SiteService siteService,
    ServerConfigurationService serverConfigurationService, PreferencesService preferencesService)
{
  this.siteHelper = siteHelper;
  this.request = request;
  this.currentSiteId = currentSiteId;
  this.siteService = siteService;
  this.session = session;
  this.preferencesService = preferencesService;
  this.serverConfigurationService = serverConfigurationService;
  
  
  
      boolean showMyWorkspace = serverConfigurationService.getBoolean("myworkspace.show",true);
      mySites = siteNeighbourhoodService.getSitesAtNode(request, session, showMyWorkspace);
  
  
  loggedIn = session.getUserId() != null;
  Site myWorkspaceSite = siteHelper.getMyWorkspace(session);
  if (myWorkspaceSite != null)
  {
    myWorkspaceSiteId = myWorkspaceSite.getId();
  }
  renderContextMap = new HashMap<String, Object>();
}

代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl

public LRS_Actor getActor(Event event) {
  String userId = null;
  if (event != null) {
    userId = event.getUserId();
  }
  if (userId == null && event != null && event.getSessionId() != null) {
    Session session = this.sessionManager.getSession(event.getSessionId());
    if (session != null) {
      userId = session.getUserId();
    }
  }
  return getActor(userId);
}

代码示例来源:origin: org.sakaiproject.metaobj/sakai-metaobj-impl

public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
  Session sakaiSession = SessionManager.getCurrentSession();
  String userId = sakaiSession.getUserId();
  String eId = sakaiSession.getUserEid();
  try {
    sakaiSession.setUserId("admin");
    sakaiSession.setUserEid("admin");
    boolean updateSchemaHashes = ServerConfigurationService.getBoolean("metaobj.schemahash.update", false);
    getStructuredArtifactDefinitionManager().verifySchemaHashes(updateSchemaHashes);
  } finally {
    sakaiSession.setUserEid(userId);
    sakaiSession.setUserId(eId);
  }
}

相关文章