/**
   * Return a TitleConfig for the AU. Returns matching entry from the title db if found, else
   * creates one
   */
  TitleConfig titleConfigFromAu(InactiveAuProxy au) {
    PluginProxy plugin = au.getPlugin();
    String auname = au.getName();
    Configuration auConfig = au.getConfiguration();
    TitleConfig tc = AuUtil.findTitleConfig(auConfig, plugin.getPlugin());
    if (tc != null) {
      return tc;
    }

    tc = new TitleConfig(auname, plugin.getPluginId());
    ArrayList<ConfigParamAssignment> params = new ArrayList();
    for (Iterator iter = auConfig.keyIterator(); iter.hasNext(); ) {
      String key = (String) iter.next();
      if (!ConfigParamDescr.isReservedParam(key)) {
        String val = auConfig.get(key);
        ConfigParamDescr descr = plugin.findAuConfigDescr(key);
        if (descr != null) {
          ConfigParamAssignment cpa = new ConfigParamAssignment(descr, val);
          params.add(cpa);
        } else {
          log.warning("Unknown parameter key: " + key + " in au: " + auname);
        }
      }
    }
    params.trimToSize();
    tc.setParams(params);
    return tc;
  }
Esempio n. 2
0
  /** Query the daemon for information required to set up this command */
  private boolean commandSetup() {

    Configuration configuration = null;
    Collection noEditKeys = null;
    String key;
    String value;

    /*
     * Configure a well known publication?
     */
    if ((value = getParameter(AP_E_PUBLICATION)) != null) {
      PluginProxy plugin = getTitlePlugin(value);

      /*
       * Set plugin and Title configuration information
       */
      if (plugin == null) {
        String message = "Unknown Publication:" + value;

        log.warning(message);
        return error(message);
      }

      setPlugin(plugin);
      setTitleConfig(plugin.getTitleConfig(value));

      configuration = getTitleConfig().getConfig();
      noEditKeys = getNoEditKeys();

    } else {
      /*
       * Lookup by Plugin or Class name - set the plugin
       *
       * NB: As of 23-Feb-04, this is not supported from AddAuPage.java.  See
       *     AddAuWithCompleteFunctionalityPage.java for full support.
       */
      if ((value = getParameter(AP_E_PLUGIN)) != null) {
        key = RemoteApi.pluginKeyFromId(value);

      } else if ((value = getParameter(AP_E_CLASSNAME)) != null) {
        key = RemoteApi.pluginKeyFromId(value);

      } else {
        return error("Supply a Publication, Plugin, or Class name");
      }

      if (StringUtil.isNullString(key)) {
        return error("Supply a valid Publication, Plugin, or Class name");
      }

      if (!pluginLoaded(key)) {
        return error("Plugin is not loaded: " + key);
      }

      setPlugin(getPluginProxy(key));
    }

    /*
     * Finally, return an XML rendition of the Plugin and AU key set up
     */
    generateSetupXml(configuration, noEditKeys);
    return true;
  }