/** * Gets the ToolConfiguration of a page in a site containing a given tool * * @param siteId siteId * @param toolId toolId ie sakai.profile2 * @return */ private ToolConfiguration getFirstInstanceOfTool(final String siteId, final String toolId) { try { return this.siteService.getSite(siteId).getToolForCommonId(toolId); } catch (final IdUnusedException e) { log.error("SakaiProxy.getFirstInstanceOfTool() failed for siteId: " + siteId + " and toolId: " + toolId); return null; } }
private String findPageIdFromToolId(String pageId, String toolContextPath, Site site) { // If still can't find page id see if can determine it from a well known // tool id (assumes that such a tool is in the site and the first instance of // the tool found would be the right one). String toolSegment = "/tool/"; String toolId = null; try { // does the URL contain a tool id? if (toolContextPath.contains(toolSegment)) { toolId = toolContextPath.substring(toolContextPath.lastIndexOf(toolSegment)+toolSegment.length()); ToolConfiguration toolConfig = site.getToolForCommonId(toolId); log.debug("trying to resolve page id from toolId: [{}]", toolId); if (toolConfig != null) { pageId = toolConfig.getPageId(); } } } catch (Exception e) { log.error("exception resolving page id from toolid :["+toolId+"]",e); } return pageId; }
private String findPageIdFromToolId(String pageId, String toolContextPath, Site site) { // If still can't find page id see if can determine it from a well known // tool id (assumes that such a tool is in the site and the first instance of // the tool found would be the right one). String toolSegment = "/tool/"; String toolId = null; try { // does the URL contain a tool id? if (toolContextPath.contains(toolSegment)) { toolId = toolContextPath.substring(toolContextPath.lastIndexOf(toolSegment)+toolSegment.length()); ToolConfiguration toolConfig = site.getToolForCommonId(toolId); log.debug("trying to resolve page id from toolId: [{}]", toolId); if (toolConfig != null) { pageId = toolConfig.getPageId(); } } } catch (Exception e) { log.error("exception resolving page id from toolid :["+toolId+"]",e); } return pageId; }
public String getCommonsToolId(String siteId) { try { Site site = siteService.getSite(siteId); ToolConfiguration tc = site.getToolForCommonId("sakai.commons"); return tc.getId(); } catch (Exception e) { return ""; } }
@Override protected void completeAddResourceEventValidations(Event event, Map<String, Object> validationContext) throws IllegalArgumentException, IllegalStateException { final String resourceName = (String)validationContext.get(ADD_RESOURCE_VALIDATION_KEY_RESOURCE_NAME); final EntityContentProducer ecp = (EntityContentProducer)validationContext.get(ADD_RESOURCE_VALIDATION_KEY_CONTENT_PRODUCER); String siteId = ecp.getSiteId(resourceName); if (onlyIndexSearchToolSites) { try { Site s = siteService.getSite(siteId); ToolConfiguration t = s.getToolForCommonId(SEARCH_TOOL_ID); if (t == null) { throw new IllegalArgumentException("Resource name [" + resourceName + "] for event [" + event + "] not indexable because it is not associated with a site that has the search tool"); } } catch (Exception ex) { throw new IllegalArgumentException("Event [" + event + "] not indexable because it is not associated with a site"); } } validationContext.put(ADD_RESOURCE_VALIDATION_KEY_SITE_ID, siteId); }
public Site getSiteIfCurrentUserCanAccessTool(String siteId) { Site site; try { site = siteService.getSiteVisit(siteId); } catch (Exception e) { return null; } //check user can access the tool, it might be hidden ToolConfiguration toolConfig = site.getToolForCommonId("sakai.commons"); if(!toolManager.isVisible(site, toolConfig)) { return null; } return site; } }
/** * Determines whether the site has the specified tool. * * @param siteId * The site id to check * @param toolId * The tool id to check * @return True - if it has, false - otherwise */ private boolean siteHasTool(String siteId, String toolId) { boolean result = false; try { Site site = siteService.getSite(siteId); if (site.getToolForCommonId(toolId) != null) { result = true; } } catch (IdUnusedException e) { LOG.warn("IdUnusedException while trying to determine whether site " + siteId + " has tool " + toolId + ". " + e.getMessage()); } return result; }
ToolConfiguration synTool = site.getToolForCommonId("sakai.synoptic." + getLabel()); Properties synProp = synTool.getPlacementConfig(); if (synProp != null && synProp.size() > 0) {
ToolConfiguration synTool = site.getToolForCommonId("sakai.synoptic." + getLabel()); Properties synProp = synTool.getPlacementConfig(); if (synProp != null && synProp.size() > 0) {
/** * @inheritDoc */ @Override public String channelReference(String context, String id) { /* SAK-19516: for MOTD and Admin Workspace Announcements, the channel reference * is not calculated based on the context and id, but pulled from SAKAI_TOOL_PROPERTY 'channel'. */ String channelRef = null; try { ToolConfiguration tool = m_siteService.getSite(context).getToolForCommonId(SAKAI_ANNOUNCEMENT_TOOL_ID); if (tool != null) { channelRef = tool.getConfig().getProperty(ANNOUNCEMENT_CHANNEL_PROPERTY, null); } } catch (IdUnusedException e) { // ignore the error, continue with the default method M_log.debug("Could not find channelRef in channel property, falling back to default method..."); } if (channelRef == null || channelRef.trim().length() == 0) { channelRef = super.channelReference(context, id); } return channelRef; } // channelReference
ToolConfiguration synTool = site.getToolForCommonId("sakai.synoptic." + getLabel()); Properties synProp = synTool.getPlacementConfig(); if (synProp != null && synProp.size() > 0) {
ToolConfiguration synTool = site.getToolForCommonId("sakai.synoptic." + getLabel()); Properties synProp = synTool.getPlacementConfig(); if (synProp != null && synProp.size() > 0) {
public Boolean getCalendarExistsForSite(){ String siteContext = ToolManager.getCurrentPlacement().getContext(); Site site = null; try { site = SiteService.getSite(siteContext); if (site.getToolForCommonId("sakai.schedule") != null) { return true; }else{ return false; } } catch (Exception e) { log.warn("Exception thrown while getting site", e); } return false; }
public Boolean getCalendarExistsForSite(){ String siteContext = ToolManager.getCurrentPlacement().getContext(); Site site = null; try { site = SiteService.getSite(siteContext); if (site.getToolForCommonId("sakai.schedule") != null) { return true; }else{ return false; } } catch (Exception e) { log.warn("Exception thrown while getting site", e); } return false; }
ToolConfiguration fromSynTool = fromSite.getToolForCommonId("sakai.synoptic." + getLabel()); Properties fromSynProp = fromSynTool.getPlacementConfig(); ToolConfiguration toSynTool = toSite.getToolForCommonId("sakai.synoptic." + getLabel()); Properties toSynProp = toSynTool.getPlacementConfig();
if (site.getToolForCommonId("sakai.dropbox") != null) if (site.getToolForCommonId("sakai.resources") != null)
/** * Check if a site is considered as indexable based on the current server configuration. * <p> * Not indexable sites are: * <ul> * <li>Special sites</li> * <li>Sites without the search tool (if the option is enabled)</li> * <li>User sites (if the option is enabled)</li> * <li>Any sites included in the ignoreSitesList (~admin and !admin are the default ignored sites)</li> * </ul> * </p> * * @param site site which may be indexable * @return true if the site can be index, false otherwise */ protected boolean isSiteIndexable(Site site) { getLog().debug("Check if '" + site + "' is indexable."); return !(siteService.isSpecialSite(site.getId()) || (isOnlyIndexSearchToolSites() && site.getToolForCommonId(SEARCH_TOOL_ID) == null) || (isExcludeUserSites() && siteService.isUserSite(site.getId())) || (ignoredSitesList.contains(site.getId()))); }
protected boolean updateSite(JobExecutionContext context, Site site) throws JobExecutionException { // The toolId we are wanting to add to the site. String toolId = context.getMergedJobDataMap().getString("tool"); if (toolId == null || toolId.isEmpty()) { throw new JobExecutionException("tool isn't set in job data."); } Tool tool = toolManager.getTool(toolId); if (tool == null) { throw new JobExecutionException("Failed to find tool with id: "+ toolId); } ToolConfiguration toolConfiguration = site.getToolForCommonId(toolId); if (toolConfiguration == null) { // Add the tool to the site. SitePage page = site.addPage(); page.setTitle(tool.getTitle()); page.addTool(tool); try { siteService.save(site); return true; } catch (IdUnusedException|PermissionException e) { log.warn("Failed to save site: "+ site.getId(), e); } } else { log.debug(String.format("Site: %s already has tool: %s on page: %s", site.getId(), toolId, toolConfiguration.getContainingPage().getId())); } return false; }
protected boolean updateSite(JobExecutionContext context, Site site) throws JobExecutionException { // The toolId we are wanting to add to the site. String toolId = context.getMergedJobDataMap().getString("tool"); if (toolId == null || toolId.isEmpty()) { throw new JobExecutionException("tool isn't set in job data."); } Tool tool = toolManager.getTool(toolId); if (tool == null) { throw new JobExecutionException("Failed to find tool with id: "+ toolId); } ToolConfiguration toolConfiguration = site.getToolForCommonId(toolId); if (toolConfiguration == null) { // Add the tool to the site. SitePage page = site.addPage(); page.setTitle(tool.getTitle()); page.addTool(tool); try { siteService.save(site); return true; } catch (IdUnusedException|PermissionException e) { log.warn("Failed to save site: "+ site.getId(), e); } } else { log.debug(String.format("Site: %s already has tool: %s on page: %s", site.getId(), toolId, toolConfiguration.getContainingPage().getId())); } return false; }
ToolConfiguration toolConfig = site.getToolForCommonId(placementId); if (toolConfig == null) return placementId;