use of org.olat.core.commons.services.notifications.SubscriptionContext in project OpenOLAT by OpenOLAT.
the class HistoryController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
if (!ureq.getUserSession().getRoles().isGuestOnly()) {
subsContext = new SubscriptionContext(PortfolioNotificationsHandler.TYPE_NAME, binder.getKey(), PortfolioNotificationsHandler.TYPE_NAME);
if (subsContext != null) {
String businessPath = "[Binder:" + binder.getKey() + "]";
PublisherData data = new PublisherData(PortfolioNotificationsHandler.TYPE_NAME, null, businessPath);
cSubscriptionCtrl = new ContextualSubscriptionController(ureq, getWindowControl(), subsContext, data);
listenTo(cSubscriptionCtrl);
flc.put("subscription", cSubscriptionCtrl.getInitialComponent());
}
}
dateChooser = uifactory.addDateChooser("dateChooser", "changes.since", null, formLayout);
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.set(Calendar.DATE, -8);
dateChooser.setDate(cal.getTime());
dateChooser.addActionListener(FormEvent.ONCHANGE);
}
use of org.olat.core.commons.services.notifications.SubscriptionContext in project OpenOLAT by OpenOLAT.
the class PFCourseNode method cleanupOnDelete.
@Override
public void cleanupOnDelete(ICourse course) {
super.cleanupOnDelete(course);
// mark the subscription to this node as deleted
SubscriptionContext folderSubContext = CourseModule.createTechnicalSubscriptionContext(course.getCourseEnvironment(), this);
NotificationsManager.getInstance().delete(folderSubContext);
// delete filesystem
CourseEnvironment courseEnv = course.getCourseEnvironment();
File root = Paths.get(courseEnv.getCourseBaseContainer().getRelPath(), PFManager.FILENAME_PARTICIPANTFOLDER, getIdent()).toFile();
if (root.exists()) {
FileUtils.deleteDirsAndFiles(root, true, true);
}
}
use of org.olat.core.commons.services.notifications.SubscriptionContext in project OpenOLAT by OpenOLAT.
the class PodcastCourseNode method createNodeRunConstructionResult.
/**
* @see org.olat.course.nodes.AbstractAccessableCourseNode#createNodeRunConstructionResult(org.olat.core.gui.UserRequest,
* org.olat.core.gui.control.WindowControl,
* org.olat.course.run.userview.UserCourseEnvironment,
* org.olat.course.run.userview.NodeEvaluation, java.lang.String)
*/
@Override
public NodeRunConstructionResult createNodeRunConstructionResult(UserRequest ureq, WindowControl control, UserCourseEnvironment userCourseEnv, NodeEvaluation ne, String nodecmd) {
RepositoryEntry entry = getReferencedRepositoryEntry();
// create business path courseID:nodeID
// userCourseEnv.getCourseEnvironment().getCourseResourceableId();
// getIdent();
Long courseId = userCourseEnv.getCourseEnvironment().getCourseResourceableId();
String nodeId = this.getIdent();
boolean isAdmin = ureq.getUserSession().getRoles().isOLATAdmin();
boolean isGuest = ureq.getUserSession().getRoles().isGuestOnly();
boolean isOwner = RepositoryManager.getInstance().isOwnerOfRepositoryEntry(ureq.getIdentity(), entry);
FeedSecurityCallback callback;
if (userCourseEnv.isCourseReadOnly()) {
callback = new FeedReadOnlySecurityCallback();
} else {
callback = new FeedNodeSecurityCallback(ne, isAdmin, isOwner, isGuest);
}
SubscriptionContext subsContext = CourseModule.createSubscriptionContext(userCourseEnv.getCourseEnvironment(), this);
callback.setSubscriptionContext(subsContext);
ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrap(this));
FeedMainController podcastCtr = PodcastUIFactory.getInstance(ureq.getLocale()).createMainController(entry.getOlatResource(), ureq, control, callback, courseId, nodeId);
List<ContextEntry> entries = BusinessControlFactory.getInstance().createCEListFromResourceType(nodecmd);
podcastCtr.activate(ureq, entries, null);
Controller wrapperCtrl = TitledWrapperHelper.getWrapper(ureq, control, podcastCtr, this, "o_podcast_icon");
NodeRunConstructionResult result = new NodeRunConstructionResult(wrapperCtrl);
return result;
}
use of org.olat.core.commons.services.notifications.SubscriptionContext in project OpenOLAT by OpenOLAT.
the class WikiCourseNode method cleanupOnDelete.
@Override
public void cleanupOnDelete(ICourse course) {
super.cleanupOnDelete(course);
// mark the subscription to this node as deleted
SubscriptionContext subsContext = WikiManager.createTechnicalSubscriptionContextForCourse(course.getCourseEnvironment(), this);
NotificationsManager.getInstance().delete(subsContext);
}
use of org.olat.core.commons.services.notifications.SubscriptionContext in project OpenOLAT by OpenOLAT.
the class UserFoldersTest method myFolders.
/**
* Test retrieve the folder which the user subscribe in a course.
* @throws IOException
* @throws URISyntaxException
*/
@Test
public void myFolders() throws IOException, URISyntaxException {
final Identity id = JunitTestHelper.createAndPersistIdentityAsUser("my-" + UUID.randomUUID().toString());
dbInstance.commitAndCloseSession();
// load my forums
RestConnection conn = new RestConnection();
assertTrue(conn.login(id.getName(), "A6B7C8"));
// subscribed to nothing
URI uri = UriBuilder.fromUri(getContextURI()).path("users").path(id.getKey().toString()).path("folders").build();
HttpGet method = conn.createGet(uri, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
InputStream body = response.getEntity().getContent();
FolderVOes folders = conn.parse(body, FolderVOes.class);
Assert.assertNotNull(folders);
Assert.assertNotNull(folders.getFolders());
Assert.assertEquals(0, folders.getFolders().length);
// subscribe to the forum
IdentityEnvironment ienv = new IdentityEnvironment(id, new Roles(false, false, false, false, false, false, false));
new CourseTreeVisitor(myCourse, ienv).visit(new Visitor() {
@Override
public void visit(INode node) {
if (node instanceof BCCourseNode) {
BCCourseNode folderNode = (BCCourseNode) node;
String relPath = BCCourseNode.getFoldernodePathRelToFolderBase(myCourse.getCourseEnvironment(), folderNode);
String businessPath = "[RepositoryEntry:" + myCourseRe.getKey() + "][CourseNode:" + folderNode.getIdent() + "]";
SubscriptionContext folderSubContext = new SubscriptionContext("CourseModule", myCourse.getResourceableId(), folderNode.getIdent());
PublisherData folderPdata = new PublisherData("FolderModule", relPath, businessPath);
NotificationsManager.getInstance().subscribe(id, folderSubContext, folderPdata);
}
}
}, new VisibleTreeFilter());
dbInstance.commitAndCloseSession();
// retrieve my folders
HttpGet method2 = conn.createGet(uri, MediaType.APPLICATION_JSON, true);
HttpResponse response2 = conn.execute(method2);
assertEquals(200, response2.getStatusLine().getStatusCode());
InputStream body2 = response2.getEntity().getContent();
FolderVOes folders2 = conn.parse(body2, FolderVOes.class);
Assert.assertNotNull(folders2);
Assert.assertNotNull(folders2.getFolders());
Assert.assertEquals(1, folders2.getFolders().length);
}
Aggregations