Class: Namespaces::Groups::ArchiveService
- Inherits:
-
Groups::BaseService
- Object
- BaseService
- Groups::BaseService
- Namespaces::Groups::ArchiveService
- Includes:
- ArchiveEvents
- Defined in:
- app/services/namespaces/groups/archive_service.rb
Constant Summary collapse
- NotAuthorizedError =
ServiceResponse.error( message: "You don't have permissions to archive this group!" )
- AlreadyArchivedError =
ServiceResponse.error( message: 'Group is already archived!' )
- AncestorAlreadyArchivedError =
ServiceResponse.error( message: 'Cannot archive group since one of the ancestor groups is already archived!' )
- ScheduledDeletionError =
ServiceResponse.error( message: 'Cannot archive group since it is scheduled for deletion.' )
- 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 included from ArchiveEvents
#publish_events, #publish_group_archived_event
Methods inherited from Groups::BaseService
Methods inherited from BaseService
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
Constructor Details
This class inherits a constructor from Groups::BaseService
Instance Method Details
#execute ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/services/namespaces/groups/archive_service.rb', line 24 def execute unless can?(current_user, :archive_group, group) && Feature.enabled?(:archive_group, group.root_ancestor) return NotAuthorizedError end return AlreadyArchivedError if group.self_archived? return AncestorAlreadyArchivedError if group.ancestors_archived? return ScheduledDeletionError if group.scheduled_for_deletion_in_hierarchy_chain? if unarchive_descendants? group.transaction do archive_group group.unarchive_descendants! group.unarchive_all_projects! end else archive_group end after_archive ServiceResponse.success rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved, StateMachines::InvalidTransition = "Failed to archive group! #{group.errors..to_sentence}".strip ServiceResponse.error(message: ) end |