Class: Projects::UnarchiveService

Inherits:
BaseProjectService show all
Includes:
ArchiveEvents
Defined in:
app/services/projects/unarchive_service.rb

Constant Summary collapse

NotAuthorizedError =
ServiceResponse.error(
  message: "You don't have permissions to unarchive this project."
)
AncestorArchivedError =
ServiceResponse.error(
  message: 'Cannot unarchive project since one of the ancestors is archived.'
)
UnarchivingFailedError =
ServiceResponse.error(
  message: 'Failed to unarchive project.'
)

Instance Attribute Summary

Attributes inherited from BaseProjectService

#project

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

#initialize

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

#can?, #can_all?, #can_any?

Constructor Details

This class inherits a constructor from BaseProjectService

Instance Method Details

#executeObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/services/projects/unarchive_service.rb', line 17

def execute
  return NotAuthorizedError unless can?(current_user, :archive_project, project)
  return AncestorArchivedError if project.ancestors_archived?

  if unarchive_project
    after_unarchive
    ServiceResponse.success
  else
    errors = project.errors.full_messages.to_sentence
    return ServiceResponse.error(message: errors) if errors.presence

    UnarchivingFailedError
  end
end