Changeset 22285

Show
Ignore:
Timestamp:
23.06.2010 13:52:02 (9 years ago)
Author:
kjdon
Message:

new toOID takes an extra arg, repos_id, so its generates ids like oai:repos-id:collname:doc-id. old version is still used for set spec ids which remain like demo:CL5. another method to extrac the collection name from a full id

Location:
main/trunk/greenstone2/runtime-src/src/oaiservr
Files:
2 modified

Legend:

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

    r20589 r22285  
    4545 *  that use ':' instead. 
    4646 */ 
     47void oaiclassifier::toOAI(const text_t repos_id, const text_t &collection, text_t &classifier) 
     48{ 
     49  
     50  text_t tmp = "oai:"; 
     51  tmp.append(repos_id); 
     52  tmp.append(":"); 
     53  tmp.append(collection); 
     54  toOAI(tmp, classifier); 
     55 
     56} 
     57 
     58/** 
     59 *  Called to convert GS classifier/document identifiers that use 
     60 *  a '.' to separate levels in the hierarchy into OAI identifiers 
     61 *  that use ':' instead. 
     62 */ 
    4763void oaiclassifier::toOAI(const text_t &collection, text_t &classifier) 
    4864{ 
     
    5672   
    5773  classifier = tmp; 
     74} 
     75 
     76void  oaiclassifier::getCollectionFromOAIID(const text_t oai_id, text_t &collection_id) { 
     77 
     78  // id is like oai:repos-id:collection:OID, we just want the collection bit 
     79 
     80  text_t::const_iterator begin = oai_id.begin(); 
     81  text_t::const_iterator end = oai_id.end(); 
     82  text_t::const_iterator colon = findchar(begin, end, ':'); // 1 
     83  if (colon != end) { 
     84    colon = findchar(colon+1, end, ':'); // 2 
     85  } 
     86  text_t::const_iterator third_colon; 
     87  if (colon !=end) { 
     88    third_colon = findchar(colon+1, end, ':'); 
     89  } 
     90  if (third_colon != end) { 
     91    collection_id = substr(colon+1, third_colon); 
     92  } 
    5893} 
    5994 
  • main/trunk/greenstone2/runtime-src/src/oaiservr/oaitools.h

    r15414 r22285  
    1111                ostream &logout); 
    1212  static void   toOAI(const text_t &collection, text_t &classifier); 
     13  static void   toOAI(const text_t repos_id, const text_t &collection, text_t &classifier); 
    1314  static void   toGSDL(text_t &collection, text_t &classifier); 
     15  static void  getCollectionFromOAIID(const text_t oai_id, text_t &collection_id); 
    1416 private: 
    1517  static void   swapColonsAndPeriods(text_t &classifier);