Search in sources :

Example 6 with SearchIndexException

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);
    }
}
Also used : Group(org.opencastproject.index.service.impl.index.group.Group) SearchRequestBuilder(org.elasticsearch.action.search.SearchRequestBuilder) SearchMetadataCollection(org.opencastproject.matterhorn.search.impl.SearchMetadataCollection) SearchIndexException(org.opencastproject.matterhorn.search.SearchIndexException) IOException(java.io.IOException) GroupQueryBuilder(org.opencastproject.index.service.impl.index.group.GroupQueryBuilder)

Example 7 with SearchIndexException

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");
    }
}
Also used : User(org.opencastproject.security.api.User) SearchIndexException(org.opencastproject.matterhorn.search.SearchIndexException) EventIndexUtils.getOrCreateEvent(org.opencastproject.index.service.impl.index.event.EventIndexUtils.getOrCreateEvent) Event(org.opencastproject.index.service.impl.index.event.Event) NotFoundException(org.opencastproject.util.NotFoundException) DublinCoreCatalog(org.opencastproject.metadata.dublincore.DublinCoreCatalog)

Example 8 with SearchIndexException

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");
    }
}
Also used : User(org.opencastproject.security.api.User) SearchIndexException(org.opencastproject.matterhorn.search.SearchIndexException) SerializableTheme(org.opencastproject.message.broker.api.theme.SerializableTheme) Theme(org.opencastproject.index.service.impl.index.theme.Theme) SerializableTheme(org.opencastproject.message.broker.api.theme.SerializableTheme)

Example 9 with SearchIndexException

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());
    }
}
Also used : AccessControlList(org.opencastproject.security.api.AccessControlList) User(org.opencastproject.security.api.User) SearchIndexException(org.opencastproject.matterhorn.search.SearchIndexException) MediaPackage(org.opencastproject.mediapackage.MediaPackage) ManagedAcl(org.opencastproject.authorization.xacml.manager.api.ManagedAcl) Event(org.opencastproject.index.service.impl.index.event.Event) EventIndexUtils.getOrCreateEvent(org.opencastproject.index.service.impl.index.event.EventIndexUtils.getOrCreateEvent) EventIndexUtils.updateEvent(org.opencastproject.index.service.impl.index.event.EventIndexUtils.updateEvent) DublinCoreCatalog(org.opencastproject.metadata.dublincore.DublinCoreCatalog)

Example 10 with SearchIndexException

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));
    }
}
Also used : User(org.opencastproject.security.api.User) SearchIndexException(org.opencastproject.matterhorn.search.SearchIndexException) NotFoundException(org.opencastproject.util.NotFoundException)

Aggregations

SearchIndexException (org.opencastproject.matterhorn.search.SearchIndexException)43 NotFoundException (org.opencastproject.util.NotFoundException)18 WebApplicationException (javax.ws.rs.WebApplicationException)15 Path (javax.ws.rs.Path)14 RestQuery (org.opencastproject.util.doc.rest.RestQuery)14 Event (org.opencastproject.index.service.impl.index.event.Event)11 IOException (java.io.IOException)10 IndexServiceException (org.opencastproject.index.service.exception.IndexServiceException)10 UnauthorizedException (org.opencastproject.security.api.UnauthorizedException)10 SearchMetadataCollection (org.opencastproject.matterhorn.search.impl.SearchMetadataCollection)9 Produces (javax.ws.rs.Produces)8 SchedulerException (org.opencastproject.scheduler.api.SchedulerException)8 User (org.opencastproject.security.api.User)8 GET (javax.ws.rs.GET)7 ParseException (java.text.ParseException)6 ArrayList (java.util.ArrayList)6 JSONException (org.codehaus.jettison.json.JSONException)6 EventCommentException (org.opencastproject.event.comment.EventCommentException)6 Series (org.opencastproject.index.service.impl.index.series.Series)6 Theme (org.opencastproject.index.service.impl.index.theme.Theme)6