Class: Projects::ArchiveService
- Inherits:
-
BaseProjectService
- Object
- BaseContainerService
- BaseProjectService
- Projects::ArchiveService
- Includes:
- ArchiveEvents
- Defined in:
- app/services/projects/archive_service.rb
Constant Summary collapse
- NotAuthorizedError =
ServiceResponse.error( message: "You don't have permissions to archive this project." )
- AlreadyArchivedError =
ServiceResponse.error( message: 'Project is already archived.' )
- AncestorAlreadyArchivedError =
ServiceResponse.error( message: 'Cannot archive project since one of the ancestors is already archived.' )
- ScheduledDeletionError =
ServiceResponse.error( message: 'Cannot archive project since it is scheduled for deletion.' )
- ArchivingFailedError =
ServiceResponse.error( message: 'Failed to archive project.' )
Instance Attribute Summary
Attributes inherited from BaseProjectService
Attributes inherited from BaseContainerService
#container, #current_user, #group, #params, #project
Instance Method Summary collapse
Methods included from ArchiveEvents
#publish_events, #publish_project_archived_event
Methods inherited from BaseProjectService
Methods inherited from BaseContainerService
#group_container?, #initialize, #namespace_container?, #project_container?, #project_group, #root_ancestor
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 BaseProjectService
Instance Method Details
#execute ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/services/projects/archive_service.rb', line 23 def execute return NotAuthorizedError unless can?(current_user, :archive_project, project) return AlreadyArchivedError if project.self_archived? return AncestorAlreadyArchivedError if project.ancestors_archived? return ScheduledDeletionError if project.scheduled_for_deletion_in_hierarchy_chain? if archive_project after_archive ServiceResponse.success else errors = project.errors..to_sentence return ServiceResponse.error(message: errors) if errors.presence ArchivingFailedError end end |