def processMessage(self, dsid, obj, comime):
        try:
            # do actions based on DSID then on MIME
            if dsid == 'MODS':
                coalliance_metadata.add_handle_to_mods(obj)
                DSC.mods_to_dc(obj, 'MODS', 'DC')
            elif dsid == 'TN':
                pass
            elif dsid == 'POLICY':
                coalliance_metadata.add_policy_to_rels(obj)
            else:
                comime.dispatch(dsid)

        except FedoraConnectionException:
            self.logger.warning('Object %s does not exist.' % obj.pid)
 def create_derivative(self,
                       relationship,
                       postfix,
                       function,
                       dsid=None,
                       args=None):
     # make sure we are not creating a derivative of a derivative
     if (not self.test_derivative()):
         # we default to creating a derivative of ourselves
         if not dsid:
             dsid = self.dsid
         # see if we need a derivative
         relationships = self.relsint.getRelationships(
             subject=self.dsid, predicate=relationship)
         if relationships:
             did = relationships[0][2].data
             if DSC.check_dates(self.obj, self.dsid, did):
                 self.call_function(function, dsid, did, args)
                 self.relsint.update()
         else:
             did = self.dsid.rsplit('.', 1)[0]
             did += postfix
             did = mangle_dsid(did)
             if did == self.dsid or did in self.obj:
                 did = self.dsid.rsplit('.', 1)[0]
                 did += '.d'
                 did += postfix
                 did = mangle_dsid(did)
             r = self.call_function(function, dsid, did, args)
             if (r == 0):
                 self.relsint.addRelationship(self.dsid, relationship, did)
                 self.relsint.update()
    def create_thumbnail(self, obj, dsid, tnid):
        r = DSC.create_thumbnail(obj, dsid, tnid)

        if r == 0:
            relationships = self.relsint.getRelationships(subject='TN', predicate='fromMime')
            if (not relationships and 'TN' not in obj):
                DSC.create_thumbnail(obj, dsid, 'TN')
                self.relsint.addRelationship('TN', 'fromMime', rels_object(obj[dsid].mimeType, rels_object.LITERAL))
            elif(relationships):
                current_mime = relationships[0][2].data
                new_mime = obj[dsid].mimeType
                if (current_mime.split('/')[0] != 'image') and (new_mime.split('/')[0] == 'image'):
                    DSC.create_thumbnail(obj, dsid, 'TN')
                    self.relsint.purgeRelationships(subject='TN', predicate='fromMime')
                    self.relsint.addRelationship('TN', 'fromMime', new_mime)
        return r
    def fedoraMessage(self, message, obj, client):
        # Take a look at what content model we are dealing with
        # do some fun stuff based on this
        pp = pprint.PrettyPrinter(indent=4)

        if 'jwa:audioCModel' in message['content_models']:
            if 'TN' not in obj:
                obj.addDataStream('TN', controlGroup=u'R', location=AUDIO_THUMB_LOCATION, \
                    mimeType=u'image/png')
        if 'jwa:imageCModel' in message['content_models'] and (
                message['dsid'] == 'ORIGINAL'
                or message['method'] == 'ingest'):
            DSC.create_jp2(obj, 'ORIGINAL', 'JP2')
            DSC.create_thumbnail(obj, 'ORIGINAL', 'TN')
        if 'jwa:documentCModel' in message['content_models'] and (
                message['dsid'] == 'ORIGINAL'
                or message['method'] == 'ingest'):
            if obj['ORIGINAL'].mimeType == 'application/pdf':
                DSC.create_swf(obj, 'ORIGINAL', 'FLEXPAPER')
                DSC.create_thumbnail(obj, 'ORIGINAL', 'TN')
            else:
                r = DSC.create_pdf(obj, 'ORIGINAL', 'PDF')
                if r == 0:
                    DSC.create_thumbnail(obj, 'PDF', 'TN')
                    DSC.create_swf(obj, 'PDF', 'FLEXPAPER')
                else:
                    obj.addDataStream('TN', controlGroup=u'R', location=BINARY_THUMB_LOCATION, \
                        mimeType=u'image/png')
Example #5
0
    def fedoraMessage(self, message, obj, client):
        # Take a look at what content model we are dealing with
        # do some fun stuff based on this
        pp = pprint.PrettyPrinter(indent=4)        

        if 'jwa:audioCModel' in message['content_models']:
            if 'TN' not in obj:
               obj.addDataStream('TN', controlGroup=u'R', location=AUDIO_THUMB_LOCATION, \
                   mimeType=u'image/png')
        if 'jwa:imageCModel' in message['content_models'] and (message['dsid'] == 'ORIGINAL' or message['method'] == 'ingest'):
            DSC.create_jp2(obj, 'ORIGINAL', 'JP2')
            DSC.create_thumbnail(obj, 'ORIGINAL', 'TN')
        if 'jwa:documentCModel' in message['content_models'] and (message['dsid'] == 'ORIGINAL' or message['method'] == 'ingest'):
            if obj['ORIGINAL'].mimeType == 'application/pdf':
                DSC.create_swf(obj, 'ORIGINAL', 'FLEXPAPER')
                DSC.create_thumbnail(obj, 'ORIGINAL', 'TN')
            else:
                r = DSC.create_pdf(obj, 'ORIGINAL', 'PDF')
                if r == 0:
                    DSC.create_thumbnail(obj, 'PDF', 'TN')
                    DSC.create_swf(obj, 'PDF', 'FLEXPAPER')
                else:
                    obj.addDataStream('TN', controlGroup=u'R', location=BINARY_THUMB_LOCATION, \
                        mimeType=u'image/png')