public void reset(ToolConfiguration configuration) { portletWindows.remove(configuration.getId()); } }
/** * Read tool properties from storage into the tool's properties. * * @param tool * The tool for which properties are desired. */ public void readToolProperties(ToolConfiguration tool, Properties props) { super.readProperties(null, "SAKAI_SITE_TOOL_PROPERTY", "TOOL_ID", tool.getId(), props); }
/** * @inheritDoc */ public void saveToolConfig(final ToolConfiguration tool) { // in a transaction m_sql.transact(new Runnable() { public void run() { saveToolConfigTx(tool); } }, "siteToolConfig:" + tool.getId()); }
public String getCommonsToolId(String siteId) { try { Site site = siteService.getSite(siteId); ToolConfiguration tc = site.getToolForCommonId("sakai.commons"); return tc.getId(); } catch (Exception e) { return ""; } }
/** * Captures the rules for the various tools and when they want a popup * * @param <code>pageTool</code> * The tools configuration object. * @return The url to be uded in the popup of null of there is no * tool-requested popup. */ public static String getToolPopupUrl(ToolConfiguration pageTool) { Properties pro = pageTool.getConfig(); String source = null; if ( "sakai.web.168".equals(pageTool.getToolId()) && "true".equals(pro.getProperty("popup")) ) { source = pro.getProperty("source"); } else if ( "sakai.iframe".equals(pageTool.getToolId()) && "true".equals(pro.getProperty("popup")) ) { source = pro.getProperty("source"); } else if ( "sakai.basiclti".equals(pageTool.getToolId()) && "on".equals(pro.getProperty("imsti.newpage")) ) { source = "/access/basiclti/site/"+pageTool.getContext()+"/"+pageTool.getId(); } return source; }
private void notifyCacheRemove(String key, Object payload) { // clear the tool ids for this site if ((payload != null) && (payload instanceof Site)) { Site site = (Site) payload; for (Iterator<SitePage> pages = site.getPages().iterator(); pages.hasNext();) { SitePage page = (SitePage) pages.next(); m_pages.remove(page.getId()); for (Iterator<ToolConfiguration> tools = page.getTools().iterator(); tools.hasNext();) { ToolConfiguration tool = (ToolConfiguration) tools.next(); m_tools.remove(tool.getId()); } } for (Iterator<Group> groups = site.getGroups().iterator(); groups.hasNext();) { Group group = (Group) groups.next(); m_groups.remove(group.getId()); } } }
/** * 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; }
final String placementId = toolConfig.getId();
final String placementId = toolConfig.getId();
m_tools.put(tool.getId(), tool);
/** * Look through the pages in a site and get the page URL for a tool. * * @param <code>req</code> * The request object. If you have no access to the request object, * you can leave this null and we will try to pull the request * from ThreadLocal - if we fail it is a RunTime exception. * @param <code>site</code> * The site * @param <code>pageTool</code> * The placement / tool configuration * @return The page if found otherwise null. */ public static String getPageUrlForTool(HttpServletRequest req, Site site, ToolConfiguration pageTool) { if ( req == null ) req = getRequestFromThreadLocal(); SitePage thePage = getPageForTool(site, pageTool.getId()); if ( thePage == null ) return null; return getPageUrl(req, site, thePage); }
toolConfiguration.getId(), request.getContextPath() + request.getServletPath() + Web.makePath(parts, 1, 3), Web.makePath(parts,
/** * The transactino code for saving a tool config. */ protected void saveToolConfigTx(ToolConfiguration tool) { // delete this tool and tool properties Object fields[] = new Object[2]; fields[0] = caseId(tool.getSiteId()); fields[1] = caseId(tool.getId()); String statement = siteServiceSql.getDeleteToolPropertySql(); m_sql.dbWrite(statement, fields); statement = siteServiceSql.getDeleteToolSql(); m_sql.dbWrite(statement, fields); // write the tool statement = siteServiceSql.getInsertToolSql(); fields = new Object[7]; fields[0] = tool.getId(); fields[1] = tool.getPageId(); fields[2] = caseId(tool.getSiteId()); fields[3] = tool.getToolId(); fields[4] = Integer.valueOf(tool.getPageOrder()); fields[5] = tool.getTitle(); fields[6] = tool.getLayoutHints(); m_sql.dbWrite(statement, fields); // write the tool's properties writeProperties("SAKAI_SITE_TOOL_PROPERTY", "TOOL_ID", tool.getId(), "SITE_ID", caseId(tool.getSiteId()), tool.getPlacementConfig()); }
private void notifyCacheRemove(@SuppressWarnings("UnusedParameters") String key, Site site) { // clear the tool ids for this site //noinspection ConstantConditions if (site != null && site instanceof Site) { for (SitePage page : site.getPages()) { m_cachePages.remove(page.getId()); for (ToolConfiguration tool : page.getTools()) { m_cacheTools.remove(tool.getId()); } } for (Group group : site.getGroups()) { m_cacheGroups.remove(group.getId()); } } }
toolData.setPlacementId(tc.getId()); toolData.setTitle(tool.getTitle()); toolData.setDescription(tool.getDescription());
/** * sets up the default perms for a tool. Use's the tool id as the qualifier. * Assumes that if no perms exist for the tool, the perms should be set to the defaults. * * @param toolConfig */ public void toolSiteChanged(ToolConfiguration toolConfig) { Id toolId = getIdManager().getId(toolConfig.getId()); PermissionsEdit edit = new PermissionsEdit(); edit.setQualifier(toolId); edit.setName(getPermissionEditName()); edit.setSiteId(toolConfig.getContainingPage().getContainingSite().getId()); getPermissionManager().fillPermissions(edit); if (edit.getPermissions() == null || edit.getPermissions().size() == 0) { createDefaultPermissions(edit.getSiteId(), toolId); } }
private void notifyCachePut(String siteReference, Site site) { //noinspection ConstantConditions if (site != null && site instanceof Site) { Collection<SitePage> sitePages; Collection<Group> siteGroups; // TODO: If the boolean versions of getPages and getGroups are added to the Site interface, this check should be removed. if (site instanceof BaseSite) { //noinspection unchecked sitePages = ((BaseSite) site).getPages(false); //noinspection unchecked siteGroups = ((BaseSite) site).getGroups(false); } else { sitePages = site.getPages(); siteGroups = site.getGroups(); } // add the pages and tools to the cache for (SitePage page : sitePages) { m_cachePages.put(page.getId(), siteReference); for (ToolConfiguration tool : page.getTools()) { m_cacheTools.put(tool.getId(), siteReference); } } // add the groups to the cache for (Group group : siteGroups) { m_cacheGroups.put(group.getId(), siteReference); } } }