Search in sources :

Example 81 with CollaborationTools

use of org.olat.collaboration.CollaborationTools in project openolat by klemens.

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());
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) CollaborationTools(org.olat.collaboration.CollaborationTools) RepositoryEntry(org.olat.repository.RepositoryEntry) File(java.io.File) URL(java.net.URL) SearchBusinessGroupParams(org.olat.group.model.SearchBusinessGroupParams) Test(org.junit.Test)

Example 82 with CollaborationTools

use of org.olat.collaboration.CollaborationTools in project openolat by klemens.

the class BusinessGroupServiceTest method testEnableDisableAndCheckForTool.

/**
 * checks if tools can be enabled disabled or checked against being enabled.
 * TOols are configured with the help of the generic properties storage.
 *
 * @throws Exception
 */
@Test
public void testEnableDisableAndCheckForTool() throws Exception {
    Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("coll-tools");
    BusinessGroup found = businessGroupService.createBusinessGroup(coach, "Collaboration", "Collaboration", -1, -1, false, false, null);
    dbInstance.commitAndCloseSession();
    CollaborationTools myCTSMngr = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(found);
    String[] availableTools = CollaborationToolsFactory.getInstance().getAvailableTools().clone();
    for (int i = 0; i < availableTools.length; i++) {
        String msg = "Tool " + availableTools[i] + " is enabled";
        boolean enabled = myCTSMngr.isToolEnabled(availableTools[i]);
        // all tools are disabled by default exept the news tool
        assertTrue(msg, !enabled);
    }
    for (int i = 0; i < availableTools.length; i++) {
        myCTSMngr.setToolEnabled(availableTools[i], true);
    }
    for (int i = 0; i < availableTools.length; i++) {
        String msg = "Tool " + availableTools[i] + " is enabled";
        boolean enabled = myCTSMngr.isToolEnabled(availableTools[i]);
        assertTrue(msg, enabled);
    }
    for (int i = 0; i < availableTools.length; i++) {
        myCTSMngr.setToolEnabled(availableTools[i], false);
    }
    for (int i = 0; i < availableTools.length; i++) {
        String msg = "Tool " + availableTools[i] + " is disabled";
        boolean enabled = myCTSMngr.isToolEnabled(availableTools[i]);
        assertTrue(msg, !enabled);
    }
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) CollaborationTools(org.olat.collaboration.CollaborationTools) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 83 with CollaborationTools

use of org.olat.collaboration.CollaborationTools in project openolat by klemens.

the class CourseGroupWebService method getFolder.

@Path("{groupKey}/folder")
public VFSWebservice getFolder(@PathParam("groupKey") Long groupKey, @Context HttpServletRequest request) {
    BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
    BusinessGroup bg = bgs.loadBusinessGroup(groupKey);
    if (bg == null) {
        return null;
    }
    if (!isGroupManager(request)) {
        Identity identity = RestSecurityHelper.getIdentity(request);
        if (!bgs.isIdentityInBusinessGroup(identity, bg)) {
            return null;
        }
    }
    CollaborationTools collabTools = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(bg);
    if (!collabTools.isToolEnabled(CollaborationTools.TOOL_FOLDER)) {
        return null;
    }
    String relPath = collabTools.getFolderRelPath();
    QuotaManager qm = QuotaManager.getInstance();
    Quota folderQuota = qm.getCustomQuota(relPath);
    if (folderQuota == null) {
        Quota defQuota = qm.getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_GROUPS);
        folderQuota = QuotaManager.getInstance().createQuota(relPath, defQuota.getQuotaKB(), defQuota.getUlLimitKB());
    }
    SubscriptionContext subsContext = null;
    VFSWebServiceSecurityCallback secCallback = new VFSWebServiceSecurityCallback(true, true, true, folderQuota, subsContext);
    OlatRootFolderImpl rootContainer = new OlatRootFolderImpl(relPath, null);
    rootContainer.setLocalSecurityCallback(secCallback);
    return new VFSWebservice(rootContainer);
}
Also used : VFSWebServiceSecurityCallback(org.olat.core.util.vfs.restapi.VFSWebServiceSecurityCallback) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) Quota(org.olat.core.util.vfs.Quota) BusinessGroupService(org.olat.group.BusinessGroupService) BusinessGroup(org.olat.group.BusinessGroup) CollaborationTools(org.olat.collaboration.CollaborationTools) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) Identity(org.olat.core.id.Identity) QuotaManager(org.olat.core.util.vfs.QuotaManager) VFSWebservice(org.olat.core.util.vfs.restapi.VFSWebservice) Path(javax.ws.rs.Path)

Example 84 with CollaborationTools

use of org.olat.collaboration.CollaborationTools in project openolat by klemens.

the class LearningGroupWebService method getForum.

/**
 * Return the Forum web service
 * @param groupKey The key of the group
 * @param request The HTTP Request
 * @return
 */
@Path("{groupKey}/forum")
public ForumWebService getForum(@PathParam("groupKey") Long groupKey, @Context HttpServletRequest request) {
    BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
    BusinessGroup bg = CoreSpringFactory.getImpl(BusinessGroupService.class).loadBusinessGroup(groupKey);
    if (bg == null) {
        return null;
    }
    if (!isGroupManager(request)) {
        Identity identity = RestSecurityHelper.getIdentity(request);
        if (!bgs.isIdentityInBusinessGroup(identity, bg)) {
            return null;
        }
    }
    CollaborationTools collabTools = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(bg);
    if (collabTools.isToolEnabled(CollaborationTools.TOOL_FORUM)) {
        Forum forum = collabTools.getForum();
        return new ForumWebService(forum);
    }
    return null;
}
Also used : BusinessGroupService(org.olat.group.BusinessGroupService) BusinessGroup(org.olat.group.BusinessGroup) ForumWebService(org.olat.modules.fo.restapi.ForumWebService) CollaborationTools(org.olat.collaboration.CollaborationTools) Identity(org.olat.core.id.Identity) Forum(org.olat.modules.fo.Forum) Path(javax.ws.rs.Path)

Example 85 with CollaborationTools

use of org.olat.collaboration.CollaborationTools in project openolat by klemens.

the class LearningGroupWebService method getWiki.

/**
 * Return the Forum web service
 * @param groupKey The key of the group
 * @param request The HTTP Request
 * @return
 */
@Path("{groupKey}/wiki")
public GroupWikiWebService getWiki(@PathParam("groupKey") Long groupKey, @Context HttpServletRequest request) {
    BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
    BusinessGroup bg = bgs.loadBusinessGroup(groupKey);
    if (bg == null) {
        return null;
    }
    if (!isGroupManager(request)) {
        Identity identity = RestSecurityHelper.getIdentity(request);
        if (!bgs.isIdentityInBusinessGroup(identity, bg)) {
            return null;
        }
    }
    CollaborationTools collabTools = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(bg);
    if (collabTools.isToolEnabled(CollaborationTools.TOOL_WIKI)) {
        return new GroupWikiWebService(bg);
    }
    return null;
}
Also used : BusinessGroupService(org.olat.group.BusinessGroupService) BusinessGroup(org.olat.group.BusinessGroup) GroupWikiWebService(org.olat.modules.wiki.restapi.GroupWikiWebService) CollaborationTools(org.olat.collaboration.CollaborationTools) Identity(org.olat.core.id.Identity) Path(javax.ws.rs.Path)

Aggregations

CollaborationTools (org.olat.collaboration.CollaborationTools)98 BusinessGroup (org.olat.group.BusinessGroup)58 Identity (org.olat.core.id.Identity)30 Test (org.junit.Test)28 HttpResponse (org.apache.http.HttpResponse)22 BusinessGroupService (org.olat.group.BusinessGroupService)22 Path (javax.ws.rs.Path)18 WindowControl (org.olat.core.gui.control.WindowControl)18 URI (java.net.URI)16 HttpGet (org.apache.http.client.methods.HttpGet)16 ContextEntry (org.olat.core.id.context.ContextEntry)16 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)14 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)14 Forum (org.olat.modules.fo.Forum)12 Activateable2 (org.olat.core.gui.control.generic.dtabs.Activateable2)10 RepositoryEntry (org.olat.repository.RepositoryEntry)10 IOException (java.io.IOException)8 VFSContainer (org.olat.core.util.vfs.VFSContainer)8 InputStream (java.io.InputStream)7 ArrayList (java.util.ArrayList)6