/**
   * An adapter method that converts the <code>SiteInfo</code> object to <code>SiteCatalogEntry
   * </code> object.
   *
   * @param s <code>SiteInfo</code> to be converted.
   * @param logger the hande to the LogManager
   * @return the converted <code>SiteCatalogEntry</code> object.
   */
  public static SiteCatalogEntry convert(SiteInfo s, LogManager logger) {
    SiteCatalogEntry3 site = new SiteCatalogEntry3();

    /* set the handle */
    site.setSiteHandle((String) s.getInfo(SiteInfo.HANDLE));

    VDSSysInfo sysinfo = (VDSSysInfo) s.getInfo(SiteInfo.SYSINFO);
    if (sysinfo != null) {
      site.setVDSSysInfo(sysinfo);
    }

    // describe the head node filesystem
    HeadNodeFS hfs = new HeadNodeFS();

    /* set the work directory as shared scratch */
    HeadNodeScratch hscratch = new HeadNodeScratch();
    SharedDirectory hscratchShared = new SharedDirectory();
    String workDir = s.getExecMountPoint();
    for (Iterator it = ((List) s.getInfo(SiteInfo.GRIDFTP)).iterator(); it.hasNext(); ) {
      GridFTPServer g = (GridFTPServer) it.next();
      hscratchShared.addFileServer(
          new FileServer("gsiftp", (String) g.getInfo(GridFTPServer.GRIDFTP_URL), workDir));
    }
    hscratchShared.setInternalMountPoint(new InternalMountPoint(workDir));
    hscratch.setSharedDirectory(hscratchShared);
    hfs.setScratch(hscratch);

    /* set the storage directory as shared storage */
    HeadNodeStorage hstorage = new HeadNodeStorage();
    SharedDirectory hstorageShared = new SharedDirectory();
    String storageDir = null;
    for (Iterator it = ((List) s.getInfo(SiteInfo.GRIDFTP)).iterator(); it.hasNext(); ) {
      GridFTPServer g = (GridFTPServer) it.next();
      storageDir = (String) g.getInfo(GridFTPServer.STORAGE_DIR);
      hstorageShared.addFileServer(
          new FileServer("gsiftp", (String) g.getInfo(GridFTPServer.GRIDFTP_URL), storageDir));
    }
    hstorageShared.setInternalMountPoint(new InternalMountPoint(storageDir));
    hstorage.setSharedDirectory(hstorageShared);
    hfs.setStorage(hstorage);

    site.setHeadNodeFS(hfs);

    /* set the storage directory as GridGateways */
    for (Iterator it = ((List) s.getInfo(SiteInfo.JOBMANAGER)).iterator(); it.hasNext(); ) {
      JobManager jm = (JobManager) it.next();
      GridGateway gw = new GridGateway();

      String universe = (String) jm.getInfo(JobManager.UNIVERSE);
      if (universe.equals("vanilla")) {
        gw.setJobType(GridGateway.JOB_TYPE.compute);
      } else if (universe.equals("transfer")) {
        gw.setJobType(GridGateway.JOB_TYPE.auxillary);
      } else {
        throw new RuntimeException(
            "Unknown universe type " + universe + " for site " + site.getSiteHandle());
      }

      String url = (String) jm.getInfo(JobManager.URL);
      gw.setContact(url);

      if (url.endsWith("condor")) {
        gw.setScheduler(GridGateway.SCHEDULER_TYPE.Condor);
      } else if (url.endsWith("fork")) {
        gw.setScheduler(GridGateway.SCHEDULER_TYPE.Fork);
      } else if (url.endsWith("pbs")) {
        gw.setScheduler(GridGateway.SCHEDULER_TYPE.PBS);
      } else if (url.endsWith("lsf")) {
        gw.setScheduler(GridGateway.SCHEDULER_TYPE.LSF);
      } else if (url.endsWith("sge")) {
        gw.setScheduler(GridGateway.SCHEDULER_TYPE.SGE);
      }

      gw.setIdleNodes((String) jm.getInfo(JobManager.IDLE_NODES));
      gw.setTotalNodes((String) jm.getInfo(JobManager.TOTAL_NODES));

      site.addGridGateway(gw);
    }

    /* set the LRC as Replica Catalog */
    for (Iterator it = ((List) s.getInfo(SiteInfo.LRC)).iterator(); it.hasNext(); ) {
      LRC lrc = (LRC) it.next();
      ReplicaCatalog rc = new ReplicaCatalog(lrc.getURL(), "LRC");
      site.addReplicaCatalog(rc);
    }

    /* add Profiles */
    for (Iterator it = ((List) s.getInfo(SiteInfo.PROFILE)).iterator(); it.hasNext(); ) {
      site.addProfile((Profile) it.next());
    }

    // do another conversion.
    SiteCatalogEntry result = Adapter.convert(site);

    logger.log("SiteCatalogEntry object created is " + result, LogManager.DEBUG_MESSAGE_LEVEL);
    return result;
  }