Search in sources :

Example 26 with CollaborationTools

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

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.");
    }
}
Also used : AssertException(org.olat.core.logging.AssertException) BusinessGroup(org.olat.group.BusinessGroup) SearchResourceContext(org.olat.search.service.SearchResourceContext) WikiPage(org.olat.modules.wiki.WikiPage) CollaborationTools(org.olat.collaboration.CollaborationTools) Wiki(org.olat.modules.wiki.Wiki) WikiPageDocument(org.olat.search.service.document.WikiPageDocument) Document(org.apache.lucene.document.Document)

Example 27 with CollaborationTools

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

the class CourseGroupWebService 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 = 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_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 28 with CollaborationTools

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

the class LearningGroupWebService 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;
    VFSSecurityCallback 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) VFSSecurityCallback(org.olat.core.util.vfs.callbacks.VFSSecurityCallback) VFSWebservice(org.olat.core.util.vfs.restapi.VFSWebservice) Path(javax.ws.rs.Path)

Example 29 with CollaborationTools

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

the class LearningGroupWebService method getNews.

/**
 * Returns the  news.
 *
 * @response.representation.401.doc The roles of the authenticated user are not sufficient
 * @response.representation.404.doc The business group cannot be found or the news tool is not enabled
 * @param groupKey The key of the group
 * @param request The HTTP Request
 * @return
 */
@GET
@Path("{groupKey}/news")
@Produces({ MediaType.TEXT_PLAIN })
public Response getNews(@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 Response.serverError().status(Status.NOT_FOUND).build();
    }
    if (!isGroupManager(request)) {
        Identity identity = RestSecurityHelper.getIdentity(request);
        if (!bgs.isIdentityInBusinessGroup(identity, bg)) {
            return Response.serverError().status(Status.UNAUTHORIZED).build();
        }
    }
    CollaborationTools tools = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(bg);
    if (tools.isToolEnabled(CollaborationTools.TOOL_NEWS)) {
        String news = tools.lookupNews();
        if (news == null) {
            return Response.serverError().status(Status.NOT_FOUND).build();
        }
        return Response.ok(news).build();
    } else {
        return Response.serverError().status(Status.NOT_FOUND).build();
    }
}
Also used : BusinessGroupService(org.olat.group.BusinessGroupService) BusinessGroup(org.olat.group.BusinessGroup) CollaborationTools(org.olat.collaboration.CollaborationTools) Identity(org.olat.core.id.Identity) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 30 with CollaborationTools

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

the class LearningGroupWebService method postNews.

/**
 * Update the news.
 *
 * @response.representation.401.doc The roles of the authenticated user are not sufficient
 * @response.representation.404.doc The business group cannot be found or the news tool is not enabled
 * @param groupKey The key of the group
 * @param news The news
 * @param request The HTTP request
 * @return
 */
@POST
@Path("{groupKey}/news")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Response postNews(@PathParam("groupKey") Long groupKey, @FormParam("news") String news, @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(news);
        return Response.ok(news).build();
    } else {
        return Response.serverError().status(Status.NOT_FOUND).build();
    }
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) BusinessGroupService(org.olat.group.BusinessGroupService) CollaborationTools(org.olat.collaboration.CollaborationTools) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes)

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