@Test public void testProcess() throws Exception { File file = new File(track.getURI()); Workspace workspace = EasyMock.createNiceMock(Workspace.class); EasyMock.expect(workspace.get(EasyMock.anyObject())) .andReturn(file); Capture<String> filenameCapture = Capture.newInstance(); EasyMock.expect(workspace.putInCollection( EasyMock.anyString(), EasyMock.capture(filenameCapture), EasyMock.anyObject())) .andReturn(new URI("timelinepreviews.png")); EasyMock.replay(workspace); TimelinePreviewsServiceImpl instance = new TimelinePreviewsServiceImpl(); instance.setWorkspace(workspace); String trackXml = MediaPackageElementParser.getAsXml(track); Job job = new JobImpl(1); job.setJobType(TimelinePreviewsServiceImpl.JOB_TYPE); job.setOperation(TimelinePreviewsServiceImpl.Operation.TimelinePreview.toString()); job.setArguments(Arrays.asList(trackXml, String.valueOf(10))); String result = instance.process(job); assertNotNull(result); MediaPackageElement timelinepreviewsAttachment = MediaPackageElementParser.getFromXml(result); assertEquals(new URI("timelinepreviews.png"), timelinepreviewsAttachment.getURI()); assertTrue(filenameCapture.hasCaptured()); }
@Override protected String process(Job job) throws Exception { Operation op = null; String operation = job.getOperation(); List<String> arguments = job.getArguments(); try { op = Operation.valueOf(operation); switch (op) { case TimelinePreview: Track track = (Track) MediaPackageElementParser .getFromXml(arguments.get(0)); int imageCount = Integer.parseInt(arguments.get(1)); Attachment timelinePreviewsMpe = generatePreviewImages(job, track, imageCount); return MediaPackageElementParser.getAsXml(timelinePreviewsMpe); default: throw new IllegalStateException("Don't know how to handle operation '" + operation + "'"); } } catch (IllegalArgumentException e) { throw new ServiceRegistryException("This service can't handle operations of type '" + op + "'", e); } catch (IndexOutOfBoundsException e) { throw new ServiceRegistryException("This argument list for operation '" + op + "' does not meet expectations", e); } catch (Exception e) { throw new ServiceRegistryException("Error handling operation '" + op + "'", e); } }
TimelinePreviewsServiceImpl extends AbstractJobProducer implements
TimelinePreviewsService, ManagedService { @Override protected String process(Job job) throws Exception { Operation op = null; String operation = job.getOperation(); List<String> arguments = job.getArguments(); try { op = Operation.valueOf(operation); switch (op) { case TimelinePreview: Track track = (Track) MediaPackageElementParser .getFromXml(arguments.get(0)); int imageCount = Integer.parseInt(arguments.get(1)); Attachment timelinePreviewsMpe = generatePreviewImages(job, track, imageCount); return MediaPackageElementParser.getAsXml(timelinePreviewsMpe); default: throw new IllegalStateException("Don't know how to handle operation '" + operation + "'"); } } catch (IllegalArgumentException e) { throw new ServiceRegistryException("This service can't handle operations of type '" + op + "'", e); } catch (IndexOutOfBoundsException e) { throw new ServiceRegistryException("This argument list for operation '" + op + "' does not meet expectations", e); } catch (Exception e) { throw new ServiceRegistryException("Error handling operation '" + op + "'", e); } } }
TimelinePreviewsServiceImpl extends AbstractJobProducer implements
TimelinePreviewsService, ManagedService { @Override protected String process(Job job) throws Exception { Operation op = null; String operation = job.getOperation(); List<String> arguments = job.getArguments(); try { op = Operation.valueOf(operation); switch (op) { case TimelinePreview: Track track = (Track) MediaPackageElementParser .getFromXml(arguments.get(0)); int imageCount = Integer.parseInt(arguments.get(1)); Attachment timelinePreviewsMpe = generatePreviewImages(job, track, imageCount); return MediaPackageElementParser.getAsXml(timelinePreviewsMpe); default: throw new IllegalStateException("Don't know how to handle operation '" + operation + "'"); } } catch (IllegalArgumentException e) { throw new ServiceRegistryException("This service can't handle operations of type '" + op + "'", e); } catch (IndexOutOfBoundsException e) { throw new ServiceRegistryException("This argument list for operation '" + op + "' does not meet expectations", e); } catch (Exception e) { throw new ServiceRegistryException("Error handling operation '" + op + "'", e); } } TimelinePreviewsServiceImpl(); }
TimelinePreviewsServiceImpl extends AbstractJobProducer implements
TimelinePreviewsService, ManagedService { @Override protected String process(Job job) throws Exception { Operation op = null; String operation = job.getOperation(); List<String> arguments = job.getArguments(); try { op = Operation.valueOf(operation); switch (op) { case TimelinePreview: Track track = (Track) MediaPackageElementParser .getFromXml(arguments.get(0)); int imageCount = Integer.parseInt(arguments.get(1)); Attachment timelinePreviewsMpe = generatePreviewImages(job, track, imageCount); return MediaPackageElementParser.getAsXml(timelinePreviewsMpe); default: throw new IllegalStateException("Don't know how to handle operation '" + operation + "'"); } } catch (IllegalArgumentException e) { throw new ServiceRegistryException("This service can't handle operations of type '" + op + "'", e); } catch (IndexOutOfBoundsException e) { throw new ServiceRegistryException("This argument list for operation '" + op + "' does not meet expectations", e); } catch (Exception e) { throw new ServiceRegistryException("Error handling operation '" + op + "'", e); } } TimelinePreviewsServiceImpl(); @Override void activate(ComponentContext cc); @Override void updated(Dictionary<String, ?> properties); @Override Job createTimelinePreviewImages(Track track, int imageCount); void setSecurityService(SecurityService securityService); void setUserDirectoryService(
      UserDirectoryService userDirectoryService); void setOrganizationDirectoryService(
      OrganizationDirectoryService organizationDirectory); }
TimelinePreviewsServiceImpl extends AbstractJobProducer implements
TimelinePreviewsService, ManagedService { @Override protected String process(Job job) throws Exception { Operation op = null; String operation = job.getOperation(); List<String> arguments = job.getArguments(); try { op = Operation.valueOf(operation); switch (op) { case TimelinePreview: Track track = (Track) MediaPackageElementParser .getFromXml(arguments.get(0)); int imageCount = Integer.parseInt(arguments.get(1)); Attachment timelinePreviewsMpe = generatePreviewImages(job, track, imageCount); return MediaPackageElementParser.getAsXml(timelinePreviewsMpe); default: throw new IllegalStateException("Don't know how to handle operation '" + operation + "'"); } } catch (IllegalArgumentException e) { throw new ServiceRegistryException("This service can't handle operations of type '" + op + "'", e); } catch (IndexOutOfBoundsException e) { throw new ServiceRegistryException("This argument list for operation '" + op + "' does not meet expectations", e); } catch (Exception e) { throw new ServiceRegistryException("Error handling operation '" + op + "'", e); } } TimelinePreviewsServiceImpl(); @Override void activate(ComponentContext cc); @Override void updated(Dictionary<String, ?> properties); @Override Job createTimelinePreviewImages(Track track, int imageCount); void setSecurityService(SecurityService securityService); void setUserDirectoryService(
      UserDirectoryService userDirectoryService); void setOrganizationDirectoryService(
      OrganizationDirectoryService organizationDirectory); static final String COLLECTION_ID; static final String FFMPEG_BINARY_CONFIG; static final String FFMPEG_BINARY_DEFAULT; static final String OPT_RESOLUTION_X; static final int DEFAULT_RESOLUTION_X; static final String OPT_RESOLUTION_Y; static final int DEFAULT_RESOLUTION_Y; static final String OPT_OUTPUT_FORMAT; static final String DEFAULT_OUTPUT_FORMAT; static final String OPT_MIMETYPE; static final String DEFAULT_MIMETYPE; static final float DEFAULT_TIMELINEPREVIEWS_JOB_LOAD; static final String TIMELINEPREVIEWS_JOB_LOAD_KEY; }