Class: Import::Offline::Exports::CreateService
- Inherits:
-
Object
- Object
- Import::Offline::Exports::CreateService
- Includes:
- Gitlab::Utils::StrongMemoize
- Defined in:
- app/services/import/offline/exports/create_service.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(current_user, source_hostname, portable_params, storage_config, organization_id) ⇒ CreateService
constructor
A new instance of CreateService.
Constructor Details
#initialize(current_user, source_hostname, portable_params, storage_config, organization_id) ⇒ CreateService
Returns a new instance of CreateService.
28 29 30 31 32 33 34 |
# File 'app/services/import/offline/exports/create_service.rb', line 28 def initialize(current_user, source_hostname, portable_params, storage_config, organization_id) @current_user = current_user @source_hostname = source_hostname @portable_params = portable_params @storage_config = storage_config @organization_id = organization_id end |
Instance Method Details
#execute ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/services/import/offline/exports/create_service.rb', line 36 def execute return feature_flag_disabled_error unless Feature.enabled?(:offline_transfer_exports, current_user) return invalid_params_error unless portable_params_valid? return unless user_can_export_all_portables? validate_object_storage! offline_export = Import::Offline::Export.create!( user: current_user, organization_id: organization_id, source_hostname: source_hostname, configuration: configuration ) ServiceResponse.success(payload: offline_export) rescue ActiveRecord::RecordInvalid => e service_error(e.) rescue Excon::Error, StandardError => e # Providing a nonexistent AWS S3 bucket results in a NoMethodError caused by an excon error. # Check if error's cause is an excon error for a more useful error to the user raise e unless e.is_a?(Excon::Error) || e.cause.is_a?(Excon::Error) # Excon errors may be long and contain sensitive information depending on provider implementation service_error(s_('OfflineTransfer|Unable to access object storage bucket.')) end |