IngestServiceImpl extends AbstractJobProducer implements IngestService, ManagedService { private MediaPackage mergeScheduledMediaPackage(MediaPackage mp) throws IngestException { if (schedulerService == null) { logger.warn("No scheduler service available to merge mediapackage!"); return mp; } try { MediaPackage scheduledMp = schedulerService.getMediaPackage(mp.getIdentifier().toString()); logger.info("Found matching scheduled event for id '{}', merging mediapackage...", mp.getIdentifier().toString()); mergeMediaPackageElements(mp, scheduledMp); mergeMediaPackageMetadata(mp, scheduledMp); return mp; } catch (NotFoundException e) { logger.debug("No scheduler mediapackage found with id {}, skip merging", mp.getIdentifier()); return mp; } catch (Exception e) { throw new IngestException(String.format("Unable to get event media package from scheduler event %s", mp.getIdentifier()), e); } } IngestServiceImpl(); @Override @Activate void activate(ComponentContext cc); @Deactivate void deactivate(); @Override void updated(Dictionary<String, ?> properties); @Reference void setHttpClient(TrustedHttpClient httpClient); @Reference void setServiceRegistry(ServiceRegistry serviceRegistry); @Reference void setMediaInspectionService(MediaInspectionService mediaInspectionService); WorkflowInstance addZippedMediaPackage(InputStream zipStream); @Override WorkflowInstance addZippedMediaPackage(InputStream zipStream, String wd, Map<String, String> workflowConfig); @Override WorkflowInstance addZippedMediaPackage(InputStream zipStream, String workflowDefinitionId,
          Map<String, String> workflowConfig, Long workflowInstanceId); @Override MediaPackage createMediaPackage(); @Override MediaPackage createMediaPackage(String mediaPackageId); @Override MediaPackage addTrack(URI uri, MediaPackageElementFlavor flavor, MediaPackage mediaPackage); @Override MediaPackage addTrack(URI uri, MediaPackageElementFlavor flavor, String[] tags, MediaPackage mediaPackage); @Override MediaPackage addTrack(InputStream in, String fileName, MediaPackageElementFlavor flavor,
          MediaPackage mediaPackage); @Override MediaPackage addTrack(InputStream in, String fileName, MediaPackageElementFlavor flavor, String[] tags,
          MediaPackage mediaPackage); @Override MediaPackage addPartialTrack(URI uri, MediaPackageElementFlavor flavor, long startTime,
          MediaPackage mediaPackage); @Override MediaPackage addPartialTrack(InputStream in, String fileName, MediaPackageElementFlavor flavor, long startTime,
          MediaPackage mediaPackage); @Override MediaPackage addCatalog(URI uri, MediaPackageElementFlavor flavor, MediaPackage mediaPackage); @Override MediaPackage addCatalog(InputStream in, String fileName, MediaPackageElementFlavor flavor,
          MediaPackage mediaPackage); @Override MediaPackage addCatalog(InputStream in, String fileName, MediaPackageElementFlavor flavor, String[] tags,
          MediaPackage mediaPackage); @Override MediaPackage addAttachment(URI uri, MediaPackageElementFlavor flavor, MediaPackage mediaPackage); @Override MediaPackage addAttachment(InputStream in, String fileName, MediaPackageElementFlavor flavor, String[] tags,
          MediaPackage mediaPackage); @Override MediaPackage addAttachment(InputStream in, String fileName, MediaPackageElementFlavor flavor,
          MediaPackage mediaPackage); @Override WorkflowInstance ingest(MediaPackage mp); @Override WorkflowInstance ingest(MediaPackage mp, String wd, Map<String, String> properties); @Override WorkflowInstance ingest(MediaPackage mp, String workflowDefinitionId, Map<String, String> properties,
          Long workflowInstanceId); @Override void schedule(MediaPackage mediaPackage, String workflowDefinitionID, Map<String, String> properties); @Override void discardMediaPackage(MediaPackage mp); @Reference void setWorkflowService(WorkflowService workflowService); @Reference void setWorkingFileRepository(WorkingFileRepository workingFileRepository); @Reference void setSeriesService(SeriesService seriesService); @Reference void setDublinCoreService(DublinCoreCatalogService dublinCoreService); @Reference void setSecurityService(SecurityService securityService); @Reference void setUserDirectoryService(UserDirectoryService userDirectoryService); @Reference( policy = ReferencePolicy.DYNAMIC, cardinality = ReferenceCardinality.OPTIONAL, unbind = "unsetSchedulerService" ) void setSchedulerService(SchedulerService schedulerService); void unsetSchedulerService(SchedulerService schedulerService); @Reference void setOrganizationDirectoryService(OrganizationDirectoryService organizationDirectory); static Function<MediaPackageElement, Job> newEnrichJob(final MediaInspectionService svc); static Function<Job, Track> payloadAsTrack(final ServiceRegistry reg); static final String LEGACY_MEDIAPACKAGE_ID_KEY; static final String JOB_TYPE; static final String INGEST_ZIP; static final String INGEST_TRACK; static final String INGEST_TRACK_FROM_URI; static final String INGEST_ATTACHMENT; static final String INGEST_ATTACHMENT_FROM_URI; static final String INGEST_CATALOG; static final String INGEST_CATALOG_FROM_URI; static final float DEFAULT_INGEST_FILE_JOB_LOAD; static final float DEFAULT_INGEST_ZIP_JOB_LOAD; static final String FILE_JOB_LOAD_KEY; static final String ZIP_JOB_LOAD_KEY; static final String DOWNLOAD_SOURCE; static final String DOWNLOAD_USER; static final String DOWNLOAD_PASSWORD; static final boolean DEFAULT_ALLOW_SERIES_MODIFICATIONS; static final boolean DEFAULT_ALLOW_ONLY_NEW_FLAVORS; static final boolean DEFAULT_SKIP; @Deprecated
  static final String MODIFY_OPENCAST_SERIES_KEY; static final String ADD_ONLY_NEW_FLAVORS_KEY; static final String SKIP_CATALOGS_KEY; static final String SKIP_ATTACHMENTS_KEY; }
@Test public void testMergeScheduledMediaPackage() throws Exception { MediaPackage ingestMediaPackage = MediaPackageParser .getFromXml(IOUtils.toString(getClass().getResourceAsStream("/source-manifest-partial.xml"), "UTF-8")); Dictionary<String, String> properties = new Hashtable<>(); properties.put(IngestServiceImpl.SKIP_ATTACHMENTS_KEY, "false"); properties.put(IngestServiceImpl.SKIP_CATALOGS_KEY, "false"); properties.put(IngestServiceImpl.ADD_ONLY_NEW_FLAVORS_KEY, "false"); service.updated(properties); MediaPackage mergedMediaPackage = service.ingest(ingestMediaPackage).getMediaPackage(); Assert.assertEquals(4, mergedMediaPackage.getTracks().length); Track track = mergedMediaPackage.getTrack("track-1"); Assert.assertEquals("/vonlya1.mov", track.getURI().toString()); Assert.assertEquals(4, mergedMediaPackage.getCatalogs().length); Assert.assertEquals(2, mergedMediaPackage.getAttachments().length); Attachment attachment = mergedMediaPackage.getAttachment("cover"); Assert.assertEquals("attachments/cover.png", attachment.getURI().toString()); Assert.assertEquals(10045L, mergedMediaPackage.getDuration().doubleValue(), 0L); Assert.assertEquals("t2", mergedMediaPackage.getTitle()); Assert.assertEquals("s2", mergedMediaPackage.getSeries()); Assert.assertEquals("st2", mergedMediaPackage.getSeriesTitle()); Assert.assertEquals("l2", mergedMediaPackage.getLicense()); Assert.assertEquals(1, mergedMediaPackage.getSubjects().length); Assert.assertEquals("s2", mergedMediaPackage.getSubjects()[0]); Assert.assertEquals(1, mergedMediaPackage.getContributors().length); Assert.assertEquals("sd2", mergedMediaPackage.getContributors()[0]); Assert.assertEquals(1, mergedMediaPackage.getCreators().length); Assert.assertEquals("p2", mergedMediaPackage.getCreators()[0]); }