Search in sources :

Example 61 with Event

use of org.opencastproject.index.service.impl.index.event.Event in project opencast by opencast.

the class TestEventEndpoint method createEvent.

private Event createEvent(String id, String title, Source source) throws URISyntaxException {
    Event event = EasyMock.createNiceMock(Event.class);
    EasyMock.expect(event.getIdentifier()).andReturn(id).anyTimes();
    EasyMock.expect(event.getTitle()).andReturn(title).anyTimes();
    EasyMock.expect(event.getSeriesId()).andReturn("seriesId").anyTimes();
    EasyMock.expect(event.getReviewStatus()).andReturn(ReviewStatus.UNSENT.toString()).anyTimes();
    EasyMock.expect(event.getEventStatus()).andReturn("EVENTS.EVENTS.STATUS.ARCHIVE").anyTimes();
    EasyMock.expect(event.getOptedOut()).andReturn(true).anyTimes();
    EasyMock.expect(event.getRecordingStartDate()).andReturn("2013-03-20T04:00:00Z").anyTimes();
    EasyMock.expect(event.getRecordingEndDate()).andReturn("2013-03-20T05:00:00Z").anyTimes();
    EasyMock.expect(event.getTechnicalStartTime()).andReturn("2013-03-20T04:00:00Z").anyTimes();
    EasyMock.expect(event.getTechnicalEndTime()).andReturn("2013-03-20T05:00:00Z").anyTimes();
    EasyMock.expect(event.getWorkflowState()).andReturn(WorkflowInstance.WorkflowState.SUCCEEDED.name()).anyTimes();
    List<Publication> publist = new ArrayList<>();
    publist.add(new PublicationImpl("engage", "rest", new URI("engage.html?e=p-1"), MimeType.mimeType("text", "xml")));
    EasyMock.expect(event.getPublications()).andReturn(publist).anyTimes();
    EasyMock.expect(event.getAccessPolicy()).andReturn("{\"acl\":{\"ace\":[{\"allow\":true,\"action\":\"read\",\"role\":\"ROLE_ADMIN\"},{\"allow\":true,\"action\":\"write\",\"role\":\"ROLE_ADMIN\"}]}}\"").anyTimes();
    EasyMock.expect(event.hasRecordingStarted()).andReturn(true);
    // Simulate different event sources
    switch(source) {
        case ARCHIVE:
            EasyMock.expect(event.getArchiveVersion()).andReturn(1000L).anyTimes();
            break;
        case SCHEDULE:
            EasyMock.expect(event.getWorkflowId()).andReturn(1000L).anyTimes();
            break;
        default:
    }
    EasyMock.replay(event);
    return event;
}
Also used : PublicationImpl(org.opencastproject.mediapackage.PublicationImpl) ArrayList(java.util.ArrayList) Event(org.opencastproject.index.service.impl.index.event.Event) Publication(org.opencastproject.mediapackage.Publication) URI(java.net.URI)

Example 62 with Event

use of org.opencastproject.index.service.impl.index.event.Event in project opencast by opencast.

the class AbstractSearchIndex method getByQuery.

/**
 * @param query
 *          The query to use to retrieve the events that match the query
 * @return {@link SearchResult} collection of {@link Event} from a query.
 * @throws SearchIndexException
 *           Thrown if there is an error getting the results.
 */
public SearchResult<Event> getByQuery(EventSearchQuery query) throws SearchIndexException {
    logger.debug("Searching index using event query '{}'", query);
    // Create the request builder
    SearchRequestBuilder requestBuilder = getSearchRequestBuilder(query, new EventQueryBuilder(query));
    try {
        return executeQuery(query, requestBuilder, new Fn<SearchMetadataCollection, Event>() {

            @Override
            public Event apply(SearchMetadataCollection metadata) {
                try {
                    return EventIndexUtils.toRecordingEvent(metadata);
                } catch (IOException e) {
                    return chuck(e);
                }
            }
        });
    } catch (Throwable t) {
        throw new SearchIndexException("Error querying event index", t);
    }
}
Also used : SearchRequestBuilder(org.elasticsearch.action.search.SearchRequestBuilder) SearchMetadataCollection(org.opencastproject.matterhorn.search.impl.SearchMetadataCollection) SearchIndexException(org.opencastproject.matterhorn.search.SearchIndexException) EventQueryBuilder(org.opencastproject.index.service.impl.index.event.EventQueryBuilder) Event(org.opencastproject.index.service.impl.index.event.Event) IOException(java.io.IOException)

Example 63 with Event

use of org.opencastproject.index.service.impl.index.event.Event in project opencast by opencast.

the class AbstractSearchIndex method deleteScheduling.

/**
 * Delete an event from the scheduling service
 *
 * @param organization
 *          The organization the event is a part of.
 * @param user
 *          The user that is requesting to delete the event.
 * @param uid
 *          The identifier of the event.
 * @throws SearchIndexException
 *           Thrown if there is an issue with deleting the event.
 * @throws NotFoundException
 *           Thrown if the event cannot be found.
 */
public void deleteScheduling(String organization, User user, String uid) throws SearchIndexException, NotFoundException {
    Event event = EventIndexUtils.getEvent(uid, organization, user, this);
    if (event == null)
        throw new NotFoundException("No event with id " + uid + " found.");
    event.setOptedOut(null);
    event.setBlacklisted(null);
    event.setReviewDate(null);
    event.setReviewStatus(null);
    event.setSchedulingStatus(null);
    event.setRecordingStatus(null);
    if (toDelete(event)) {
        delete(Event.DOCUMENT_TYPE, uid.concat(organization));
    } else {
        addOrUpdate(event);
    }
}
Also used : Event(org.opencastproject.index.service.impl.index.event.Event) NotFoundException(org.opencastproject.util.NotFoundException)

Example 64 with Event

use of org.opencastproject.index.service.impl.index.event.Event in project opencast by opencast.

the class AbstractSearchIndex method deleteWorkflow.

/**
 * Delete an event from the workflow service
 *
 * @param organization
 *          The organization the event is a part of.
 * @param user
 *          The user that is requesting to delete the event.
 * @param uid
 *          The identifier of the event.
 * @param workflowId
 *          The identifier of the workflow.
 * @throws SearchIndexException
 *           Thrown if there is an issue with deleting the event.
 * @throws NotFoundException
 *           Thrown if the event cannot be found.
 */
public void deleteWorkflow(String organization, User user, String uid, Long workflowId) throws SearchIndexException, NotFoundException {
    Event event = EventIndexUtils.getEvent(uid, organization, user, this);
    if (event == null)
        throw new NotFoundException("No event with id " + uid + " found.");
    if (event.getWorkflowId() == workflowId) {
        logger.debug("Workflow {} is the current workflow of event {}. Removing it from event.", uid, workflowId);
        event.setWorkflowId(null);
        event.setWorkflowDefinitionId(null);
        event.setWorkflowState(null);
        event.setWorkflowScheduledDate(null);
    }
    if (toDelete(event)) {
        delete(Event.DOCUMENT_TYPE, uid.concat(organization));
    } else {
        addOrUpdate(event);
    }
}
Also used : Event(org.opencastproject.index.service.impl.index.event.Event) NotFoundException(org.opencastproject.util.NotFoundException)

Example 65 with Event

use of org.opencastproject.index.service.impl.index.event.Event in project opencast by opencast.

the class IndexServiceImpl method updateEventAcl.

@Override
public AccessControlList updateEventAcl(String id, AccessControlList acl, AbstractSearchIndex index) throws IllegalArgumentException, IndexServiceException, SearchIndexException, NotFoundException, UnauthorizedException {
    Opt<Event> optEvent = getEvent(id, index);
    if (optEvent.isNone())
        throw new NotFoundException("Cannot find an event with id " + id);
    Event event = optEvent.get();
    MediaPackage mediaPackage = getEventMediapackage(event);
    switch(getEventSource(event)) {
        case WORKFLOW:
            // Not updating the acl as the workflow might have already passed the point of distribution.
            throw new IllegalArgumentException("Unable to update the ACL of this event as it is currently processing.");
        case ARCHIVE:
            mediaPackage = authorizationService.setAcl(mediaPackage, AclScope.Episode, acl).getA();
            assetManager.takeSnapshot(DEFAULT_OWNER, mediaPackage);
            return acl;
        case SCHEDULE:
            mediaPackage = authorizationService.setAcl(mediaPackage, AclScope.Episode, acl).getA();
            try {
                schedulerService.updateEvent(id, Opt.<Date>none(), Opt.<Date>none(), Opt.<String>none(), Opt.<Set<String>>none(), Opt.some(mediaPackage), Opt.<Map<String, String>>none(), Opt.<Map<String, String>>none(), Opt.<Opt<Boolean>>none(), SchedulerService.ORIGIN);
            } catch (SchedulerException e) {
                throw new IndexServiceException("Unable to update the acl for the scheduled event", e);
            }
            return acl;
        default:
            logger.error("Unknown event source '{}' unable to update ACL!", getEventSource(event));
            throw new IndexServiceException(String.format("Unable to update the ACL as '{}' is an unknown event source.", getEventSource(event)));
    }
}
Also used : SchedulerException(org.opencastproject.scheduler.api.SchedulerException) MediaPackage(org.opencastproject.mediapackage.MediaPackage) Event(org.opencastproject.index.service.impl.index.event.Event) NotFoundException(org.opencastproject.util.NotFoundException) IndexServiceException(org.opencastproject.index.service.exception.IndexServiceException)

Aggregations

Event (org.opencastproject.index.service.impl.index.event.Event)67 Path (javax.ws.rs.Path)35 RestQuery (org.opencastproject.util.doc.rest.RestQuery)34 NotFoundException (org.opencastproject.util.NotFoundException)26 WebApplicationException (javax.ws.rs.WebApplicationException)24 SearchIndexException (org.opencastproject.matterhorn.search.SearchIndexException)22 Produces (javax.ws.rs.Produces)21 IndexServiceException (org.opencastproject.index.service.exception.IndexServiceException)19 MediaPackage (org.opencastproject.mediapackage.MediaPackage)19 SchedulerException (org.opencastproject.scheduler.api.SchedulerException)19 ParseException (java.text.ParseException)17 JSONException (org.codehaus.jettison.json.JSONException)17 UrlSigningException (org.opencastproject.security.urlsigning.exception.UrlSigningException)17 GET (javax.ws.rs.GET)16 AclServiceException (org.opencastproject.authorization.xacml.manager.api.AclServiceException)16 UnauthorizedException (org.opencastproject.security.api.UnauthorizedException)16 EventCommentException (org.opencastproject.event.comment.EventCommentException)15 WorkflowDatabaseException (org.opencastproject.workflow.api.WorkflowDatabaseException)15 JobEndpointException (org.opencastproject.adminui.exception.JobEndpointException)14 WorkflowStateException (org.opencastproject.workflow.api.WorkflowStateException)14