From 61ec64b4373756f8e14e9902714fc8f12574002b Mon Sep 17 00:00:00 2001
From: oshahid
Date: Mon, 16 Nov 2026 19:19:50 +0530
Subject: [PATCH 1/9] feat: add support for linking OneDrive, Teams, and
SharePoint folders to topics
---
.../collaboration/BrainTopicChangeUtils.java | 10 +-
src/prerna/collaboration/BrainTopicLinks.java | 244 ++++++++++++++++++
src/prerna/collaboration/BrainTopicUtils.java | 6 +-
.../collaboration/CollaborationDbUtils.java | 4 +
.../CollaborationOwlCreator.java | 15 ++
5 files changed, 276 insertions(+), 3 deletions(-)
create mode 100644 src/prerna/collaboration/BrainTopicLinks.java
diff --git a/src/prerna/collaboration/BrainTopicChangeUtils.java b/src/prerna/collaboration/BrainTopicChangeUtils.java
index c1b11e78ba..a410ffbe1a 100644
--- a/src/prerna/collaboration/BrainTopicChangeUtils.java
+++ b/src/prerna/collaboration/BrainTopicChangeUtils.java
@@ -77,6 +77,8 @@ public final class BrainTopicChangeUtils {
private static final String FOLDER_TOPIC = "BRAIN_TOPIC_FOLDER";
// OneDrive and Teams files linked to the topics; likewise only when there are some
private static final String FILE_TOPIC = "BRAIN_TOPIC_FILE";
+ // OneDrive, Teams and SharePoint folders linked to the topics
+ private static final String LINK_TOPIC = "BRAIN_TOPIC_LINK";
// work items linked to the topics; likewise only when there are some
private static final String TASK_TOPIC = "WORK_TASK_TOPIC";
// memories linked to the topics, keyed by memory: the rows and every link they have
@@ -255,7 +257,7 @@ private static Map undoInReview(User user, String changeId) {
+ CollaborationDbUtils.placeholders(topicIds.size()) + ")",
params(ownerId, ownerType, topicIds));
}
- for (String table : List.of(ROOM_TOPIC, FOLDER_TOPIC, TASK_TOPIC, FILE_TOPIC)) {
+ for (String table : List.of(ROOM_TOPIC, FOLDER_TOPIC, TASK_TOPIC, FILE_TOPIC, LINK_TOPIC)) {
CollaborationDbUtils.update(conn,
"DELETE FROM " + table + OWNED + " AND TOPIC_ID IN ("
+ CollaborationDbUtils.placeholders(topicIds.size()) + ")",
@@ -355,6 +357,12 @@ private static Map>> scopeRows(Connection conn,
if (!files.isEmpty()) {
rows.put(FILE_TOPIC, files);
}
+ List
*
*
@@ -968,9 +981,9 @@ public boolean alreadyTold() {
*
* @param accessToken Microsoft Graph access token for the user
* @param copy the local copy to upload
- * @param informed whether the owner asked for this save themselves, which
- * is what lets it write over a change they were already
- * told about; a save nobody asked for never does
+ * @param informed whether the owner asked for this save themselves, which is
+ * what lets it write over a change they were already told
+ * about; a save nobody asked for never does
* @return the file as OneDrive now holds it
* @throws SaveBackRefused if the file is not a recorded copy, or its original
* is gone or has changed
@@ -1325,8 +1338,8 @@ private static long downloadBytes(String accessToken, Map item,
*
*
* @param url what to fetch
- * @param headers the request headers, or null for a url that is pre-authenticated,
- * which a failure then does not quote
+ * @param headers the request headers, or null for a url that is
+ * pre-authenticated, which a failure then does not quote
* @param file where the bytes go, in a folder that exists
* @param name what a refusal calls the file
* @return how many bytes were written; the file is left as it was when there
@@ -1446,11 +1459,11 @@ private static String sessionUpload(String accessToken, String driveId, String i
/**
* Sends a file to an upload session in pieces, for whichever helper opened the
- * session. A session whose upload fails is cancelled: while one is open OneDrive
- * answers every other upload of the same file with a 409, "currently being
- * uploaded", for a quarter of an hour or so, which is how one refusal of a file
- * open in Office became many. The failure does not quote the session's url,
- * which is what signs its requests.
+ * session. A session whose upload fails is cancelled: while one is open
+ * OneDrive answers every other upload of the same file with a 409, "currently
+ * being uploaded", for a quarter of an hour or so, which is how one refusal of
+ * a file open in Office became many. The failure does not quote the session's
+ * url, which is what signs its requests.
*
* @param uploadUrl the url the session answered with
* @param file the file to send
@@ -1488,7 +1501,8 @@ public static String sendToUploadSession(String uploadUrl, File file, String fil
try {
HttpHelperUtility.deleteRequestStringBody(uploadUrl, null, null, null, null);
} catch (Exception notCancelled) {
- // the url is what signs the request, so the failure, which quotes it, is not logged
+ // the url is what signs the request, so the failure, which quotes it, is not
+ // logged
classLogger.warn("Could not cancel the upload session of {}; Graph refuses another upload of that "
+ "file until the session expires", fileName);
}
@@ -1507,8 +1521,10 @@ public static String sendToUploadSession(String uploadUrl, File file, String fil
* @return the failure itself when it does not quote the url, or one that says
* the same without it
*/
- // shortcut: HttpHelperUtility logs the url itself when the connection drops, before it throws;
- // have it leave query strings out of its own lines once that has to be closed too
+ // shortcut: HttpHelperUtility logs the url itself when the connection drops,
+ // before it throws;
+ // have it leave query strings out of its own lines once that has to be closed
+ // too
private static Exception withoutUrl(Exception e, String url, String what) {
String why = e.getMessage();
if (why == null || !why.contains(url)) {
@@ -1585,11 +1601,11 @@ private static void remember(File copy, String driveId, String itemId, String ve
* @param itemId the folder the upload names, or null
* @param folderPath the folder path the upload names, or null
* @param fileName the name the upload gives the file
- * @return true when the local file is a recorded copy and the upload names
- * its original, or names nowhere else to go
+ * @return true when the local file is a recorded copy and the upload names its
+ * original, or names nowhere else to go
*/
- private static boolean isOriginal(String accessToken, File copy, String driveId, String itemId,
- String folderPath, String fileName) throws Exception {
+ private static boolean isOriginal(String accessToken, File copy, String driveId, String itemId, String folderPath,
+ String fileName) throws Exception {
MicrosoftOneDriveSources.Source source = MicrosoftOneDriveSources.read(copy);
if (source == null) {
return false;
@@ -1994,4 +2010,18 @@ public static Map getItemFixture(String driveId, String itemId)
return MicrosoftOneDriveItemMapper.toDriveItem(item, driveId);
}
-}
+ public static String getFileContentFixture(String driveId, String itemId) throws Exception {
+ String fixturePath = fixturePath();
+ if (fixturePath == null) {
+ throw new IllegalStateException("Fixture mode is not enabled. Set " + FIXTURE_SETTING
+ + " environment variable or DI property and ensure onedrive-m365.json exists next to mail.json.");
+ }
+ OneDriveFixtureSource source = OneDriveFixtureSource.of(fixturePath);
+ String content = source.getFileContent(driveId, itemId);
+ if (content == null) {
+ throw new IllegalStateException(
+ "No content found for item in fixture data for drive = " + driveId + ", item = " + itemId);
+ }
+ return content;
+ }
+}
\ No newline at end of file
From c9d9756a10873cdf241edd860100cdd494ae16a8 Mon Sep 17 00:00:00 2001
From: oshahid
Date: Tue, 24 Nov 2026 16:30:23 +0530
Subject: [PATCH 8/9] feat: enhance description of linked Microsoft 365 folders
in BrainTopicBrief
---
src/prerna/collaboration/BrainTopicBrief.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/prerna/collaboration/BrainTopicBrief.java b/src/prerna/collaboration/BrainTopicBrief.java
index 3b7706f739..84f268732c 100644
--- a/src/prerna/collaboration/BrainTopicBrief.java
+++ b/src/prerna/collaboration/BrainTopicBrief.java
@@ -253,7 +253,8 @@ private static String linkedFoldersBrief(String ownerId, String ownerType, Strin
return "";
}
StringBuilder out = new StringBuilder(
- "\nLinked Microsoft 365 folders: the agent lists and reads files from these by default. "
+ "\nLinked Microsoft 365 folders: the owner linked these to this topic because they contain "
+ + "relevant files for this topic's work. The agent lists and reads files from these by default. "
+ "To list files, call ListDriveFiles for a OneDrive link, or ListChannelFiles for Teams. "
+ "Availability is marked 'ok' or 'unavailable' (access lost):");
for (Map link : links.subList(0, Math.min(links.size(), MAX_ITEMS))) {
From e26fe97426b0624e908ac4347adbd03cfa05622b Mon Sep 17 00:00:00 2001
From: oshahid
Date: Thu, 26 Nov 2026 14:16:05 +0530
Subject: [PATCH 9/9] feat: add import for Path in MicrosoftTeamsHelper
---
src/prerna/io/connector/ms/teams/MicrosoftTeamsHelper.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/prerna/io/connector/ms/teams/MicrosoftTeamsHelper.java b/src/prerna/io/connector/ms/teams/MicrosoftTeamsHelper.java
index 83a29252ab..df3cb477d4 100644
--- a/src/prerna/io/connector/ms/teams/MicrosoftTeamsHelper.java
+++ b/src/prerna/io/connector/ms/teams/MicrosoftTeamsHelper.java
@@ -32,6 +32,7 @@
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
+import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;