-
Notifications
You must be signed in to change notification settings - Fork 1
/
constants.go
349 lines (323 loc) · 9.87 KB
/
constants.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
package constants
import (
"errors"
)
const (
AccessConsortia = "consortia"
AccessInstitution = "institution"
AccessRestricted = "restricted"
ActionApproveDelete = "ApproveDelete"
ActionCreate = "Create"
ActionDelete = "Delete"
ActionFinishBulkDelete = "FinishBulkDelete"
ActionFixityCheck = "Fixity Check"
ActionRestoreFile = "Restore File"
ActionGlacierRestore = "Glacier Restore"
ActionIngest = "Ingest"
ActionRead = "Read"
ActionRequestDelete = "RequestDelete"
ActionRestoreObject = "Restore Object"
ActionUpdate = "Update"
AlertDeletionCancelled = "Deletion Cancelled"
AlertDeletionCompleted = "Deletion Completed"
AlertDeletionConfirmed = "Deletion Confirmed"
AlertDeletionRequested = "Deletion Requested"
AlertFailedFixity = "Failed Fixity Check"
AlertPasswordChanged = "Password Changed"
AlertPasswordReset = "Password Reset"
AlertRestorationCompleted = "Restoration Completed"
AlertStalledItems = "Stalled Work Items"
AlertWelcome = "Welcome New User"
AlgMd5 = "md5"
AlgSha1 = "sha1"
AlgSha256 = "sha256"
AlgSha512 = "sha512"
APIUserHeader = "X-Pharos-API-User"
APIKeyHeader = "X-Pharos-API-Key"
APIPrefixAdmin = "/admin-api/"
APIPrefixMember = "/member-api/"
BTRProfileIdentifier = "https://github.com/dpscollaborative/btr_bagit_profile/releases/download/1.0/btr-bagit-profile.json"
CSRFCookieName = "csrf_token"
CSRFHeaderName = "X-CSRF-Token"
CSRFTokenName = "csrf_token"
DefaultProfileIdentifier = "https://raw.githubusercontent.com/APTrust/preservation-services/master/profiles/aptrust-v2.2.json"
EmailServiceSES = "SES"
EmailServiceSMTP = "SMTP"
EventAccessAssignment = "access assignment"
EventCapture = "capture"
EventCompression = "compression"
EventCreation = "creation"
EventDeaccession = "deaccession"
EventDecompression = "decompression"
EventDecryption = "decryption"
EventDeletion = "deletion"
EventDigestCalculation = "message digest calculation"
EventFixityCheck = "fixity check"
EventIdentifierAssignment = "identifier assignment"
EventIngestion = "ingestion"
EventMigration = "migration"
EventNormalization = "normalization"
EventReplication = "replication"
EventSignatureValidation = "digital signature validation"
EventValidation = "validation"
EventVirusCheck = "virus check"
IngestPreFetch = "ingest01_prefetch"
IngestValidation = "ingest02_bag_validation"
IngestReingestCheck = "ingest03_reingest_check"
IngestStaging = "ingest04_staging"
IngestFormatIdentification = "ingest05_format_identification"
IngestStorage = "ingest06_storage"
IngestStorageValidation = "ingest07_storage_validation"
IngestRecord = "ingest08_record"
IngestCleanup = "ingest09_cleanup"
InstTypeMember = "MemberInstitution"
InstTypeSubscriber = "SubscriptionInstitution"
MetaSpotTestsRunning = "spot restore is running"
MetaSpotTestsLastRun = "spot restore last run"
OutcomeFailure = "Failure"
OutcomeSuccess = "Success"
RoleInstAdmin = "institutional_admin"
RoleInstUser = "institutional_user"
RoleNone = "none"
RoleSysAdmin = "admin"
SecondFactorAuthy = "Authy"
SecondFactorBackupCode = "Backup Code"
SecondFactorSMS = "SMS"
StageAvailableInS3 = "Available in S3"
StageCleanup = "Cleanup"
StageCopyToStaging = "Copy To Staging"
StageFetch = "Fetch"
StageFormatIdentification = "Format Identification"
StagePackage = "Package"
StageReceive = "Receive"
StageRecord = "Record"
StageReingestCheck = "Reingest Check"
StageRequested = "Requested"
StageResolve = "Resolve"
StageRestoring = "Restoring"
StageStorageValidation = "Storage Validation"
StageStore = "Store"
StageUnpack = "Unpack"
StageValidate = "Validate"
StateActive = "A"
StateDeleted = "D"
StatusCancelled = "Cancelled"
StatusFailed = "Failed"
StatusPending = "Pending"
StatusStarted = "Started"
StatusSuccess = "Success"
StatusSuspended = "Suspended"
StorageOptionGlacierDeepOH = "Glacier-Deep-OH"
StorageOptionGlacierDeepOR = "Glacier-Deep-OR"
StorageOptionGlacierDeepVA = "Glacier-Deep-VA"
StorageOptionGlacierOH = "Glacier-OH"
StorageOptionGlacierOR = "Glacier-OR"
StorageOptionGlacierVA = "Glacier-VA"
StorageOptionStandard = "Standard"
StorageOptionWasabiOR = "Wasabi-OR"
StorageOptionWasabiVA = "Wasabi-VA"
SystemUser = "system@aptrust.org"
TopicDelete = "delete_item"
TopicE2EDelete = "e2e_deletion_post_test"
TopicE2EFixity = "e2e_fixity_post_test"
TopicE2EIngest = "e2e_ingest_post_test"
TopicE2EReingest = "e2e_reingest_post_test"
TopicE2ERestore = "e2e_restoration_post_test"
TopicFileRestore = "restore_file"
TopicFixity = "fixity_check"
TopicGlacierRestore = "restore_glacier"
TopicObjectRestore = "restore_object"
TwoFactorAuthy = "onetouch"
TwoFactorNone = "none"
TwoFactorSMS = "sms"
)
var AccessSettings = []string{
AccessConsortia,
AccessInstitution,
AccessRestricted,
}
var AlertTypes = []string{
AlertDeletionCancelled,
AlertDeletionCompleted,
AlertDeletionConfirmed,
AlertDeletionRequested,
AlertFailedFixity,
AlertRestorationCompleted,
AlertPasswordChanged,
AlertPasswordReset,
AlertStalledItems,
AlertWelcome,
}
var APIPrefixes = []string{
APIPrefixAdmin,
APIPrefixMember,
}
var CompletedStatusValues = []string{
StatusCancelled,
StatusFailed,
StatusSuccess,
}
var DigestAlgs = []string{
AlgMd5,
AlgSha1,
AlgSha256,
AlgSha512,
}
var EventOutcomes = []string{
OutcomeFailure,
OutcomeSuccess,
}
var EventTypes = []string{
EventAccessAssignment,
EventCreation,
EventDeletion,
EventDigestCalculation,
EventFixityCheck,
EventIdentifierAssignment,
EventIngestion,
EventReplication,
EventValidation,
}
var GlacierOnlyOptions = []string{
StorageOptionGlacierDeepOH,
StorageOptionGlacierDeepOR,
StorageOptionGlacierDeepVA,
StorageOptionGlacierOH,
StorageOptionGlacierOR,
StorageOptionGlacierVA,
}
var IncompleteStatusValues = []string{
StatusPending,
StatusStarted,
}
var IngestStagesInOrder = []string{
StageReceive,
StageValidate,
StageReingestCheck,
StageCopyToStaging,
StageFormatIdentification,
StageStore,
StageStorageValidation,
StageRecord,
StageCleanup,
}
var InstTypes = []string{
InstTypeMember,
InstTypeSubscriber,
}
var Roles = []string{
RoleInstAdmin,
RoleInstUser,
RoleNone,
RoleSysAdmin,
}
var SecondFactorTypes = []string{
SecondFactorAuthy,
SecondFactorBackupCode,
SecondFactorSMS,
}
var Stages = []string{
StageAvailableInS3,
StageCleanup,
StageCopyToStaging,
StageFormatIdentification,
StageFetch,
StagePackage,
StageReceive,
StageRecord,
StageReingestCheck,
StageRequested,
StageResolve,
StageRestoring,
StageStorageValidation,
StageStore,
StageUnpack,
StageValidate,
}
var States = []string{
StateActive,
StateDeleted,
}
var Statuses = []string{
StatusCancelled,
StatusFailed,
StatusPending,
StatusStarted,
StatusSuccess,
StatusSuspended,
}
var StorageOptions = []string{
StorageOptionGlacierDeepOH,
StorageOptionGlacierDeepOR,
StorageOptionGlacierDeepVA,
StorageOptionGlacierOH,
StorageOptionGlacierOR,
StorageOptionGlacierVA,
StorageOptionStandard,
StorageOptionWasabiOR,
StorageOptionWasabiVA,
}
var UserActions = []string{
ActionCreate,
ActionRead,
ActionUpdate,
ActionDelete,
ActionRequestDelete,
ActionApproveDelete,
ActionFinishBulkDelete,
ActionRestoreObject,
ActionRestoreFile,
}
var WorkItemActions = []string{
ActionDelete,
ActionGlacierRestore,
ActionIngest,
ActionRestoreFile,
ActionRestoreObject,
}
var NonIngestTopics = []string{
TopicDelete,
TopicFileRestore,
TopicFixity,
TopicGlacierRestore,
TopicObjectRestore,
}
// NSQIngestTopicFor maps ingest stage names to NSQ topics.
var NSQIngestTopicFor = map[string]string{
StageReceive: IngestPreFetch,
StageValidate: IngestValidation,
StageReingestCheck: IngestReingestCheck,
StageCopyToStaging: IngestStaging,
StageFormatIdentification: IngestFormatIdentification,
StageStore: IngestStorage,
StageStorageValidation: IngestStorageValidation,
StageRecord: IngestRecord,
StageCleanup: IngestCleanup,
}
// All other common errors are defined in common. We had to move this
// one into constants to prevent an illegal import cycle.
// ErrInvalidRequeue occurs when someone attempts to requeue an item to the
// wrong stage, or to a stage for which no NSQ topic exists.
var ErrInvalidRequeue = errors.New("item cannot be requeued to the specified stage")
func TopicFor(action, stage string) (string, error) {
var err error
topic := ""
switch action {
case ActionDelete:
topic = TopicDelete
case ActionRestoreFile:
topic = TopicFileRestore
case ActionGlacierRestore:
topic = TopicGlacierRestore
case ActionRestoreObject:
topic = TopicObjectRestore
case ActionIngest:
topic = NSQIngestTopicFor[stage]
default:
topic = ""
}
if topic == "" {
err = ErrInvalidRequeue
}
return topic, err
}