Skip to content

Commit

Permalink
processing wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mcantelon committed Oct 31, 2024
1 parent 86321ba commit 0b20fe4
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions internal/workflow/processing.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,16 +440,6 @@ func (w *ProcessingWorkflow) SessionHandler(
return err
}

// Validate PREMIS.
activityOpts := withActivityOptsForRequest(sessCtx)
err := temporalsdk_workflow.ExecuteActivity(activityOpts, xmlvalidate.Name, xmlvalidate.Params{
XMLPath: filepath.Join(tinfo.TempPath, "data", "metadata", "premis.xml"),
XSDPath: w.cfg.ValidatePREMIS.XSDPath,
}).Get(activityOpts, nil)
if err != nil {
return err
}

// Classify the SIP.
{
activityOpts := withActivityOptsForLocalAction(sessCtx)
Expand Down Expand Up @@ -845,6 +835,11 @@ func (w *ProcessingWorkflow) transferA3m(
tinfo.SendToFailed.ActivityName = activities.SendToFailedPIPsName
tinfo.SendToFailed.NeedsZipping = true

err := w.validatePREMIS(sessCtx, filepath.Join(tinfo.Bundle.FullPath, "metadata", "premis.xml"))
if err != nil {
return err
}

// Send PIP to a3m for preservation.
{
activityOpts := temporalsdk_workflow.WithActivityOptions(sessCtx, temporalsdk_workflow.ActivityOptions{
Expand Down Expand Up @@ -894,6 +889,11 @@ func (w *ProcessingWorkflow) transferAM(ctx temporalsdk_workflow.Context, tinfo
tinfo.PackageType = enums.PackageTypeBagIt
}

err = w.validatePREMIS(ctx, filepath.Join(tinfo.TempPath, "data", "metadata", "premis.xml"))
if err != nil {
return err
}

// Zip PIP.
activityOpts := withActivityOptsForLocalAction(ctx)
var zipResult archivezip.Result
Expand Down Expand Up @@ -1199,3 +1199,21 @@ func (w *ProcessingWorkflow) sendToFailedBucket(

return nil
}

func (w *ProcessingWorkflow) validatePREMIS(
ctx temporalsdk_workflow.Context,
xmlPath string,
) error {
// Validate PREMIS.
activityOpts := withActivityOptsForRequest(ctx)
err := temporalsdk_workflow.ExecuteActivity(activityOpts, xmlvalidate.Name, xmlvalidate.Params{
XMLPath: xmlPath,
XSDPath: w.cfg.ValidatePREMIS.XSDPath,
}).Get(activityOpts, nil)
if err != nil {
return err

}

return nil
}

0 comments on commit 0b20fe4

Please sign in to comment.