private String getContextId() { if (TestUtil.isRunningTests()) { return "test-context"; } Placement placement = ToolManager.getCurrentPlacement(); String presentSiteId = placement.getContext(); return presentSiteId; }
/** * 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(); }
/** * 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(); }
public boolean setTemporaryPlacement(Site site) { if (site == null) return false; Placement ppp = ToolManager.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 = ToolManager.getCurrentPlacement(); if (ppp == null) { System.out.println("WARNING portal-temporary placement not set - null"); } else { String cont = ppp.getContext(); if (site.getId().equals(cont)) { return true; } else { System.out.println( "WARNING portal-temporary placement mismatch site=" + site.getId() + " context=" + cont); } } return false; }
public BaseResourceEdit(String id, SyllabusData data) { Placement placement = ToolManager.getCurrentPlacement(); String currentSiteId = placement.getContext(); m_id = id; m_data = data; m_reference = Entity.SEPARATOR + currentSiteId + Entity.SEPARATOR + m_id; m_properties = new BaseResourcePropertiesEdit(); m_properties.addProperty(ResourceProperties.PROP_DISPLAY_NAME, data.getTitle()); }
/* * public void setRelease(String release) { this.release = release; } * * public String getRelease() { return release; } */ public ArrayList getGradebooks() { if (userId == null) { userId = SessionManager.getCurrentSessionUserId(); if (userId != null) { try { userEid = UserDirectoryService.getUserEid(userId); } catch (UserNotDefinedException e) { LOG.error("UserNotDefinedException", e); } } } Placement placement = ToolManager.getCurrentPlacement(); String currentSiteId = placement.getContext(); siteId = currentSiteId; try { if (checkAccess()) { // logger.info("**** Getting by context!"); gradebooks = new ArrayList(gradebookManager.getGradebooksByContext(siteId, sortBy, ascending)); } else { // logger.info("**** Getting RELEASED by context!"); gradebooks = new ArrayList( gradebookManager.getReleasedGradebooksByContext(siteId, sortBy, ascending)); } } catch (Exception e) { gradebooks = null; } if (gradebooks != null && gradebooks.size() > 0) gradebooksExist = true; else gradebooksExist = false; return gradebooks; }
private String getCurrentSiteId() { Placement placement = ToolManager.getCurrentPlacement(); return placement.getContext(); }
/** Populate the state with configuration settings */ protected void initState(SessionState state, VelocityPortlet portlet, JetspeedRunData rundata) { // TODO: we might want to keep this from running for each request - but by letting it we get // fresh info each time... -ggolden super.initState(state, portlet, rundata); Placement placement = ToolManager.getCurrentPlacement(); Properties config = placement.getConfig(); // set the pass_pid parameter boolean passPid = false; String passPidStr = config.getProperty(PASS_PID, "false"); state.removeAttribute(PASS_PID); if ("true".equalsIgnoreCase(passPidStr)) { state.setAttribute(PASS_PID, Boolean.TRUE); passPid = true; } // Assume macro expansion (disable on request) boolean macroExpansion = true; String macroExpansionStr = config.getProperty(MACRO_EXPANSION, "true"); state.removeAttribute(MACRO_EXPANSION); if ("false".equalsIgnoreCase(macroExpansionStr)) { state.setAttribute(MACRO_EXPANSION, Boolean.FALSE); macroExpansion = false; } // set the special setting String special = config.getProperty(SPECIAL); final String sakaiPropertiesUrlKey = config.getProperty(SAKAI_PROPERTIES_URL_KEY); final String hideOptions = config.getProperty(HIDE_OPTIONS); // check for an older way the ChefWebPagePortlet took parameters, converting to our "special" // values if (special == null) { if ("true".equals(config.getProperty("site"))) { special = SPECIAL_SITE; } else if ("true".equals(config.getProperty("workspace"))) { special = SPECIAL_WORKSPACE; } else if ("true".equals(config.getProperty("worksite"))) { special = SPECIAL_WORKSITE; } else if ("true".equals(config.getProperty("annotatedurl"))) { special = SPECIAL_ANNOTATEDURL; } } state.removeAttribute(SPECIAL); if ((special != null) && (special.trim().length() > 0)) { state.setAttribute(SPECIAL, special); } state.removeAttribute(HIDE_OPTIONS); if ((hideOptions != null) && (hideOptions.trim().length() > 0)) { state.setAttribute(HIDE_OPTIONS, hideOptions); } // set the source url setting String source = StringUtils.trimToNull(config.getProperty(SOURCE)); // check for an older way the ChefWebPagePortlet took parameters, converting to our "source" // value if (source == null) { source = StringUtils.trimToNull(config.getProperty("url")); } // store the raw as-configured source url state.removeAttribute(SOURCE); if (source != null) { state.setAttribute(SOURCE, source); } // compute working URL, modified from the configuration URL if special String url = sourceUrl( special, source, placement.getContext(), macroExpansion, passPid, placement.getId(), sakaiPropertiesUrlKey); state.setAttribute(URL, url); // set the height state.setAttribute(HEIGHT, config.getProperty(HEIGHT, "600px")); state.setAttribute(ANNOTATED_TEXT, config.getProperty(ANNOTATED_TEXT, "")); if (config.getProperty(TARGETPAGE_URL) != null) { // set Target page url for Annotated URL Tool state.setAttribute(TARGETPAGE_URL, config.getProperty(TARGETPAGE_URL)); // set Target page name for Annotated URL Tool state.setAttribute(TARGETPAGE_NAME, config.getProperty(TARGETPAGE_NAME)); } // set the title state.setAttribute(TITLE, placement.getTitle()); if (state.getAttribute(STATE_PAGE_TITLE) == null) { SitePage p = SiteService.findPage(getCurrentSitePageId()); state.setAttribute(STATE_PAGE_TITLE, p.getTitle()); } // if events found in tool registration file put them in state if ((StringUtils.trimToNull(config.getProperty(EVENT_ACCESS_WEB_CONTENT)) != null)) { state.setAttribute(EVENT_ACCESS_WEB_CONTENT, config.getProperty(EVENT_ACCESS_WEB_CONTENT)); } if ((StringUtils.trimToNull(config.getProperty(EVENT_REVISE_WEB_CONTENT)) != null)) { state.setAttribute(EVENT_REVISE_WEB_CONTENT, config.getProperty(EVENT_REVISE_WEB_CONTENT)); } if (m_eventTrackingService == null) { m_eventTrackingService = (EventTrackingService) ComponentManager.get("org.sakaiproject.event.api.EventTrackingService"); } }