本文整理匯總了Java中org.sakaiproject.tool.api.Placement.getContext方法的典型用法代碼示例。如果您正苦於以下問題:Java Placement.getContext方法的具體用法?Java Placement.getContext怎麽用?Java Placement.getContext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.sakaiproject.tool.api.Placement
的用法示例。
在下文中一共展示了Placement.getContext方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getSiteId
import org.sakaiproject.tool.api.Placement; //導入方法依賴的package包/類
/**
* Get the current site id
* @param state SessionState
* @throws SessionDataException
* @return Site id (GUID)
*/
private String getSiteId(SessionState state) throws SessionDataException
{
// Check if it is state (i.e. we are a helper in site.info)
String retval = (String) state.getAttribute(STATE_SITE_INSTANCE_ID);
if ( retval != null ) return retval;
// If it is not in state, we must be stand alone
Placement placement = ToolManager.getCurrentPlacement();
if (placement == null)
{
throw new SessionDataException("No current tool placement");
}
return placement.getContext();
}
示例2: getContextId
import org.sakaiproject.tool.api.Placement; //導入方法依賴的package包/類
/**
* ContextId is present site id for now.
*/
private String getContextId() {
if (TestUtil.isRunningTests()) {
return "test-context";
}
String presentSiteId = null;
Placement placement = toolManager.getCurrentPlacement();
if(placement == null){
//current placement is null.. let's try another approach to getting the site id
if(sessionManager.getCurrentToolSession() != null){
ToolConfiguration toolConfig = siteService.findTool(sessionManager.getCurrentToolSession().getId());
if(toolConfig != null){
presentSiteId = toolConfig.getSiteId();
}
}
}else{
presentSiteId = placement.getContext();
}
log.debug("site: " + presentSiteId);
return presentSiteId;
}
示例3: getContextId
import org.sakaiproject.tool.api.Placement; //導入方法依賴的package包/類
private String getContextId() {
if (TestUtil.isRunningTests()) {
return "test-context";
}
Placement placement = toolManager.getCurrentPlacement();
String presentSiteId = placement.getContext();
return presentSiteId;
}
示例4: getSiteId
import org.sakaiproject.tool.api.Placement; //導入方法依賴的package包/類
/**
* Get the current site id
* @throws SessionDataException
* @return Site id (GUID)
*/
private String getSiteId() throws SessionDataException
{
Placement placement = ToolManager.getCurrentPlacement();
if (placement == null)
{
throw new SessionDataException("No current tool placement");
}
return placement.getContext();
}
示例5: getContentItemFromRequest
import org.sakaiproject.tool.api.Placement; //導入方法依賴的package包/類
/**
* Create a ContentItem from the current request (may throw runtime)
*/
public static ContentItem getContentItemFromRequest(Map<String, Object> tool)
{
Placement placement = ToolManager.getCurrentPlacement();
String siteId = placement.getContext();
String toolSiteId = (String) tool.get(LTIService.LTI_SITE_ID);
if ( toolSiteId != null && ! toolSiteId.equals(siteId) ) {
throw new RuntimeException("Incorrect site id");
}
HttpServletRequest req = ToolUtils.getRequestFromThreadLocal();
String lti_log = req.getParameter("lti_log");
String lti_errorlog = req.getParameter("lti_errorlog");
if ( lti_log != null ) log.debug(lti_log);
if ( lti_errorlog != null ) log.warn(lti_errorlog);
ContentItem contentItem = new ContentItem(req);
String oauth_consumer_key = req.getParameter("oauth_consumer_key");
String oauth_secret = (String) tool.get(LTIService.LTI_SECRET);
oauth_secret = decryptSecret(oauth_secret);
String URL = getOurServletPath(req);
if ( ! contentItem.validate(oauth_consumer_key, oauth_secret, URL) ) {
log.warn("Provider failed to validate message: {}", contentItem.getErrorMessage());
String base_string = contentItem.getBaseString();
if ( base_string != null ) log.warn("base_string={}", base_string);
throw new RuntimeException("Failed OAuth validation");
}
return contentItem;
}
示例6: setTemporaryPlacement
import org.sakaiproject.tool.api.Placement; //導入方法依賴的package包/類
public boolean setTemporaryPlacement(Site site)
{
if (site == null) return false;
Placement ppp = getToolManager().getCurrentPlacement();
if (ppp != null && site.getId().equals(ppp.getContext()))
{
return true;
}
// Create a site-only placement
Placement placement = new org.sakaiproject.util.Placement("portal-temporary", /* toolId */
null, /* tool */null,
/* config */null, /* context */site.getId(), /* title */null);
ThreadLocalManager.set(CURRENT_PLACEMENT, placement);
// Debugging
ppp = getToolManager().getCurrentPlacement();
if (ppp == null)
{
log.warn("portal-temporary placement not set - null");
}
else
{
String cont = ppp.getContext();
if (site.getId().equals(cont))
{
return true;
}
else
{
log.warn("portal-temporary placement mismatch site="
+ site.getId() + " context=" + cont);
}
}
return false;
}
示例7: getContext
import org.sakaiproject.tool.api.Placement; //導入方法依賴的package包/類
/**
* @inheritDoc
*/
public String getContext(Object request) {
Placement placement = ToolManager.getCurrentPlacement();
if(placement == null) {
log.error("Placement is null");
return null;
}
return placement.getContext();
}
示例8: siteId
import org.sakaiproject.tool.api.Placement; //導入方法依賴的package包/類
private String siteId() {
if(siteId == null){
Placement placement = toolManager.getCurrentPlacement();
siteId = placement.getContext();
}
return siteId;
}
示例9: getSiteId
import org.sakaiproject.tool.api.Placement; //導入方法依賴的package包/類
private String getSiteId() {
if(siteId == null){
Placement placement = M_tm.getCurrentPlacement();
siteId = placement.getContext();
}
return siteId;
}
示例10: getSiteId
import org.sakaiproject.tool.api.Placement; //導入方法依賴的package包/類
public String getSiteId()
{
if(siteId == null){
Placement placement = ToolManager.getCurrentPlacement();
if(placement != null){
siteId = placement.getContext();
}
}
return siteId;
}
示例11: getCurrentSiteId
import org.sakaiproject.tool.api.Placement; //導入方法依賴的package包/類
/**
* Get the current site id.
* @return the site id.
*/
public String getCurrentSiteId(boolean accessViaUrl){
// access via url => users does not login via any sites
String currentSiteId = null;
if (!accessViaUrl)
{
// cwen
Placement thisPlacement = ToolManager.getCurrentPlacement();
if(thisPlacement != null)
currentSiteId = thisPlacement.getContext();
}
return currentSiteId;
}
示例12: getSiteId
import org.sakaiproject.tool.api.Placement; //導入方法依賴的package包/類
public String getSiteId()
{
siteId = null;
Placement currentPlacement = ToolManager.getCurrentPlacement();
if(currentPlacement != null)
siteId = currentPlacement.getContext();
return siteId;
}
示例13: getGradebookUid
import org.sakaiproject.tool.api.Placement; //導入方法依賴的package包/類
/**
* @see org.sakaiproject.tool.gradebook.facades.ContextManagement#getGradebookUid(java.lang.Object)
*/
public String getGradebookUid(Object notNeededInSakai) {
// get the Tool Placement, and return the tool's context if available
Placement placement = ToolManager.getCurrentPlacement();
if(placement == null) {
log.error("Placement is null");
return DEFAULT_GRADEBOOK_NAME;
}
return placement.getContext();
}
示例14: BaseEvent
import org.sakaiproject.tool.api.Placement; //導入方法依賴的package包/類
/**
* Construct
*
* @param event
* The Event id.
* @param resource
* The resource id.
* @param modify
* If the event caused a modify, true, if it was just an access, false.
* @param priority
* The Event's notification priority.
*/
public BaseEvent(String event, String resource, boolean modify, int priority, LRS_Statement lrsStatement)
{
setEvent(event);
setResource(resource);
m_lrsStatement = lrsStatement;
m_modify = modify;
m_priority = priority;
// Find the context using the reference (let the service that it belongs to parse it)
if (resource != null && !"".equals(resource)) {
Reference ref = entityManager().newReference(resource);
if (ref != null) {
m_context = ref.getContext();
}
}
// If we still need to find the context, try the tool placement
if (m_context == null) {
Placement placement = toolManager().getCurrentPlacement();
if (placement != null) {
m_context = placement.getContext();
}
}
// KNL-997
String uId = sessionManager().getCurrentSessionUserId();
if (uId == null)
{
uId = "?";
}
setUserId(uId);
}
示例15: getContextId
import org.sakaiproject.tool.api.Placement; //導入方法依賴的package包/類
private String getContextId() {
if (TestUtil.isRunningTests()) {
return "test-context";
}
Placement placement = toolManager.getCurrentPlacement();
String presentSiteId = placement.getContext();
return presentSiteId;
}