Esempio n. 1
0
 def __init__(self, sourceNamespace, setNamespace, opts, mode='latest'):
     for key, value in opts.items():
         setattr(self, key, value)
     Utils.validateRequired(opts, ['targetURL'])
     self.batchTag = Utils.getCurrentBatchTimestamp()
     self.logger = gl.gleanomaticLogger(sourceNamespace, setNamespace,
                                        self.batchTag)
     self.logger.info("Initializing RESTPublisher")
     self.reader = RSReader(sourceNamespace, setNamespace,
                            {"batchTag": self.batchTag}, mode)
Esempio n. 2
0
 def __init__(self,sourceNamespace,setNamespace,opts={}):
     self.batchTag = Utils.getCurrentBatchTimestamp()
     self.logger = gl.gleanomaticLogger(sourceNamespace,setNamespace,self.batchTag)
     self.logger.info("Initializing RSLoader")
     self.targetURI = appConfig.targetURI
     self.targetEndpoint = rc.RSRestClient(self.targetURI,self.logger)
     self.sourceNamespace = sourceNamespace
     self.setNamespace = setNamespace
     self.createDump = appConfig.createDump
    
     for key, value in opts.items():
         setattr(self, key, value)
Esempio n. 3
0
 def initRecord(self, resID):
     resURL = str(self.config.targetURI) + "/resource/" + str(resID)
     resourceJSON = Utils.getContent(resURL)
     self.resource = Utils.jsonToDict(resourceJSON)
     self.logger = gl.gleanomaticLogger(self.resource['sourceNamespace'],
                                        self.resource['setNamespace'],
                                        'OAIMap')
     self.logger.info("Initializing record in OAIMap.")
     mapConfig = maps[self.resource["sourceNamespace"]][
         self.resource["setNamespace"]]
     if 'prefix' in mapConfig:
         self.prefix = mapConfig['prefix']
     self.mapper = self.getMapper(mapConfig["mapper"])
     url = str(self.config.targetURI) + "/content/" + str(resID)
     content = Utils.getContent(url)
     try:
         data = Utils.getDictFromXML(content)
     except Exception as e:
         self.logger.critical("Could not get dict from xml. ERROR: " +
                              str(e))
         raise Exception(str(e))
     try:
         record = data["OAI-PMH"]["GetRecord"]["record"]
         self.header = record["header"]
         self.metadata = record["metadata"]
     except KeyError as e:
         try:
             self.header = record["header"]
         except KeyError as e:
             self.logger.critical(
                 "Could not find metadata or header in record.")
             raise BadOAIRecord(str(e))
         try:
             status = self.header["status"]
         except KeyError as e:
             try:
                 status = self.header["@status"]
             except KeyError as e:
                 self.logger.critical("No status in header.")
                 raise BadOAIRecord(str(e))
         if status == 'deleted':
             self.deleted = True
         else:
             self.logger.critical("Unknown status type: " + str(status))
             raise BadOAIRecord("No metadata.  Unknown status: " +
                                str(status))
     if not self.deleted:
         mbr = MOHUBBaseRecord()
         self.resultRecord = mbr.getBaseRecord()
     return record
Esempio n. 4
0
 def initRecord(self):
     resURL = str(self.config.targetURI) + "/resource/" + str(self.resID)
     resourceJSON = Utils.getContent(resURL)
     self.resource = Utils.jsonToDict(resourceJSON)
     self.logger = gl.gleanomaticLogger(self.resource['sourceNamespace'],self.resource['setNamespace'],'MimsyMap')
     self.logger.info("Initializing record in MimsyMap.")
     url = str(self.config.targetURI) + "/content/" + str(self.resID)
     try:
         response = Utils.getResponse(url)
         record = Utils.getJSONFromResponse(response)
     except Exception as e:
         raise gError("Could not get data from url",e,self.logger)
     if not self.deleted:
         mbr = MOHUBBaseRecord()
         self.resultRecord = mbr.getBaseRecord()
     return record
Esempio n. 5
0
from gleanomatic.RSRestClient import RSRestClient

if len(sys.argv) < 2:
    print("USAGE: deleteByNamespace.py {sourceNamespace}/{setNamespace}\n")
    exit()

localhost = "http://*****:*****@type' in res['rs:ln']:
            if str(res['rs:ln']['@type']).lower() == 'application/json':
                subResListURL = res['rs:ln']['@href']
                subResListURL = subResListURL.replace(localhost,