Пример #1
0
  /**
   * Returns an environment variable for a particular site set in the Site Catalog.
   *
   * @param siteID the name of the site.
   * @param envVariable the environment variable whose value is required.
   * @return value of the environment variable if found, else null
   */
  public String getEnvironmentVariable(String siteID, String envVariable) {
    String result = null;

    // get all environment variables
    List envs = this.getPoolProfile(siteID, Profile.ENV);
    if (envs == null) {
      return result;
    }

    // traverse through all the environment variables
    for (Iterator it = envs.iterator(); it.hasNext(); ) {
      Profile p = (Profile) it.next();
      if (p.getProfileKey().equals(envVariable)) {
        result = p.getProfileValue();
        break;
      }
    }

    return result;
  }
Пример #2
0
  /**
   * It returns profile information associated with a particular namespace and pool.
   *
   * @param siteID the name of the site, whose profile information you want.
   * @param namespace the namespace correspoinding to which the profile information of a particular
   *     site is desired.
   * @return List of <code>Profile</code> objects NULL when the information about the site is not
   *     there or no profile information associated with the site.
   * @see org.griphyn.cPlanner.classes.Profile
   */
  public List getPoolProfile(String siteID, String namespace) {
    logMessage("List getPoolProfile(String siteID, String namespace");
    logMessage("\tList getPoolProfile(" + siteID + "," + namespace + ")");
    List profileList = null;
    ArrayList namespList = null;
    // sanity checks
    if (siteID == null || namespace == null || namespace.length() < 2) {
      return null;
    }

    // check if the namespace asked for
    // is a valid namespace or not
    if (!Namespace.isNamespaceValid(namespace)) {
      mLogger.log(
          "Namespace " + namespace + " not suppored. Ignoring", LogManager.WARNING_MESSAGE_LEVEL);
      return null;
    }

    // get information about all the profiles
    profileList = this.getPoolProfile(siteID);

    if (profileList == null) {
      return profileList;
    }

    // iterate through the list and add to the namespace list
    Iterator it = profileList.iterator();
    namespList = new ArrayList(3);
    Profile poolPf = null;
    while (it.hasNext()) {
      poolPf = (Profile) it.next();
      if (poolPf.getProfileNamespace().equalsIgnoreCase(namespace)) {
        namespList.add(poolPf);
      }
    }

    if (namespList.isEmpty()) {
      namespList = null;
    }
    return namespList;
  }