Search in sources :

Example 76 with PublisherData

use of org.olat.core.commons.services.notifications.PublisherData in project OpenOLAT by OpenOLAT.

the class InfoSubscriptionManagerImpl method subscribe.

@Override
public void subscribe(OLATResourceable resource, String resSubPath, String businessPath, Identity identity) {
    PublisherData data = getInfoPublisherData(resource, businessPath);
    SubscriptionContext context = getInfoSubscriptionContext(resource, resSubPath);
    notificationsManager.subscribe(identity, context, data);
}
Also used : SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) PublisherData(org.olat.core.commons.services.notifications.PublisherData)

Example 77 with PublisherData

use of org.olat.core.commons.services.notifications.PublisherData in project OpenOLAT by OpenOLAT.

the class InfoSubscriptionManagerImpl method getInfoPublisherData.

@Override
public PublisherData getInfoPublisherData(OLATResourceable resource, String businessPath) {
    String resId = resource.getResourceableId() == null ? "0" : resource.getResourceableId().toString();
    PublisherData publisherData = new PublisherData(PUBLISHER_TYPE, resId, businessPath);
    return publisherData;
}
Also used : PublisherData(org.olat.core.commons.services.notifications.PublisherData)

Example 78 with PublisherData

use of org.olat.core.commons.services.notifications.PublisherData in project OpenOLAT by OpenOLAT.

the class NotificationsWebService method subscribe.

@PUT
@Path("subscribers")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response subscribe(PublisherVO publisherVO, @Context HttpServletRequest request) {
    if (!isAdmin(request)) {
        return Response.serverError().status(Status.NOT_FOUND).build();
    }
    NotificationsManager notificationsMgr = NotificationsManager.getInstance();
    BaseSecurity securityManager = CoreSpringFactory.getImpl(BaseSecurity.class);
    SubscriptionContext subscriptionContext = new SubscriptionContext(publisherVO.getResName(), publisherVO.getResId(), publisherVO.getSubidentifier());
    PublisherData publisherData = new PublisherData(publisherVO.getType(), publisherVO.getData(), publisherVO.getBusinessPath());
    List<UserVO> userVoes = publisherVO.getUsers();
    List<Long> identityKeys = new ArrayList<>();
    for (UserVO userVo : userVoes) {
        identityKeys.add(userVo.getKey());
    }
    List<Identity> identities = securityManager.loadIdentityByKeys(identityKeys);
    notificationsMgr.subscribe(identities, subscriptionContext, publisherData);
    return Response.ok().build();
}
Also used : UserVO(org.olat.user.restapi.UserVO) NotificationsManager(org.olat.core.commons.services.notifications.NotificationsManager) ArrayList(java.util.ArrayList) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) Identity(org.olat.core.id.Identity) PublisherData(org.olat.core.commons.services.notifications.PublisherData) BaseSecurity(org.olat.basesecurity.BaseSecurity) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) PUT(javax.ws.rs.PUT)

Example 79 with PublisherData

use of org.olat.core.commons.services.notifications.PublisherData in project OpenOLAT by OpenOLAT.

the class MailManagerImpl method subscribe.

@Override
public void subscribe(Identity identity) {
    PublisherData data = getPublisherData();
    SubscriptionContext context = getSubscriptionContext();
    if (context != null) {
        notificationsManager.subscribe(identity, context, data);
    }
}
Also used : SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) PublisherData(org.olat.core.commons.services.notifications.PublisherData)

Example 80 with PublisherData

use of org.olat.core.commons.services.notifications.PublisherData in project OpenOLAT by OpenOLAT.

the class MailManagerImpl method getPublisherData.

@Override
public PublisherData getPublisherData() {
    String data = "";
    String businessPath = "[Inbox:0]";
    PublisherData publisherData = new PublisherData("Inbox", data, businessPath);
    return publisherData;
}
Also used : PublisherData(org.olat.core.commons.services.notifications.PublisherData)

Aggregations

PublisherData (org.olat.core.commons.services.notifications.PublisherData)100 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)84 Test (org.junit.Test)64 Identity (org.olat.core.id.Identity)60 Publisher (org.olat.core.commons.services.notifications.Publisher)42 RepositoryEntry (org.olat.repository.RepositoryEntry)22 BusinessGroup (org.olat.group.BusinessGroup)20 HttpResponse (org.apache.http.HttpResponse)16 HttpGet (org.apache.http.client.methods.HttpGet)16 Subscriber (org.olat.core.commons.services.notifications.Subscriber)16 ArrayList (java.util.ArrayList)14 ContextualSubscriptionController (org.olat.core.commons.services.notifications.ui.ContextualSubscriptionController)12 Forum (org.olat.modules.fo.Forum)12 UriBuilder (javax.ws.rs.core.UriBuilder)10 SubscriptionInfoVO (org.olat.core.commons.services.notifications.restapi.vo.SubscriptionInfoVO)8 SubscriptionListItemVO (org.olat.core.commons.services.notifications.restapi.vo.SubscriptionListItemVO)8 DBRuntimeException (org.olat.core.logging.DBRuntimeException)8 ICourse (org.olat.course.ICourse)8 File (java.io.File)6 URI (java.net.URI)6