microsoftgraph / microsoftgraph/msgraph-sdk-java

How to restore a Deleted Calendar Event Using Graph API

未關閉
#2,561 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

status:waiting-for-triage
主要語言
Java
星號
444
分支
154
平均合併
18 小時 28 分鐘
30 天內合併 PR
4

描述

Context
We are currently migrating functionality from EWS to Microsoft Graph API (Java). We have a requirement to delete and then programmatically restore calendar events. While our EWS implementation works perfectly, we are struggling to locate the deleted events using the Graph API.

Current EWS Implementation (Working)
In EWS, we use DeleteMode.HardDelete and then search the RecoverableItemsPurges folder to move the item back to the Calendar.

// How we delete meeting from calendar
if (msg instanceof MeetingMessage) {
    MeetingMessage meetingMessage = MeetingMessage.bind(service, msg.getId());
    ItemId masterId = meetingMessage.getAssociatedAppointmentId();
    if (masterId != null) {
        Appointment appointment = Appointment.bind(service, masterId);
        appointment.delete(DeleteMode.HardDelete);
    }
}

// How we restore the message
ItemView itemView = new ItemView(EwsServer.FOLDER_VIEW_PAGE_SIZE);
itemView.setTraversal(ItemTraversal.Shallow);

SearchFilter filterColl = new SearchFilter.SearchFilterCollection(
    LogicalOperator.And, 
    new SearchFilter.IsEqualTo(ItemSchema.Subject, message.getSubject()),
    new SearchFilter.IsEqualTo(EmailMessageSchema.Sender, message.getSender().getAddress())
);

FindItemsResults<Item> deletedItems = server.getExchangeService()
    .findItems(WellKnownFolderName.RecoverableItemsPurges, filterColl, itemView);

if (deletedItems.getItems().size() > 0) {
    for (Item item : deletedItems.getItems()) {
        item.move(WellKnownFolderName.Calendar);
        break;
    }
}

Problem: Graph API Implementation (Not Working)
When using the Graph SDK, we cannot find the event in the recoverable items folders after a deletion.

Deletion code:

graphClient.users().byUserId(mailboxBeingScanned)
    .calendar().events().byEventId(eventId)
    .permanentDelete().post();
//we have tried delete method as this as well
graphClient.users().byUserId(mailboxBeingScanned)
    .calendar().events().byEventId(eventId)
    .delete();

Attempted recovery code:
We have tried searching recoverableitemspurges, deleteditems, and recoverableitemsdeletions using the internetMessageId, but the collection always returns empty.

MessageCollectionResponse eventMessage = graphClient.users().byUserId(mailboxBeingScanned)
    .mailFolders().byMailFolderId("recoverableitemspurges")
    .messages()
    .get(requestConfiguration -> {
        requestConfiguration.queryParameters.filter = "internetMessageId eq '<MN2PR13...prod.outlook.com>'";
    });

Questions

  1. When using permanentDelete() on a Calendar Event in Graph, does it land in a different folder than it would via EWS?

  2. What is the correct mailFolderId or endpoint to query for items in the "Recoverable Items" partition specifically for Calendar events?

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 Graph SDK Java 刪除呼叫以及 issue 中顯示的 mailFolders/messages 復原查詢開始。確認 permanentDelete() 和 delete() 是否會將行事曆事件放在不同的位置,找出正確的 Recoverable Items 端點或資料夾 ID,並驗證是否可以找到該事件以進行復原。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
java
領域
api
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
冷清
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。