Gc restore multi framework (#639)
* Abstraction extended to restore. Application logic moved to service_functions.go
This commit is contained in:
parent
b524053e96
commit
6e7335cc4d
@ -258,6 +258,37 @@ func GetCopyRestoreFolder(service graph.Service, user string) (*string, error) {
|
|||||||
return isFolder, nil
|
return isFolder, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RestoreExchangeObject(
|
||||||
|
ctx context.Context,
|
||||||
|
bits []byte,
|
||||||
|
category string,
|
||||||
|
policy control.CollisionPolicy,
|
||||||
|
service graph.Service,
|
||||||
|
destination, user string,
|
||||||
|
) error {
|
||||||
|
var setting optionIdentifier
|
||||||
|
switch category {
|
||||||
|
case mailCategory:
|
||||||
|
setting = messages
|
||||||
|
case contactsCategory:
|
||||||
|
setting = contacts
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("type: %s not supported for exchange restore", category)
|
||||||
|
}
|
||||||
|
|
||||||
|
switch setting {
|
||||||
|
case messages:
|
||||||
|
switch policy {
|
||||||
|
case control.Copy:
|
||||||
|
return RestoreMailMessage(ctx, bits, service, control.Copy, destination, user)
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("restore policy: %s not supported", policy)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("type: %s not supported for exchange restore", category)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// RestoreMailMessage utility function to place an exchange.Mail
|
// RestoreMailMessage utility function to place an exchange.Mail
|
||||||
// message into the user's M365 Exchange account.
|
// message into the user's M365 Exchange account.
|
||||||
// @param bits - byte array representation of exchange.Message from Corso backstore
|
// @param bits - byte array representation of exchange.Message from Corso backstore
|
||||||
|
|||||||
@ -278,14 +278,11 @@ func (gc *GraphConnector) RestoreMessages(ctx context.Context, dcs []data.Collec
|
|||||||
errs = support.WrapAndAppend(itemData.UUID(), err, errs)
|
errs = support.WrapAndAppend(itemData.UUID(), err, errs)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
switch policy {
|
category := dc.FullPath()[2]
|
||||||
case control.Copy:
|
err = exchange.RestoreExchangeObject(ctx, buf.Bytes(), category, policy, &gc.graphService, *folderID, user)
|
||||||
err = exchange.RestoreMailMessage(ctx, buf.Bytes(), &gc.graphService, control.Copy, *folderID, user)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs = support.WrapAndAppend(itemData.UUID(), err, errs)
|
errs = support.WrapAndAppend(itemData.UUID(), err, errs)
|
||||||
}
|
|
||||||
default:
|
|
||||||
errs = support.WrapAndAppend(itemData.UUID(), errors.New("restore policy not supported"), errs)
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
successes++
|
successes++
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user