Search in sources :

Example 1 with SerializableTheme

use of org.opencastproject.message.broker.api.theme.SerializableTheme 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)

Aggregations

Theme (org.opencastproject.index.service.impl.index.theme.Theme)1 SearchIndexException (org.opencastproject.matterhorn.search.SearchIndexException)1 SerializableTheme (org.opencastproject.message.broker.api.theme.SerializableTheme)1 User (org.opencastproject.security.api.User)1