use of org.opencastproject.matterhorn.search.SearchIndexException in project opencast by opencast.
the class IndexServiceImpl method updateAllEventMetadata.
@Override
public MetadataList updateAllEventMetadata(String id, String metadataJSON, AbstractSearchIndex index) throws IllegalArgumentException, IndexServiceException, NotFoundException, SearchIndexException, UnauthorizedException {
MetadataList metadataList;
try {
metadataList = getMetadataListWithAllEventCatalogUIAdapters();
metadataList.fromJSON(metadataJSON);
} catch (Exception e) {
logger.warn("Not able to parse the event metadata {}: {}", metadataJSON, getStackTrace(e));
throw new IllegalArgumentException("Not able to parse the event metadata " + metadataJSON, e);
}
return updateEventMetadata(id, metadataList, index);
}
use of org.opencastproject.matterhorn.search.SearchIndexException in project opencast by opencast.
the class EventIndexUtils method updateComments.
/**
* Update an event with the given has comments and has open comments status.
*
* @param eventId
* the event id
* @param hasComments
* whether it has comments
* @param hasOpenComments
* whether it has open comments
* @param organization
* the organization
* @param user
* the user
* @param searchIndex
* the serach index
* @throws SearchIndexException
* if error occurs
* @throws NotFoundException
* if event has not been found
*/
public static void updateComments(String eventId, boolean hasComments, boolean hasOpenComments, boolean needsCutting, String organization, User user, AbstractSearchIndex searchIndex) throws SearchIndexException, NotFoundException {
if (!hasComments && hasOpenComments)
throw new IllegalStateException("Invalid comment update request: You can't have open comments without having any comments!");
if (!hasOpenComments && needsCutting)
throw new IllegalStateException("Invalid comment update request: You can't have an needs cutting comment without having any open comments!");
Event event = getEvent(eventId, organization, user, searchIndex);
if (event == null)
throw new NotFoundException("No event with id " + eventId + " found.");
event.setHasComments(hasComments);
event.setHasOpenComments(hasOpenComments);
event.setNeedsCutting(needsCutting);
try {
searchIndex.addOrUpdate(event);
} catch (SearchIndexException e) {
logger.warn("Unable to update event '{}': {}", event, ExceptionUtils.getStackTrace(e));
}
}
use of org.opencastproject.matterhorn.search.SearchIndexException in project opencast by opencast.
the class AbstractSearchIndex method addOrUpdate.
/**
* Add or update a series in the search index.
*
* @param series
* @throws SearchIndexException
*/
public void addOrUpdate(Series series) throws SearchIndexException {
logger.debug("Adding resource {} to search index", series);
// if (!preparedIndices.contains(resource.getURI().getSite().getIdentifier())) {
// try {
// createIndex(resource.getURI().getSite());
// } catch (IOException e) {
// throw new SearchIndexException(e);
// }
// }
// Add the resource to the index
SearchMetadataCollection inputDocument = SeriesIndexUtils.toSearchMetadata(series);
List<SearchMetadata<?>> resourceMetadata = inputDocument.getMetadata();
ElasticsearchDocument doc = new ElasticsearchDocument(inputDocument.getIdentifier(), inputDocument.getDocumentType(), resourceMetadata);
try {
update(doc);
} catch (Throwable t) {
throw new SearchIndexException("Cannot write resource " + series + " to index", t);
}
}
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 themes that match the query
* @return {@link SearchResult} collection of {@link Theme} from a query.
* @throws SearchIndexException
* Thrown if there is an error getting the results.
*/
public SearchResult<Theme> getByQuery(ThemeSearchQuery query) throws SearchIndexException {
logger.debug("Searching index using theme query '{}'", query);
// Create the request builder
SearchRequestBuilder requestBuilder = getSearchRequestBuilder(query, new ThemeQueryBuilder(query));
try {
return executeQuery(query, requestBuilder, new Fn<SearchMetadataCollection, Theme>() {
@Override
public Theme apply(SearchMetadataCollection metadata) {
try {
return ThemeIndexUtils.toTheme(metadata);
} catch (IOException e) {
return chuck(e);
}
}
});
} catch (Throwable t) {
throw new SearchIndexException("Error querying theme index", t);
}
}
use of org.opencastproject.matterhorn.search.SearchIndexException in project opencast by opencast.
the class AbstractSearchIndex method addOrUpdate.
/**
* Adds or updates the theme in the search index.
*
* @param theme
* The theme to add
* @throws SearchIndexException
* Thrown if unable to add or update the theme.
*/
public void addOrUpdate(Theme theme) throws SearchIndexException {
logger.debug("Adding resource {} to search index", theme);
// if (!preparedIndices.contains(resource.getURI().getSite().getIdentifier())) {
// try {
// createIndex(resource.getURI().getSite());
// } catch (IOException e) {
// throw new SearchIndexException(e);
// }
// }
// Add the resource to the index
SearchMetadataCollection inputDocument = ThemeIndexUtils.toSearchMetadata(theme);
List<SearchMetadata<?>> resourceMetadata = inputDocument.getMetadata();
ElasticsearchDocument doc = new ElasticsearchDocument(inputDocument.getIdentifier(), inputDocument.getDocumentType(), resourceMetadata);
try {
update(doc);
} catch (Throwable t) {
throw new SearchIndexException("Cannot write resource " + theme + " to index", t);
}
}
Aggregations