Class: Namespaces::Groups::UnarchiveService

Inherits:
Groups::BaseService show all
Defined in:
app/services/namespaces/groups/unarchive_service.rb

Constant Summary collapse

NotAuthorizedError =
ServiceResponse.error(
  message: "You don't have permissions to unarchive this group!"
)
AlreadyUnarchivedError =
ServiceResponse.error(
  message: 'Group is already unarchived!'
)
AncestorArchivedError =
ServiceResponse.error(
  message: 'Cannot unarchive group since one of the ancestor groups is archived!'
)
UnarchivingFailedError =
ServiceResponse.error(
  message: 'Failed to unarchive group!'
)
Error =
Class.new(StandardError)
UpdateError =
Class.new(Error)

Constants inherited from BaseService

BaseService::UnauthorizedError

Instance Attribute Summary

Attributes inherited from Groups::BaseService

#current_user, #group, #params

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from Groups::BaseService

#initialize

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 Groups::BaseService

Instance Method Details

#executeObject



22
23
24
25
26
27
28
29
30
# File 'app/services/namespaces/groups/unarchive_service.rb', line 22

def execute
  return NotAuthorizedError unless can?(current_user, :archive_group, group)
  return AncestorArchivedError if group.ancestors_archived?
  return AlreadyUnarchivedError unless group.archived
  return UnarchivingFailedError unless group.unarchive

  after_unarchive
  ServiceResponse.success
end