@Test public void testSimpleToolRegistration() { activeToolManager .register(getClass().getResourceAsStream("site-info-original.xml")); Tool tool = activeToolManager.getTool("sakai.siteinfo"); assertNotNull(tool); assertEquals("sakai.siteinfo", tool.getId()); assertEquals("Site Info", tool.getTitle()); assertEquals("For showing worksite information and site participants.", tool.getDescription()); assertEquals(null, tool.getHome()); Properties registeredConfig = tool.getRegisteredConfig(); assertEquals("course,project,portfolio", registeredConfig.getProperty("siteTypes")); assertEquals("project", registeredConfig.getProperty("defaultSiteType")); assertEquals("project", registeredConfig.getProperty("publicChangeableSiteTypes")); assertEquals("course", registeredConfig.getProperty("publicSiteTypes")); assertEquals("", registeredConfig.getProperty("privateSiteTypes")); assertEquals("siteinfo", registeredConfig.getProperty("site_mode")); assertEquals("site.visit", registeredConfig.getProperty("functions.require")); assertNull(registeredConfig.getProperty("title")); Set<String> categories = tool.getCategories(); assertTrue(categories.contains("course")); assertTrue(categories.contains("project")); assertTrue(categories.contains("portfolio")); assertFalse(categories.contains("other")); assertEquals(AccessSecurity.PORTAL, tool.getAccessSecurity()); Properties finalConfig = tool.getFinalConfig(); assertEquals("siteinfo", finalConfig.getProperty("site_mode")); assertNull(finalConfig.getProperty("siteTypes")); Properties mutableConfig = tool.getMutableConfig(); assertEquals("project", mutableConfig.getProperty("defaultSiteType")); assertNull(mutableConfig.getProperty("site_mode")); Set<String> keywords = tool.getKeywords(); assertTrue(keywords.contains("site")); assertTrue(keywords.contains("setup")); assertFalse(keywords.contains("notfound")); assertEquals(1, activeToolManager.findTools(null, null).size()); assertEquals(1, activeToolManager.findTools(Collections.<String>emptySet(), null).size()); assertEquals(1, activeToolManager.findTools(Collections.singleton("project"), null).size()); assertEquals(1, activeToolManager.findTools(null, Collections.singleton("site")).size()); assertTrue(activeToolManager.findTools(Collections.singleton("other"), null).isEmpty()); assertTrue(activeToolManager.findTools(null, Collections.singleton("notfound")).isEmpty()); }
public void register(Tool tool, ServletContext context) { ActiveTool at = null; if (tool instanceof MyActiveTool) { at = (MyActiveTool) tool; } else if (tool instanceof ActiveTool) { at = (ActiveTool) tool; } else { at = new MyActiveTool(tool); } if (at instanceof MyActiveTool) { ((MyActiveTool) at).setServletContext(context); } String portletContext = null; Properties toolProps = at.getFinalConfig(); if (toolProps != null) { portletContext = toolProps .getProperty(TOOL_PORTLET_CONTEXT_PATH); } if (!"websphere".equals(serverConfigurationService().getString("servlet.container")) && portletContext == null ) { RequestDispatcher dispatcher = context.getNamedDispatcher(at.getId()); if (dispatcher == null) { M_log.warn("missing dispatcher for tool: " + at.getId()); } } m_tools.put(at.getId(), at); }
ActiveToolComponent extends ToolComponent implements ActiveToolManager { public void register(Tool tool, ServletContext context) { ActiveTool at = null; if (tool instanceof MyActiveTool) { at = (MyActiveTool) tool; } else if (tool instanceof ActiveTool) { at = (ActiveTool) tool; } else { at = new MyActiveTool(tool); } if (at instanceof MyActiveTool) { ((MyActiveTool) at).setServletContext(context); } String portletContext = null; Properties toolProps = at.getFinalConfig(); if (toolProps != null) { portletContext = toolProps .getProperty(TOOL_PORTLET_CONTEXT_PATH); } if (!"websphere".equals(serverConfigurationService().getString("servlet.container")) && portletContext == null ) { RequestDispatcher dispatcher = context.getNamedDispatcher(at.getId()); if (dispatcher == null) { M_log.warn("missing dispatcher for tool: " + at.getId()); } } m_tools.put(at.getId(), at); } }
ActiveToolComponent extends ToolComponent implements ActiveToolManager { public void register(Tool tool, ServletContext context) { ActiveTool at = null; if (tool instanceof MyActiveTool) { at = (MyActiveTool) tool; } else if (tool instanceof ActiveTool) { at = (ActiveTool) tool; } else { at = new MyActiveTool(tool); } if (at instanceof MyActiveTool) { ((MyActiveTool) at).setServletContext(context); } String portletContext = null; Properties toolProps = at.getFinalConfig(); if (toolProps != null) { portletContext = toolProps .getProperty(TOOL_PORTLET_CONTEXT_PATH); } if (!"websphere".equals(serverConfigurationService().getString("servlet.container")) && portletContext == null ) { RequestDispatcher dispatcher = context.getNamedDispatcher(at.getId()); if (dispatcher == null) { M_log.warn("missing dispatcher for tool: " + at.getId()); } } m_tools.put(at.getId(), at); }  }
ActiveToolComponent extends ToolComponent implements ActiveToolManager { public void register(Tool tool, ServletContext context) { ActiveTool at = null; if (tool instanceof MyActiveTool) { at = (MyActiveTool) tool; } else if (tool instanceof ActiveTool) { at = (ActiveTool) tool; } else { at = new MyActiveTool(tool); } if (at instanceof MyActiveTool) { ((MyActiveTool) at).setServletContext(context); } String portletContext = null; Properties toolProps = at.getFinalConfig(); if (toolProps != null) { portletContext = toolProps .getProperty(TOOL_PORTLET_CONTEXT_PATH); } if (!"websphere".equals(serverConfigurationService().getString("servlet.container")) && portletContext == null ) { RequestDispatcher dispatcher = context.getNamedDispatcher(at.getId()); if (dispatcher == null) { M_log.warn("missing dispatcher for tool: " + at.getId()); } } m_tools.put(at.getId(), at); }  void register(Tool tool, ServletContext context); void register(Document toolXml, ServletContext context); List<Tool> parseTools(File toolXmlFile); List<Tool> parseTools(InputStream toolXmlStream); List<Tool> parseTools(Document toolXml); void register(File toolXmlFile, ServletContext context); void register(InputStream toolXmlStream, ServletContext context); ActiveTool getActiveTool(String id); }
ActiveToolComponent extends ToolComponent implements ActiveToolManager { public void register(Tool tool, ServletContext context) { ActiveTool at = null; if (tool instanceof MyActiveTool) { at = (MyActiveTool) tool; } else if (tool instanceof ActiveTool) { at = (ActiveTool) tool; } else { at = new MyActiveTool(tool); } if (at instanceof MyActiveTool) { ((MyActiveTool) at).setServletContext(context); } String portletContext = null; Properties toolProps = at.getFinalConfig(); if (toolProps != null) { portletContext = toolProps .getProperty(TOOL_PORTLET_CONTEXT_PATH); } if (!"websphere".equals(serverConfigurationService().getString("servlet.container")) && portletContext == null ) { RequestDispatcher dispatcher = context.getNamedDispatcher(at.getId()); if (dispatcher == null) { M_log.warn("missing dispatcher for tool: " + at.getId()); } } m_tools.put(at.getId(), at); }  void register(Tool tool, ServletContext context); void register(Document toolXml, ServletContext context); List<Tool> parseTools(File toolXmlFile); List<Tool> parseTools(InputStream toolXmlStream); List<Tool> parseTools(Document toolXml); void register(File toolXmlFile, ServletContext context); void register(InputStream toolXmlStream, ServletContext context); ActiveTool getActiveTool(String id); static final String TOOL_PORTLET_CONTEXT_PATH; }