Ignore:
Timestamp:
2010-10-27T14:41:49+13:00 (13 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.

Location:
main/trunk/greenstone2/runtime-src/src/oaiservr
Files:
2 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()
  • main/trunk/greenstone2/runtime-src/src/oaiservr/oaiconfig.h

    r22739 r23233  
    6161  text_t getBaseLibraryURL();
    6262  text_t getBaseDocRoot();
     63  text_t getRelativeBaseDocRoot();
    6364  text_t getRepositoryName();
    6465  text_t getRepositoryId();
     
    6768 private:
    6869  bool configureCollection(const text_t &gsdlhome, const text_t &collection);
    69  
     70  text_t generateBaseServerURL();
    7071  text_t    repositoryName; // human readable name
    7172  text_t repositoryId; // unique (among oai servers) domain name or id for the repository
    7273  text_t repositoryIdVersion; // 1.1 or 2.0 for identifier scheme
    73   text_t    baseURL; // URL of oaiserver.cgi
    74   text_t    baseLibraryURL; // URL of library.cgi (used for urls to greenstone documents )
    75   text_t    baseDocRoot; // Base URL for gsdl directory (used for urls to source documents )
     74  text_t    baseServerURL; // URL of web server
     75  text_t    oaiserverPath; // relative path for oaiserver
     76  text_t    libraryPath; //relative path for library.cgi (used for urls to greenstone documents )
     77  text_t    docRootPath; // relative path for gsdl directory (used for urls to source documents and oai xsl )
    7678  text_t    oaiVersion;        // The version of OAI running
    7779  int       resumptionSize;    // The number of items to produce before spitting out a resumptionToken
Note: See TracChangeset for help on using the changeset viewer.