@Override public Optional<ContentHierarchyAndSummaries> process( ProgData progData, Channel channel, DateTimeZone zone, Timestamp updatedAt) { try { log.trace("Channel: {} ProgData: {} UpdatedAt: {}", channel, progData, updatedAt); if (shouldNotProcess(progData)) { return Optional.absent(); } Optional<Brand> possibleBrand = getBrand(progData, channel, updatedAt); Brand brandSummary = null; if (possibleBrand.isPresent() && hasBrandSummary(progData)) { brandSummary = getBrandSummary(progData, possibleBrand.get(), updatedAt); } Optional<Series> possibleSeries = getSeries(progData, channel, updatedAt); Series seriesSummary = null; if (possibleSeries.isPresent() && hasSeriesSummary(progData)) { seriesSummary = getSeriesSummary(progData, possibleSeries.get(), updatedAt); } boolean isEpisode = possibleBrand.isPresent() || possibleSeries.isPresent(); ItemAndBroadcast itemAndBroadcast = isClosedBrand(possibleBrand) ? getClosedEpisode(progData, channel, zone, updatedAt) : getFilmOrEpisode(progData, channel, zone, isEpisode, updatedAt); Item item = itemAndBroadcast.getItem(); // TODO: there is an unknown bug preventing this from working (MBST-17174) if (!isEpisode) { item.setParentRef(null); } item.setGenericDescription(isGenericDescription(progData)); item.addAlias(PaHelper.getProgIdAlias(progData.getProgId())); item.setLastUpdated(updatedAt.toDateTimeUTC()); return Optional.of( new ContentHierarchyAndSummaries( possibleBrand, possibleSeries, item, itemAndBroadcast.getBroadcast().requireValue(), Optional.fromNullable(brandSummary), Optional.fromNullable(seriesSummary))); } catch (Exception e) { log.error("Failed to process PA programme data", e); adapterLog.record( new AdapterLogEntry(Severity.ERROR) .withCause(e) .withSource(PaProgrammeProcessor.class) .withDescription(e.getMessage())); } return Optional.absent(); }