Example #1
0
    def islandoraMessage(self, method, message, client):
        if method == 'generateDerivatives':
            if 'pid' not in message:
                self.logger.error("No PID passed in message.")
            try:
                obj = client.getObject(message['pid'])
                comime = CoallianceMime(obj)
                for dsid in obj:
                    self.processMessage(dsid, obj, comime)
            except:
                self.logger.exception('Pid does not exist. Pid %s' % message['pid'])
            self.logger.info('Derivative generation process complete for PID: %s' % message['pid'])
        elif method == 'regenerateDerivatives':
            if 'pid' not in message:
                self.logger.error("No PID passed in message.")
            try:
                obj = client.getObject(message['pid'])
                try:
                    obj['TN'].delete()
                except:
                    pass
                relsint = rels_int(obj, rels_namespace('coal', 'http://www.coalliance.org/ontologies/relsint'), 'coal')
                relationships = relsint.getRelationships()
                try:
                    obj['RELS-INT'].delete()
                except:
                    pass
                for relationship in relationships:
                    try:
                        obj[relationship[2].data].delete()
                    except:
                        pass
		self.stomp.send('/topic/islandora', json.dumps(message), {'method' : 'generateDerivatives'})
            except:
                self.logger.exception('Pid does not exist. Pid %s' % message['pid'])
Example #2
0
 def fedoraMessage(self, message, obj, client):
     # if this is a ingest method, then we want to do actions for each datastream
     comime = CoallianceMime(obj)
     if message['method'] == 'ingest':
         for dsid in obj:
             self.processMessage(dsid, obj, comime)
     # clean up the rels if this was a purge
     elif message['method'] == 'purgeDatastream':
         relsint = rels_int(obj, rels_namespace('coal', 'http://www.coalliance.org/ontologies/relsint'), 'coal')
         relsint.purgeRelationships(subject=message['dsid'])
         relsint.purgeRelationships(object=message['dsid'])
         relsint.update()
     # else we just mess with the one that was changed
     elif message['dsid']:
         self.processMessage(message['dsid'], obj, comime)
 def fedoraMessage(self, message, obj, client):
     # if this is a ingest method, then we want to do actions for each datastream
     comime = CoallianceMime(obj)
     if message['method'] == 'ingest':
         for dsid in obj:
             self.processMessage(dsid, obj, comime)
     # clean up the rels if this was a purge
     elif message['method'] == 'purgeDatastream':
         relsint = rels_int(obj, rels_namespace('coal', 'http://www.coalliance.org/ontologies/relsint'), 'coal')
         relsint.purgeRelationships(subject=message['dsid'])
         relsint.purgeRelationships(object=message['dsid'])
         relsint.update()
     # else we just mess with the one that was changed
     elif message['dsid']:
         self.processMessage(message['dsid'], obj, comime)
 def dispatch(self, dsid):
     self.relsint = rels_int(self.obj, rels_namespace('coal', 'http://www.coalliance.org/ontologies/relsint'), 'coal')
     self.dsid = dsid
     try:
         # translate - / + . into _ for the mimetype function
         trantab = string.maketrans('-/+.','____')
         if(self.obj[dsid].mimeType):
             mime =  self.obj[dsid].mimeType.encode('ascii')
             mime_function_name = mime.translate(trantab)
             # get the function from the self object and run it
             mime_function = getattr( self, mime_function_name, self.mimetype_none )
             mime_function()
     except KeyError:
         # we catch a key error because .mimeType throws one 
         # if no mimeType is defined 
         pass
    def islandoraMessage(self, method, message, client):
        if method == 'generateDerivatives':
            if 'pid' not in message:
                self.logger.error("No PID passed in message.")
            try:
                obj = client.getObject(message['pid'])
                comime = CoallianceMime(obj)
                for dsid in obj:
                    self.processMessage(dsid, obj, comime)
                if 'TN' not in obj:
                    self.logger.info('No TN datastream on object, attempting to find a derivative to copy')
                    for dsid in obj:
                        if re.search(".*-tn.jpg\Z", dsid, 0):
                            try:
                                self.logger.info('Creating TN DS from %s .' % dsid)
                                comime.create_thumbnail(obj, dsid, 'TN')
                                break;
                            except:
                                self.logger.exception('Could not create TN Datastream from %s .' % dsid)
            except:
                self.logger.exception('Pid does not exist. Pid %s' % message['pid'])
            self.logger.info('Derivative generation process complete for PID: %s' % message['pid'])
        elif method == 'regenerateDerivatives':
            if 'pid' not in message:
                self.logger.error("No PID passed in message.")
            try:
                obj = client.getObject(message['pid'])
                try:
                    obj['TN'].delete()
                except:
                    pass
                relsint = rels_int(obj, rels_namespace('coal', 'http://www.coalliance.org/ontologies/relsint'), 'coal')
                relationships = relsint.getRelationships()
                try:
                    obj['RELS-INT'].delete()
                except:
                    pass
                for relationship in relationships:
                    try:
                        obj[relationship[2].data].delete()
                    except:
                        pass
		self.stomp.send('/topic/islandora', json.dumps(message), {'method' : 'generateDerivatives'})
            except:
                self.logger.exception('Pid does not exist. Pid %s' % message['pid'])
 def islandoraMessage(self, method, message, client):
     if method == 'generateDerivatives':
         if 'pid' not in message:
             self.logger.error("No PID passed in message.")
         try:
             obj = client.getObject(message['pid'])
             comime = CoallianceMime(obj)
             for dsid in obj:
                 self.processMessage(dsid, obj, comime)
         except:
             self.logger.exception('Pid does not exist. Pid %s' %
                                   message['pid'])
         self.logger.info(
             'Derivative generation process complete for PID: %s' %
             message['pid'])
     elif method == 'regenerateDerivatives':
         if 'pid' not in message:
             self.logger.error("No PID passed in message.")
         try:
             obj = client.getObject(message['pid'])
             try:
                 obj['TN'].delete()
             except:
                 pass
             relsint = rels_int(
                 obj,
                 rels_namespace(
                     'coal',
                     'http://www.coalliance.org/ontologies/relsint'),
                 'coal')
             relationships = relsint.getRelationships()
             try:
                 obj['RELS-INT'].delete()
             except:
                 pass
             for relationship in relationships:
                 try:
                     obj[relationship[2].data].delete()
                 except:
                     pass
             self.stomp.send('/topic/islandora', json.dumps(message),
                             {'method': 'generateDerivatives'})
         except:
             self.logger.exception('Pid does not exist. Pid %s' %
                                   message['pid'])