Search in sources :

Example 6 with Event

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

the class EventIndexUtilsTest method testUpdateSeriesNameInputSeriesEventuallyAddedToIndexExpectsSetsName.

@Test
@SuppressWarnings("unchecked")
public void testUpdateSeriesNameInputSeriesEventuallyAddedToIndexExpectsSetsName() throws SearchIndexException {
    // Input data
    String seriesId = "my_series";
    String eventId = "my_event";
    // Mocks
    Series series = EasyMock.createMock(Series.class);
    EasyMock.expect(series.getTitle()).andReturn(seriesId);
    SearchResultItem<Series> seriesResult = EasyMock.createMock(SearchResultItem.class);
    EasyMock.expect(seriesResult.getSource()).andReturn(series);
    ArrayList<SearchResultItem<Series>> seriesCollection = new ArrayList<SearchResultItem<Series>>();
    seriesCollection.add(seriesResult);
    SearchResult<Series> eventuallyResult = EasyMock.createMock(SearchResult.class);
    EasyMock.expect(eventuallyResult.getHitCount()).andReturn(0L);
    EasyMock.expect(eventuallyResult.getHitCount()).andReturn(0L);
    EasyMock.expect(eventuallyResult.getHitCount()).andReturn(1L);
    EasyMock.expect(eventuallyResult.getItems()).andReturn(seriesCollection.toArray(new SearchResultItem[1]));
    Event event = EasyMock.createMock(Event.class);
    EasyMock.expect(event.getSeriesId()).andReturn(seriesId).anyTimes();
    EasyMock.expect(event.getSeriesName()).andReturn(null).anyTimes();
    EasyMock.expect(event.getIdentifier()).andReturn(eventId).anyTimes();
    event.setSeriesName(seriesId);
    EasyMock.expectLastCall();
    AbstractSearchIndex searchIndex = EasyMock.createMock(AbstractSearchIndex.class);
    EasyMock.expect(searchIndex.getByQuery(EasyMock.anyObject(SeriesSearchQuery.class))).andReturn(eventuallyResult);
    EasyMock.expect(searchIndex.getByQuery(EasyMock.anyObject(SeriesSearchQuery.class))).andReturn(eventuallyResult);
    EasyMock.expect(searchIndex.getByQuery(EasyMock.anyObject(SeriesSearchQuery.class))).andReturn(eventuallyResult);
    EasyMock.replay(eventuallyResult, event, searchIndex, series, seriesResult);
    // Run test
    EventIndexUtils.updateSeriesName(event, defaultOrganization.getId(), user, searchIndex, 3, 50L);
}
Also used : AbstractSearchIndex(org.opencastproject.index.service.impl.index.AbstractSearchIndex) Series(org.opencastproject.index.service.impl.index.series.Series) SeriesSearchQuery(org.opencastproject.index.service.impl.index.series.SeriesSearchQuery) SearchResultItem(org.opencastproject.matterhorn.search.SearchResultItem) ArrayList(java.util.ArrayList) Event(org.opencastproject.index.service.impl.index.event.Event) Test(org.junit.Test)

Example 7 with Event

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

the class EventIndexUtilsTest method testUpdateSeriesNameInputSeriesNotAddedToIndexExpectsGivesUp.

@Test
public void testUpdateSeriesNameInputSeriesNotAddedToIndexExpectsGivesUp() throws SearchIndexException {
    // Input data
    String seriesId = "my_series";
    String eventId = "my_event";
    // Mocks
    @SuppressWarnings("unchecked") SearchResult<Series> emptyResult = EasyMock.createMock(SearchResult.class);
    EasyMock.expect(emptyResult.getHitCount()).andReturn(0L).anyTimes();
    Event event = EasyMock.createMock(Event.class);
    EasyMock.expect(event.getSeriesId()).andReturn(seriesId).anyTimes();
    EasyMock.expect(event.getSeriesName()).andReturn(null).anyTimes();
    EasyMock.expect(event.getIdentifier()).andReturn(eventId).anyTimes();
    AbstractSearchIndex searchIndex = EasyMock.createMock(AbstractSearchIndex.class);
    EasyMock.expect(searchIndex.getByQuery(EasyMock.anyObject(SeriesSearchQuery.class))).andReturn(emptyResult);
    EasyMock.expect(searchIndex.getByQuery(EasyMock.anyObject(SeriesSearchQuery.class))).andReturn(emptyResult);
    EasyMock.expect(searchIndex.getByQuery(EasyMock.anyObject(SeriesSearchQuery.class))).andReturn(emptyResult);
    EasyMock.replay(emptyResult, event, searchIndex);
    // Run test
    EventIndexUtils.updateSeriesName(event, defaultOrganization.getId(), user, searchIndex, 3, 50L);
}
Also used : AbstractSearchIndex(org.opencastproject.index.service.impl.index.AbstractSearchIndex) Series(org.opencastproject.index.service.impl.index.series.Series) SeriesSearchQuery(org.opencastproject.index.service.impl.index.series.SeriesSearchQuery) Event(org.opencastproject.index.service.impl.index.event.Event) Test(org.junit.Test)

Example 8 with Event

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

the class SchedulerMessageReceiverImplTest method testUpdateCreator.

@Test
public void testUpdateCreator() throws Exception {
    DublinCoreCatalog catalog = DublinCores.read(getClass().getResourceAsStream("/dublincore.xml"));
    SchedulerItem schedulerItem = SchedulerItem.updateCatalog("uuid", catalog);
    // Test initial set of creator
    scheduler.execute(schedulerItem);
    Event event = index.getEventResult();
    assertNotNull(event);
    assertEquals("Current user is expected to be creator as no other creator has been set explicitly", "Creator", event.getCreator());
    // Test updating creator
    event.setCreator("Hans");
    index.setInitialEvent(event);
    scheduler.execute(schedulerItem);
    event = index.getEventResult();
    assertNotNull(event);
    assertEquals("Creator has been updated", "Hans", event.getCreator());
}
Also used : SchedulerItem(org.opencastproject.message.broker.api.scheduler.SchedulerItem) Event(org.opencastproject.index.service.impl.index.event.Event) DublinCoreCatalog(org.opencastproject.metadata.dublincore.DublinCoreCatalog) Test(org.junit.Test)

Example 9 with Event

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

the class IndexServiceImpl method changeOptOutStatus.

@Override
public void changeOptOutStatus(String eventId, boolean optout, AbstractSearchIndex index) throws NotFoundException, SchedulerException, SearchIndexException, UnauthorizedException {
    Opt<Event> optEvent = getEvent(eventId, index);
    if (optEvent.isNone())
        throw new NotFoundException("Cannot find an event with id " + eventId);
    schedulerService.updateEvent(eventId, Opt.<Date>none(), Opt.<Date>none(), Opt.<String>none(), Opt.<Set<String>>none(), Opt.<MediaPackage>none(), Opt.<Map<String, String>>none(), Opt.<Map<String, String>>none(), Opt.some(Opt.some(optout)), SchedulerService.ORIGIN);
    logger.debug("Setting event {} to opt out status of {}", eventId, optout);
}
Also used : Event(org.opencastproject.index.service.impl.index.event.Event) NotFoundException(org.opencastproject.util.NotFoundException)

Example 10 with Event

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

the class IndexServiceImpl method updateEventMetadata.

@Override
public MetadataList updateEventMetadata(String id, MetadataList metadataList, AbstractSearchIndex index) throws 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);
    Opt<Set<String>> presenters = Opt.none();
    Opt<MetadataCollection> eventCatalog = metadataList.getMetadataByAdapter(getCommonEventCatalogUIAdapter());
    if (eventCatalog.isSome()) {
        presenters = updatePresenters(eventCatalog.get());
    }
    updateMediaPackageMetadata(mediaPackage, metadataList);
    switch(getEventSource(event)) {
        case WORKFLOW:
            Opt<WorkflowInstance> workflowInstance = getCurrentWorkflowInstance(event.getIdentifier());
            if (workflowInstance.isNone()) {
                logger.error("No workflow instance for event {} found!", event.getIdentifier());
                throw new IndexServiceException("No workflow instance found for event " + event.getIdentifier());
            }
            try {
                WorkflowInstance instance = workflowInstance.get();
                instance.setMediaPackage(mediaPackage);
                updateWorkflowInstance(instance);
            } catch (WorkflowException e) {
                logger.error("Unable to update workflow event {} with metadata {} because {}", id, RestUtils.getJsonStringSilent(metadataList.toJSON()), getStackTrace(e));
                throw new IndexServiceException("Unable to update workflow event " + id);
            }
            break;
        case ARCHIVE:
            assetManager.takeSnapshot(DEFAULT_OWNER, mediaPackage);
            break;
        case SCHEDULE:
            try {
                schedulerService.updateEvent(id, Opt.<Date>none(), Opt.<Date>none(), Opt.<String>none(), presenters, Opt.some(mediaPackage), Opt.<Map<String, String>>none(), Opt.<Map<String, String>>none(), Opt.<Opt<Boolean>>none(), SchedulerService.ORIGIN);
            } catch (SchedulerException e) {
                logger.error("Unable to update scheduled event {} with metadata {} because {}", id, RestUtils.getJsonStringSilent(metadataList.toJSON()), getStackTrace(e));
                throw new IndexServiceException("Unable to update scheduled event " + id);
            }
            break;
        default:
            logger.error("Unkown event source!");
    }
    return metadataList;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) WorkflowSet(org.opencastproject.workflow.api.WorkflowSet) SchedulerException(org.opencastproject.scheduler.api.SchedulerException) WorkflowException(org.opencastproject.workflow.api.WorkflowException) NotFoundException(org.opencastproject.util.NotFoundException) WorkflowInstance(org.opencastproject.workflow.api.WorkflowInstance) MediaPackage(org.opencastproject.mediapackage.MediaPackage) Event(org.opencastproject.index.service.impl.index.event.Event) MetadataCollection(org.opencastproject.metadata.dublincore.MetadataCollection) 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