GoogleSpeechTranscriptionService extends AbstractJobProducer implements TranscriptionService { @Override public void transcriptionError(String mpId, Object obj) throws TranscriptionServiceException { JSONObject jsonObj = null; String jobId = null; try { jsonObj = (JSONObject) obj; jobId = (String) jsonObj.get("name"); database.updateJobControl(jobId, TranscriptionJobControl.Status.Error.name()); TranscriptionJobControl jobControl = database.findByJob(jobId); logger.warn("Error received for media package {}, job id {}", jobControl.getMediaPackageId(), jobId); sendEmail(TRANSCRIPTION_ERROR, String.format("There was a transcription error for for media package %s, job id %s.", jobControl.getMediaPackageId(), jobId)); } catch (TranscriptionDatabaseException e) { logger.warn("Transcription error. State in db could not be updated to error for mpId {}, jobId {}", mpId, jobId); throw new TranscriptionServiceException("Could not update transcription job control db", e); } } GoogleSpeechTranscriptionService(); void activate(ComponentContext cc); @Override Job startTranscription(String mpId, Track track, String language); @Override Job startTranscription(String mpId, Track track); @Override void transcriptionDone(String mpId, Object obj); @Override String getLanguage(); @Override void transcriptionError(String mpId, Object obj); String getTranscriptionResults(String jobId); @Override MediaPackageElement getGeneratedTranscription(String mpId, String jobId); String getTranscriptionStatus(String mpId); void setServiceRegistry(ServiceRegistry serviceRegistry); void setSecurityService(SecurityService securityService); void setUserDirectoryService(UserDirectoryService userDirectoryService); void setOrganizationDirectoryService(OrganizationDirectoryService organizationDirectoryService); void setSmtpService(SmtpService service); void setWorkspace(Workspace ws); void setWorkingFileRepository(WorkingFileRepository wfr); void setDatabase(TranscriptionDatabase service); void setAssetManager(AssetManager service); void setWorkflowService(WorkflowService service); static final String DEFAULT_WF_DEF; static final String ENABLED_CONFIG; static final String GOOGLE_SPEECH_LANGUAGE; static final String PROFANITY_FILTER; static final String WORKFLOW_CONFIG; static final String DISPATCH_WORKFLOW_INTERVAL_CONFIG; static final String COMPLETION_CHECK_BUFFER_CONFIG; static final String MAX_PROCESSING_TIME_CONFIG; static final String NOTIFICATION_EMAIL_CONFIG; static final String CLEANUP_RESULTS_DAYS_CONFIG; static final String GOOGLE_CLOUD_CLIENT_ID; static final String GOOGLE_CLOUD_CLIENT_SECRET; static final String GOOGLE_CLOUD_REFRESH_TOKEN; static final String GOOGLE_CLOUD_BUCKET; static final String GOOGLE_CLOUD_TOKEN_ENDPOINT_URL; static final String ENCODING_EXTENSION; }
@Test public void testTranscriptionError() throws Exception { InputStream stream = GoogleSpeechTranscriptionServiceTest.class.getResourceAsStream("/" + PULLED_TRANSCRIPTION_FILE); database.storeJobControl(MP_ID, TRACK_ID, JOB_ID, TranscriptionJobControl.Status.InProgress.name(), TRACK_DURATION, DATE_EXPECTED, PROVIDER); JSONObject obj = (JSONObject) jsonParser.parse(new InputStreamReader(stream)); service.transcriptionError(MP_ID, obj); TranscriptionJobControl job = database.findByJob(JOB_ID); Assert.assertNotNull(job); Assert.assertEquals(TranscriptionJobControl.Status.Error.name(), job.getStatus()); Assert.assertNull(job.getDateCompleted()); }