@Test public void testGetEventScheduling() throws IOException { String expectedJson = IOUtils.toString(getClass().getResource("/event-scheduling-expected.json"), UTF_8); String eventId = TestEventsEndpoint.SCHEDULING_GET_EVENT; String result = given().pathParam("event_id", eventId).expect().statusCode(SC_OK).when() .get(env.host("{event_id}/scheduling")).asString(); assertThat(result, SameJSONAs.sameJSONAs(expectedJson).allowingAnyArrayOrdering()); }
@GET @Path("{eventId}/scheduling") @Produces({ ApiMediaType.JSON, ApiMediaType.VERSION_1_1_0, ApiMediaType.VERSION_1_2_0, ApiMediaType.VERSION_1_3_0, ApiMediaType.VERSION_1_4_0, ApiMediaType.VERSION_1_5_0 }) @RestQuery(name = "geteventscheduling", description = "Returns an event's scheduling information.", returnDescription = "", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = STRING) }, responses = { @RestResponse(description = "The scheduling information for the specified event is returned.", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "The specified event has no scheduling information.", responseCode = HttpServletResponse.SC_NO_CONTENT), @RestResponse(description = "The specified event does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) public Response getEventScheduling(@HeaderParam("Accept") String acceptHeader, @PathParam("eventId") String id) throws Exception { try { final Opt<Event> event = indexService.getEvent(id, externalIndex); if (event.isNone()) { return ApiResponses.notFound(String.format("Unable to find event with id '%s'", id)); } final JObject scheduling = SchedulingInfo.of(event.get().getIdentifier(), schedulerService).toJson(); if (!scheduling.isEmpty()) { return ApiResponses.Json.ok(acceptHeader, scheduling); } return Response.noContent().build(); } catch (SearchIndexException e) { logger.error("Unable to get list of publications from event with id '{}'", id, e); throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR); } }
EventsEndpoint implements ManagedService { @GET @Path("{eventId}/scheduling") @Produces({ ApiMediaType.JSON, ApiMediaType.VERSION_1_1_0, ApiMediaType.VERSION_1_2_0, ApiMediaType.VERSION_1_3_0, ApiMediaType.VERSION_1_4_0, ApiMediaType.VERSION_1_5_0 }) @RestQuery(name = "geteventscheduling", description = "Returns an event's scheduling information.", returnDescription = "", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = STRING) }, responses = { @RestResponse(description = "The scheduling information for the specified event is returned.", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "The specified event has no scheduling information.", responseCode = HttpServletResponse.SC_NO_CONTENT), @RestResponse(description = "The specified event does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) public Response getEventScheduling(@HeaderParam("Accept") String acceptHeader, @PathParam("eventId") String id) throws Exception { try { final Opt<Event> event = indexService.getEvent(id, externalIndex); if (event.isNone()) { return ApiResponses.notFound(String.format("Unable to find event with id '%s'", id)); } final JObject scheduling = SchedulingInfo.of(event.get().getIdentifier(), schedulerService).toJson(); if (!scheduling.isEmpty()) { return ApiResponses.Json.ok(acceptHeader, scheduling); } return Response.noContent().build(); } catch (SearchIndexException e) { logger.error("Unable to get list of publications from event with id '{}'", id, e); throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR); } } }
EventsEndpoint implements ManagedService { @GET @Path("{eventId}/scheduling") @Produces({ ApiMediaType.JSON, ApiMediaType.VERSION_1_1_0, ApiMediaType.VERSION_1_2_0, ApiMediaType.VERSION_1_3_0, ApiMediaType.VERSION_1_4_0, ApiMediaType.VERSION_1_5_0 }) @RestQuery(name = "geteventscheduling", description = "Returns an event's scheduling information.", returnDescription = "", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = STRING) }, responses = { @RestResponse(description = "The scheduling information for the specified event is returned.", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "The specified event has no scheduling information.", responseCode = HttpServletResponse.SC_NO_CONTENT), @RestResponse(description = "The specified event does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) public Response getEventScheduling(@HeaderParam("Accept") String acceptHeader, @PathParam("eventId") String id) throws Exception { try { final Opt<Event> event = indexService.getEvent(id, externalIndex); if (event.isNone()) { return ApiResponses.notFound(String.format("Unable to find event with id '%s'", id)); } final JObject scheduling = SchedulingInfo.of(event.get().getIdentifier(), schedulerService).toJson(); if (!scheduling.isEmpty()) { return ApiResponses.Json.ok(acceptHeader, scheduling); } return Response.noContent().build(); } catch (SearchIndexException e) { logger.error("Unable to get list of publications from event with id '{}'", id, e); throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR); } }  }
EventsEndpoint implements ManagedService { @GET @Path("{eventId}/scheduling") @Produces({ ApiMediaType.JSON, ApiMediaType.VERSION_1_1_0, ApiMediaType.VERSION_1_2_0, ApiMediaType.VERSION_1_3_0, ApiMediaType.VERSION_1_4_0, ApiMediaType.VERSION_1_5_0 }) @RestQuery(name = "geteventscheduling", description = "Returns an event's scheduling information.", returnDescription = "", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = STRING) }, responses = { @RestResponse(description = "The scheduling information for the specified event is returned.", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "The specified event has no scheduling information.", responseCode = HttpServletResponse.SC_NO_CONTENT), @RestResponse(description = "The specified event does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) public Response getEventScheduling(@HeaderParam("Accept") String acceptHeader, @PathParam("eventId") String id) throws Exception { try { final Opt<Event> event = indexService.getEvent(id, externalIndex); if (event.isNone()) { return ApiResponses.notFound(String.format("Unable to find event with id '%s'", id)); } final JObject scheduling = SchedulingInfo.of(event.get().getIdentifier(), schedulerService).toJson(); if (!scheduling.isEmpty()) { return ApiResponses.Json.ok(acceptHeader, scheduling); } return Response.noContent().build(); } catch (SearchIndexException e) { logger.error("Unable to get list of publications from event with id '{}'", id, e); throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR); } }  void setIndexService(IndexService indexService); void setIngestService(IngestService ingestService); void setUrlSigningService(UrlSigningService urlSigningService); SecurityService getSecurityService(); SchedulerService getSchedulerService(); void setSchedulerService(SchedulerService schedulerService); void setCommonEventCatalogUIAdapter(CommonEventCatalogUIAdapter eventCatalogUIAdapter); void addCatalogUIAdapter(EventCatalogUIAdapter catalogUIAdapter); void removeCatalogUIAdapter(EventCatalogUIAdapter catalogUIAdapter); CaptureAgentStateService getAgentStateService(); void setAgentStateService(CaptureAgentStateService agentStateService); List<EventCatalogUIAdapter> getEventCatalogUIAdapters(String organization); @Override void updated(Dictionary<String, ?> properties); static boolean isNullOrEmpty(List<String> list); @GET @Path("{eventId}") @RestQuery(name = "getevent", description = "Returns a single event. By setting the optional sign parameter to true, the method will pre-sign distribution urls if signing is turned on in Opencast. Remember to consider the maximum validity of signed URLs when caching this response.", returnDescription = "", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = STRING) }, restParameters = { @RestParameter(name = "sign", isRequired = false, description = "Whether distribution urls should be signed.", type = Type.BOOLEAN), @RestParameter(name = "withacl", isRequired = false, description = "Whether the acl metadata should be included in the response.", type = Type.BOOLEAN), @RestParameter(name = "withmetadata", isRequired = false, description = "Whether the metadata catalogs should be included in the response.", type = Type.BOOLEAN), @RestParameter(name = "withscheduling", isRequired = false, description = "Whether the scheduling information should be included in the response.", type = Type.BOOLEAN), @RestParameter(name = "withpublications", isRequired = false, description = "Whether the publication ids and urls should be included in the response.", type = Type.BOOLEAN), }, responses = { @RestResponse(description = "The event is returned.", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "The specified event does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) Response getEvent(@HeaderParam("Accept") String acceptHeader, @PathParam("eventId") String id,
          @QueryParam("sign") boolean sign, @QueryParam("withacl") Boolean withAcl,
          @QueryParam("withmetadata") Boolean withMetadata, @QueryParam("withscheduling") Boolean withScheduling,
          @QueryParam("withpublications") Boolean withPublications); @GET @Path("{eventId}/media") Response getEventMedia(@HeaderParam("Accept") String acceptHeader, @PathParam("eventId") String id); @DELETE @Path("{eventId}") @RestQuery(name = "deleteevent", description = "Deletes an event.", returnDescription = "", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = STRING) }, responses = { @RestResponse(description = "The event has been deleted.", responseCode = HttpServletResponse.SC_NO_CONTENT), @RestResponse(description = "The specified event does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) Response deleteEvent(@HeaderParam("Accept") String acceptHeader, @PathParam("eventId") String id); @POST @Path("{eventId}") @RestQuery(name = "updateeventmetadata", description = "Updates an event.", returnDescription = "", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = STRING) }, restParameters = { @RestParameter(name = "acl", isRequired = false, description = "A collection of roles with their possible action", type = Type.STRING), @RestParameter(name = "metadata", isRequired = false, description = "Event metadata as Form param", type = Type.STRING), @RestParameter(name = "scheduling", isRequired = false, description = "Scheduling information as Form param", type = Type.STRING), @RestParameter(name = "presenter", isRequired = false, description = "Presenter movie track", type = Type.FILE), @RestParameter(name = "presentation", isRequired = false, description = "Presentation movie track", type = Type.FILE), @RestParameter(name = "audio", isRequired = false, description = "Audio track", type = Type.FILE), @RestParameter(name = "processing", isRequired = false, description = "Processing instructions task configuration", type = Type.STRING), }, responses = { @RestResponse(description = "The event has been updated.", responseCode = HttpServletResponse.SC_NO_CONTENT), @RestResponse(description = "The event could not be updated due to a scheduling conflict.", responseCode = HttpServletResponse.SC_CONFLICT), @RestResponse(description = "The specified event does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) Response updateEventMetadata(@HeaderParam("Accept") String acceptHeader, @Context HttpServletRequest request,
          @PathParam("eventId") String eventId); @POST @Path("/") @Consumes(MediaType.MULTIPART_FORM_DATA) @RestQuery(name = "createevent", description = "Creates an event by sending metadata, access control list, processing instructions and files in a multipart request.", returnDescription = "", restParameters = { @RestParameter(name = "acl", isRequired = false, description = "A collection of roles with their possible action", type = STRING), @RestParameter(name = "metadata", description = "Event metadata as Form param", isRequired = false, type = STRING), @RestParameter(name = "scheduling", description = "Scheduling information as Form param", isRequired = false, type = STRING), @RestParameter(name = "presenter", description = "Presenter movie track", isRequired = false, type = Type.FILE), @RestParameter(name = "presentation", description = "Presentation movie track", isRequired = false, type = Type.FILE), @RestParameter(name = "audio", description = "Audio track", isRequired = false, type = Type.FILE), @RestParameter(name = "processing", description = "Processing instructions task configuration", isRequired = false, type = STRING) }, responses = { @RestResponse(description = "A new event is created and its identifier is returned in the Location header.", responseCode = HttpServletResponse.SC_CREATED), @RestResponse(description = "The event could not be created due to a scheduling conflict.", responseCode = HttpServletResponse.SC_CONFLICT), @RestResponse(description = "The request is invalid or inconsistent..", responseCode = HttpServletResponse.SC_BAD_REQUEST) }) Response createNewEvent(@HeaderParam("Accept") String acceptHeader, @Context HttpServletRequest request); @GET @Path("/") @RestQuery(name = "getevents", description = "Returns a list of events. By setting the optional sign parameter to true, the method will pre-sign distribution urls if signing is turned on in Opencast. Remember to consider the maximum validity of signed URLs when caching this response.", returnDescription = "", restParameters = { @RestParameter(name = "sign", isRequired = false, description = "Whether distribution urls should be signed.", type = Type.BOOLEAN), @RestParameter(name = "withacl", isRequired = false, description = "Whether the acl metadata should be included in the response.", type = Type.BOOLEAN), @RestParameter(name = "withmetadata", isRequired = false, description = "Whether the metadata catalogs should be included in the response.", type = Type.BOOLEAN), @RestParameter(name = "withscheduling", isRequired = false, description = "Whether the scheduling information should be included in the response.", type = Type.BOOLEAN), @RestParameter(name = "withpublications", isRequired = false, description = "Whether the publication ids and urls should be included in the response.", type = Type.BOOLEAN), @RestParameter(name = "onlyWithWriteAccess", isRequired = false, description = "Whether only to get the events to which we have write access.", type = Type.BOOLEAN), @RestParameter(name = "filter", isRequired = false, description = "A comma seperated list of filters to limit the results with. A filter is the filter's name followed by a colon \":\" and then the value to filter with so it is the form <Filter Name>:<Value to Filter With>.", type = STRING), @RestParameter(name = "sort", description = "Sort the results based upon a list of comma seperated sorting criteria. In the comma seperated list each type of sorting is specified as a pair such as: <Sort Name>:ASC or <Sort Name>:DESC. Adding the suffix ASC or DESC sets the order as ascending or descending order and is mandatory.", isRequired = false, type = STRING), @RestParameter(name = "limit", description = "The maximum number of results to return for a single request.", isRequired = false, type = RestParameter.Type.INTEGER), @RestParameter(name = "offset", description = "The index of the first result to return.", isRequired = false, type = RestParameter.Type.INTEGER) }, responses = { @RestResponse(description = "A (potentially empty) list of events is returned.", responseCode = HttpServletResponse.SC_OK) }) Response getEvents(@HeaderParam("Accept") String acceptHeader, @QueryParam("id") String id,
          @QueryParam("commentReason") String reasonFilter, @QueryParam("commentResolution") String resolutionFilter,
          @QueryParam("filter") List<String> filter, @QueryParam("sort") String sort, @QueryParam("offset") Integer offset,
          @QueryParam("limit") Integer limit, @QueryParam("sign") boolean sign, @QueryParam("withacl") Boolean withAcl,
          @QueryParam("withmetadata") Boolean withMetadata, @QueryParam("withscheduling") Boolean withScheduling,
          @QueryParam("onlyWithWriteAccess") Boolean onlyWithWriteAccess, @QueryParam("withpublications") Boolean withPublications); @GET @Path("{eventId}/acl") @RestQuery(name = "geteventacl", description = "Returns an event's access policy.", returnDescription = "", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = STRING) }, responses = { @RestResponse(description = "The access control list for the specified event is returned.", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "The specified event does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) Response getEventAcl(@HeaderParam("Accept") String acceptHeader, @PathParam("eventId") String id); @PUT @Path("{eventId}/acl") @RestQuery(name = "updateeventacl", description = "Update an event's access policy.", returnDescription = "", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = STRING) }, restParameters = { @RestParameter(name = "acl", isRequired = true, description = "Access policy", type = STRING) }, responses = { @RestResponse(description = "The access control list for the specified event is updated.", responseCode = HttpServletResponse.SC_NO_CONTENT), @RestResponse(description = "The specified event does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) Response updateEventAcl(@HeaderParam("Accept") String acceptHeader, @PathParam("eventId") String id,
          @FormParam("acl") String acl); @POST @Path("{eventId}/acl/{action}") @RestQuery(name = "addeventace", description = "Grants permission to execute action on the specified event to any user with role role. Note that this is a convenience method to avoid having to build and post a complete access control list.", returnDescription = "", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = STRING), @RestParameter(name = "action", description = "The action that is allowed to be executed", isRequired = true, type = STRING) }, restParameters = { @RestParameter(name = "role", isRequired = true, description = "The role that is granted permission", type = STRING) }, responses = { @RestResponse(description = "The permission has been created in the access control list of the specified event.", responseCode = HttpServletResponse.SC_NO_CONTENT), @RestResponse(description = "The specified event does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) Response addEventAce(@HeaderParam("Accept") String acceptHeader, @PathParam("eventId") String id,
          @PathParam("action") String action, @FormParam("role") String role); @DELETE @Path("{eventId}/acl/{action}/{role}") @RestQuery(name = "deleteeventace", description = "Revokes permission to execute action on the specified event from any user with role role.", returnDescription = "", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = STRING), @RestParameter(name = "action", description = "The action that is no longer allowed to be executed", isRequired = true, type = STRING), @RestParameter(name = "role", description = "The role that is no longer granted permission", isRequired = true, type = STRING) }, responses = { @RestResponse(description = "The permission has been revoked from the access control list of the specified event.", responseCode = HttpServletResponse.SC_NO_CONTENT), @RestResponse(description = "The specified event does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) Response deleteEventAce(@HeaderParam("Accept") String acceptHeader, @PathParam("eventId") String id,
          @PathParam("action") String action, @PathParam("role") String role); @GET @Path("{eventId}/metadata") @RestQuery(name = "geteventmetadata", description = "Returns the event's metadata of the specified type. For a metadata catalog there is the flavor such as 'dublincore/episode' and this is the unique type.", returnDescription = "", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = STRING) }, restParameters = { @RestParameter(name = "type", isRequired = false, description = "The type of metadata to get", type = STRING) }, responses = { @RestResponse(description = "The metadata collection is returned.", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "The specified event does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) Response getAllEventMetadata(@HeaderParam("Accept") String acceptHeader, @PathParam("eventId") String id,
          @QueryParam("type") String type); @PUT @Path("{eventId}/metadata") @RestQuery(name = "updateeventmetadata", description = "Update the metadata with the matching type of the specified event. For a metadata catalog there is the flavor such as 'dublincore/episode' and this is the unique type.", returnDescription = "", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = STRING) }, restParameters = { @RestParameter(name = "type", isRequired = true, description = "The type of metadata to update", type = STRING), @RestParameter(name = "metadata", description = "Metadata catalog in JSON format", isRequired = true, type = STRING) }, responses = { @RestResponse(description = "The metadata of the given namespace has been updated.", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "The request is invalid or inconsistent.", responseCode = HttpServletResponse.SC_BAD_REQUEST), @RestResponse(description = "The specified event does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) Response updateEventMetadataByType(@HeaderParam("Accept") String acceptHeader, @PathParam("eventId") String id,
          @QueryParam("type") String type, @FormParam("metadata") String metadataJSON); @DELETE @Path("{eventId}/metadata") @RestQuery(name = "deleteeventmetadata", description = "Delete the metadata namespace catalog of the specified event. This will remove all fields and values of the catalog.", returnDescription = "", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = STRING) }, restParameters = { @RestParameter(name = "type", isRequired = true, description = "The type of metadata to delete", type = STRING) }, responses = { @RestResponse(description = "The metadata of the given namespace has been updated.", responseCode = HttpServletResponse.SC_NO_CONTENT), @RestResponse(description = "The main metadata catalog dublincore/episode cannot be deleted as it has mandatory fields.", responseCode = HttpServletResponse.SC_FORBIDDEN), @RestResponse(description = "The specified event does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) Response deleteEventMetadataByType(@HeaderParam("Accept") String acceptHeader, @PathParam("eventId") String id,
          @QueryParam("type") String type); @GET @Path("{eventId}/publications") @RestQuery(name = "geteventpublications", description = "Returns an event's list of publications.", returnDescription = "", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = STRING) }, restParameters = { @RestParameter(name = "sign", description = "Whether distribution urls should be signed.", isRequired = false, type = Type.BOOLEAN) }, responses = { @RestResponse(description = "The list of publications is returned.", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "The specified event does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) Response getEventPublications(@HeaderParam("Accept") String acceptHeader, @PathParam("eventId") String id,
          @QueryParam("sign") boolean sign); @GET @Path("{eventId}/publications/{publicationId}") @RestQuery(name = "geteventpublication", description = "Returns a single publication.", returnDescription = "", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = STRING), @RestParameter(name = "publicationId", description = "The publication id", isRequired = true, type = STRING) }, restParameters = { @RestParameter(name = "sign", description = "Whether distribution urls should be signed.", isRequired = false, type = Type.BOOLEAN) }, responses = { @RestResponse(description = "The track details are returned.", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "The specified event or publication does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) Response getEventPublication(@HeaderParam("Accept") String acceptHeader, @PathParam("eventId") String eventId,
          @PathParam("publicationId") String publicationId, @QueryParam("sign") boolean sign); @GET @Path("{eventId}/scheduling") @Produces({ ApiMediaType.JSON, ApiMediaType.VERSION_1_1_0, ApiMediaType.VERSION_1_2_0, ApiMediaType.VERSION_1_3_0, ApiMediaType.VERSION_1_4_0, ApiMediaType.VERSION_1_5_0 }) @RestQuery(name = "geteventscheduling", description = "Returns an event's scheduling information.", returnDescription = "", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = STRING) }, responses = { @RestResponse(description = "The scheduling information for the specified event is returned.", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "The specified event has no scheduling information.", responseCode = HttpServletResponse.SC_NO_CONTENT), @RestResponse(description = "The specified event does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) Response getEventScheduling(@HeaderParam("Accept") String acceptHeader, @PathParam("eventId") String id); @PUT @Path("{eventId}/scheduling") @Produces({ ApiMediaType.JSON, ApiMediaType.VERSION_1_1_0, ApiMediaType.VERSION_1_2_0, ApiMediaType.VERSION_1_3_0, ApiMediaType.VERSION_1_4_0, ApiMediaType.VERSION_1_5_0 }) @RestQuery(name = "updateeventscheduling", description = "Update an event's scheduling information.", returnDescription = "", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = Type.STRING) }, restParameters = { @RestParameter(name = "scheduling", isRequired = true, description = "Scheduling Information", type = Type.STRING), @RestParameter(name = "allowConflict", description = "Allow conflicts when updating scheduling", isRequired = false, type = Type.BOOLEAN) }, responses = { @RestResponse(description = "The scheduling information for the specified event is updated.", responseCode = HttpServletResponse.SC_NO_CONTENT), @RestResponse(description = "The specified event has no scheduling information to update.", responseCode = HttpServletResponse.SC_NOT_ACCEPTABLE), @RestResponse(description = "The scheduling information could not be updated due to a conflict.", responseCode = HttpServletResponse.SC_CONFLICT), @RestResponse(description = "The specified event does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) Response updateEventScheduling(@HeaderParam("Accept") String acceptHeader, @PathParam("eventId") String id,
                                 @FormParam("scheduling") String scheduling,
                                 @FormParam("allowConflict") @DefaultValue("false") boolean allowConflict); }
EventsEndpoint implements ManagedService { @GET @Path("{eventId}/scheduling") @Produces({ ApiMediaType.JSON, ApiMediaType.VERSION_1_1_0, ApiMediaType.VERSION_1_2_0, ApiMediaType.VERSION_1_3_0, ApiMediaType.VERSION_1_4_0, ApiMediaType.VERSION_1_5_0 }) @RestQuery(name = "geteventscheduling", description = "Returns an event's scheduling information.", returnDescription = "", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = STRING) }, responses = { @RestResponse(description = "The scheduling information for the specified event is returned.", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "The specified event has no scheduling information.", responseCode = HttpServletResponse.SC_NO_CONTENT), @RestResponse(description = "The specified event does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) public Response getEventScheduling(@HeaderParam("Accept") String acceptHeader, @PathParam("eventId") String id) throws Exception { try { final Opt<Event> event = indexService.getEvent(id, externalIndex); if (event.isNone()) { return ApiResponses.notFound(String.format("Unable to find event with id '%s'", id)); } final JObject scheduling = SchedulingInfo.of(event.get().getIdentifier(), schedulerService).toJson(); if (!scheduling.isEmpty()) { return ApiResponses.Json.ok(acceptHeader, scheduling); } return Response.noContent().build(); } catch (SearchIndexException e) { logger.error("Unable to get list of publications from event with id '{}'", id, e); throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR); } }  void setIndexService(IndexService indexService); void setIngestService(IngestService ingestService); void setUrlSigningService(UrlSigningService urlSigningService); SecurityService getSecurityService(); SchedulerService getSchedulerService(); void setSchedulerService(SchedulerService schedulerService); void setCommonEventCatalogUIAdapter(CommonEventCatalogUIAdapter eventCatalogUIAdapter); void addCatalogUIAdapter(EventCatalogUIAdapter catalogUIAdapter); void removeCatalogUIAdapter(EventCatalogUIAdapter catalogUIAdapter); CaptureAgentStateService getAgentStateService(); void setAgentStateService(CaptureAgentStateService agentStateService); List<EventCatalogUIAdapter> getEventCatalogUIAdapters(String organization); @Override void updated(Dictionary<String, ?> properties); static boolean isNullOrEmpty(List<String> list); @GET @Path("{eventId}") @RestQuery(name = "getevent", description = "Returns a single event. By setting the optional sign parameter to true, the method will pre-sign distribution urls if signing is turned on in Opencast. Remember to consider the maximum validity of signed URLs when caching this response.", returnDescription = "", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = STRING) }, restParameters = { @RestParameter(name = "sign", isRequired = false, description = "Whether distribution urls should be signed.", type = Type.BOOLEAN), @RestParameter(name = "withacl", isRequired = false, description = "Whether the acl metadata should be included in the response.", type = Type.BOOLEAN), @RestParameter(name = "withmetadata", isRequired = false, description = "Whether the metadata catalogs should be included in the response.", type = Type.BOOLEAN), @RestParameter(name = "withscheduling", isRequired = false, description = "Whether the scheduling information should be included in the response.", type = Type.BOOLEAN), @RestParameter(name = "withpublications", isRequired = false, description = "Whether the publication ids and urls should be included in the response.", type = Type.BOOLEAN), }, responses = { @RestResponse(description = "The event is returned.", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "The specified event does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) Response getEvent(@HeaderParam("Accept") String acceptHeader, @PathParam("eventId") String id,
          @QueryParam("sign") boolean sign, @QueryParam("withacl") Boolean withAcl,
          @QueryParam("withmetadata") Boolean withMetadata, @QueryParam("withscheduling") Boolean withScheduling,
          @QueryParam("withpublications") Boolean withPublications); @GET @Path("{eventId}/media") Response getEventMedia(@HeaderParam("Accept") String acceptHeader, @PathParam("eventId") String id); @DELETE @Path("{eventId}") @RestQuery(name = "deleteevent", description = "Deletes an event.", returnDescription = "", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = STRING) }, responses = { @RestResponse(description = "The event has been deleted.", responseCode = HttpServletResponse.SC_NO_CONTENT), @RestResponse(description = "The specified event does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) Response deleteEvent(@HeaderParam("Accept") String acceptHeader, @PathParam("eventId") String id); @POST @Path("{eventId}") @RestQuery(name = "updateeventmetadata", description = "Updates an event.", returnDescription = "", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = STRING) }, restParameters = { @RestParameter(name = "acl", isRequired = false, description = "A collection of roles with their possible action", type = Type.STRING), @RestParameter(name = "metadata", isRequired = false, description = "Event metadata as Form param", type = Type.STRING), @RestParameter(name = "scheduling", isRequired = false, description = "Scheduling information as Form param", type = Type.STRING), @RestParameter(name = "presenter", isRequired = false, description = "Presenter movie track", type = Type.FILE), @RestParameter(name = "presentation", isRequired = false, description = "Presentation movie track", type = Type.FILE), @RestParameter(name = "audio", isRequired = false, description = "Audio track", type = Type.FILE), @RestParameter(name = "processing", isRequired = false, description = "Processing instructions task configuration", type = Type.STRING), }, responses = { @RestResponse(description = "The event has been updated.", responseCode = HttpServletResponse.SC_NO_CONTENT), @RestResponse(description = "The event could not be updated due to a scheduling conflict.", responseCode = HttpServletResponse.SC_CONFLICT), @RestResponse(description = "The specified event does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) Response updateEventMetadata(@HeaderParam("Accept") String acceptHeader, @Context HttpServletRequest request,
          @PathParam("eventId") String eventId); @POST @Path("/") @Consumes(MediaType.MULTIPART_FORM_DATA) @RestQuery(name = "createevent", description = "Creates an event by sending metadata, access control list, processing instructions and files in a multipart request.", returnDescription = "", restParameters = { @RestParameter(name = "acl", isRequired = false, description = "A collection of roles with their possible action", type = STRING), @RestParameter(name = "metadata", description = "Event metadata as Form param", isRequired = false, type = STRING), @RestParameter(name = "scheduling", description = "Scheduling information as Form param", isRequired = false, type = STRING), @RestParameter(name = "presenter", description = "Presenter movie track", isRequired = false, type = Type.FILE), @RestParameter(name = "presentation", description = "Presentation movie track", isRequired = false, type = Type.FILE), @RestParameter(name = "audio", description = "Audio track", isRequired = false, type = Type.FILE), @RestParameter(name = "processing", description = "Processing instructions task configuration", isRequired = false, type = STRING) }, responses = { @RestResponse(description = "A new event is created and its identifier is returned in the Location header.", responseCode = HttpServletResponse.SC_CREATED), @RestResponse(description = "The event could not be created due to a scheduling conflict.", responseCode = HttpServletResponse.SC_CONFLICT), @RestResponse(description = "The request is invalid or inconsistent..", responseCode = HttpServletResponse.SC_BAD_REQUEST) }) Response createNewEvent(@HeaderParam("Accept") String acceptHeader, @Context HttpServletRequest request); @GET @Path("/") @RestQuery(name = "getevents", description = "Returns a list of events. By setting the optional sign parameter to true, the method will pre-sign distribution urls if signing is turned on in Opencast. Remember to consider the maximum validity of signed URLs when caching this response.", returnDescription = "", restParameters = { @RestParameter(name = "sign", isRequired = false, description = "Whether distribution urls should be signed.", type = Type.BOOLEAN), @RestParameter(name = "withacl", isRequired = false, description = "Whether the acl metadata should be included in the response.", type = Type.BOOLEAN), @RestParameter(name = "withmetadata", isRequired = false, description = "Whether the metadata catalogs should be included in the response.", type = Type.BOOLEAN), @RestParameter(name = "withscheduling", isRequired = false, description = "Whether the scheduling information should be included in the response.", type = Type.BOOLEAN), @RestParameter(name = "withpublications", isRequired = false, description = "Whether the publication ids and urls should be included in the response.", type = Type.BOOLEAN), @RestParameter(name = "onlyWithWriteAccess", isRequired = false, description = "Whether only to get the events to which we have write access.", type = Type.BOOLEAN), @RestParameter(name = "filter", isRequired = false, description = "A comma seperated list of filters to limit the results with. A filter is the filter's name followed by a colon \":\" and then the value to filter with so it is the form <Filter Name>:<Value to Filter With>.", type = STRING), @RestParameter(name = "sort", description = "Sort the results based upon a list of comma seperated sorting criteria. In the comma seperated list each type of sorting is specified as a pair such as: <Sort Name>:ASC or <Sort Name>:DESC. Adding the suffix ASC or DESC sets the order as ascending or descending order and is mandatory.", isRequired = false, type = STRING), @RestParameter(name = "limit", description = "The maximum number of results to return for a single request.", isRequired = false, type = RestParameter.Type.INTEGER), @RestParameter(name = "offset", description = "The index of the first result to return.", isRequired = false, type = RestParameter.Type.INTEGER) }, responses = { @RestResponse(description = "A (potentially empty) list of events is returned.", responseCode = HttpServletResponse.SC_OK) }) Response getEvents(@HeaderParam("Accept") String acceptHeader, @QueryParam("id") String id,
          @QueryParam("commentReason") String reasonFilter, @QueryParam("commentResolution") String resolutionFilter,
          @QueryParam("filter") List<String> filter, @QueryParam("sort") String sort, @QueryParam("offset") Integer offset,
          @QueryParam("limit") Integer limit, @QueryParam("sign") boolean sign, @QueryParam("withacl") Boolean withAcl,
          @QueryParam("withmetadata") Boolean withMetadata, @QueryParam("withscheduling") Boolean withScheduling,
          @QueryParam("onlyWithWriteAccess") Boolean onlyWithWriteAccess, @QueryParam("withpublications") Boolean withPublications); @GET @Path("{eventId}/acl") @RestQuery(name = "geteventacl", description = "Returns an event's access policy.", returnDescription = "", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = STRING) }, responses = { @RestResponse(description = "The access control list for the specified event is returned.", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "The specified event does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) Response getEventAcl(@HeaderParam("Accept") String acceptHeader, @PathParam("eventId") String id); @PUT @Path("{eventId}/acl") @RestQuery(name = "updateeventacl", description = "Update an event's access policy.", returnDescription = "", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = STRING) }, restParameters = { @RestParameter(name = "acl", isRequired = true, description = "Access policy", type = STRING) }, responses = { @RestResponse(description = "The access control list for the specified event is updated.", responseCode = HttpServletResponse.SC_NO_CONTENT), @RestResponse(description = "The specified event does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) Response updateEventAcl(@HeaderParam("Accept") String acceptHeader, @PathParam("eventId") String id,
          @FormParam("acl") String acl); @POST @Path("{eventId}/acl/{action}") @RestQuery(name = "addeventace", description = "Grants permission to execute action on the specified event to any user with role role. Note that this is a convenience method to avoid having to build and post a complete access control list.", returnDescription = "", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = STRING), @RestParameter(name = "action", description = "The action that is allowed to be executed", isRequired = true, type = STRING) }, restParameters = { @RestParameter(name = "role", isRequired = true, description = "The role that is granted permission", type = STRING) }, responses = { @RestResponse(description = "The permission has been created in the access control list of the specified event.", responseCode = HttpServletResponse.SC_NO_CONTENT), @RestResponse(description = "The specified event does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) Response addEventAce(@HeaderParam("Accept") String acceptHeader, @PathParam("eventId") String id,
          @PathParam("action") String action, @FormParam("role") String role); @DELETE @Path("{eventId}/acl/{action}/{role}") @RestQuery(name = "deleteeventace", description = "Revokes permission to execute action on the specified event from any user with role role.", returnDescription = "", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = STRING), @RestParameter(name = "action", description = "The action that is no longer allowed to be executed", isRequired = true, type = STRING), @RestParameter(name = "role", description = "The role that is no longer granted permission", isRequired = true, type = STRING) }, responses = { @RestResponse(description = "The permission has been revoked from the access control list of the specified event.", responseCode = HttpServletResponse.SC_NO_CONTENT), @RestResponse(description = "The specified event does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) Response deleteEventAce(@HeaderParam("Accept") String acceptHeader, @PathParam("eventId") String id,
          @PathParam("action") String action, @PathParam("role") String role); @GET @Path("{eventId}/metadata") @RestQuery(name = "geteventmetadata", description = "Returns the event's metadata of the specified type. For a metadata catalog there is the flavor such as 'dublincore/episode' and this is the unique type.", returnDescription = "", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = STRING) }, restParameters = { @RestParameter(name = "type", isRequired = false, description = "The type of metadata to get", type = STRING) }, responses = { @RestResponse(description = "The metadata collection is returned.", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "The specified event does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) Response getAllEventMetadata(@HeaderParam("Accept") String acceptHeader, @PathParam("eventId") String id,
          @QueryParam("type") String type); @PUT @Path("{eventId}/metadata") @RestQuery(name = "updateeventmetadata", description = "Update the metadata with the matching type of the specified event. For a metadata catalog there is the flavor such as 'dublincore/episode' and this is the unique type.", returnDescription = "", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = STRING) }, restParameters = { @RestParameter(name = "type", isRequired = true, description = "The type of metadata to update", type = STRING), @RestParameter(name = "metadata", description = "Metadata catalog in JSON format", isRequired = true, type = STRING) }, responses = { @RestResponse(description = "The metadata of the given namespace has been updated.", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "The request is invalid or inconsistent.", responseCode = HttpServletResponse.SC_BAD_REQUEST), @RestResponse(description = "The specified event does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) Response updateEventMetadataByType(@HeaderParam("Accept") String acceptHeader, @PathParam("eventId") String id,
          @QueryParam("type") String type, @FormParam("metadata") String metadataJSON); @DELETE @Path("{eventId}/metadata") @RestQuery(name = "deleteeventmetadata", description = "Delete the metadata namespace catalog of the specified event. This will remove all fields and values of the catalog.", returnDescription = "", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = STRING) }, restParameters = { @RestParameter(name = "type", isRequired = true, description = "The type of metadata to delete", type = STRING) }, responses = { @RestResponse(description = "The metadata of the given namespace has been updated.", responseCode = HttpServletResponse.SC_NO_CONTENT), @RestResponse(description = "The main metadata catalog dublincore/episode cannot be deleted as it has mandatory fields.", responseCode = HttpServletResponse.SC_FORBIDDEN), @RestResponse(description = "The specified event does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) Response deleteEventMetadataByType(@HeaderParam("Accept") String acceptHeader, @PathParam("eventId") String id,
          @QueryParam("type") String type); @GET @Path("{eventId}/publications") @RestQuery(name = "geteventpublications", description = "Returns an event's list of publications.", returnDescription = "", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = STRING) }, restParameters = { @RestParameter(name = "sign", description = "Whether distribution urls should be signed.", isRequired = false, type = Type.BOOLEAN) }, responses = { @RestResponse(description = "The list of publications is returned.", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "The specified event does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) Response getEventPublications(@HeaderParam("Accept") String acceptHeader, @PathParam("eventId") String id,
          @QueryParam("sign") boolean sign); @GET @Path("{eventId}/publications/{publicationId}") @RestQuery(name = "geteventpublication", description = "Returns a single publication.", returnDescription = "", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = STRING), @RestParameter(name = "publicationId", description = "The publication id", isRequired = true, type = STRING) }, restParameters = { @RestParameter(name = "sign", description = "Whether distribution urls should be signed.", isRequired = false, type = Type.BOOLEAN) }, responses = { @RestResponse(description = "The track details are returned.", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "The specified event or publication does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) Response getEventPublication(@HeaderParam("Accept") String acceptHeader, @PathParam("eventId") String eventId,
          @PathParam("publicationId") String publicationId, @QueryParam("sign") boolean sign); @GET @Path("{eventId}/scheduling") @Produces({ ApiMediaType.JSON, ApiMediaType.VERSION_1_1_0, ApiMediaType.VERSION_1_2_0, ApiMediaType.VERSION_1_3_0, ApiMediaType.VERSION_1_4_0, ApiMediaType.VERSION_1_5_0 }) @RestQuery(name = "geteventscheduling", description = "Returns an event's scheduling information.", returnDescription = "", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = STRING) }, responses = { @RestResponse(description = "The scheduling information for the specified event is returned.", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "The specified event has no scheduling information.", responseCode = HttpServletResponse.SC_NO_CONTENT), @RestResponse(description = "The specified event does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) Response getEventScheduling(@HeaderParam("Accept") String acceptHeader, @PathParam("eventId") String id); @PUT @Path("{eventId}/scheduling") @Produces({ ApiMediaType.JSON, ApiMediaType.VERSION_1_1_0, ApiMediaType.VERSION_1_2_0, ApiMediaType.VERSION_1_3_0, ApiMediaType.VERSION_1_4_0, ApiMediaType.VERSION_1_5_0 }) @RestQuery(name = "updateeventscheduling", description = "Update an event's scheduling information.", returnDescription = "", pathParameters = { @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = Type.STRING) }, restParameters = { @RestParameter(name = "scheduling", isRequired = true, description = "Scheduling Information", type = Type.STRING), @RestParameter(name = "allowConflict", description = "Allow conflicts when updating scheduling", isRequired = false, type = Type.BOOLEAN) }, responses = { @RestResponse(description = "The scheduling information for the specified event is updated.", responseCode = HttpServletResponse.SC_NO_CONTENT), @RestResponse(description = "The specified event has no scheduling information to update.", responseCode = HttpServletResponse.SC_NOT_ACCEPTABLE), @RestResponse(description = "The scheduling information could not be updated due to a conflict.", responseCode = HttpServletResponse.SC_CONFLICT), @RestResponse(description = "The specified event does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) Response updateEventScheduling(@HeaderParam("Accept") String acceptHeader, @PathParam("eventId") String id,
                                 @FormParam("scheduling") String scheduling,
                                 @FormParam("allowConflict") @DefaultValue("false") boolean allowConflict);  }