1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-18 20:59:43 +02:00

[WIP] Backup process outline

This commit is contained in:
sauls8t 2018-10-10 15:13:09 +01:00
parent 8bbb0d3e82
commit 4094677792
18 changed files with 678 additions and 220 deletions

62
model/action/action.go Normal file
View file

@ -0,0 +1,62 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// This software (Documize Community Edition) is licensed under
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
//
// You can operate outside the AGPL restrictions by purchasing
// Documize Enterprise Edition and obtaining a commercial license
// by contacting <sales@documize.com>.
//
// https://documize.com
package action
import (
"time"
"github.com/documize/community/core/timeutil"
"github.com/documize/community/model"
)
// UserAction represents an action that a user should perform on a document.
type UserAction struct {
model.BaseEntity
OrgID string `json:"orgId"`
DocumentID string `json:"documentId"`
UserID string `json:"userId"`
ActionType Type `json:"actionType"`
RefType string `json:"refType"` // page or attachment
RefTypeID string `json:"refTypeId"` // page or attachment ID
Note string `json:"note"`
RequestorID string `json:"requestorId"`
Requested time.Time `json:"requestedDate"`
Due time.Time `json:"dueDate"`
Completed timeutil.NullTime `json:"completedDate"`
IsComplete bool `json:"isComplete"`
}
// Type determines type of action that has been requested of a user
type Type int
const (
// ActionTypeRead document
ActionTypeRead Type = 1
// ActionTypeFeedback for a document
ActionTypeFeedback Type = 2
// ActionTypeContribute to document
ActionTypeContribute Type = 3
// ActionTypeApprovalRequest for a section change
ActionTypeApprovalRequest Type = 4
// ActionTypeApproved section change
ActionTypeApproved Type = 5
// ActionTypeRejected section change
ActionTypeRejected Type = 6
// ActionTypePublish content as Live
ActionTypePublish Type = 7
)

View file

@ -28,55 +28,81 @@ type AppEvent struct {
type EventType string
const (
EventTypeDocumentAdd EventType = "added-document"
EventTypeDocumentUpload EventType = "uploaded-document"
EventTypeDocumentView EventType = "viewed-document"
EventTypeDocumentUpdate EventType = "updated-document"
EventTypeDocumentDelete EventType = "removed-document"
EventTypeDocumentRevisions EventType = "viewed-document-revisions"
EventTypeDocumentPermission EventType = "changed-document-permissions"
EventTypeSpaceAdd EventType = "added-space"
EventTypeSpaceUpdate EventType = "updated-space"
EventTypeSpaceDelete EventType = "removed-space"
EventTypeSpacePermission EventType = "changed-space-permissions"
EventTypeSpaceJoin EventType = "joined-space"
EventTypeSpaceInvite EventType = "invited-space"
EventTypeCategoryPermission EventType = "changed-category-permissions"
EventTypeSectionAdd EventType = "added-document-section"
EventTypeSectionUpdate EventType = "updated-document-section"
EventTypeSectionDelete EventType = "removed-document-section"
EventTypeSectionRollback EventType = "rolled-back-document-section"
EventTypeSectionResequence EventType = "resequenced-document-section"
EventTypeSectionCopy EventType = "copied-document-section"
EventTypeAttachmentAdd EventType = "added-attachment"
EventTypeAttachmentDownload EventType = "downloaded-attachment"
EventTypeAttachmentDelete EventType = "removed-attachment"
EventTypePinAdd EventType = "added-pin"
EventTypePinDelete EventType = "removed-pin"
EventTypePinResequence EventType = "resequenced-pin"
EventTypeBlockAdd EventType = "added-reusable-block"
EventTypeBlockUpdate EventType = "updated-reusable-block"
EventTypeBlockDelete EventType = "removed-reusable-block"
EventTypeTemplateAdd EventType = "added-document-template"
EventTypeTemplateUse EventType = "used-document-template"
EventTypeUserAdd EventType = "added-user"
EventTypeUserUpdate EventType = "updated-user"
EventTypeUserDelete EventType = "removed-user"
EventTypeUserPasswordReset EventType = "reset-user-password"
EventTypeAccountAdd EventType = "added-account"
EventTypeSystemLicense EventType = "changed-system-license"
EventTypeSystemAuth EventType = "changed-system-auth"
EventTypeSystemSMTP EventType = "changed-system-smtp"
EventTypeSessionStart EventType = "started-session"
EventTypeSearch EventType = "searched"
EventTypeCategoryAdd EventType = "added-category"
EventTypeCategoryDelete EventType = "removed-category"
EventTypeCategoryUpdate EventType = "updated-category"
EventTypeCategoryLink EventType = "linked-category"
EventTypeCategoryUnlink EventType = "unlinked-category"
EventTypeGroupAdd EventType = "added-group"
EventTypeGroupDelete EventType = "removed-group"
EventTypeGroupUpdate EventType = "updated-group"
EventTypeGroupJoin EventType = "joined-group"
EventTypeGroupLeave EventType = "left-group"
EventTypeDocumentAdd EventType = "added-document"
EventTypeDocumentUpload EventType = "uploaded-document"
EventTypeDocumentView EventType = "viewed-document"
EventTypeDocumentUpdate EventType = "updated-document"
EventTypeDocumentDelete EventType = "removed-document"
EventTypeDocumentRevisions EventType = "viewed-document-revisions"
EventTypeDocumentPermission EventType = "changed-document-permissions"
EventTypeSpaceAdd EventType = "added-space"
EventTypeSpaceUpdate EventType = "updated-space"
EventTypeSpaceDelete EventType = "removed-space"
EventTypeSpacePermission EventType = "changed-space-permissions"
EventTypeSpaceJoin EventType = "joined-space"
EventTypeSpaceInvite EventType = "invited-space"
EventTypeCategoryPermission EventType = "changed-category-permissions"
EventTypeSectionAdd EventType = "added-document-section"
EventTypeSectionUpdate EventType = "updated-document-section"
EventTypeSectionDelete EventType = "removed-document-section"
EventTypeSectionRollback EventType = "rolled-back-document-section"
EventTypeSectionResequence EventType = "resequenced-document-section"
EventTypeSectionCopy EventType = "copied-document-section"
EventTypeAttachmentAdd EventType = "added-attachment"
EventTypeAttachmentDownload EventType = "downloaded-attachment"
EventTypeAttachmentDelete EventType = "removed-attachment"
EventTypePinAdd EventType = "added-pin"
EventTypePinDelete EventType = "removed-pin"
EventTypePinResequence EventType = "resequenced-pin"
EventTypeBlockAdd EventType = "added-reusable-block"
EventTypeBlockUpdate EventType = "updated-reusable-block"
EventTypeBlockDelete EventType = "removed-reusable-block"
EventTypeTemplateAdd EventType = "added-document-template"
EventTypeTemplateUse EventType = "used-document-template"
EventTypeUserAdd EventType = "added-user"
EventTypeUserUpdate EventType = "updated-user"
EventTypeUserDelete EventType = "removed-user"
EventTypeUserPasswordReset EventType = "reset-user-password"
EventTypeAccountAdd EventType = "added-account"
EventTypeSystemLicense EventType = "changed-system-license"
EventTypeSystemAuth EventType = "changed-system-auth"
EventTypeSystemSMTP EventType = "changed-system-smtp"
EventTypeSessionStart EventType = "started-session"
EventTypeSearch EventType = "searched"
EventTypeCategoryAdd EventType = "added-category"
EventTypeCategoryDelete EventType = "removed-category"
EventTypeCategoryUpdate EventType = "updated-category"
EventTypeCategoryLink EventType = "linked-category"
EventTypeCategoryUnlink EventType = "unlinked-category"
EventTypeGroupAdd EventType = "added-group"
EventTypeGroupDelete EventType = "removed-group"
EventTypeGroupUpdate EventType = "updated-group"
EventTypeGroupJoin EventType = "joined-group"
EventTypeGroupLeave EventType = "left-group"
EventTypeSecureShare EventType = "shared-secure-document"
EventTypeFeedbackAdd EventType = "added-feedback"
EventTypeFeedbackEdit EventType = "edited-feedback"
EventTypePDF EventType = "generated-pdf"
EventTypeActionAdd EventType = "added-action"
EventTypeActionUpdate EventType = "updated-action"
EventTypeActionView EventType = "viewed-actions"
EventTypeActionDelete EventType = "removed-action"
EventTypeWorkflowApprovalRequested EventType = "request-approval"
EventTypeWorkflowApprovalWithdrawn EventType = "withdrew-approval"
EventTypeWorkflowDiscardChanges EventType = "discarded-changes"
EventTypeWorkflowApprovedChange EventType = "approved-change"
EventTypeWorkflowRejectedChange EventType = "rejected-change"
EventTypeWorkflowPublishRequested EventType = "requested-publication"
// EventTypeVersionAdd records addition of version
EventTypeVersionAdd EventType = "added-version"
// EventTypeVersionRemove records removal of version
EventTypeVersionRemove EventType = "removed-version"
// EventTypeVersionUnversion records disassociation of document from versioning group
EventTypeVersionUnversion EventType = "un-versioned-document"
// EventTypeVersionReorder records reordering of versions
EventTypeVersionReorder EventType = "reordered-version"
)

70
model/backup/backup.go Normal file
View file

@ -0,0 +1,70 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// This software (Documize Community Edition) is licensed under
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
//
// You can operate outside the AGPL restrictions by purchasing
// Documize Enterprise Edition and obtaining a commercial license
// by contacting <sales@documize.com>.
//
// https://documize.com
// Package backup handle data backup/restore to/from ZIP format.
package backup
import (
"time"
"github.com/documize/community/core/env"
)
// Manifest contains backup meta information.
type Manifest struct {
// ID is unique per backup.
ID string `json:"id"`
// A value of "*' means all tenants/oragnizations are backed up (requires global admin permission).
// A genuine ID means only that specific organization is backed up.
OrgID string `json:"org"`
// Product edition at the time of the backup.
Edition string `json:"edition"`
// When the backup took place.
Created time.Time `json:"created"`
// Product version at the time of the backup.
Major string `json:"major"`
Minor string `json:"minor"`
Patch string `json:"patch"`
Revision int `json:"revision"`
Version string `json:"version"`
// Database provider used by source system.
StoreType env.StoreType `json:"storeType"`
}
// ExportSpec controls what data is exported to the backup file.
type ExportSpec struct {
// A value of "*' means all tenants/oragnizations are backed up (requires global admin permission).
// A genuine ID means only that specific organization is backed up.
OrgID string `json:"org"`
// Retain will keep the backup file on disk after operation is complete.
// File is located in the same folder as the running executable.
Retain bool `json:"retain"`
}
// SystemBackup happens if org ID is "*".
func (e *ExportSpec) SystemBackup() bool {
return e.OrgID == "*"
}
// ImportSpec controls what content is imported and how.
type ImportSpec struct {
// Overwrite current organization settings.
OverwriteOrg bool `json:"overwriteOrg"`
// Recreate users.
CreateUsers bool `json:"createUsers"`
}