use of org.opencastproject.serviceregistry.api.ServiceRegistryException in project opencast by opencast.
the class StreamingDistributionServiceImpl method retract.
/**
* {@inheritDoc}
*
* @see org.opencastproject.distribution.api.DistributionService#retract(String,
* org.opencastproject.mediapackage.MediaPackage, String) java.lang.String)
*/
@Override
public Job retract(String channelId, MediaPackage mediaPackage, Set<String> elementIds) throws DistributionException {
if (locations.isNone())
return null;
RequireUtil.notNull(mediaPackage, "mediaPackage");
RequireUtil.notNull(elementIds, "elementId");
RequireUtil.notNull(channelId, "channelId");
//
try {
return serviceRegistry.createJob(JOB_TYPE, Operation.Retract.toString(), Arrays.asList(channelId, MediaPackageParser.getAsXml(mediaPackage), gson.toJson(elementIds)), retractJobLoad);
} catch (ServiceRegistryException e) {
throw new DistributionException("Unable to create a job", e);
}
}
use of org.opencastproject.serviceregistry.api.ServiceRegistryException in project opencast by opencast.
the class WowzaAdaptiveStreamingDistributionService method process.
/**
* {@inheritDoc}
*
* @see org.opencastproject.job.api.AbstractJobProducer#process(org.opencastproject.job.api.Job)
*/
@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);
String channelId = arguments.get(0);
MediaPackage mediapackage = MediaPackageParser.getFromXml(arguments.get(1));
Set<String> elementIds = gson.fromJson(arguments.get(2), new TypeToken<Set<String>>() {
}.getType());
switch(op) {
case Distribute:
MediaPackageElement[] distributedElements = distributeElements(channelId, mediapackage, elementIds);
if (logger.isDebugEnabled()) {
for (MediaPackageElement element : distributedElements) if (element != null)
logger.debug("Distributed element {} with URL {}", element.getIdentifier(), element.getURI());
}
ArrayList<MediaPackageElement> distributedElementsList = new ArrayList<MediaPackageElement>();
if (distributedElements != null) {
for (int i = 0; i < distributedElements.length; i++) {
if (distributedElements[i] != null)
distributedElementsList.add(distributedElements[i]);
}
}
return (!distributedElementsList.isEmpty()) ? MediaPackageElementParser.getArrayAsXml(distributedElementsList) : null;
case Retract:
MediaPackageElement[] retractedElements = null;
if (distributionDirectory != null) {
if (streamingUri != null || adaptiveStreamingUri != null) {
retractedElements = retractElements(channelId, mediapackage, elementIds);
if (logger.isDebugEnabled()) {
for (MediaPackageElement element : retractedElements) if (element != null)
logger.debug("Retracted element {} with URL {}", element.getIdentifier(), element.getURI());
}
}
}
ArrayList<MediaPackageElement> retractedElementsList = new ArrayList<MediaPackageElement>();
if (retractedElements != null) {
for (MediaPackageElement element : retractedElements) {
if (element != null) {
retractedElementsList.add(element);
}
}
}
return (!retractedElementsList.isEmpty()) ? MediaPackageElementParser.getArrayAsXml(retractedElementsList) : null;
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);
}
}
use of org.opencastproject.serviceregistry.api.ServiceRegistryException in project opencast by opencast.
the class WowzaAdaptiveStreamingDistributionService method distribute.
/**
* {@inheritDoc}
*
* @see org.opencastproject.distribution.api.StreamingDistributionService#distribute(java.lang.String,
* org.opencastproject.mediapackage.MediaPackage, java.util.Set)
*/
@Override
public Job distribute(String channelId, MediaPackage mediapackage, Set<String> elementIds) throws DistributionException, MediaPackageException {
notNull(mediapackage, "mediapackage");
notNull(elementIds, "elementIds");
notNull(channelId, "channelId");
if (streamingUri == null && adaptiveStreamingUri == null)
throw new IllegalStateException("A least one streaming url must be set (org.opencastproject.streaming.url,org.opencastproject.adaptive-streaming.url)");
if (distributionDirectory == null)
throw new IllegalStateException("Streaming distribution directory must be set (org.opencastproject.streaming.directory)");
try {
return serviceRegistry.createJob(JOB_TYPE, Operation.Distribute.toString(), Arrays.asList(channelId, MediaPackageParser.getAsXml(mediapackage), gson.toJson(elementIds)), distributeJobLoad);
} catch (ServiceRegistryException e) {
throw new DistributionException("Unable to create a job", e);
}
}
use of org.opencastproject.serviceregistry.api.ServiceRegistryException in project opencast by opencast.
the class AwsS3DistributionServiceImpl method distribute.
/**
* {@inheritDoc}
*
* @see org.opencastproject.distribution.api.DownloadDistributionService#distribute(String,
* org.opencastproject.mediapackage.MediaPackage, String, boolean)
*/
@Override
public Job distribute(String channelId, MediaPackage mediaPackage, Set<String> elementIds, boolean checkAvailability) throws DistributionException, MediaPackageException {
notNull(mediaPackage, "mediapackage");
notNull(elementIds, "elementIds");
notNull(channelId, "channelId");
try {
return serviceRegistry.createJob(JOB_TYPE, Operation.Distribute.toString(), Arrays.asList(channelId, MediaPackageParser.getAsXml(mediaPackage), gson.toJson(elementIds), Boolean.toString(checkAvailability)));
} catch (ServiceRegistryException e) {
throw new DistributionException("Unable to create a job", e);
}
}
use of org.opencastproject.serviceregistry.api.ServiceRegistryException in project opencast by opencast.
the class AwsS3DistributionServiceImpl method retract.
@Override
public Job retract(String channelId, MediaPackage mediapackage, Set<String> elementIds) throws DistributionException {
notNull(mediapackage, "mediapackage");
notNull(elementIds, "elementIds");
notNull(channelId, "channelId");
try {
return serviceRegistry.createJob(JOB_TYPE, Operation.Retract.toString(), Arrays.asList(channelId, MediaPackageParser.getAsXml(mediapackage), gson.toJson(elementIds)));
} catch (ServiceRegistryException e) {
throw new DistributionException("Unable to create a job", e);
}
}
Aggregations