use of org.opencastproject.matterhorn.search.SearchIndexException in project opencast by opencast.
the class AbstractSearchIndex method getByQuery.
/**
* @param query
* The query to use to retrieve the groups that match the query
* @return {@link SearchResult} collection of {@link Group} from a query.
* @throws SearchIndexException
* Thrown if there is an error getting the results.
*/
public SearchResult<Group> getByQuery(GroupSearchQuery query) throws SearchIndexException {
logger.debug("Searching index using group query '{}'", query);
// Create the request builder
SearchRequestBuilder requestBuilder = getSearchRequestBuilder(query, new GroupQueryBuilder(query));
try {
return executeQuery(query, requestBuilder, new Fn<SearchMetadataCollection, Group>() {
@Override
public Group apply(SearchMetadataCollection metadata) {
try {
return GroupIndexUtils.toGroup(metadata);
} catch (IOException e) {
return chuck(e);
}
}
});
} catch (Throwable t) {
throw new SearchIndexException("Error querying series index", t);
}
}
use of org.opencastproject.matterhorn.search.SearchIndexException in project opencast by opencast.
the class SchedulerMessageReceiverImpl method execute.
@Override
protected void execute(SchedulerItem schedulerItem) {
DublinCoreCatalog dc = schedulerItem.getEvent();
Event event = null;
String organization = getSecurityService().getOrganization().getId();
User user = getSecurityService().getUser();
switch(schedulerItem.getType()) {
case UpdateCatalog:
logger.debug("Received Update Catalog");
// Load or create the corresponding recording event
try {
event = getOrCreateEvent(schedulerItem.getMediaPackageId(), organization, user, getSearchIndex());
if (isBlank(event.getCreator()))
event.setCreator(getSecurityService().getUser().getName());
if (event.getBlacklisted() == null)
event.setBlacklisted(false);
if (event.getOptedOut() == null)
event.setOptedOut(false);
if (dc != null)
EventIndexUtils.updateEvent(event, dc);
} catch (SearchIndexException e) {
logger.error("Error retrieving the recording event from the search index: {}", getStackTrace(e));
return;
}
// Update series name if not already done
try {
EventIndexUtils.updateSeriesName(event, organization, user, getSearchIndex());
} catch (SearchIndexException e) {
logger.error("Error updating the series name of the event to index: {}", getStackTrace(e));
}
// Persist the scheduling event
updateEvent(event);
break;
case UpdateAcl:
logger.debug("Received Update ACL");
// Load the corresponding recording event
try {
event = EventIndexUtils.getOrCreateEvent(schedulerItem.getMediaPackageId(), organization, user, getSearchIndex());
event.setAccessPolicy(AccessControlParser.toJsonSilent(schedulerItem.getAcl()));
} catch (SearchIndexException e) {
logger.error("Error retrieving the recording event from the search index: {}", getStackTrace(e));
return;
}
// Persist the scheduling event
updateEvent(event);
return;
case UpdateAgentId:
logger.debug("Received update event '{}' with agent id to '{}'", schedulerItem.getId(), schedulerItem.getAgentId());
// Load the corresponding recording event
try {
event = EventIndexUtils.getOrCreateEvent(schedulerItem.getMediaPackageId(), organization, user, getSearchIndex());
event.setAgentId(schedulerItem.getAgentId());
} catch (SearchIndexException e) {
logger.error("Error retrieving the recording event from the search index: {}", getStackTrace(e));
return;
}
// Persist the scheduling event
updateEvent(event);
return;
case UpdateProperties:
logger.debug("Received update event '{}' CA Properties '{}'", schedulerItem.getId(), schedulerItem.getProperties());
// Load the corresponding recording event
try {
event = EventIndexUtils.getOrCreateEvent(schedulerItem.getMediaPackageId(), organization, user, getSearchIndex());
event.setAgentConfiguration(schedulerItem.getProperties());
} catch (SearchIndexException e) {
logger.error("Error retrieving the recording event from the search index: {}", getStackTrace(e));
return;
}
// Persist the scheduling event
updateEvent(event);
return;
case UpdateOptOut:
logger.debug("Received Update opt out status");
// Load the corresponding recording event
try {
event = EventIndexUtils.getOrCreateEvent(schedulerItem.getMediaPackageId(), organization, user, getSearchIndex());
event.setOptedOut(schedulerItem.getOptOut());
} catch (SearchIndexException e) {
logger.error("Error retrieving the recording event from the search index: {}", getStackTrace(e));
return;
}
// Persist the scheduling event
updateEvent(event);
return;
case UpdateBlacklist:
logger.debug("Received Update blacklist status");
// Load the corresponding recording event
try {
event = EventIndexUtils.getOrCreateEvent(schedulerItem.getMediaPackageId(), organization, user, getSearchIndex());
event.setBlacklisted(schedulerItem.getBlacklisted());
} catch (SearchIndexException e) {
logger.error("Error retrieving the recording event from the search index: {}", e.getMessage());
return;
}
// Persist the scheduling event
updateEvent(event);
return;
case UpdateReviewStatus:
logger.debug("Received Update review status");
// Load the corresponding recording event
try {
event = EventIndexUtils.getOrCreateEvent(schedulerItem.getMediaPackageId(), organization, user, getSearchIndex());
event.setReviewStatus(schedulerItem.getReviewStatus());
if (schedulerItem.getReviewDate() != null)
event.setReviewDate(DateTimeSupport.toUTC(schedulerItem.getReviewDate().getTime()));
} catch (SearchIndexException e) {
logger.error("Error retrieving the recording event from the search index: {}", getStackTrace(e));
return;
}
// Persist the scheduling event
updateEvent(event);
return;
case UpdateRecordingStatus:
logger.debug("Received Update Recording {}", schedulerItem.getMediaPackageId());
// Load the corresponding recording event
try {
event = EventIndexUtils.getOrCreateEvent(schedulerItem.getMediaPackageId(), organization, user, getSearchIndex());
event.setRecordingStatus(schedulerItem.getRecordingState());
} catch (SearchIndexException e) {
logger.error("Error retrieving the recording event from the search index: {}", getStackTrace(e));
return;
}
// Persist the scheduling event
updateEvent(event);
return;
case DeleteRecordingStatus:
logger.debug("Received Delete recording status {}", schedulerItem.getMediaPackageId());
// Load the corresponding recording event
try {
event = EventIndexUtils.getOrCreateEvent(schedulerItem.getMediaPackageId(), organization, user, getSearchIndex());
event.setRecordingStatus(null);
} catch (SearchIndexException e) {
logger.error("Error retrieving the recording event from the search index: {}", getStackTrace(e));
return;
}
// Persist the scheduling event
updateEvent(event);
return;
case UpdateEnd:
String endTime = schedulerItem.getEnd() == null ? null : DateTimeSupport.toUTC(schedulerItem.getEnd().getTime());
logger.debug("Received update event '{}' end time '{}'", schedulerItem.getId(), endTime);
// Load the corresponding recording event
try {
event = EventIndexUtils.getOrCreateEvent(schedulerItem.getMediaPackageId(), organization, user, getSearchIndex());
event.setTechnicalEndTime(endTime);
} catch (SearchIndexException e) {
logger.error("Error retrieving the recording event from the search index: {}", getStackTrace(e));
return;
}
// Persist the scheduling event
updateEvent(event);
return;
case UpdateStart:
String startTime = schedulerItem.getStart() == null ? null : DateTimeSupport.toUTC(schedulerItem.getStart().getTime());
logger.debug("Received update event '{}' start time '{}'", schedulerItem.getId(), startTime);
// Load the corresponding recording event
try {
event = EventIndexUtils.getOrCreateEvent(schedulerItem.getMediaPackageId(), organization, user, getSearchIndex());
event.setTechnicalStartTime(startTime);
} catch (SearchIndexException e) {
logger.error("Error retrieving the recording event from the search index: {}", getStackTrace(e));
return;
}
// Persist the scheduling event
updateEvent(event);
return;
case UpdatePresenters:
logger.debug("Received update event '{}' with presenters '{}'", schedulerItem.getId(), schedulerItem.getPresenters());
try {
event = EventIndexUtils.getOrCreateEvent(schedulerItem.getMediaPackageId(), organization, user, getSearchIndex());
event.setTechnicalPresenters(new ArrayList<>(schedulerItem.getPresenters()));
} catch (SearchIndexException e) {
logger.error("Error retrieving the recording event from the search index: {}", getStackTrace(e));
return;
}
// Persist the scheduling event
updateEvent(event);
return;
case Delete:
logger.debug("Received Delete Event {}", schedulerItem.getMediaPackageId());
// Remove the scheduling from the search index
try {
getSearchIndex().deleteScheduling(organization, user, schedulerItem.getMediaPackageId());
logger.debug("Scheduled recording {} removed from the {} search index", schedulerItem.getMediaPackageId(), getSearchIndex().getIndexName());
} catch (NotFoundException e) {
logger.warn("Scheduled recording {} not found for deletion", schedulerItem.getMediaPackageId());
} catch (SearchIndexException e) {
logger.error("Error deleting the recording event from the search index: {}", getStackTrace(e));
return;
}
return;
default:
throw new IllegalArgumentException("Unhandled type of SchedulerItem");
}
}
use of org.opencastproject.matterhorn.search.SearchIndexException in project opencast by opencast.
the class ThemeMessageReceiverImpl method execute.
@Override
protected void execute(ThemeItem themeItem) {
String organization = getSecurityService().getOrganization().getId();
User user = getSecurityService().getUser();
switch(themeItem.getType()) {
case Update:
SerializableTheme serializableTheme = themeItem.getTheme();
logger.debug("Update the theme with id '{}', name '{}', description '{}', organization '{}'", serializableTheme.getId(), serializableTheme.getName(), serializableTheme.getDescription(), organization);
try {
Theme theme = ThemeIndexUtils.getOrCreate(serializableTheme.getId(), organization, user, getSearchIndex());
theme.setCreationDate(serializableTheme.getCreationDate());
theme.setDefault(serializableTheme.isDefault());
theme.setName(serializableTheme.getName());
theme.setDescription(serializableTheme.getDescription());
theme.setCreator(serializableTheme.getCreator());
theme.setBumperActive(serializableTheme.isBumperActive());
theme.setBumperFile(serializableTheme.getBumperFile());
theme.setTrailerActive(serializableTheme.isTrailerActive());
theme.setTrailerFile(serializableTheme.getTrailerFile());
theme.setTitleSlideActive(serializableTheme.isTitleSlideActive());
theme.setTitleSlideBackground(serializableTheme.getTitleSlideBackground());
theme.setTitleSlideMetadata(serializableTheme.getTitleSlideMetadata());
theme.setLicenseSlideActive(serializableTheme.isLicenseSlideActive());
theme.setLicenseSlideBackground(serializableTheme.getLicenseSlideBackground());
theme.setLicenseSlideDescription(serializableTheme.getLicenseSlideDescription());
theme.setWatermarkActive(serializableTheme.isWatermarkActive());
theme.setWatermarkFile(serializableTheme.getWatermarkFile());
theme.setWatermarkPosition(serializableTheme.getWatermarkPosition());
getSearchIndex().addOrUpdate(theme);
} catch (SearchIndexException e) {
logger.error("Error storing the theme {} to the search index: {}", serializableTheme.getId(), ExceptionUtils.getStackTrace(e));
return;
}
break;
case Delete:
logger.debug("Received Delete Theme Event {}", themeItem.getThemeId());
// Remove the theme from the search index
try {
getSearchIndex().delete(Theme.DOCUMENT_TYPE, Long.toString(themeItem.getThemeId()).concat(organization));
logger.debug("Theme {} removed from {} search index", themeItem.getThemeId(), getSearchIndex().getIndexName());
} catch (SearchIndexException e) {
logger.error("Error deleting the group {} from the search index: {}", themeItem.getThemeId(), ExceptionUtils.getStackTrace(e));
return;
}
return;
default:
throw new IllegalArgumentException("Unhandled type of ThemeItem");
}
}
use of org.opencastproject.matterhorn.search.SearchIndexException in project opencast by opencast.
the class AssetManagerMessageReceiverImpl method handleMessage.
/**
* Handle an update message.
*/
private void handleMessage(TakeSnapshot msg) {
logger.debug("Received AssetManager take snapshot message");
final MediaPackage mp = msg.getMediapackage();
final Opt<DublinCoreCatalog> episodeDublincore = msg.getEpisodeDublincore();
final String organization = getSecurityService().getOrganization().getId();
final User user = getSecurityService().getUser();
// Load or create the corresponding recording event
final Event event;
try {
event = getOrCreateEvent(mp.getIdentifier().toString(), organization, user, getSearchIndex());
final AccessControlList acl = msg.getAcl();
List<ManagedAcl> acls = aclServiceFactory.serviceFor(getSecurityService().getOrganization()).getAcls();
for (final ManagedAcl managedAcl : AccessInformationUtil.matchAcls(acls, acl)) {
event.setManagedAcl(managedAcl.getName());
}
event.setAccessPolicy(AccessControlParser.toJsonSilent(acl));
event.setArchiveVersion(msg.getVersion());
if (isBlank(event.getCreator()))
event.setCreator(getSecurityService().getUser().getName());
updateEvent(event, mp);
if (episodeDublincore.isSome()) {
updateEvent(event, episodeDublincore.get());
}
} catch (SearchIndexException e) {
logger.error("Error retrieving the recording event from the search index: {}", e.getMessage());
return;
}
// Update series name if not already done
try {
EventIndexUtils.updateSeriesName(event, organization, user, getSearchIndex());
} catch (SearchIndexException e) {
logger.error("Error updating the series name of the event to index: {}", ExceptionUtils.getStackTrace(e));
}
// Persist the scheduling event
try {
getSearchIndex().addOrUpdate(event);
logger.debug("Asset manager entry {} updated in the admin ui search index", event.getIdentifier());
} catch (SearchIndexException e) {
logger.error("Error retrieving the recording event from the search index: {}", e.getMessage());
}
}
use of org.opencastproject.matterhorn.search.SearchIndexException in project opencast by opencast.
the class AssetManagerMessageReceiverImpl method handleMessage.
/**
* Handle a delete message.
*/
private void handleMessage(DeleteEpisode msg) {
final String eventId = msg.getMediaPackageId();
final String organization = getSecurityService().getOrganization().getId();
final User user = getSecurityService().getUser();
logger.debug("Received AssetManager delete episode message {}", eventId);
// Remove the archived entry from the search index
try {
getSearchIndex().deleteAssets(organization, user, eventId);
logger.debug("Archived media package {} removed from admin ui search index", eventId);
} catch (NotFoundException e) {
logger.warn("Archived media package {} not found for deletion", eventId);
} catch (SearchIndexException e) {
logger.error("Error deleting the archived entry {} from the search index: {}", eventId, ExceptionUtils.getStackTrace(e));
}
}
Aggregations