Class ConfluenceBackupRestoreManager
- java.lang.Object
-
- com.atlassian.confluence.impl.backuprestore.ConfluenceBackupRestoreManager
-
- All Implemented Interfaces:
BackupRestoreManager
public class ConfluenceBackupRestoreManager extends Object implements BackupRestoreManager
Responsible for accepting backup/restore operations, checking permissions, managing the queue and cluster-wide locks. Uses BackupRestoreService for the actual backup/restore operations. NOTE: At this moment, this implementation does not support Confluence cluster. So each mode works independently.- Since:
- 7.17.0
-
-
Constructor Summary
Constructors Constructor Description ConfluenceBackupRestoreManager(BackupRestoreJobRunner backupRestoreJobRunner, BackupRestorePermissionsHelper permissionsHelper, BackupRestoreJobDao backupRestoreJobDao, com.atlassian.beehive.ClusterLockService clusterLockService, ConfluenceBackupRestoreJobCanceller confluenceBackupRestoreJobCanceller, com.atlassian.event.api.EventPublisher eventPublisher, BackupRestoreFilesystemManager backupRestoreFilesystemManager, ZduManager zduManager, IndependentBackupRestoreJobManager independentBackupRestoreJobManager)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassertUserHasSystemAdminPermissions()Checks whether the current user can upload a backup file.intcancelAllJobsFromQueue()Cancels all queued jobs including jobs in QUEUED state and PROCESSING state.Optional<BackupRestoreJob>cancelJob(Long jobId)Cancels the job.Collection<BackupRestoreJob>findJobs(BackupRestoreJobsSearchFilter backupRestoreJobsSearchFilter)Returns jobs based on the filter provided.Optional<BackupRestoreJob>getJob(Long jobId)Get job by id.BackupRestoreSettingsgetSettingsById(long jobId)Returns job settings.Optional<BackupRestoreJobResult>getStatisticsById(long jobId)voidprocessJobsFromTheQueue()BackupRestoreJobstartSiteBackup(BackupRestoreSettings siteBackupSettings)Queues a new site backup job if possible.BackupRestoreJobstartSiteRestore(BackupRestoreSettings siteRestoreSettings)Queues the new site restore job if possible.BackupRestoreJobstartSpaceBackup(BackupRestoreSettings spaceBackupSettings)Adds the new space backup job to the queue.BackupRestoreJobstartSpaceRestore(BackupRestoreSettings spaceRestoreSettings)Adds the new space restore job to the queue.
-
-
-
Constructor Detail
-
ConfluenceBackupRestoreManager
public ConfluenceBackupRestoreManager(BackupRestoreJobRunner backupRestoreJobRunner, BackupRestorePermissionsHelper permissionsHelper, BackupRestoreJobDao backupRestoreJobDao, com.atlassian.beehive.ClusterLockService clusterLockService, ConfluenceBackupRestoreJobCanceller confluenceBackupRestoreJobCanceller, com.atlassian.event.api.EventPublisher eventPublisher, BackupRestoreFilesystemManager backupRestoreFilesystemManager, ZduManager zduManager, IndependentBackupRestoreJobManager independentBackupRestoreJobManager)
-
-
Method Detail
-
startSiteBackup
public BackupRestoreJob startSiteBackup(BackupRestoreSettings siteBackupSettings) throws NotPermittedException
Queues a new site backup job if possible. Throws an exception if the operation is not permitted. The user has to be a sysadmin to perform this operation.- Specified by:
startSiteBackupin interfaceBackupRestoreManager- Parameters:
siteBackupSettings- site backup settings- Throws:
NotPermittedException
-
startSiteRestore
public BackupRestoreJob startSiteRestore(BackupRestoreSettings siteRestoreSettings) throws NotPermittedException
Queues the new site restore job if possible. It cancels all other jobs and starts the restore just after. Throws an exception if the operation is not permitted.- Specified by:
startSiteRestorein interfaceBackupRestoreManager- Parameters:
siteRestoreSettings- site restore settings- Throws:
NotPermittedException
-
startSpaceRestore
public BackupRestoreJob startSpaceRestore(BackupRestoreSettings spaceRestoreSettings) throws NotPermittedException
Adds the new space restore job to the queue. Throws an exception if the operation is not permitted. The user has to the a sysadmin to perform this operation.- Specified by:
startSpaceRestorein interfaceBackupRestoreManager- Parameters:
spaceRestoreSettings- space restore settings- Throws:
NotPermittedException
-
getJob
public Optional<BackupRestoreJob> getJob(Long jobId) throws NotPermittedException
Get job by id.- Specified by:
getJobin interfaceBackupRestoreManager- Throws:
NotPermittedException
-
startSpaceBackup
public BackupRestoreJob startSpaceBackup(BackupRestoreSettings spaceBackupSettings) throws NotPermittedException, TheSameSpaceBackupRestoreJobAlreadyInProgressException, IllegalArgumentException
Adds the new space backup job to the queue. Throws an exception if the operation is not permitted. Support either single-space backup ot multi-space backups (depends on how many space ids are provided).- Specified by:
startSpaceBackupin interfaceBackupRestoreManager- Parameters:
spaceBackupSettings- space backup settings- Throws:
NotPermittedExceptionTheSameSpaceBackupRestoreJobAlreadyInProgressExceptionIllegalArgumentException
-
processJobsFromTheQueue
public void processJobsFromTheQueue()
-
cancelJob
public Optional<BackupRestoreJob> cancelJob(Long jobId) throws NotPermittedException
Cancels the job. If the job is already cancelled or failed, the method will do nothing. Throws an exception if the operation is not permitted.- Specified by:
cancelJobin interfaceBackupRestoreManager- Parameters:
jobId- jobId- Returns:
- the job
- Throws:
NotPermittedException
-
cancelAllJobsFromQueue
public int cancelAllJobsFromQueue() throws NotPermittedExceptionDescription copied from interface:BackupRestoreManagerCancels all queued jobs including jobs in QUEUED state and PROCESSING state.- Specified by:
cancelAllJobsFromQueuein interfaceBackupRestoreManager- Returns:
- number of cancelled jobs.
- Throws:
NotPermittedException
-
findJobs
public Collection<BackupRestoreJob> findJobs(BackupRestoreJobsSearchFilter backupRestoreJobsSearchFilter)
Returns jobs based on the filter provided. Permissions are based on the user SysAdmins can return all, Users can return only jobs that they have space export permissions for- Specified by:
findJobsin interfaceBackupRestoreManager- Parameters:
backupRestoreJobsSearchFilter- properties to filter jobs by- Returns:
- List of BackupRestoreJobs
-
assertUserHasSystemAdminPermissions
public void assertUserHasSystemAdminPermissions() throws NotPermittedExceptionDescription copied from interface:BackupRestoreManagerChecks whether the current user can upload a backup file. Throws a PermissionException if the user does not have permission.- Specified by:
assertUserHasSystemAdminPermissionsin interfaceBackupRestoreManager- Throws:
NotPermittedException
-
getSettingsById
public BackupRestoreSettings getSettingsById(long jobId)
Description copied from interface:BackupRestoreManagerReturns job settings.- Specified by:
getSettingsByIdin interfaceBackupRestoreManager- Parameters:
jobId- job id- Returns:
- settings
-
getStatisticsById
public Optional<BackupRestoreJobResult> getStatisticsById(long jobId)
- Specified by:
getStatisticsByIdin interfaceBackupRestoreManager- Parameters:
jobId-- Returns:
- job's statistics or empty statistics record if no statistics exist
-
-