Search in sources :

Example 61 with ServiceRegistryException

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);
    }
}
Also used : DistributionException(org.opencastproject.distribution.api.DistributionException) ServiceRegistryException(org.opencastproject.serviceregistry.api.ServiceRegistryException)

Example 62 with ServiceRegistryException

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);
    }
}
Also used : MediaPackageElement(org.opencastproject.mediapackage.MediaPackageElement) ServiceRegistryException(org.opencastproject.serviceregistry.api.ServiceRegistryException) CaptionConverterException(org.opencastproject.caption.api.CaptionConverterException) ConfigurationException(org.osgi.service.cm.ConfigurationException) ServiceRegistryException(org.opencastproject.serviceregistry.api.ServiceRegistryException) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) NotFoundException(org.opencastproject.util.NotFoundException) IOException(java.io.IOException) MediaPackageException(org.opencastproject.mediapackage.MediaPackageException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedCaptionFormatException(org.opencastproject.caption.api.UnsupportedCaptionFormatException)

Example 63 with ServiceRegistryException

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;
}
Also used : HashMap(java.util.HashMap) HostRegistration(org.opencastproject.serviceregistry.api.HostRegistration) ListProviderException(org.opencastproject.index.service.exception.ListProviderException) ServersListQuery(org.opencastproject.index.service.resources.list.query.ServersListQuery) ServiceRegistryException(org.opencastproject.serviceregistry.api.ServiceRegistryException)

Example 64 with ServiceRegistryException

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);
    }
}
Also used : EncoderException(org.opencastproject.composer.api.EncoderException) EncodingProfile(org.opencastproject.composer.api.EncodingProfile) ServiceRegistryException(org.opencastproject.serviceregistry.api.ServiceRegistryException)

Example 65 with ServiceRegistryException

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);
    }
}
Also used : EncoderException(org.opencastproject.composer.api.EncoderException) ArrayList(java.util.ArrayList) EncodingProfile(org.opencastproject.composer.api.EncodingProfile) Attachment(org.opencastproject.mediapackage.Attachment) ServiceRegistryException(org.opencastproject.serviceregistry.api.ServiceRegistryException)

Aggregations

ServiceRegistryException (org.opencastproject.serviceregistry.api.ServiceRegistryException)99 NotFoundException (org.opencastproject.util.NotFoundException)61 ConfigurationException (org.osgi.service.cm.ConfigurationException)41 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)30 URISyntaxException (java.net.URISyntaxException)29 Job (org.opencastproject.job.api.Job)29 PersistenceException (javax.persistence.PersistenceException)26 RollbackException (javax.persistence.RollbackException)26 TrustedHttpClientException (org.opencastproject.security.api.TrustedHttpClientException)26 NoResultException (javax.persistence.NoResultException)25 MediaPackageException (org.opencastproject.mediapackage.MediaPackageException)25 IOException (java.io.IOException)24 ArrayList (java.util.ArrayList)24 EntityManager (javax.persistence.EntityManager)22 MediaPackage (org.opencastproject.mediapackage.MediaPackage)20 URI (java.net.URI)16 MediaPackageElement (org.opencastproject.mediapackage.MediaPackageElement)14 DistributionException (org.opencastproject.distribution.api.DistributionException)13 Attachment (org.opencastproject.mediapackage.Attachment)12 WorkflowOperationException (org.opencastproject.workflow.api.WorkflowOperationException)12