use of org.olat.modules.fo.restapi.ForumVO in project OpenOLAT by OpenOLAT.
the class UserMgmtTest method testUserForums.
@Test
public void testUserForums() throws IOException, URISyntaxException {
RestConnection conn = new RestConnection();
assertTrue(conn.login(id1.getName(), "A6B7C8"));
URI uri = UriBuilder.fromUri(getContextURI()).path("users").path(id1.getKey().toString()).path("forums").queryParam("start", 0).queryParam("limit", 20).build();
HttpGet method = conn.createGet(uri, MediaType.APPLICATION_JSON + ";pagingspec=1.0", true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
ForumVOes forums = conn.parse(response, ForumVOes.class);
assertNotNull(forums);
assertNotNull(forums.getForums());
assertTrue(forums.getForums().length > 0);
for (ForumVO forum : forums.getForums()) {
Long groupKey = forum.getGroupKey();
if (groupKey != null) {
BusinessGroup bg = businessGroupService.loadBusinessGroup(groupKey);
assertNotNull(bg);
CollaborationTools bgCTSMngr = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(bg);
assertTrue(bgCTSMngr.isToolEnabled(CollaborationTools.TOOL_FORUM));
assertNotNull(forum.getForumKey());
assertEquals(bg.getName(), forum.getName());
assertEquals(bg.getKey(), forum.getGroupKey());
assertTrue(businessGroupService.isIdentityInBusinessGroup(id1, bg));
} else {
assertNotNull(forum.getCourseKey());
}
}
conn.shutdown();
}
use of org.olat.modules.fo.restapi.ForumVO in project openolat by klemens.
the class CoursesForumsTest method testGetForumInfo.
@Test
public void testGetForumInfo() throws IOException, URISyntaxException {
boolean loggedIN = conn.login("administrator", "openolat");
assertTrue(loggedIN);
URI uri = UriBuilder.fromUri(getNodeURI()).build();
HttpGet get = conn.createGet(uri, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(get);
assertEquals(200, response.getStatusLine().getStatusCode());
ForumVO forum = conn.parse(response, ForumVO.class);
assertNotNull(forum);
}
use of org.olat.modules.fo.restapi.ForumVO in project openolat by klemens.
the class CoursesInfosWebService method collect.
private CourseInfoVO collect(final Identity identity, final Roles roles, final RepositoryEntry entry, final Set<Long> forumNotified, final Map<Long, Set<String>> courseNotified) {
CourseInfoVO info = new CourseInfoVO();
info.setRepoEntryKey(entry.getKey());
info.setSoftKey(entry.getSoftkey());
info.setDisplayName(entry.getDisplayname());
ACService acManager = CoreSpringFactory.getImpl(ACService.class);
AccessResult result = acManager.isAccessible(entry, identity, false);
if (result.isAccessible()) {
try {
final ICourse course = CourseFactory.loadCourse(entry);
final List<FolderVO> folders = new ArrayList<FolderVO>();
final List<ForumVO> forums = new ArrayList<ForumVO>();
final IdentityEnvironment ienv = new IdentityEnvironment(identity, roles);
new CourseTreeVisitor(course, ienv).visit(new Visitor() {
@Override
public void visit(INode node) {
if (node instanceof BCCourseNode) {
BCCourseNode bcNode = (BCCourseNode) node;
folders.add(BCWebService.createFolderVO(ienv, course, bcNode, courseNotified.get(course.getResourceableId())));
} else if (node instanceof FOCourseNode) {
FOCourseNode forumNode = (FOCourseNode) node;
forums.add(ForumCourseNodeWebService.createForumVO(course, forumNode, forumNotified));
}
}
}, new VisibleTreeFilter());
info.setKey(course.getResourceableId());
info.setTitle(course.getCourseTitle());
info.setFolders(folders.toArray(new FolderVO[folders.size()]));
info.setForums(forums.toArray(new ForumVO[forums.size()]));
} catch (Exception e) {
log.error("", e);
}
}
return info;
}
use of org.olat.modules.fo.restapi.ForumVO in project OpenOLAT by OpenOLAT.
the class CoursesInfosWebService method collect.
private CourseInfoVO collect(final Identity identity, final Roles roles, final RepositoryEntry entry, final Set<Long> forumNotified, final Map<Long, Set<String>> courseNotified) {
CourseInfoVO info = new CourseInfoVO();
info.setRepoEntryKey(entry.getKey());
info.setSoftKey(entry.getSoftkey());
info.setDisplayName(entry.getDisplayname());
ACService acManager = CoreSpringFactory.getImpl(ACService.class);
AccessResult result = acManager.isAccessible(entry, identity, false);
if (result.isAccessible()) {
try {
final ICourse course = CourseFactory.loadCourse(entry);
final List<FolderVO> folders = new ArrayList<FolderVO>();
final List<ForumVO> forums = new ArrayList<ForumVO>();
final IdentityEnvironment ienv = new IdentityEnvironment(identity, roles);
new CourseTreeVisitor(course, ienv).visit(new Visitor() {
@Override
public void visit(INode node) {
if (node instanceof BCCourseNode) {
BCCourseNode bcNode = (BCCourseNode) node;
folders.add(BCWebService.createFolderVO(ienv, course, bcNode, courseNotified.get(course.getResourceableId())));
} else if (node instanceof FOCourseNode) {
FOCourseNode forumNode = (FOCourseNode) node;
forums.add(ForumCourseNodeWebService.createForumVO(course, forumNode, forumNotified));
}
}
}, new VisibleTreeFilter());
info.setKey(course.getResourceableId());
info.setTitle(course.getCourseTitle());
info.setFolders(folders.toArray(new FolderVO[folders.size()]));
info.setForums(forums.toArray(new ForumVO[forums.size()]));
} catch (Exception e) {
log.error("", e);
}
}
return info;
}
use of org.olat.modules.fo.restapi.ForumVO in project OpenOLAT by OpenOLAT.
the class CoursesForumsTest method testGetForumInfo.
@Test
public void testGetForumInfo() throws IOException, URISyntaxException {
boolean loggedIN = conn.login("administrator", "openolat");
assertTrue(loggedIN);
URI uri = UriBuilder.fromUri(getNodeURI()).build();
HttpGet get = conn.createGet(uri, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(get);
assertEquals(200, response.getStatusLine().getStatusCode());
ForumVO forum = conn.parse(response, ForumVO.class);
assertNotNull(forum);
}
Aggregations