use of org.olat.modules.fo.Forum in project openolat by klemens.
the class NotificationsTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
if (!setup) {
userSubscriberId = JunitTestHelper.createAndPersistIdentityAsUser("rest-notifications-test-1");
userAndForumSubscriberId = JunitTestHelper.createAndPersistIdentityAsUser("rest-notifications-test-2");
JunitTestHelper.createAndPersistIdentityAsUser("rest-notifications-test-3");
SubscriptionContext subContext = UsersSubscriptionManager.getInstance().getNewUsersSubscriptionContext();
PublisherData publisherData = UsersSubscriptionManager.getInstance().getNewUsersPublisherData();
if (!notificationManager.isSubscribed(userSubscriberId, subContext)) {
notificationManager.subscribe(userSubscriberId, subContext, publisherData);
}
if (!notificationManager.isSubscribed(userAndForumSubscriberId, subContext)) {
notificationManager.subscribe(userAndForumSubscriberId, subContext, publisherData);
}
// create a forum
forum = ForumManager.getInstance().addAForum();
Message m1 = createMessage(userSubscriberId, forum);
Assert.assertNotNull(m1);
// subscribe
SubscriptionContext forumSubContext = new SubscriptionContext("NotificationRestCourse", forum.getKey(), "2387");
PublisherData forumPdata = new PublisherData(OresHelper.calculateTypeName(Forum.class), forum.getKey().toString(), "");
if (!notificationManager.isSubscribed(userAndForumSubscriberId, forumSubContext)) {
notificationManager.subscribe(userAndForumSubscriberId, forumSubContext, forumPdata);
}
notificationManager.markPublisherNews(forumSubContext, userSubscriberId, true);
// generate one notification
String randomLogin = UUID.randomUUID().toString().replace("-", "");
JunitTestHelper.createAndPersistIdentityAsUser(randomLogin);
setup = true;
}
dbInstance.commitAndCloseSession();
}
use of org.olat.modules.fo.Forum in project openolat by klemens.
the class FOCourseNodeIndexer method doIndexForum.
/**
* Index a forum in a course.
* @param parentResourceContext
* @param course
* @param courseNode
* @param indexWriter
* @throws IOException
*/
private void doIndexForum(SearchResourceContext parentResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
if (log.isDebug())
log.debug("Index Course Forum...");
ForumManager fom = ForumManager.getInstance();
CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
Property forumKeyProperty = cpm.findCourseNodeProperty(courseNode, null, null, FOCourseNode.FORUM_KEY);
// Check if forum-property exist
if (forumKeyProperty != null) {
Long forumKey = forumKeyProperty.getLongValue();
Forum forum = fom.loadForum(forumKey);
parentResourceContext.setDocumentType(TYPE);
doIndexAllMessages(parentResourceContext, forum, indexWriter);
}
}
use of org.olat.modules.fo.Forum 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;
}
use of org.olat.modules.fo.Forum in project openolat by klemens.
the class OLATUpgrade_12_3_0 method createDialogElement.
private void createDialogElement(DialogElement element, RepositoryEntry entry, String nodeIdent) {
try {
Identity author = null;
if (StringHelper.isLong(element.getAuthor())) {
author = securityManager.loadIdentityByKey(Long.valueOf(element.getAuthor()));
} else if (StringHelper.containsNonWhitespace(element.getAuthor())) {
author = securityManager.findIdentityByName(element.getAuthor());
}
Forum forum = forumManager.loadForum(element.getForumKey());
if (forum == null) {
log.error("Missing forum", null);
return;
}
Object currentElement = dialogElementsManager.getDialogElementByForum(forum.getKey());
if (currentElement != null) {
return;
}
Date date = element.getDate() == null ? new Date() : element.getDate();
DialogElementImpl el = new DialogElementImpl();
el.setCreationDate(date);
el.setLastModified(date);
el.setFilename(element.getFilename());
el.setSize(getFileSize(forum.getKey()));
el.setEntry(entry);
el.setSubIdent(nodeIdent);
el.setAuthor(author);
el.setForum(forum);
dbInstance.getCurrentEntityManager().persist(el);
} catch (Exception e) {
log.error("", e);
}
}
use of org.olat.modules.fo.Forum in project openolat by klemens.
the class ForumNodeForumCallback method loadForum.
private Forum loadForum(CourseEnvironment courseEnv, Property prop) {
final ForumManager fom = CoreSpringFactory.getImpl(ForumManager.class);
Long forumKey = prop.getLongValue();
Forum forum = fom.loadForum(forumKey);
if (forum == null) {
throw new OLATRuntimeException(FOCourseNode.class, "Tried to load forum with key " + forumKey.longValue() + " in course " + courseEnv.getCourseResourceableId() + " for node " + getIdent() + " as defined in course node property but forum manager could not load forum.", null);
}
return forum;
}
Aggregations