microsoftgraph / microsoftgraph/msgraph-sdk-java
How to restore a Deleted Calendar Event Using Graph API
还没有人认领这个 Issue。
- 主要语言
- 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
-
When using permanentDelete() on a Calendar Event in Graph, does it land in a different folder than it would via EWS?
-
What is the correct mailFolderId or endpoint to query for items in the "Recoverable Items" partition specifically for Calendar events?
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 Graph SDK Java 删除调用以及 issue 中显示的 mailFolders/messages 恢复查询开始。确定 permanentDelete() 和 delete() 是否会将日历事件放置在不同的位置,识别正确的 Recoverable Items 端点或文件夹 ID,并验证是否可以找到该事件以进行恢复。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- java
- 领域
- api
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100