Exemple #1
0
 def obj_create(self, bundle, **kwargs):
     retval = super(tardis.tardis_portal.api.DataFileResource, self)\
         .obj_create(bundle, **kwargs)
     if 'replicas' not in bundle.data or not bundle.data['replicas']:
         # no replica specified: return upload path and create dfo for
         # new path
         datafile = bundle.obj
         try:
             ip = get_ip(bundle.request)
             uploader = Uploader.objects\
                 .filter(wan_ip_address=ip,
                         instruments__id=datafile.dataset.instrument.id)\
                 .first()
             uploader_registration_request = \
                 UploaderRegistrationRequest.objects.get(uploader=uploader)
             sbox = uploader_registration_request.approved_storage_box
         except:
             logger.warning(traceback.format_exc())
             sbox = datafile.get_receiving_storage_box()
         if sbox is None:
             raise NotImplementedError
         dfo = DataFileObject(
             datafile=datafile,
             storage_box=sbox)
         dfo.create_set_uri()
         dfo.save()
         self.temp_url = dfo.get_full_path()
     return retval
Exemple #2
0
    def obj_create(self, bundle, **kwargs):
        '''
        Creates a new DataFile object from the provided bundle.data dict.

        If a duplicate key error occurs, responds with HTTP Error 409: CONFLICT
        '''
        try:
            retval = super(DataFileResource, self).obj_create(bundle, **kwargs)
        except IntegrityError as err:
            if "duplicate key" in str(err):
                raise ImmediateHttpResponse(HttpResponse(status=409))
            raise
        if 'replicas' not in bundle.data or not bundle.data['replicas']:
            # no replica specified: return upload path and create dfo for
            # new path
            sbox = bundle.obj.get_receiving_storage_box()
            if sbox is None:
                raise NotImplementedError
            dfo = DataFileObject(
                datafile=bundle.obj,
                storage_box=sbox)
            dfo.create_set_uri()
            dfo.save()
            self.temp_url = dfo.get_full_path()
        return retval
Exemple #3
0
 def obj_create(self, bundle, **kwargs):
     retval = super(DataFileResource, self).obj_create(bundle, **kwargs)
     if 'replicas' not in bundle.data or not bundle.data['replicas']:
         # no replica specified: return upload path and create dfo for
         # new path
         sbox = bundle.obj.get_receiving_storage_box()
         if sbox is None:
             raise NotImplementedError
         dfo = DataFileObject(datafile=bundle.obj, storage_box=sbox)
         dfo.create_set_uri()
         dfo.save()
         self.temp_url = dfo.get_full_path()
     return retval
    def obj_create(self, bundle, **kwargs):
        '''
        Creates a new DataFile object from the provided bundle.data dict.

        If a duplicate key error occurs, responds with HTTP Error 409: CONFLICT
        '''
        try:
            retval = super(tardis.tardis_portal.api.DataFileResource, self)\
                .obj_create(bundle, **kwargs)
        except IntegrityError as err:
            if "duplicate key" in str(err):
                raise ImmediateHttpResponse(HttpResponse(status=409))
            raise
        if 'replicas' not in bundle.data or not bundle.data['replicas']:
            # no replica specified: return upload path and create dfo for
            # new path
            datafile = bundle.obj
            try:
                if 'uploader_uuid' in bundle.data and \
                        'requester_key_fingerprint' in bundle.data:
                    uploader_uuid = bundle.data['uploader_uuid']
                    fingerprint = bundle.data['requester_key_fingerprint']
                    uploader = Uploader.objects.get(uuid=uploader_uuid)
                    uploader_registration_request = \
                        UploaderRegistrationRequest.objects.get(
                            uploader=uploader,
                            requester_key_fingerprint=fingerprint)
                    sbox = uploader_registration_request.approved_storage_box
                else:
                    ip = get_ip(bundle.request)
                    instrument_id = datafile.dataset.instrument.id
                    uploader = Uploader.objects\
                        .filter(wan_ip_address=ip,
                                instruments__id=instrument_id)\
                        .first()
                    uploader_registration_request = \
                        UploaderRegistrationRequest.objects\
                        .get(uploader=uploader)
                    sbox = uploader_registration_request.approved_storage_box
            except:
                logger.warning(traceback.format_exc())
                sbox = datafile.get_receiving_storage_box()
            if sbox is None:
                raise NotImplementedError
            dfo = DataFileObject(
                datafile=datafile,
                storage_box=sbox)
            dfo.create_set_uri()
            dfo.save()
            self.temp_url = dfo.get_full_path()
        return retval
Exemple #5
0
    def obj_create(self, bundle, **kwargs):
        '''
        Creates a new DataFile object from the provided bundle.data dict.

        If a duplicate key error occurs, responds with HTTP Error 409: CONFLICT
        '''
        try:
            retval = super(DataFileAppResource, self).obj_create(bundle, **kwargs)
        except IntegrityError as err:
            if "duplicate key" in str(err):
                raise ImmediateHttpResponse(HttpResponse(status=409))
            raise
        if 'replicas' not in bundle.data or not bundle.data['replicas']:
            # no replica specified: return upload path and create dfo for
            # new path
            datafile = bundle.obj
            try:
                if 'uploader_uuid' in bundle.data and \
                        'requester_key_fingerprint' in bundle.data:
                    uploader_uuid = bundle.data['uploader_uuid']
                    fingerprint = bundle.data['requester_key_fingerprint']
                    uploader = Uploader.objects.get(uuid=uploader_uuid)
                    uploader_registration_request = \
                        UploaderRegistrationRequest.objects.get(
                            uploader=uploader,
                            requester_key_fingerprint=fingerprint)
                    sbox = uploader_registration_request.approved_storage_box
                else:
                    ip = get_ip(bundle.request)
                    instrument_id = datafile.dataset.instrument.id
                    uploader = Uploader.objects\
                        .filter(wan_ip_address=ip,
                                instruments__id=instrument_id)\
                        .first()
                    uploader_registration_request = \
                        UploaderRegistrationRequest.objects\
                        .get(uploader=uploader)
                    sbox = uploader_registration_request.approved_storage_box
            except:
                logger.warning(traceback.format_exc())
                sbox = datafile.get_receiving_storage_box()
            if sbox is None:
                raise NotImplementedError
            dfo = DataFileObject(
                datafile=datafile,
                storage_box=sbox)
            dfo.create_set_uri()
            dfo.save()
            self.temp_url = dfo.get_full_path()
        return retval
Exemple #6
0
 def obj_create(self, bundle, **kwargs):
     retval = super(DataFileResource, self).obj_create(bundle, **kwargs)
     if 'replicas' not in bundle.data or not bundle.data['replicas']:
         # no replica specified: return upload path and create dfo for
         # new path
         sbox = bundle.obj.get_receiving_storage_box()
         if sbox is None:
             raise NotImplementedError
         dfo = DataFileObject(
             datafile=bundle.obj,
             storage_box=sbox)
         dfo.create_set_uri()
         dfo.save()
         self.temp_url = dfo.get_full_path()
     return retval