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;
}
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);
}
}
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);
}
}
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);
}
}
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)));
}
}
Aggregations