use of org.opencastproject.serviceregistry.api.ServiceRegistryException in project opencast by opencast.
the class DownloadDistributionServiceImpl 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)), 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 CaptionServiceImpl method process.
/**
* {@inheritDoc}
*
* @see org.opencastproject.job.api.AbstractJobProducer#process(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);
MediaPackageElement catalog = MediaPackageElementParser.getFromXml(arguments.get(0));
String inputFormat = arguments.get(1);
String outputFormat = arguments.get(2);
MediaPackageElement resultingCatalog = null;
switch(op) {
case Convert:
resultingCatalog = convert(job, catalog, inputFormat, outputFormat, null);
return MediaPackageElementParser.getAsXml(resultingCatalog);
case ConvertWithLanguage:
String language = arguments.get(3);
resultingCatalog = convert(job, catalog, inputFormat, outputFormat, language);
return MediaPackageElementParser.getAsXml(resultingCatalog);
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 ServersListProvider method getList.
@Override
public Map<String, String> getList(String listName, ResourceListQuery query, Organization organization) throws ListProviderException {
Map<String, String> list = new HashMap<String, String>();
if (StringUtils.equalsIgnoreCase(LIST_STATUS, listName)) {
list.put(SERVER_STATUS_ONLINE, SERVER_STATUS_LABEL_ONLINE);
list.put(SERVER_STATUS_OFFLINE, SERVER_STATUS_LABEL_OFFLINE);
list.put(SERVER_STATUS_MAINTENANCE, SERVER_STATUS_LABEL_MAINTENANCE);
return list;
}
ServersListQuery serversQuery;
try {
serversQuery = (ServersListQuery) query;
} catch (ClassCastException ex) {
serversQuery = new ServersListQuery(query);
}
Option<String> fHostname = serversQuery.getHostname();
Option<String> fStatus = serversQuery.getStatus();
List<HostRegistration> allServers;
try {
allServers = serviceRegistry.getHostRegistrations();
} catch (ServiceRegistryException e) {
throw new ListProviderException("Not able to get the list of the hosts from the services registry");
}
for (HostRegistration server : allServers) {
boolean vOnline = server.isOnline();
boolean vMaintenance = server.isMaintenanceMode();
String vHostname = server.getBaseUrl();
if (fHostname.isSome() && !StringUtils.equalsIgnoreCase(StringUtils.trimToEmpty(fHostname.get()), vHostname))
continue;
if (fStatus.isSome()) {
switch(StringUtils.trimToEmpty(fStatus.get())) {
case SERVER_STATUS_ONLINE:
if (!vOnline)
continue;
break;
case SERVER_STATUS_OFFLINE:
if (vOnline)
continue;
break;
case SERVER_STATUS_MAINTENANCE:
if (!vMaintenance)
continue;
break;
default:
break;
}
}
switch(listName) {
case LIST_HOSTNAME:
default:
list.put(vHostname, vHostname);
break;
}
}
return list;
}
use of org.opencastproject.serviceregistry.api.ServiceRegistryException in project opencast by opencast.
the class ComposerServiceImpl method parallelEncode.
/**
* {@inheritDoc}
*
* @see org.opencastproject.composer.api.ComposerService#encode(org.opencastproject.mediapackage.Track,
* java.lang.String)
*/
@Override
public Job parallelEncode(Track sourceTrack, String profileId) throws EncoderException, MediaPackageException {
try {
final EncodingProfile profile = profileScanner.getProfile(profileId);
logger.info("Starting parallel encode with profile {} with job load {}", profileId, df.format(profile.getJobLoad()));
return serviceRegistry.createJob(JOB_TYPE, Operation.ParallelEncode.toString(), Arrays.asList(profileId, MediaPackageElementParser.getAsXml(sourceTrack)), profile.getJobLoad());
} catch (ServiceRegistryException e) {
throw new EncoderException("Unable to create a job", e);
}
}
use of org.opencastproject.serviceregistry.api.ServiceRegistryException in project opencast by opencast.
the class ComposerServiceImpl method composite.
/**
* {@inheritDoc}
*/
@Override
public Job composite(Dimension compositeTrackSize, Option<LaidOutElement<Track>> upperTrack, LaidOutElement<Track> lowerTrack, Option<LaidOutElement<Attachment>> watermark, String profileId, String background) throws EncoderException, MediaPackageException {
List<String> arguments = new ArrayList<>(9);
arguments.add(PROFILE_ID_INDEX, profileId);
arguments.add(LOWER_TRACK_INDEX, MediaPackageElementParser.getAsXml(lowerTrack.getElement()));
arguments.add(LOWER_TRACK_LAYOUT_INDEX, Serializer.json(lowerTrack.getLayout()).toJson());
if (upperTrack.isNone()) {
arguments.add(UPPER_TRACK_INDEX, NOT_AVAILABLE);
arguments.add(UPPER_TRACK_LAYOUT_INDEX, NOT_AVAILABLE);
} else {
arguments.add(UPPER_TRACK_INDEX, MediaPackageElementParser.getAsXml(upperTrack.get().getElement()));
arguments.add(UPPER_TRACK_LAYOUT_INDEX, Serializer.json(upperTrack.get().getLayout()).toJson());
}
arguments.add(COMPOSITE_TRACK_SIZE_INDEX, Serializer.json(compositeTrackSize).toJson());
arguments.add(BACKGROUND_COLOR_INDEX, background);
if (watermark.isSome()) {
LaidOutElement<Attachment> watermarkLaidOutElement = watermark.get();
arguments.add(WATERMARK_INDEX, MediaPackageElementParser.getAsXml(watermarkLaidOutElement.getElement()));
arguments.add(WATERMARK_LAYOUT_INDEX, Serializer.json(watermarkLaidOutElement.getLayout()).toJson());
}
try {
final EncodingProfile profile = profileScanner.getProfile(profileId);
return serviceRegistry.createJob(JOB_TYPE, Operation.Composite.toString(), arguments, profile.getJobLoad());
} catch (ServiceRegistryException e) {
throw new EncoderException("Unable to create composite job", e);
}
}
Aggregations