Search in sources :

Example 6 with SeriesCatalogUIAdapter

use of org.opencastproject.metadata.dublincore.SeriesCatalogUIAdapter in project opencast by opencast.

the class SeriesEndpoint method getAllMetadata.

private Response getAllMetadata(String id) throws SearchIndexException {
    Opt<Series> optSeries = indexService.getSeries(id, externalIndex);
    if (optSeries.isNone())
        return ApiResponses.notFound("Cannot find a series with id '%s'.", id);
    MetadataList metadataList = new MetadataList();
    List<SeriesCatalogUIAdapter> catalogUIAdapters = indexService.getSeriesCatalogUIAdapters();
    catalogUIAdapters.remove(indexService.getCommonSeriesCatalogUIAdapter());
    for (SeriesCatalogUIAdapter adapter : catalogUIAdapters) {
        final Opt<MetadataCollection> optSeriesMetadata = adapter.getFields(id);
        if (optSeriesMetadata.isSome()) {
            metadataList.add(adapter.getFlavor(), adapter.getUITitle(), optSeriesMetadata.get());
        }
    }
    MetadataCollection collection = getSeriesMetadata(optSeries.get());
    ExternalMetadataUtils.changeSubjectToSubjects(collection);
    ExternalMetadataUtils.changeTypeOrderedTextToText(collection);
    metadataList.add(indexService.getCommonSeriesCatalogUIAdapter(), collection);
    return okJson(metadataList.toJSON());
}
Also used : MetadataList(org.opencastproject.index.service.catalog.adapter.MetadataList) Series(org.opencastproject.index.service.impl.index.series.Series) MetadataCollection(org.opencastproject.metadata.dublincore.MetadataCollection) SeriesCatalogUIAdapter(org.opencastproject.metadata.dublincore.SeriesCatalogUIAdapter)

Example 7 with SeriesCatalogUIAdapter

use of org.opencastproject.metadata.dublincore.SeriesCatalogUIAdapter in project opencast by opencast.

the class SeriesEndpoint method getMetadataByType.

private Response getMetadataByType(String id, String type) throws SearchIndexException {
    Opt<Series> optSeries = indexService.getSeries(id, externalIndex);
    if (optSeries.isNone())
        return ApiResponses.notFound("Cannot find a series with id '%s'.", id);
    // Try the main catalog first as we load it from the index.
    if (typeMatchesSeriesCatalogUIAdapter(type, indexService.getCommonSeriesCatalogUIAdapter())) {
        MetadataCollection collection = getSeriesMetadata(optSeries.get());
        ExternalMetadataUtils.changeSubjectToSubjects(collection);
        ExternalMetadataUtils.changeTypeOrderedTextToText(collection);
        return ApiResponses.Json.ok(ApiVersion.VERSION_1_0_0, collection.toJSON());
    }
    // Try the other catalogs
    List<SeriesCatalogUIAdapter> catalogUIAdapters = indexService.getSeriesCatalogUIAdapters();
    catalogUIAdapters.remove(indexService.getCommonSeriesCatalogUIAdapter());
    for (SeriesCatalogUIAdapter adapter : catalogUIAdapters) {
        if (typeMatchesSeriesCatalogUIAdapter(type, adapter)) {
            final Opt<MetadataCollection> optSeriesMetadata = adapter.getFields(id);
            if (optSeriesMetadata.isSome()) {
                return ApiResponses.Json.ok(ApiVersion.VERSION_1_0_0, optSeriesMetadata.get().toJSON());
            }
        }
    }
    return ApiResponses.notFound("Cannot find a catalog with type '%s' for series with id '%s'.", type, id);
}
Also used : Series(org.opencastproject.index.service.impl.index.series.Series) MetadataCollection(org.opencastproject.metadata.dublincore.MetadataCollection) SeriesCatalogUIAdapter(org.opencastproject.metadata.dublincore.SeriesCatalogUIAdapter)

Aggregations

SeriesCatalogUIAdapter (org.opencastproject.metadata.dublincore.SeriesCatalogUIAdapter)7 MetadataCollection (org.opencastproject.metadata.dublincore.MetadataCollection)5 MetadataList (org.opencastproject.index.service.catalog.adapter.MetadataList)4 Series (org.opencastproject.index.service.impl.index.series.Series)4 URI (java.net.URI)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 ParseException (org.json.simple.parser.ParseException)2 MediaPackageElementFlavor (org.opencastproject.mediapackage.MediaPackageElementFlavor)2 AccessControlList (org.opencastproject.security.api.AccessControlList)2 NotFoundException (org.opencastproject.util.NotFoundException)2 RestQuery (org.opencastproject.util.doc.rest.RestQuery)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 HashSet (java.util.HashSet)1 GET (javax.ws.rs.GET)1 PUT (javax.ws.rs.PUT)1 JSONArray (org.json.simple.JSONArray)1