use of org.opencastproject.index.service.impl.index.event.Event in project opencast by opencast.
the class AbstractEventEndpoint method createEventCommentReply.
@POST
@Path("{eventId}/comment/{commentId}/reply")
@RestQuery(name = "createeventcommentreply", description = "Creates an event comment reply", returnDescription = "The updated comment as JSON.", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = RestParameter.Type.STRING), @RestParameter(name = "commentId", isRequired = true, description = "The comment identifier", type = STRING) }, restParameters = { @RestParameter(name = "text", isRequired = true, description = "The comment reply text", type = TEXT), @RestParameter(name = "resolved", isRequired = false, description = "Flag defining if this reply solve or not the comment.", type = BOOLEAN) }, reponses = { @RestResponse(responseCode = SC_NOT_FOUND, description = "The event or comment to extend with a reply has not been found."), @RestResponse(responseCode = HttpServletResponse.SC_BAD_REQUEST, description = "If no text is set."), @RestResponse(responseCode = SC_OK, description = "The updated comment as JSON.") })
public Response createEventCommentReply(@PathParam("eventId") String eventId, @PathParam("commentId") long commentId, @FormParam("text") String text, @FormParam("resolved") Boolean resolved) throws Exception {
if (StringUtils.isBlank(text))
return Response.status(Status.BAD_REQUEST).build();
Opt<Event> optEvent = getIndexService().getEvent(eventId, getIndex());
if (optEvent.isNone())
return notFound("Cannot find an event with id '%s'.", eventId);
EventComment comment = null;
try {
comment = getEventCommentService().getComment(commentId);
EventComment updatedComment;
if (resolved != null && resolved) {
// If the resolve flag is set to true, change to comment to resolved
updatedComment = EventComment.create(comment.getId(), comment.getEventId(), comment.getOrganization(), comment.getText(), comment.getAuthor(), comment.getReason(), true, comment.getCreationDate(), new Date(), comment.getReplies());
} else {
updatedComment = comment;
}
User author = getSecurityService().getUser();
EventCommentReply reply = EventCommentReply.create(Option.<Long>none(), text, author);
updatedComment.addReply(reply);
updatedComment = getEventCommentService().updateComment(updatedComment);
List<EventComment> comments = getEventCommentService().getComments(eventId);
getIndexService().updateCommentCatalog(optEvent.get(), comments);
return Response.ok(updatedComment.toJson().toJson()).build();
} catch (Exception e) {
logger.warn("Could not create event comment reply on comment {}: {}", comment, ExceptionUtils.getStackTrace(e));
throw new WebApplicationException(e);
}
}
use of org.opencastproject.index.service.impl.index.event.Event in project opencast by opencast.
the class AbstractEventEndpoint method getCatalogList.
@GET
@Path("{eventId}/asset/catalog/catalogs.json")
@Produces(MediaType.APPLICATION_JSON)
@RestQuery(name = "getCatalogList", description = "Returns a list of catalogs from the given event as JSON", returnDescription = "The list of catalogs from the given event as JSON", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = RestParameter.Type.STRING) }, reponses = { @RestResponse(description = "Returns a list of catalogs from the given event as JSON", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "No event with this identifier was found.", responseCode = HttpServletResponse.SC_NOT_FOUND) })
public Response getCatalogList(@PathParam("eventId") String id) throws Exception {
Opt<Event> optEvent = getIndexService().getEvent(id, getIndex());
if (optEvent.isNone())
return notFound("Cannot find an event with id '%s'.", id);
MediaPackage mp = getIndexService().getEventMediapackage(optEvent.get());
return okJson(arr(getEventMediaPackageElements(mp.getCatalogs())));
}
use of org.opencastproject.index.service.impl.index.event.Event in project opencast by opencast.
the class AbstractEventEndpoint method getEventComments.
@GET
@Path("{eventId}/comments")
@Produces(MediaType.APPLICATION_JSON)
@RestQuery(name = "geteventcomments", description = "Returns all the data related to the comments tab in the event details modal as JSON", returnDescription = "All the data related to the event comments tab as JSON", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = RestParameter.Type.STRING) }, reponses = { @RestResponse(description = "Returns all the data related to the event comments tab as JSON", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "No event with this identifier was found.", responseCode = HttpServletResponse.SC_NOT_FOUND) })
public Response getEventComments(@PathParam("eventId") String eventId) throws Exception {
Opt<Event> optEvent = getIndexService().getEvent(eventId, getIndex());
if (optEvent.isNone())
return notFound("Cannot find an event with id '%s'.", eventId);
try {
List<EventComment> comments = getEventCommentService().getComments(eventId);
List<Val> commentArr = new ArrayList<>();
for (EventComment c : comments) {
commentArr.add(c.toJson());
}
return Response.ok(org.opencastproject.util.Jsons.arr(commentArr).toJson(), MediaType.APPLICATION_JSON_TYPE).build();
} catch (EventCommentException e) {
logger.error("Unable to get comments from event {}: {}", eventId, ExceptionUtils.getStackTrace(e));
throw new WebApplicationException(e);
}
}
use of org.opencastproject.index.service.impl.index.event.Event in project opencast by opencast.
the class AbstractEventEndpoint method getAssetList.
@GET
@Path("{eventId}/asset/assets.json")
@Produces(MediaType.APPLICATION_JSON)
@RestQuery(name = "getAssetList", description = "Returns the number of assets from each types as JSON", returnDescription = "The number of assets from each types as JSON", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = RestParameter.Type.STRING) }, reponses = { @RestResponse(description = "Returns the number of assets from each types as JSON", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "No event with this identifier was found.", responseCode = HttpServletResponse.SC_NOT_FOUND) })
public Response getAssetList(@PathParam("eventId") String id) throws Exception {
Opt<Event> optEvent = getIndexService().getEvent(id, getIndex());
if (optEvent.isNone())
return notFound("Cannot find an event with id '%s'.", id);
MediaPackage mp = getIndexService().getEventMediapackage(optEvent.get());
int attachments = mp.getAttachments().length;
int catalogs = mp.getCatalogs().length;
int media = mp.getTracks().length;
int publications = mp.getPublications().length;
return okJson(obj(f("attachments", v(attachments)), f("catalogs", v(catalogs)), f("media", v(media)), f("publications", v(publications))));
}
use of org.opencastproject.index.service.impl.index.event.Event in project opencast by opencast.
the class AbstractEventEndpoint method getAttachmentsList.
@GET
@Path("{eventId}/asset/attachment/attachments.json")
@Produces(MediaType.APPLICATION_JSON)
@RestQuery(name = "getAttachmentsList", description = "Returns a list of attachments from the given event as JSON", returnDescription = "The list of attachments from the given event as JSON", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = RestParameter.Type.STRING) }, reponses = { @RestResponse(description = "Returns a list of attachments from the given event as JSON", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "No event with this identifier was found.", responseCode = HttpServletResponse.SC_NOT_FOUND) })
public Response getAttachmentsList(@PathParam("eventId") String id) throws Exception {
Opt<Event> optEvent = getIndexService().getEvent(id, getIndex());
if (optEvent.isNone())
return notFound("Cannot find an event with id '%s'.", id);
MediaPackage mp = getIndexService().getEventMediapackage(optEvent.get());
return okJson(arr(getEventMediaPackageElements(mp.getAttachments())));
}
Aggregations