Class: Packages::Maven::FindOrCreatePackageService

Inherits:
BaseService
  • Object
show all
Defined in:
app/services/packages/maven/find_or_create_package_service.rb

Constant Summary collapse

SNAPSHOT_TERM =
'-SNAPSHOT'
MAX_FILE_NAME_LENGTH =
5000
DuplicatePackageError =
Class.new(StandardError)

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?, #can_all?, #can_any?

Constructor Details

This class inherits a constructor from BaseService

Instance Method Details

#executeObject



10
11
12
13
14
15
16
17
18
# File 'app/services/packages/maven/find_or_create_package_service.rb', line 10

def execute
  return ServiceResponse.error(message: 'File name is too long') if file_name_too_long?

  begin
    find_or_create_package
  rescue DuplicatePackageError
    retry # in case of a race condition, retry the block. 2nd attempt should succeed
  end
end