예제 #1
0
 protected Properties extractPropertiesFromTool() {
   Placement placement = toolManager.getCurrentPlacement();
   Properties props = placement.getPlacementConfig();
   if (props.isEmpty()) props = placement.getConfig();
   return props;
 }
예제 #2
0
 public ToolConfigBean(Placement currentPlacement, String defaultHomePageName) {
   m_properties = currentPlacement.getConfig();
   this.defaultHomePageName = defaultHomePageName;
 }
예제 #3
0
  /** 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");
    }
  }