generateGranulesIndex.php 1.23 KB
<?php
/** 
*   @file generateGranulesIndex.php
*   @brief
*   @version $Id:  $ 
*/
       
       require_once '../DDserverWeb_ini.php';

        $ddSys = new DOMDocument('1.0');
        $ddSys->load(baseDir.'/DDsys.xml');
        $dataSets = $ddSys->getElementsByTagName('VI');
      
        foreach ($dataSets as $VI) 
        {
            $id = $VI->getElementsByTagName('NAME')->item(0)->nodeValue;
            
            $base =  $VI->getElementsByTagName('NAME')->item(0)->getAttribute('base');
            if ($base !== "LOCAL") continue; // REMOTE BASE
            
            $main = array();
            $index = array();  
            $location = $VI->getElementsByTagName("LOCATION")->item(0)->nodeValue; 
            
            if (file_exists($location."RestrictedAccess")) continue; // PrivateAccess
            
            foreach (glob($location."*.nc.gz") as $granule) 
            {                  
                $cmd = 'stat --printf="%s" '. $granule; 
                $file = basename($granule,".nc.gz");         
                $index[$file] = exec($cmd);
            }

            $main[substr($location,strlen(baseDir))] = $index;
            file_put_contents("../GRANULES/$id.json", json_encode($main));

        }
 
?>