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
Exemplo n.º 2
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')
Exemplo n.º 3
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')