Class: Import::FogbugzService
- Inherits:
-
BaseService
- Object
- BaseService
- BaseService
- Import::FogbugzService
- Defined in:
- app/services/import/fogbugz_service.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Attributes inherited from BaseService
Instance Method Summary collapse
Methods inherited from BaseService
Methods inherited from BaseService
Methods included from BaseServiceUtility
#deny_visibility_level, #event_service, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level
Methods included from Gitlab::Allowable
Constructor Details
This class inherits a constructor from Import::BaseService
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'app/services/import/fogbugz_service.rb', line 5 def client @client end |
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user.
5 6 7 |
# File 'app/services/import/fogbugz_service.rb', line 5 def current_user @current_user end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
5 6 7 |
# File 'app/services/import/fogbugz_service.rb', line 5 def params @params end |
Instance Method Details
#execute(credentials) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/services/import/fogbugz_service.rb', line 7 def execute(credentials) url = credentials[:uri] if blocked_url?(url) return log_and_return_error("Invalid URL: #{url}", _("Invalid URL: %{url}") % { url: url }, :bad_request) end unless return log_and_return_error( "You don't have permissions to import this project", _("You don't have permissions to import this project"), :unauthorized ) end unless repo return log_and_return_error( "Project #{repo_id} could not be found", s_("Fogbugz|Project %{repo} could not be found") % { repo: repo_id }, :unprocessable_entity) end project = create_project(credentials) if project.persisted? success(project) elsif project.errors[:import_source_disabled].present? error(project.errors[:import_source_disabled], :forbidden) else error(project_save_error(project), :unprocessable_entity) end rescue StandardError => e log_and_return_error( "Fogbugz import failed due to an error: #{e}", s_("Fogbugz|Fogbugz import failed due to an error: %{error}" % { error: e }), :bad_request) end |