\DNDataArchive
Represents a file archive of database and/or assets extracted from a specific Deploynaut environment.
The model can also represent a request to upload a file later,
through offline processes like mailing a DVD. In order to associate
and authenticate those requests easily, an upload token is generated for every archive.
The "OriginalEnvironment" points to original source of this snapshot
(the one it was backed up from). It will be empty if the snapshot has been created with offline process.
The "Environment" denotes the ownership of the snapshot. It will be initially set to match the
"OriginalEnvironment", but can be changed later. During the offline process the ownership can be set up
arbitrarily.
When moving snapshots, the file always remains in its initial location.
The archive can have associations to :
- Zero transfers if a manual upload was requested, but not fulfilled yet
- One transfer with Direction=get for a backup from an environment
- One or more transfers with Direction=push for a restore to an environment
The "Author" is either the person creating the archive through a "backup" operation,
the person uploading through a web form, or the person requesting a manual upload.
The "Mode" is what the "Author" said the file includes (either 'only assets', 'only
database', or both). This is used in the ArchiveList.ss template.
Synopsis
- // members
- private static array $db = ;
- private static array $has_one = ;
- private static array $has_many = ;
- private static string $singular_name = 'Data Archive';
- private static string $plural_name = 'Data Archives';
- private static array $summary_fields = ;
- private static array $searchable_fields = ;
- private static array $_cache_can_restore = ;
- private static array $_cache_can_download = ;
- // methods
- public static void get_mode_map()
- public static String generate_upload_token()
- public void onBeforeWrite()
- public void onAfterDelete()
- public void getCMSFields()
- public void getDefaultSearchContext()
- public string FileSize()
- public void getModeNice()
- public boolean isPending()
- public void canView()
- public true canRestore()
- public true canDownload()
- public true canDelete()
- public boolean canMoveTo()
- public ArrayList validTargetEnvironments()
- public string generateFilename()
- public String generateFilepath()
- public bool attachFile()
- public bool extractArchive()
- public ValidationResult validateArchiveContents()
- public bool fixArchivePermissions()
- public bool setArchiveFromFiles()
Hierarchy
Extends
- DataObject
Members
private
- $_cache_can_download
- $_cache_can_restore
- $db
- $has_many
- $has_one
- $plural_name
- $searchable_fields
- $singular_name
- $summary_fields
Methods
public
- FileSize() — Calculates and returns a human-readable size of this archive file. If the file exists, it will determine whether to display the output in bytes, kilobytes, megabytes, or gigabytes.
- attachFile() — Attach an sspak file path to this archive and associate the transfer.
- canDelete() — Whether a {@link Member} can delete this archive from staging area.
- canDownload() — Whether a {@link Member} can download this archive to their PC.
- canMoveTo() — Check if this member can move archive into the environment.
- canRestore() — Whether a {@link Member} can restore this archive to an environment.
- canView() — Inferred from both restore and backup permissions.
- extractArchive() — Extract the current sspak contents into the given working directory.
- fixArchivePermissions() — Given a path that already exists and contains an extracted sspak, including the assets, fix all of the file permissions so they're in a state ready to be pushed to remote servers.
- generateFilename() — Returns a unique filename, including project/environment/timestamp details.
- generateFilepath() — Returns a path unique to a specific transfer, including project/environment details.
- generate_upload_token() — Returns a unique token to correlate an offline item (posted DVD) with a specific archive placeholder.
- getCMSFields()
- getDefaultSearchContext()
- getModeNice()
- get_mode_map()
- isPending() — Some archives don't have files attached to them yet, because a file has been posted offline and is waiting to be uploaded against this "archive placeholder".
- onAfterDelete()
- onBeforeWrite()
- setArchiveFromFiles() — Given extracted sspak contents, create an sspak from it and overwrite the current ArchiveFile with it's contents.
- validTargetEnvironments() — Finds all environments within this project where the archive can be moved to.
- validateArchiveContents() — Validate that an sspak contains the correct content.