use of org.olat.collaboration.CollaborationTools in project OpenOLAT by OpenOLAT.
the class GroupWikiIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext parentResourceContext, Object businessObj, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
if (!(businessObj instanceof BusinessGroup))
throw new AssertException("businessObj must be BusinessGroup");
BusinessGroup businessGroup = (BusinessGroup) businessObj;
// Index Group Wiki
if (isLogDebugEnabled())
logDebug("Analyse Wiki for Group=" + businessGroup);
CollaborationTools collabTools = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(businessGroup);
if (collabTools.isToolEnabled(CollaborationTools.TOOL_WIKI)) {
try {
Wiki wiki = WikiManager.getInstance().getOrLoadWiki(businessGroup);
// loop over all wiki pages
List<WikiPage> wikiPageList = wiki.getAllPagesWithContent();
for (WikiPage wikiPage : wikiPageList) {
SearchResourceContext wikiResourceContext = new SearchResourceContext(parentResourceContext);
wikiResourceContext.setBusinessControlFor(BusinessGroupMainRunController.ORES_TOOLWIKI);
wikiResourceContext.setDocumentType(TYPE);
wikiResourceContext.setFilePath(wikiPage.getPageName());
Document document = WikiPageDocument.createDocument(wikiResourceContext, wikiPage);
indexWriter.addDocument(document);
}
} catch (NullPointerException nex) {
logWarn("NullPointerException in GroupWikiIndexer.doIndex.", nex);
}
} else {
if (isLogDebugEnabled())
logDebug("Group=" + businessGroup + " has no Wiki.");
}
}
use of org.olat.collaboration.CollaborationTools in project OpenOLAT by OpenOLAT.
the class BusinessGroupImportExportTest method importLearningGroupsWithResource.
@Test
public void importLearningGroupsWithResource() throws URISyntaxException {
RepositoryEntry resource = JunitTestHelper.createAndPersistRepositoryEntry();
URL input = BusinessGroupImportExportTest.class.getResource("learninggroupexport_2.xml");
File importXml = new File(input.toURI());
businessGroupService.importGroups(resource, importXml);
dbInstance.commitAndCloseSession();
// check if all three groups are imported
List<BusinessGroup> groups = businessGroupService.findBusinessGroups(null, resource, 0, -1);
Assert.assertNotNull(groups);
Assert.assertEquals(3, groups.size());
// get first group (members true, true, false) (no collaboration tools)
SearchBusinessGroupParams params = new SearchBusinessGroupParams();
params.setExactName("Export group 1");
List<BusinessGroup> group1List = businessGroupService.findBusinessGroups(params, resource, 0, -1);
Assert.assertNotNull(group1List);
Assert.assertEquals(1, group1List.size());
// check settings of the first group
BusinessGroup group1 = group1List.get(0);
Assert.assertEquals("Export group 1", group1.getName());
Assert.assertEquals("<p>Export group 1</p>", group1.getDescription());
Assert.assertFalse(group1.getAutoCloseRanksEnabled().booleanValue());
Assert.assertFalse(group1.getWaitingListEnabled().booleanValue());
// check display members settings
Assert.assertTrue(group1.isOwnersVisibleIntern());
Assert.assertTrue(group1.isParticipantsVisibleIntern());
Assert.assertFalse(group1.isWaitingListVisibleIntern());
// check collaboration tools
CollaborationTools toolGroup1 = CollaborationToolsFactory.getInstance().getCollaborationToolsIfExists(group1);
Assert.assertNotNull(toolGroup1);
Assert.assertFalse(toolGroup1.isToolEnabled(CollaborationTools.TOOL_CALENDAR));
Assert.assertFalse(toolGroup1.isToolEnabled(CollaborationTools.TOOL_CHAT));
Assert.assertFalse(toolGroup1.isToolEnabled(CollaborationTools.TOOL_CONTACT));
Assert.assertFalse(toolGroup1.isToolEnabled(CollaborationTools.TOOL_FOLDER));
Assert.assertFalse(toolGroup1.isToolEnabled(CollaborationTools.TOOL_FORUM));
Assert.assertFalse(toolGroup1.isToolEnabled(CollaborationTools.TOOL_NEWS));
Assert.assertFalse(toolGroup1.isToolEnabled(CollaborationTools.TOOL_PORTFOLIO));
Assert.assertFalse(toolGroup1.isToolEnabled(CollaborationTools.TOOL_WIKI));
// get third group (members true, true, true) (all collaboration tools)
params.setExactName("Export group 3");
List<BusinessGroup> group3List = businessGroupService.findBusinessGroups(params, resource, 0, -1);
Assert.assertNotNull(group3List);
Assert.assertEquals(1, group3List.size());
// check settings of the first group
BusinessGroup group3 = group3List.get(0);
Assert.assertEquals("Export group 3", group3.getName());
Assert.assertEquals("<p>Export group 2</p>", group3.getDescription());
Assert.assertFalse(group3.getAutoCloseRanksEnabled().booleanValue());
Assert.assertTrue(group3.getWaitingListEnabled().booleanValue());
Assert.assertEquals(new Integer(25), group3.getMaxParticipants());
// check display members settings
Assert.assertTrue(group3.isOwnersVisibleIntern());
Assert.assertTrue(group3.isParticipantsVisibleIntern());
Assert.assertTrue(group3.isWaitingListVisibleIntern());
// check collaboration tools
CollaborationTools toolGroup3 = CollaborationToolsFactory.getInstance().getCollaborationToolsIfExists(group3);
Assert.assertNotNull(toolGroup3);
Assert.assertTrue(toolGroup3.isToolEnabled(CollaborationTools.TOOL_CALENDAR));
// Assert.assertTrue(toolGroup3.isToolEnabled(CollaborationTools.TOOL_CHAT)); chat is not enabled during unit tests
Assert.assertTrue(toolGroup3.isToolEnabled(CollaborationTools.TOOL_CONTACT));
Assert.assertTrue(toolGroup3.isToolEnabled(CollaborationTools.TOOL_FOLDER));
Assert.assertTrue(toolGroup3.isToolEnabled(CollaborationTools.TOOL_FORUM));
Assert.assertTrue(toolGroup3.isToolEnabled(CollaborationTools.TOOL_NEWS));
Assert.assertTrue(toolGroup3.isToolEnabled(CollaborationTools.TOOL_PORTFOLIO));
Assert.assertTrue(toolGroup3.isToolEnabled(CollaborationTools.TOOL_WIKI));
Assert.assertEquals("<p>Hello Mitglied</p>", toolGroup3.lookupNews());
}
use of org.olat.collaboration.CollaborationTools in project OpenOLAT by OpenOLAT.
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.collaboration.CollaborationTools in project OpenOLAT by OpenOLAT.
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());
}
use of org.olat.collaboration.CollaborationTools in project OpenOLAT by OpenOLAT.
the class LearningGroupWebService method deleteNews.
/**
* Deletes the news of the group if the news tool is enabled.
* @response.representation.200.doc The news are deleted
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @response.representation.404.doc The business group cannot be found or hte news tool is not enabled
* @param groupKey The key of the group
* @param request The HTTP request
* @return
*/
@DELETE
@Path("{groupKey}/news")
public Response deleteNews(@PathParam("groupKey") Long groupKey, @Context HttpServletRequest request) {
BusinessGroup bg = CoreSpringFactory.getImpl(BusinessGroupService.class).loadBusinessGroup(groupKey);
if (bg == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
if (!isGroupManager(request)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
CollaborationTools tools = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(bg);
if (tools.isToolEnabled(CollaborationTools.TOOL_NEWS)) {
tools.saveNews(null);
return Response.ok().build();
} else {
return Response.serverError().status(Status.NOT_FOUND).build();
}
}
Aggregations