SoxRestService extends AbstractJobProducerEndpoint { @POST @Path("normalize") @Produces(MediaType.TEXT_XML) @RestQuery(name = "normalize", description = "Starts audio normalization process", restParameters = { @RestParameter(description = "The track containing the audio stream", isRequired = true, name = "sourceAudioTrack", type = Type.TEXT), @RestParameter(description = "The target RMS level dB", isRequired = true, name = "targetRmsLevDb", type = Type.INTEGER) }, responses = { @RestResponse(description = "Results in an xml document containing the job for the audio normalization task", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "If required parameters aren't set or if sourceAudioTrack isn't from the type Track", responseCode = HttpServletResponse.SC_BAD_REQUEST) }, returnDescription = "") public Response normalize(@FormParam("sourceAudioTrack") String sourceAudioTrackAsXml, @FormParam("targetRmsLevDb") Float targetRmsLevDb) throws Exception { if (StringUtils.isBlank(sourceAudioTrackAsXml)) return Response.status(Response.Status.BAD_REQUEST).entity("sourceAudioTrack must not be null").build(); if (targetRmsLevDb == null) return Response.status(Response.Status.BAD_REQUEST).entity("targetRmsLevDb must not be null").build(); MediaPackageElement sourceTrack = MediaPackageElementParser.getFromXml(sourceAudioTrackAsXml); if (!Track.TYPE.equals(sourceTrack.getElementType())) return Response.status(Response.Status.BAD_REQUEST).entity("sourceAudioTrack element must be of type track") .build(); try { Job job = soxService.normalize((Track) sourceTrack, targetRmsLevDb); return Response.ok().entity(new JaxbJob(job)).build(); } catch (SoxException e) { logger.warn("Unable to normalize the track: " + e.getMessage()); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } }  void setSoxService(SoxService soxService); void activate(ComponentContext cc); @POST @Path("analyze") @Produces(MediaType.TEXT_XML) @RestQuery(name = "analyze", description = "Starts an audio analyzing process", restParameters = { @RestParameter(description = "The track just containing the audio stream", isRequired = true, name = "sourceAudioTrack", type = Type.TEXT) }, responses = { @RestResponse(description = "Results in an xml document containing the job for the analyzing task", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "If required parameters aren't set or if sourceAudioTrack isn't from the type Track", responseCode = HttpServletResponse.SC_BAD_REQUEST) }, returnDescription = "") Response analyze(@FormParam("sourceAudioTrack") String sourceAudioTrackAsXml); @POST @Path("normalize") @Produces(MediaType.TEXT_XML) @RestQuery(name = "normalize", description = "Starts audio normalization process", restParameters = { @RestParameter(description = "The track containing the audio stream", isRequired = true, name = "sourceAudioTrack", type = Type.TEXT), @RestParameter(description = "The target RMS level dB", isRequired = true, name = "targetRmsLevDb", type = Type.INTEGER) }, responses = { @RestResponse(description = "Results in an xml document containing the job for the audio normalization task", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "If required parameters aren't set or if sourceAudioTrack isn't from the type Track", responseCode = HttpServletResponse.SC_BAD_REQUEST) }, returnDescription = "") Response normalize(@FormParam("sourceAudioTrack") String sourceAudioTrackAsXml,
          @FormParam("targetRmsLevDb") Float targetRmsLevDb); @Override JobProducer getService(); @Override ServiceRegistry getServiceRegistry();  }
@Test public void testNormalize() throws Exception { Response response = restService.normalize(MediaPackageElementParser.getAsXml(audioTrack), -30f); Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); Assert.assertEquals(new JaxbJob(job), response.getEntity()); }