Search in sources :

Example 6 with PublisherVO

use of org.olat.core.commons.services.notifications.restapi.vo.PublisherVO in project openolat by klemens.

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();
}
Also used : NotificationsManager(org.olat.core.commons.services.notifications.NotificationsManager) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) Publisher(org.olat.core.commons.services.notifications.Publisher) PublisherVO(org.olat.core.commons.services.notifications.restapi.vo.PublisherVO) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)6 PublisherVO (org.olat.core.commons.services.notifications.restapi.vo.PublisherVO)6 HttpResponse (org.apache.http.HttpResponse)4 Test (org.junit.Test)4 Publisher (org.olat.core.commons.services.notifications.Publisher)4 Identity (org.olat.core.id.Identity)4 Forum (org.olat.modules.fo.Forum)4 File (java.io.File)2 URI (java.net.URI)2 URL (java.net.URL)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 UriBuilder (javax.ws.rs.core.UriBuilder)2 HttpGet (org.apache.http.client.methods.HttpGet)2 HttpPut (org.apache.http.client.methods.HttpPut)2 CollaborationTools (org.olat.collaboration.CollaborationTools)2 NotificationsManager (org.olat.core.commons.services.notifications.NotificationsManager)2 PublisherData (org.olat.core.commons.services.notifications.PublisherData)2 Subscriber (org.olat.core.commons.services.notifications.Subscriber)2