本文整理了Java中org.sakaiproject.tool.api.Session.getToolSession()
方法的一些代码示例,展示了Session.getToolSession()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Session.getToolSession()
方法的具体详情如下:
包路径:org.sakaiproject.tool.api.Session
类名称:Session
方法名:getToolSession
[英]Find or create a tool session for this tool placement id
[中]查找或创建此刀具放置id的刀具任务
代码示例来源:origin: sakaiproject/sakai
/**
* Detect a tool placement from the URL, and if found, setup the placement attribute and current tool session based on that id.
*
* @param s
* The sakai session.
* @param req
* The request, already prepared with the placement id if any.
* @return The tool session.
*/
protected ToolSession detectToolPlacement(Session s, HttpServletRequest req)
{
// skip if so configured
if (this.m_toolPlacement == false) return null;
ToolSession toolSession = null;
String placementId = (String) req.getParameter(Tool.PLACEMENT_ID);
if (placementId != null)
{
toolSession = s.getToolSession(placementId);
// put the session in the request attribute
req.setAttribute(Tool.TOOL_SESSION, toolSession);
// set as the current tool session
sessionManager.setCurrentToolSession(toolSession);
// put the placement id in the request attribute
req.setAttribute(Tool.PLACEMENT_ID, placementId);
}
return toolSession;
}
代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-api
/**
* Detect a tool placement from the URL, and if found, setup the placement attribute and current tool session based on that id.
*
* @param s
* The sakai session.
* @param req
* The request, already prepared with the placement id if any.
* @return The tool session.
*/
protected ToolSession detectToolPlacement(Session s, HttpServletRequest req)
{
// skip if so configured
if (this.m_toolPlacement == false) return null;
ToolSession toolSession = null;
String placementId = (String) req.getParameter(Tool.PLACEMENT_ID);
if (placementId != null)
{
toolSession = s.getToolSession(placementId);
// put the session in the request attribute
req.setAttribute(Tool.TOOL_SESSION, toolSession);
// set as the current tool session
sessionManager.setCurrentToolSession(toolSession);
// put the placement id in the request attribute
req.setAttribute(Tool.PLACEMENT_ID, placementId);
}
return toolSession;
}
代码示例来源:origin: org.sakaiproject.metaobj/sakai-metaobj-impl
public void handleAccess(HttpServletRequest req, HttpServletResponse res, Reference ref,
Collection copyrightAcceptedRefs) throws EntityPermissionException, EntityNotDefinedException, EntityAccessOverloadException, EntityCopyrightException {
ToolSession toolSession = SessionManager.getCurrentToolSession();
if (toolSession == null) {
toolSession = SessionManager.getCurrentSession().getToolSession(req.getSession(true).hashCode() + "");
SessionManager.setCurrentToolSession(toolSession);
}
super.handleAccess(req, res, ref, copyrightAcceptedRefs);
}
代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl
/**
* @inheritDoc
*/
public SessionState getSessionState(String key)
{
// map this to the sakai session's tool session concept, using key as the placement id
Session s = sessionManager().getCurrentSession();
if (s != null)
{
return new SessionStateWrapper(s.getToolSession(key));
}
log.warn("getSessionState(): no session: key: " + key);
return null;
}
代码示例来源:origin: org.sakaiproject.presence/sakai-presence-impl
/**
* Check all session presences and remove any expired ones
*/
@SuppressWarnings("unchecked")
protected void checkAllPresenceForExpiration()
{
List<Session> sessions = m_sessionManager.getSessions();
for (Iterator<Session> i = sessions.iterator(); i.hasNext();)
{
Session session = (Session) i.next();
ToolSession ts = session.getToolSession(SESSION_KEY);
Enumeration locations = ts.getAttributeNames();
while (locations.hasMoreElements())
{
String location = (String) locations.nextElement();
Presence p = (Presence) ts.getAttribute(location);
if (M_log.isDebugEnabled()) M_log.debug("checking expiry of session " + session.getId() + " in location " + location);
if (p != null && p.isExpired())
{
ts.removeAttribute(location);
}
}
}
}
代码示例来源:origin: org.sakaiproject.presence/sakai-presence-impl
/**
* Check current session presences and remove any expired ones
*/
@SuppressWarnings("unchecked")
protected void checkPresenceForExpiration()
{
Session session = m_sessionManager.getCurrentSession();
ToolSession ts = session.getToolSession(SESSION_KEY);
Enumeration locations = ts.getAttributeNames();
while (locations.hasMoreElements())
{
String location = (String) locations.nextElement();
Presence p = (Presence) ts.getAttribute(location);
if (p != null && p.isExpired())
{
ts.removeAttribute(location);
}
}
}
代码示例来源:origin: org.sakaiproject.presence/sakai-presence-impl
/**
* Check if the current session is present at the location - optionally refreshing it
*
* @param locationId
* The location to check.
* @param refresh
* If true, refresh the timeout on the presence if found
* @return True if the current session is present at that location, false if not.
*/
protected boolean checkPresence(String locationId, boolean refresh)
{
Session session = m_sessionManager.getCurrentSession();
ToolSession ts = session.getToolSession(SESSION_KEY);
Presence p = (Presence) ts.getAttribute(locationId);
if ((p != null) && refresh)
{
p.setActive();
}
return (p != null);
}
代码示例来源:origin: sakaiproject/sakai
.forEach(tool -> session.getToolSession(tool.getId()).clearAttributes()); // reset each tool
代码示例来源:origin: sakaiproject/sakai
ToolSession toolSession = session.getToolSession(toSynTool.getId());
if (toolSession.getAttribute(STATE_UPDATE) == null)
代码示例来源:origin: org.sakaiproject.portal/sakai-portal-impl
.forEach(tool -> session.getToolSession(tool.getId()).clearAttributes()); // reset each tool
代码示例来源:origin: org.sakaiproject.message/sakai-message-util
ToolSession toolSession = session.getToolSession(toSynTool.getId());
if (toolSession.getAttribute(STATE_UPDATE) == null)
代码示例来源:origin: sakaiproject/sakai
.forEach(tool -> session.getToolSession(tool.getId()).clearAttributes()); // reset each tool
代码示例来源:origin: org.sakaiproject.message/sakai-message-impl
ToolSession toolSession = session.getToolSession(toSynTool.getId());
if (toolSession.getAttribute(STATE_UPDATE) == null)
代码示例来源:origin: org.sakaiproject.metaobj/sakai-metaobj-impl
public void handleAccess(HttpServletRequest req, HttpServletResponse res, Reference ref,
Collection copyrightAcceptedRefs) throws EntityPermissionException, EntityNotDefinedException, EntityAccessOverloadException, EntityCopyrightException {
String helperId = "sakai.metaobj.formView";
ToolSession toolSession = SessionManager.getCurrentToolSession();
if (toolSession == null) {
toolSession = SessionManager.getCurrentSession().getToolSession(req.getSession(true).hashCode() + "");
SessionManager.setCurrentToolSession(toolSession);
}
ActiveTool helperTool = ActiveToolManager.getActiveTool(helperId);
toolSession.setAttribute(helperTool.getId() + Tool.HELPER_DONE_URL,
"javascript:alert('hi')");
toolSession.setAttribute(ResourceEditingHelper.ATTACHMENT_ID, ref.getId());
String context = req.getContextPath() + req.getServletPath();
String toolPath = "/formView.osp";
try {
helperTool.help(req, res, context, toolPath);
}
catch (ToolException e) {
throw new EntityPermissionException(SessionManager.getCurrentSessionUserId(),
ContentHostingService.AUTH_RESOURCE_READ, ref.getReference());
}
}
代码示例来源:origin: sakaiproject/sakai
while(toolz.hasNext()){
ToolConfiguration pageTool = toolz.next();
ToolSession ts = s.getToolSession(pageTool.getId());
ts.clearAttributes();
if ( portal.isPortletPlacement(pageTool) ) hasJSR168 = true;
代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl
ToolSession ts = sessionManager().getCurrentSession().getToolSession(placement.getId());
代码示例来源:origin: org.sakaiproject.presence/sakai-presence-impl
/**
* {@inheritDoc}
*/
public void removePresence(String locationId)
{
if (locationId == null) return;
if (checkPresence(locationId, false))
{
UsageSession curSession = m_usageSessionService.getSession();
// tell maintenance
m_storage.removePresence(curSession.getId(), locationId);
// generate the event
Event event = m_eventTrackingService.newEvent(EVENT_ABSENCE, presenceReference(locationId), true);
m_eventTrackingService.post(event, curSession);
// remove from state
Session session = m_sessionManager.getCurrentSession();
ToolSession ts = session.getToolSession(SESSION_KEY);
Presence p = (Presence) ts.getAttribute(locationId);
if (p != null)
{
p.deactivate();
ts.removeAttribute(locationId);
}
}
} // removePresence
代码示例来源:origin: org.sakaiproject.presence/sakai-presence-impl
/**
* {@inheritDoc}
*/
public void setPresence(String locationId, int timeout)
{
if (locationId == null) return;
if (!checkPresence(locationId, true))
{
// presence relates a usage session (the current one) with a location
UsageSession curSession = m_usageSessionService.getSession();
if (curSession == null) return;
// update the storage
m_storage.setPresence(curSession.getId(), locationId);
// generate the event
Event event = m_eventTrackingService.newEvent(EVENT_PRESENCE, presenceReference(locationId), true);
m_eventTrackingService.post(event, curSession);
// create a presence for tracking
// bind a presence tracking object to the sakai session for auto-cleanup when logout or inactivity invalidates the sakai session
Session session = m_sessionManager.getCurrentSession();
ToolSession ts = session.getToolSession(SESSION_KEY);
Presence p = new Presence(curSession, locationId, timeout);
ts.setAttribute(locationId, p);
}
// retire any expired presence
checkPresenceForExpiration();
} // setPresence
代码示例来源:origin: org.sakaiproject.portal/sakai-portal-render-impl
ToolSession ts = s.getToolSession(placementId);
ts.clearAttributes();
portal.setResetState(null);
代码示例来源:origin: sakaiproject/sakai
ToolSession ts = s.getToolSession(placementId);
ts.clearAttributes();
portalService.setResetState(null);
内容来源于网络,如有侵权,请联系作者删除!