use of org.olat.core.commons.services.notifications.Publisher in project OpenOLAT by OpenOLAT.
the class NotificationsManagerImpl method deletePublishersOf.
/**
* deletes all publishers of the given olatresourceable. e.g. ores =
* businessgroup 123 -> deletes possible publishers: of Folder(toolfolder), of
* Forum(toolforum)
*
* @param ores
*/
@Override
public void deletePublishersOf(OLATResourceable ores) {
String type = ores.getResourceableTypeName();
Long id = ores.getResourceableId();
if (type == null || id == null)
throw new AssertException("type/id cannot be null! type:" + type + " / id:" + id);
List<Publisher> pubs = getPublishers(type, id);
if (pubs.isEmpty())
return;
String q1 = "delete from notisub sub where sub.publisher in (:publishers)";
DBQuery query1 = dbInstance.createQuery(q1);
query1.setParameterList("publishers", pubs);
query1.executeUpdate(FlushMode.AUTO);
String q2 = "delete from notipublisher pub where pub in (:publishers)";
DBQuery query2 = dbInstance.createQuery(q2);
query2.setParameterList("publishers", pubs);
query2.executeUpdate(FlushMode.AUTO);
}
use of org.olat.core.commons.services.notifications.Publisher in project OpenOLAT by OpenOLAT.
the class NotificationsManagerImpl method updatePublisherData.
@Override
public void updatePublisherData(SubscriptionContext subsContext, PublisherData data) {
Publisher publisher = getPublisherForUpdate(subsContext);
if (publisher != null) {
publisher.setData(data.getData());
dbInstance.getCurrentEntityManager().merge(publisher);
dbInstance.commit();
}
}
use of org.olat.core.commons.services.notifications.Publisher in project OpenOLAT by OpenOLAT.
the class NotificationsWebService method getPublisher.
/**
* Get the publisher by resource name and id + sub identifier.
*
* @response.representation.200.qname {http://www.example.com}publisherVo
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc The publisher
* @response.representation.200.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_PUBLISHERVO}
* @response.representation.204.doc The publisher doesn't exist
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @return It returns the <code>CourseVO</code> object representing the course.
*/
@GET
@Path("publisher/{ressourceName}/{ressourceId}/{subIdentifier}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getPublisher(@PathParam("ressourceName") String ressourceName, @PathParam("ressourceId") Long ressourceId, @PathParam("subIdentifier") String subIdentifier, @Context HttpServletRequest request) {
if (!isAdmin(request)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
NotificationsManager notificationsMgr = NotificationsManager.getInstance();
SubscriptionContext subsContext = new SubscriptionContext(ressourceName, ressourceId, subIdentifier);
Publisher publisher = notificationsMgr.getPublisher(subsContext);
if (publisher == null) {
return Response.ok().status(Status.NO_CONTENT).build();
}
PublisherVO publisherVo = new PublisherVO(publisher);
return Response.ok(publisherVo).build();
}
use of org.olat.core.commons.services.notifications.Publisher in project OpenOLAT by OpenOLAT.
the class NotificationsWebService method getSubscriber.
@GET
@Path("subscribers/{ressourceName}/{ressourceId}/{subIdentifier}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getSubscriber(@PathParam("ressourceName") String ressourceName, @PathParam("ressourceId") Long ressourceId, @PathParam("subIdentifier") String subIdentifier, @Context HttpServletRequest request) {
if (!isAdmin(request)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
NotificationsManager notificationsMgr = NotificationsManager.getInstance();
SubscriptionContext subsContext = new SubscriptionContext(ressourceName, ressourceId, subIdentifier);
Publisher publisher = notificationsMgr.getPublisher(subsContext);
if (publisher == null) {
return Response.ok().status(Status.NO_CONTENT).build();
}
List<Subscriber> subscribers = notificationsMgr.getSubscribers(publisher);
SubscriberVO[] subscriberVoes = new SubscriberVO[subscribers.size()];
int count = 0;
for (Subscriber subscriber : subscribers) {
SubscriberVO subscriberVO = new SubscriberVO();
subscriberVO.setPublisherKey(publisher.getKey());
subscriberVO.setSubscriberKey(subscriber.getKey());
subscriberVO.setIdentityKey(subscriber.getIdentity().getKey());
subscriberVoes[count++] = subscriberVO;
}
return Response.ok(subscriberVoes).build();
}
use of org.olat.core.commons.services.notifications.Publisher in project OpenOLAT by OpenOLAT.
the class NotificationsPortletRunController method getAllPortletEntries.
private List<PortletEntry<Subscriber>> getAllPortletEntries() {
notificationsList = man.getValidSubscribers(getIdentity());
// calc subscriptioninfo for all subscriptions and, if only those with news are to be shown, remove the other ones
for (Iterator<Subscriber> it_subs = notificationsList.iterator(); it_subs.hasNext(); ) {
Subscriber subscriber = it_subs.next();
Publisher pub = subscriber.getPublisher();
NotificationsHandler notifHandler = man.getNotificationsHandler(pub);
if (notifHandler == null) {
it_subs.remove();
} else {
SubscriptionInfo subsInfo = notifHandler.createSubscriptionInfo(subscriber, getLocale(), compareDate);
if (!subsInfo.hasNews()) {
it_subs.remove();
}
}
}
return convertNotificationToPortletEntryList(notificationsList);
}
Aggregations