Issue 184 Full Path added to DataCollection (#199)
Merge of Branch adds FullPath to the DataCollection() where each DataCollection is based on the folder. Thus, returning a [] DataCollection
This commit is contained in:
parent
88bc374208
commit
e0199b6b26
@ -125,11 +125,11 @@ func buildFromMap(isKey bool, mapping map[string]string) []string {
|
||||
// Assumption: User exists
|
||||
// TODO: https://github.com/alcionai/corso/issues/135
|
||||
// Add iota to this call -> mail, contacts, calendar, etc.
|
||||
func (gc *GraphConnector) ExchangeDataCollection(user string) (DataCollection, error) {
|
||||
func (gc *GraphConnector) ExchangeDataCollection(user string) ([]DataCollection, error) {
|
||||
// TODO replace with completion of Issue 124:
|
||||
collection := NewExchangeDataCollection(user, []string{gc.tenant, user})
|
||||
|
||||
//TODO: Retry handler to convert return: (DataCollection, error)
|
||||
return gc.serializeMessages(user, collection)
|
||||
return gc.serializeMessages(user)
|
||||
}
|
||||
|
||||
// optionsForMailFolders creates transforms the 'select' into a more dynamic call for MailFolders.
|
||||
@ -201,7 +201,7 @@ func (gc *GraphConnector) restoreMessages(dc DataCollection) error {
|
||||
|
||||
// serializeMessages: Temp Function as place Holder until Collections have been added
|
||||
// to the GraphConnector struct.
|
||||
func (gc *GraphConnector) serializeMessages(user string, dc ExchangeDataCollection) (DataCollection, error) {
|
||||
func (gc *GraphConnector) serializeMessages(user string) ([]DataCollection, error) {
|
||||
options := optionsForMailFolders([]string{})
|
||||
response, err := gc.client.UsersById(user).MailFolders().GetWithRequestConfigurationAndResponseHandler(options, nil)
|
||||
if err != nil {
|
||||
@ -216,8 +216,10 @@ func (gc *GraphConnector) serializeMessages(user string, dc ExchangeDataCollecti
|
||||
}
|
||||
// Time to create Exchange data Holder
|
||||
var byteArray []byte
|
||||
collections := make([]DataCollection, 0)
|
||||
var errs error
|
||||
for _, aFolder := range folderList {
|
||||
|
||||
result, err := gc.client.UsersById(user).MailFoldersById(aFolder).Messages().Get()
|
||||
if err != nil {
|
||||
errs = WrapAndAppend(user, err, errs)
|
||||
@ -233,6 +235,7 @@ func (gc *GraphConnector) serializeMessages(user string, dc ExchangeDataCollecti
|
||||
continue
|
||||
}
|
||||
objectWriter := kw.NewJsonSerializationWriter()
|
||||
edc := NewExchangeDataCollection(user, []string{gc.tenant, user, aFolder})
|
||||
|
||||
callbackFunc := func(messageItem interface{}) bool {
|
||||
message, ok := messageItem.(models.Messageable)
|
||||
@ -261,7 +264,7 @@ func (gc *GraphConnector) serializeMessages(user string, dc ExchangeDataCollecti
|
||||
return true
|
||||
}
|
||||
if byteArray != nil {
|
||||
dc.PopulateCollection(ExchangeData{id: *message.GetId(), message: byteArray})
|
||||
edc.PopulateCollection(ExchangeData{id: *message.GetId(), message: byteArray})
|
||||
}
|
||||
return true
|
||||
}
|
||||
@ -270,11 +273,11 @@ func (gc *GraphConnector) serializeMessages(user string, dc ExchangeDataCollecti
|
||||
if err != nil {
|
||||
errs = WrapAndAppend(user, err, errs)
|
||||
}
|
||||
|
||||
// Todo Retry Handler to be implemented
|
||||
edc.FinishPopulation()
|
||||
//fmt.Printf("Storing ExchangeDataColection with %d items\n", edc.Length())
|
||||
collections = append(collections, &edc)
|
||||
}
|
||||
fmt.Printf("Returning ExchangeDataColection with %d items\n", dc.Length())
|
||||
if errs != nil {
|
||||
fmt.Printf("Errors: \n%s\n", errs.Error())
|
||||
}
|
||||
dc.FinishPopulation()
|
||||
return &dc, errs
|
||||
return collections, errs
|
||||
}
|
||||
|
||||
@ -63,12 +63,13 @@ func (suite *GraphConnectorIntegrationSuite) TestGraphConnector_ExchangeDataColl
|
||||
if err := ctesting.RunOnAny(ctesting.CorsoCITests); err != nil {
|
||||
suite.T().Skip(err)
|
||||
}
|
||||
exchangeData, err := suite.connector.ExchangeDataCollection("lidiah@8qzvrj.onmicrosoft.com")
|
||||
assert.NotNil(suite.T(), exchangeData)
|
||||
collectionList, err := suite.connector.ExchangeDataCollection("lidiah@8qzvrj.onmicrosoft.com")
|
||||
assert.NotNil(suite.T(), collectionList)
|
||||
assert.Error(suite.T(), err) // TODO Remove after https://github.com/alcionai/corso/issues/140
|
||||
if err != nil {
|
||||
suite.T().Logf("Missing Data: %s\n", err.Error())
|
||||
}
|
||||
exchangeData := collectionList[0]
|
||||
suite.T().Logf("Full PathData: %s\n", exchangeData.FullPath())
|
||||
}
|
||||
|
||||
|
||||
@ -57,13 +57,13 @@ func (bo *BackupOperation) Run(ctx context.Context) (*kopia.BackupStats, error)
|
||||
return nil, errors.Wrap(err, "connecting to graph api")
|
||||
}
|
||||
|
||||
c, err := gc.ExchangeDataCollection(bo.Targets[0])
|
||||
cs, err := gc.ExchangeDataCollection(bo.Targets[0])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "retrieving application data")
|
||||
}
|
||||
|
||||
// todo: utilize stats
|
||||
stats, err := bo.kopia.BackupCollections(ctx, []connector.DataCollection{c})
|
||||
stats, err := bo.kopia.BackupCollections(ctx, cs)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "backing up application data")
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user