Skip to content

Commit

Permalink
Verify manifest before premis.xml creation
Browse files Browse the repository at this point in the history
  • Loading branch information
jraddaoui committed Aug 27, 2024
1 parent 9a7504a commit 8d85bf8
Showing 1 changed file with 34 additions and 34 deletions.
68 changes: 34 additions & 34 deletions internal/workflow/preprocessing.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,40 @@ func (w *PreprocessingWorkflow) Execute(
}
result.addEvent(validateStructureEvent)

// Verify that package contents match the manifest.
verifyManifestEvent := newEvent(ctx, "Verify SIP manifest")
var verifyManifest activities.VerifyManifestResult
e = temporalsdk_workflow.ExecuteActivity(
withLocalActOpts(ctx),
activities.VerifyManifestName,
&activities.VerifyManifestParams{SIP: identifySIP.SIP},
).Get(ctx, &verifyManifest)
if e != nil {
result.addEvent(verifyManifestEvent.Complete(
ctx,
enums.EventOutcomeSystemFailure,
"System error: manifest verification has failed",
))
return systemError(logger, "Verify manifest", &result, e), nil

Check warning on line 147 in internal/workflow/preprocessing.go

View check run for this annotation

Codecov / codecov/patch

internal/workflow/preprocessing.go#L142-L147

Added lines #L142 - L147 were not covered by tests
}

if verifyManifest.Failures != nil {
verifyManifestEvent.Complete(
ctx,
enums.EventOutcomeValidationFailure,
"Content error: SIP contents do not match %q:\n%s",
filepath.Base(identifySIP.SIP.ManifestPath),
strings.Join(verifyManifest.Failures, "\n"),
)
} else {
verifyManifestEvent.Complete(
ctx,
enums.EventOutcomeSuccess,
"SIP contents match manifest",
)
}
result.addEvent(verifyManifestEvent)

// Add PREMIS objects.
premisFilePath := filepath.Join(localPath, "metadata", "premis.xml")

Expand Down Expand Up @@ -169,40 +203,6 @@ func (w *PreprocessingWorkflow) Execute(
return nil, e
}

// Verify that package contents match the manifest.
verifyManifestEvent := newEvent(ctx, "Verify SIP manifest")
var verifyManifest activities.VerifyManifestResult
e = temporalsdk_workflow.ExecuteActivity(
withLocalActOpts(ctx),
activities.VerifyManifestName,
&activities.VerifyManifestParams{SIP: identifySIP.SIP},
).Get(ctx, &verifyManifest)
if e != nil {
result.addEvent(verifyManifestEvent.Complete(
ctx,
enums.EventOutcomeSystemFailure,
"System error: manifest verification has failed",
))
return systemError(logger, "Verify manifest", &result, e), nil
}

if verifyManifest.Failures != nil {
verifyManifestEvent.Complete(
ctx,
enums.EventOutcomeValidationFailure,
"Content error: SIP contents do not match %q:\n%s",
filepath.Base(identifySIP.SIP.ManifestPath),
strings.Join(verifyManifest.Failures, "\n"),
)
} else {
verifyManifestEvent.Complete(
ctx,
enums.EventOutcomeSuccess,
"SIP contents match manifest",
)
}
result.addEvent(verifyManifestEvent)

// Validate file formats.
validateFileFormatsEvent := newEvent(ctx, "Validate SIP file formats")
var validateFileFormats activities.ValidateFileFormatsResult
Expand Down

0 comments on commit 8d85bf8

Please sign in to comment.