diff --git a/OpenChange/MAPIStoreContext.m b/OpenChange/MAPIStoreContext.m index f4170a6f7..d67205bef 100644 --- a/OpenChange/MAPIStoreContext.m +++ b/OpenChange/MAPIStoreContext.m @@ -494,8 +494,11 @@ static inline NSURL *CompleteURLFromMapistoreURI (const char *uri) mappingId = [mapping idFromURL: childURL]; if (mappingId == NSNotFound) { + const char *owner; + [self logWithFormat: @"No id exist yet for '%@', requesting one", childURL]; - ret = mapistore_indexing_get_new_folderID (connInfo->mstore_ctx, &mappingId); + owner = [[userContext username] UTF8String]; + ret = mapistore_indexing_get_new_folderID_as_user (connInfo->mstore_ctx, owner, &mappingId); if (ret == MAPISTORE_SUCCESS) [mapping registerURL: childURL withID: mappingId]; else @@ -544,29 +547,31 @@ static inline NSURL *CompleteURLFromMapistoreURI (const char *uri) return newChangeNumbers; } +/* Get new fmids from mapistore_indexing interface using resource's + owner user */ - (NSArray *) getNewFMIDs: (uint64_t) max { - TALLOC_CTX *memCtx; + const char *owner; + enum mapistore_error ret; NSMutableArray *newFMIDs; - uint64_t count; - struct UI8Array_r *numbers; NSString *newNumber; + uint64_t count, newFID; - memCtx = talloc_zero(NULL, TALLOC_CTX); newFMIDs = [NSMutableArray arrayWithCapacity: max]; + /* Get the resource's owner name */ + owner = [[userContext username] UTF8String]; - if (mapistore_indexing_get_new_folderIDs (connInfo->mstore_ctx, - memCtx, max, &numbers) - != MAPISTORE_SUCCESS || numbers->cValues != max) - abort (); for (count = 0; count < max; count++) { - newNumber = [NSString stringWithUnsignedLongLong: numbers->lpui8[count]]; + ret = mapistore_indexing_get_new_folderID_as_user (connInfo->mstore_ctx, owner, &newFID); + if (ret != MAPISTORE_SUCCESS) + [NSException raise: @"MAPIStoreIOException" + format: @"Impossible to get new fmid for %s", owner]; + + newNumber = [NSString stringWithUnsignedLongLong: newFID]; [newFMIDs addObject: newNumber]; } - talloc_free (memCtx); - return newFMIDs; } diff --git a/OpenChange/MAPIStoreMapping.m b/OpenChange/MAPIStoreMapping.m index b7d303ed6..2e2c9a66d 100644 --- a/OpenChange/MAPIStoreMapping.m +++ b/OpenChange/MAPIStoreMapping.m @@ -258,7 +258,7 @@ MAPIStoreMappingKeyFromId (uint64_t idNbr) if (oldURL != NULL) { [self errorWithFormat: - @"url with idNbr already registered: (oldUrl='%@', newUrl='%@', id=x%.16"PRIx64")", + @"url with idNbr already registered: (oldUrl='%@', newUrl='%@', id=0x%.16"PRIx64")", oldURL, urlString, idNbr]; return NO; } @@ -306,7 +306,7 @@ MAPIStoreMappingKeyFromId (uint64_t idNbr) } else [NSException raise: NSInvalidArgumentException - format: @"number of urls and ids do not match"]; + format: @"number of urls (%d) and ids (%d) do not match", max, [idNbrs count]]; } - (void) unregisterURLWithID: (uint64_t) idNbr