use of org.opencastproject.job.api.JaxbJob in project opencast by opencast.
the class OaiPmhPublicationRestService method retract.
@POST
@Path("/retract")
@Produces(MediaType.TEXT_XML)
@RestQuery(name = "retract", description = "Retract a media package element from this publication channel", returnDescription = "The job that can be used to track the retraction", restParameters = { @RestParameter(name = "mediapackage", isRequired = true, description = "The media package", type = Type.TEXT), @RestParameter(name = "channel", isRequired = true, description = "The OAI-PMH channel to retract from", type = Type.STRING) }, reponses = { @RestResponse(responseCode = SC_OK, description = "An XML representation of the retraction job") })
public Response retract(@FormParam("mediapackage") String mediaPackageXml, @FormParam("channel") String channel) throws Exception {
Job job = null;
MediaPackage mediaPackage = null;
try {
mediaPackage = MediaPackageParser.getFromXml(mediaPackageXml);
job = service.retract(mediaPackage, channel);
} catch (IllegalArgumentException e) {
logger.debug("Unable to create an retract job", e);
return Response.status(Status.BAD_REQUEST).build();
} catch (Exception e) {
logger.warn("Unable to retract media package '{}' from the OAI-PMH channel {}", mediaPackage != null ? mediaPackage.getIdentifier().compact() : "<parsing error>", channel, e);
return Response.serverError().build();
}
return Response.ok(new JaxbJob(job)).build();
}
use of org.opencastproject.job.api.JaxbJob in project opencast by opencast.
the class YouTubePublicationRestService method publish.
@POST
@Path("/")
@Produces(MediaType.TEXT_XML)
@RestQuery(name = "publish", description = "Publish a media package element to youtube publication channel", returnDescription = "The job that can be used to track the publication", restParameters = { @RestParameter(name = "mediapackage", isRequired = true, description = "The mediapackage", type = Type.TEXT), @RestParameter(name = "elementId", isRequired = true, description = "The element to publish", type = Type.STRING) }, reponses = { @RestResponse(responseCode = SC_OK, description = "An XML representation of the publication job"), @RestResponse(responseCode = SC_BAD_REQUEST, description = "elementId does not reference a track") })
public Response publish(@FormParam("mediapackage") final String mediaPackageXml, @FormParam("elementId") final String elementId) {
final Job job;
try {
final MediaPackage mediapackage = MediaPackageParser.getFromXml(mediaPackageXml);
final Track track = mediapackage.getTrack(elementId);
if (track != null) {
job = service.publish(mediapackage, track);
} else {
return badRequest();
}
} catch (Exception e) {
logger.warn("Error publishing element '{}' to YouTube", elementId, e);
return serverError();
}
return Response.ok(new JaxbJob(job)).build();
}
use of org.opencastproject.job.api.JaxbJob in project opencast by opencast.
the class SoxRestServiceTest method testAnalyze.
@Test
public void testAnalyze() throws Exception {
Response response = restService.analyze(MediaPackageElementParser.getAsXml(audioTrack));
Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
Assert.assertEquals(new JaxbJob(job), response.getEntity());
}
use of org.opencastproject.job.api.JaxbJob in project opencast by opencast.
the class SoxRestServiceTest method testNormalize.
@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());
}
use of org.opencastproject.job.api.JaxbJob in project opencast by opencast.
the class TextAnalysisRestEndpoint method analyze.
@POST
@Produces(MediaType.TEXT_XML)
@Path("")
@RestQuery(name = "analyze", description = "Submit a track for analysis.", restParameters = { @RestParameter(description = "The image to analyze for text.", isRequired = true, name = "image", type = RestParameter.Type.FILE) }, reponses = { @RestResponse(description = "OK, The receipt to use when polling for the resulting mpeg7 catalog.", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "The argument cannot be parsed into a media package element.", responseCode = HttpServletResponse.SC_BAD_REQUEST), @RestResponse(description = "The service is unavailable at the moment.", responseCode = HttpServletResponse.SC_SERVICE_UNAVAILABLE) }, returnDescription = "The receipt to use when polling for the resulting mpeg7 catalog.")
public Response analyze(@FormParam("image") String image) {
if (service == null)
throw new WebApplicationException(Status.SERVICE_UNAVAILABLE);
try {
MediaPackageElement element = MediaPackageElementParser.getFromXml(image);
if (!(element instanceof Attachment))
throw new WebApplicationException(Status.BAD_REQUEST);
Job job = service.extract((Attachment) element);
return Response.ok(new JaxbJob(job)).build();
} catch (Exception e) {
logger.info(e.getMessage(), e);
return Response.serverError().build();
}
}
Aggregations