use of org.olat.core.commons.services.notifications.PublisherData in project OpenOLAT by OpenOLAT.
the class GTAManagerImpl method getPublisherData.
@Override
public PublisherData getPublisherData(CourseEnvironment courseEnv, GTACourseNode cNode) {
RepositoryEntry re = courseEnv.getCourseGroupManager().getCourseEntry();
String businessPath = "[RepositoryEntry:" + re.getKey() + "][CourseNode:" + cNode.getIdent() + "]";
return new PublisherData("GroupTask", "", businessPath);
}
use of org.olat.core.commons.services.notifications.PublisherData in project OpenOLAT by OpenOLAT.
the class BCCourseNodeEditForm method updatePublisher.
private void updatePublisher(VFSContainer container) {
File realFile = VFSManager.getRealFile(container);
String relPath = new File(FolderConfig.getCanonicalRoot()).toPath().relativize(realFile.toPath()).toString();
NotificationsManager notifManager = NotificationsManager.getInstance();
SubscriptionContext nodefolderSubContext = CourseModule.createSubscriptionContext(course.getCourseEnvironment(), node);
Publisher publisher = notifManager.getPublisher(nodefolderSubContext);
if (publisher != null) {
String businessPath = getWindowControl().getBusinessControl().getAsString();
String data = "/" + relPath;
PublisherData pdata = new PublisherData(OresHelper.calculateTypeName(BCCourseNode.class), data, businessPath);
notifManager.updatePublisherData(nodefolderSubContext, pdata);
}
}
use of org.olat.core.commons.services.notifications.PublisherData in project openolat by klemens.
the class UsersSubscriptionManagerImpl method getNewUsersPublisherData.
public PublisherData getNewUsersPublisherData() {
ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(new OLATResourceable() {
@Override
public Long getResourceableId() {
return 0l;
}
@Override
public String getResourceableTypeName() {
return "NewIdentityCreated";
}
});
PublisherData publisherData = new PublisherData(RES_NAME, NEW, ce.toString());
return publisherData;
}
use of org.olat.core.commons.services.notifications.PublisherData in project openolat by klemens.
the class NotificationsTest method testGetBusinessGroupFolderNotifications.
@Test
public void testGetBusinessGroupFolderNotifications() throws IOException, URISyntaxException {
// create a business group with folder notifications
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("rest-not-5-" + UUID.randomUUID().toString());
BusinessGroup group = businessGroupService.createBusinessGroup(id, "Notifications 2", "REST folder notifications for group", null, null, false, false, null);
CollaborationTools tools = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(group);
tools.setToolEnabled(CollaborationTools.TOOL_FOLDER, true);
String relPath = tools.getFolderRelPath();
dbInstance.commitAndCloseSession();
// publish
String businessPath = "[BusinessGroup:" + group.getKey() + "][toolfolder:0]";
SubscriptionContext folderSubContext = new SubscriptionContext("BusinessGroup", group.getKey(), "toolfolder");
PublisherData folderPdata = new PublisherData("FolderModule", relPath, businessPath);
notificationManager.subscribe(id, folderSubContext, folderPdata);
// add a file
OlatRootFolderImpl folder = tools.getSecuredFolder(group, folderSubContext, id, true);
String filename = addFile(folder);
// mark as published
notificationManager.markPublisherNews(folderSubContext, null, true);
dbInstance.commitAndCloseSession();
// get the notification
RestConnection conn = new RestConnection();
assertTrue(conn.login(id.getName(), "A6B7C8"));
UriBuilder request = UriBuilder.fromUri(getContextURI()).path("notifications");
HttpGet method = conn.createGet(request.build(), MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
List<SubscriptionInfoVO> infos = parseUserArray(response.getEntity().getContent());
Assert.assertNotNull(infos);
Assert.assertEquals(1, infos.size());
SubscriptionInfoVO infoVO = infos.get(0);
Assert.assertNotNull(infoVO.getItems());
Assert.assertEquals(1, infoVO.getItems().size());
SubscriptionListItemVO itemVO = infoVO.getItems().get(0);
Assert.assertNotNull(itemVO);
Assert.assertEquals(group.getKey(), itemVO.getGroupKey());
Assert.assertEquals("/" + filename, itemVO.getPath());
}
use of org.olat.core.commons.services.notifications.PublisherData in project openolat by klemens.
the class NotificationsTest method testGetBusinessGroupForumNotifications.
@Test
public void testGetBusinessGroupForumNotifications() throws IOException, URISyntaxException {
// create a business group with forum notifications
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("rest-not-4-" + UUID.randomUUID().toString());
BusinessGroup group = businessGroupService.createBusinessGroup(id, "Notifications 1", "REST forum notifications for group", null, null, false, false, null);
CollaborationTools tools = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(group);
tools.setToolEnabled(CollaborationTools.TOOL_FORUM, true);
Forum groupForum = tools.getForum();
dbInstance.commitAndCloseSession();
// publish
String businessPath = "[BusinessGroup:" + group.getKey() + "][toolforum:0]";
SubscriptionContext forumSubContext = new SubscriptionContext("BusinessGroup", group.getKey(), "toolforum");
PublisherData forumPdata = new PublisherData(OresHelper.calculateTypeName(Forum.class), groupForum.getKey().toString(), businessPath);
notificationManager.subscribe(id, forumSubContext, forumPdata);
Message message = createMessage(id, groupForum);
notificationManager.markPublisherNews(forumSubContext, null, true);
dbInstance.commitAndCloseSession();
// get the notification
RestConnection conn = new RestConnection();
assertTrue(conn.login(id.getName(), "A6B7C8"));
UriBuilder request = UriBuilder.fromUri(getContextURI()).path("notifications");
HttpGet method = conn.createGet(request.build(), MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
List<SubscriptionInfoVO> infos = parseUserArray(response.getEntity().getContent());
Assert.assertNotNull(infos);
Assert.assertEquals(1, infos.size());
SubscriptionInfoVO infoVO = infos.get(0);
Assert.assertNotNull(infoVO.getItems());
Assert.assertEquals(1, infoVO.getItems().size());
SubscriptionListItemVO itemVO = infoVO.getItems().get(0);
Assert.assertNotNull(itemVO);
Assert.assertEquals(group.getKey(), itemVO.getGroupKey());
Assert.assertEquals(message.getKey(), itemVO.getMessageKey());
}
Aggregations