当前位置: 首页>>代码示例>>Java>>正文


Java ToolConfiguration.getTool方法代码示例

本文整理汇总了Java中org.sakaiproject.site.api.ToolConfiguration.getTool方法的典型用法代码示例。如果您正苦于以下问题:Java ToolConfiguration.getTool方法的具体用法?Java ToolConfiguration.getTool怎么用?Java ToolConfiguration.getTool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.sakaiproject.site.api.ToolConfiguration的用法示例。


在下文中一共展示了ToolConfiguration.getTool方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPageForTool

import org.sakaiproject.site.api.ToolConfiguration; //导入方法依赖的package包/类
/**
 * Look through the pages in a site and find the page that corresponds to a tool.
 *
 * @param <code>site</code>
 *		The site
 * @param <code>toolId</code>
 *		The placement / tool ID
 * @return The page if found otherwise null.
 */
public static SitePage getPageForTool(Site site, String toolId)
{
	if ( site == null || toolId == null ) return null;
	List pages = site.getOrderedPages();
	for (Iterator i = pages.iterator(); i.hasNext();)
	{
		SitePage p = (SitePage) i.next();
		List<ToolConfiguration> pTools = p.getTools();
		Iterator<ToolConfiguration> toolz = pTools.iterator();
		while(toolz.hasNext()){
			ToolConfiguration tc = toolz.next();
			Tool to = tc.getTool();
			if ( toolId.equals(tc.getId()) ) {
				return p;
			}
		}
	}
	return null;
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:29,代码来源:ToolUtils.java

示例2: readToolFeatureForm

import org.sakaiproject.site.api.ToolConfiguration; //导入方法依赖的package包/类
/**
 * Read the tool feature form and update the site in state.
 * 
 * @return true if the form is accepted, false if there's a validation error (an alertMessage will be set)
 */
private boolean readToolFeatureForm(RunData data, SessionState state)
{
	// get the tool - it's there
	ToolConfiguration tool = (ToolConfiguration) state.getAttribute("tool");

	// read the form
	String feature = data.getParameters().getString("feature");

	// get this feature
	Tool t = tool.getTool();

	// if the feature has changed, update the default configuration
	if ((t == null) || (!feature.equals(t.getId())))
	{
		tool.setTool(feature, ToolManager.getTool(feature));
		tool.setTitle(ToolManager.getTool(feature).getTitle());
		tool.getPlacementConfig().clear();
	}

	return true;

}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:28,代码来源:AdminSitesAction.java

示例3: getTools

import org.sakaiproject.site.api.ToolConfiguration; //导入方法依赖的package包/类
/**
 * @inheritDoc
 */
public Collection getTools(String[] toolIds)
{
	List rv = new Vector();
	if ((toolIds == null) || (toolIds.length == 0)) return rv;

	for (Iterator iTools = getTools().iterator(); iTools.hasNext();)
	{
		ToolConfiguration tc = (ToolConfiguration) iTools.next();
		Tool tool = tc.getTool();
		if ((tool != null) && (tool.getId() != null))
		{
			for (int i = 0; i < toolIds.length; i++)
			{
				if (tool.getId().equals(toolIds[i]))
				{
					rv.add(tc);
				}
			}
		}
	}

	return rv;
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:27,代码来源:BaseSitePage.java

示例4: pageHasToolId

import org.sakaiproject.site.api.ToolConfiguration; //导入方法依赖的package包/类
/**
 * check whether the page tool list contains certain toolId
 * @param pageToolList
 * @param toolId
 * @return
 */
private boolean pageHasToolId(List pageToolList, String toolId) {
	for (Iterator iPageToolList = pageToolList.iterator(); iPageToolList.hasNext();)
	{
		ToolConfiguration toolConfiguration = (ToolConfiguration) iPageToolList.next();
		Tool t = toolConfiguration.getTool();
		if (t != null && toolId.equals(toolConfiguration.getTool().getId()))
		{
			return true;
		}
	}
	return false;
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:19,代码来源:SiteAction.java

示例5: addConfigPropertyToTool

import org.sakaiproject.site.api.ToolConfiguration; //导入方法依赖的package包/类
/**
 * Add a property to a tool on a page in a site
 *
 * @param sessionid the id of a valid session
 * @param siteid    the id of the site to add the page to
 * @param pagetitle the title of the page the tool exists in
 * @param tooltitle the title of the tool to add the property to
 * @param propname  the name of the property
 * @param propvalue the value of the property
 * @return success or exception message
 * <p/>
 * TODO: fix for if any values (except sessionid and siteid) are blank or invalid, it is still returning success - SAK-15334
 */
@WebMethod
@Path("/addConfigPropertyToTool")
@Produces("text/plain")
@GET
public String addConfigPropertyToTool(
        @WebParam(name = "sessionid", partName = "sessionid") @QueryParam("sessionid") String sessionid,
        @WebParam(name = "siteid", partName = "siteid") @QueryParam("siteid") String siteid,
        @WebParam(name = "pagetitle", partName = "pagetitle") @QueryParam("pagetitle") String pagetitle,
        @WebParam(name = "tooltitle", partName = "tooltitle") @QueryParam("tooltitle") String tooltitle,
        @WebParam(name = "propname", partName = "propname") @QueryParam("propname") String propname,
        @WebParam(name = "propvalue", partName = "propvalue") @QueryParam("propvalue") String propvalue) {
    Session session = establishSession(sessionid);

    try {

        Site siteEdit = siteService.getSite(siteid);
        List pageEdits = siteEdit.getPages();
        for (Iterator i = pageEdits.iterator(); i.hasNext(); ) {
            SitePage pageEdit = (SitePage) i.next();
            if (pageEdit.getTitle().equals(pagetitle)) {
                List toolEdits = pageEdit.getTools();
                for (Iterator j = toolEdits.iterator(); j.hasNext(); ) {
                    ToolConfiguration tool = (ToolConfiguration) j.next();
                    Tool t = tool.getTool();
                    if (tool.getTitle().equals(tooltitle)) {
                        Properties propsedit = tool.getPlacementConfig();
                        propsedit.setProperty(propname, propvalue);
                    }
                }
            }
        }
        siteService.save(siteEdit);

    } catch (Exception e) {
        log.error("WS addConfigPropertyToTool(): " + e.getClass().getName() + " : " + e.getMessage());
        return e.getClass().getName() + " : " + e.getMessage();
    }
    return "success";
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:53,代码来源:SakaiScript.java

示例6: doFilter

import org.sakaiproject.site.api.ToolConfiguration; //导入方法依赖的package包/类
public void doFilter(ServletRequest request, ServletResponse response,
		 FilterChain chain) 
throws java.io.IOException, javax.servlet.ServletException
   {
// rsf does this:
//Tool tool = (Tool) request.getAttribute("sakai.tool");
//placement = (Placement) request.getAttribute("sakai.tool.placement");
// we need to set it.

String placementId = request.getParameter("placementId");
ToolConfiguration placement = SiteService.findTool(placementId);
String siteId = placement.getSiteId();
// there was some concern whether it's safe to set up a placement to which the
// user doesn't have access. So check whether the user is in the associated site
// the user ID comes from requestfilter, which is run before this
try {
    Site site = SiteService.getSite(siteId);
    String currentUserId = UserDirectoryService.getCurrentUser().getId();
    Tool tool = placement.getTool();
    if (site != null && site.getUserRole(currentUserId) != null) {
	request.setAttribute("sakai.tool", tool);
	request.setAttribute("sakai.tool.placement", placement);
    }
} catch (Exception impossible) {
}
chain.doFilter(request, response);
   }
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:28,代码来源:AjaxFilter.java

示例7: archive

import org.sakaiproject.site.api.ToolConfiguration; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public String archive(String siteId, Document doc, Stack stack, String archivePath, List attachments)
{
	log.info("-------basic-lti-------- archive('{}')", StringUtils.join(new Object[] { siteId, doc, stack, archivePath, attachments }, "','"));

	StringBuilder results = new StringBuilder("archiving basiclti "+siteId+"\n");

	int count = 0;
	try {
		Site site = SiteService.getSite(siteId);
		log.info("SITE: {} : {}", site.getId(), site.getTitle());
		Element basicLtiList = doc.createElement("org.sakaiproject.basiclti.service.BasicLTISecurityService");

		for (SitePage sitePage : site.getPages()) {
			for (ToolConfiguration toolConfiguration : sitePage.getTools()) {
				if ( toolConfiguration.getTool() == null ) continue;
				if (toolConfiguration.getTool().getId().equals(
					TOOL_REGISTRATION)) {
					// results.append(" tool=" + toolConfiguration.getId() + "\n");
					count++;

					BasicLTIArchiveBean basicLTIArchiveBean = new BasicLTIArchiveBean();
					basicLTIArchiveBean.setPageTitle(sitePage.getTitle());
					basicLTIArchiveBean.setToolTitle(toolConfiguration.getTitle());
					basicLTIArchiveBean.setSiteToolProperties(toolConfiguration.getConfig());
				
					Node newNode = basicLTIArchiveBean.toNode(doc);
					basicLtiList.appendChild(newNode);
				}
			}
		}

		((Element) stack.peek()).appendChild(basicLtiList);
		stack.push(basicLtiList);
		stack.pop();
	}
	catch (IdUnusedException iue) {
		log.info("SITE ID {} DOES NOT EXIST.", siteId);
		results.append("Basic LTI Site does not exist\n");
	}
	// Something we did not expect
	catch (Exception e) {
		log.warn("Failed to archive: {}, error: {}", siteId, e);
		results.append("basiclti exception:"+e.getClass().getName()+"\n");
	}
	results.append("archiving basiclti ("+count+") tools archived\n");

	return results.toString();
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:50,代码来源:BasicLTISecurityServiceImpl.java

示例8: readToolForm

import org.sakaiproject.site.api.ToolConfiguration; //导入方法依赖的package包/类
/**
 * Read the tool form and update the site in state.
 * 
 * @return true if the form is accepted, false if there's a validation error (an alertMessage will be set)
 */
private boolean readToolForm(RunData data, SessionState state)
{
	// get the tool - it's there
	ToolConfiguration tool = (ToolConfiguration) state.getAttribute("tool");

	// read the form
	String title = StringUtils.trimToNull(data.getParameters().getString("title"));
	tool.setTitle(title);

	// read the layout hints
	String hints = StringUtils.trimToNull(data.getParameters().getString("layoutHints"));
	if (hints != null)
	{
		// strip all whitespace
		hints = hints.replaceAll("\\s",""); // strip all whitespace
	}
	tool.setLayoutHints(hints);

	Tool t = tool.getTool();
	if (t != null)
	{
		// read in any params
		for (Enumeration iParams = t.getRegisteredConfig().propertyNames(); iParams.hasMoreElements();)
		{
			String paramName = (String) iParams.nextElement();
			String formName = "param_" + paramName;
			String value = data.getParameters().getString(formName);
			if (value != null)
			{
				value = StringUtils.trimToNull(value);

				// if we have a value
				if (value != null)
				{
					// if this value is not the same as the tool's registered, set it in the placement
					if (!value.equals(t.getRegisteredConfig().getProperty(paramName)))
					{
						tool.getPlacementConfig().setProperty(paramName, value);
					}

					// otherwise clear it
					else
					{
						tool.getPlacementConfig().remove(paramName);
					}
				}

				// if no value
				else
				{
					tool.getPlacementConfig().remove(paramName);
				}
			}
		}
	}
	else
	{
		addAlert(state, rb.getString("sitact.plesel"));
		return false;
	}

	return true;

}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:70,代码来源:AdminSitesAction.java

示例9: BaseToolConfiguration

import org.sakaiproject.site.api.ToolConfiguration; //导入方法依赖的package包/类
/**
 * Construct as a copy of another.
 * 
 * @param other
 *        The other to copy.
 * @param page
 *        The page in which this tool lives.
 * @param exact
 *        If true, we copy ids - else we generate a new one.
 */
protected BaseToolConfiguration(BaseSiteService siteService, ToolConfiguration other, SitePage page, boolean exact)
{
	this.siteService = siteService;
	m_page = page;
	BaseToolConfiguration bOther = (BaseToolConfiguration) other;

	if (exact)
	{
		m_id = other.getId();
	}
	else
	{
		m_id = siteService.idManager().createUuid();
	}
	m_toolId = other.getToolId();
	m_tool = other.getTool();
	m_title = other.getTitle();
	m_layoutHints = other.getLayoutHints();
	m_pageId = bOther.m_pageId;
	m_pageOrder = bOther.m_pageOrder;
	m_custom_title = getTitleCustom(page);

	m_siteId = getContainingPage().getContainingSite().getId();
	m_skin = bOther.m_skin;

	Hashtable h = other.getPlacementConfig();
	// exact copying of ToolConfiguration items vs replacing occurence of
	// site id within item value, depending on "exact" setting -zqian
	if (exact)
	{
		m_config.putAll(other.getPlacementConfig());
	}
	else
	{
		for (Enumeration e = h.keys(); e.hasMoreElements();)
		{
			// replace site id string inside configuration
			String pOtherConfig = (String) e.nextElement();
			String pOtherConfigValue = (String) h.get(pOtherConfig);
			m_config.put(pOtherConfig, pOtherConfigValue.replaceAll(bOther
					.getSiteId(), m_siteId));
		}
	}
	m_configLazy = bOther.m_configLazy;
	setPageCategory();
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:57,代码来源:BaseToolConfiguration.java


注:本文中的org.sakaiproject.site.api.ToolConfiguration.getTool方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。