Ignore:
Timestamp:
2010-10-27T14:41:49+13:00 (14 years ago)
Author:
kjdon
Message:

changed the url info stored in oai.cfg. Now have one optional field for web server url. Will be automatically generated if not specified. Then there are relative paths for oaiserver, library and doc root.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/runtime-src/src/oaiservr/oaiconfig.cpp

    r22739 r23233  
    293293    this->repositoryIdVersion = cfgline[0];
    294294  }
    295   else if (key == "baseURL") {
    296     this->baseURL = cfgline[0];
    297   }
    298   else if (key == "baseLibraryURL") {
    299     this->baseLibraryURL = cfgline[0];
    300   }
    301   else if (key == "baseDocRoot") {
    302     this->baseDocRoot = cfgline[0];
    303   }
     295  else if (key == "baseServerURL") {
     296    this->baseServerURL = cfgline[0];
     297  }
     298  else if (key == "oaiserverPath") {
     299    this->oaiserverPath = cfgline[0];
     300  }
     301  else if (key == "libraryPath") {
     302    this->libraryPath = cfgline[0];
     303  }
     304  else if (key == "docRootPath") {
     305    this->docRootPath = cfgline[0];
     306  }
     307
    304308  else if (key == "oaiversion") {
    305309    this->oaiVersion = cfgline[0];
    306310  }
    307311 
     312}
     313
     314text_t oaiconfig::generateBaseServerURL() {
     315  char *server_name = getenv("SERVER_NAME");
     316  char *server_port = getenv("SERVER_PORT");
     317  text_t url = "http://";
     318  url.append(server_name);
     319  url.append(":");
     320  url.append(server_port);
     321  return url;
    308322}
    309323
     
    354368text_t oaiconfig::getBaseURL()
    355369{
    356   return this->baseURL;
     370  if (this->baseServerURL.empty()) {
     371    this->baseServerURL = generateBaseServerURL();
     372  }
     373  return this->baseServerURL + this->oaiserverPath;
    357374}
    358375text_t oaiconfig::getBaseLibraryURL()
    359376{
    360   return this->baseLibraryURL;
     377  if (this->baseServerURL.empty()) {
     378    this->baseServerURL = generateBaseServerURL();
     379  }
     380  return this->baseServerURL + this->libraryPath;
    361381}
    362382text_t oaiconfig::getBaseDocRoot()
    363383{
    364   return this->baseDocRoot;
     384  if (this->baseServerURL.empty()) {
     385    this->baseServerURL = generateBaseServerURL();
     386  }
     387  return this->baseServerURL + this->docRootPath;
     388}
     389
     390text_t oaiconfig::getRelativeBaseDocRoot()
     391{
     392  return this->docRootPath;
    365393}
    366394text_t oaiconfig::getRepositoryName()
Note: See TracChangeset for help on using the changeset viewer.