public function doExecute()
 {
     // in case this is being called from the web, plaintext
     if ($this->request->isCommandLine() == false) {
         header("Content-type: text/plain");
     }
     // set a higher than normal memory limit to account for
     // pulling down large knowledgebases
     $configMemory = $this->registry->getConfig("HARVEST_MEMORY_LIMIT", false, "500M");
     ini_set("memory_limit", $configMemory);
     echo "\n\nMETALIB KNOWLEDGEBASE PULL \n\n";
     // get configuration settings
     $this->configInstitute = $this->registry->getConfig("METALIB_INSTITUTE", true);
     $this->configPortal = $this->registry->getConfig("METALIB_PORTAL", false, $this->configInstitute);
     $this->configLanguages = $this->registry->getConfig("LANGUAGES", false);
     $this->configChunk = $this->registry->getConfig("CHUNK_KB_PULL", false, false);
     $configMetalibAddress = $this->registry->getConfig("METALIB_ADDRESS", true);
     $configMetalibUsername = $this->registry->getConfig("METALIB_USERNAME", true);
     $configMetalibPassword = $this->registry->getConfig("METALIB_PASSWORD", true);
     // metalib search object
     $this->objSearch = new Xerxes_MetaSearch($configMetalibAddress, $configMetalibUsername, $configMetalibPassword);
     // data map
     $objData = new Xerxes_DataMap();
     // clear the cache, while we're at it
     echo "   Pruning cache table . . . ";
     $status = $objData->pruneCache();
     if ($status != 1) {
         throw new Exception("could not prune cache");
     } else {
         echo "done\n";
     }
     // now the real kb stuff
     $objData->beginTransaction();
     $arrSubjects = array();
     // array of category and subcategory value objects
     $arrTypes = array();
     // array of type value objects
     $arrDatabases = array();
     // array of datatbase value objects
     echo "   Flushing KB tables . . . ";
     $objData->clearKB();
     echo "done\n";
     echo "   Fetching types . . . ";
     $arrTypes = $this->types();
     foreach ($arrTypes as $objType) {
         $objData->addType($objType);
     }
     echo "done\n";
     echo "   Fetching databases . . . ";
     $arrDatabases = $this->databases();
     foreach ($arrDatabases as $objDatabase) {
         $objData->addDatabase($objDatabase);
     }
     echo "done\n";
     echo "   Fetching categories and assigning databases . . . ";
     $languages = array(array("code" => "eng", "locale" => "C"));
     if ($this->configLanguages != null) {
         $languages = $this->configLanguages->language;
     }
     foreach ($languages as $language) {
         $locale = (string) $language["locale"];
         $code = (string) $language["code"];
         $oldlocale = setlocale(LC_CTYPE, 0);
         setlocale(LC_CTYPE, $locale);
         // this influences the iconv() call with 'ASCII//TRANSLIT' target
         $arrSubjects = $this->subjects($arrDatabases, $code);
         foreach ($arrSubjects as $objCategory) {
             $objData->addCategory($objCategory);
         }
         setlocale(LC_CTYPE, $oldlocale);
     }
     echo "done\n";
     echo "   Synching user saved databases . . . ";
     $objData->synchUserDatabases();
     echo "done\n";
     echo "   Committing changes . . . ";
     $objData->commit();
     echo "done\n";
     return 1;
 }