Search in sources :

Example 11 with Publication

use of org.opencastproject.mediapackage.Publication in project opencast by opencast.

the class LiveScheduleServiceImpl method addLivePublicationChannel.

void addLivePublicationChannel(Organization currentOrg, MediaPackage mp) throws LiveScheduleException {
    logger.debug("Adding live channel publication element to media package {}", mp);
    String engageUrlString = null;
    String playerPath = null;
    if (currentOrg != null) {
        engageUrlString = StringUtils.trimToNull(currentOrg.getProperties().get(ENGAGE_URL_PROPERTY));
        playerPath = StringUtils.trimToNull(currentOrg.getProperties().get(PLAYER_PROPERTY));
    }
    if (engageUrlString == null) {
        engageUrlString = serverUrl;
        logger.info("Using 'server.url' as a fallback for the non-existing organization level key '{}' for the publication url", ENGAGE_URL_PROPERTY);
    }
    if (playerPath == null)
        playerPath = DEFAULT_PLAYER_PATH;
    try {
        // Create new distribution element
        URI engageUri = URIUtils.resolve(new URI(engageUrlString), playerPath + "?id=" + mp.getIdentifier().compact());
        Publication publicationElement = PublicationImpl.publication(UUID.randomUUID().toString(), CHANNEL_ID, engageUri, MimeTypes.parseMimeType("text/html"));
        mp.add(publicationElement);
    } catch (URISyntaxException e) {
        throw new LiveScheduleException(e);
    }
}
Also used : Publication(org.opencastproject.mediapackage.Publication) LiveScheduleException(org.opencastproject.liveschedule.api.LiveScheduleException) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Example 12 with Publication

use of org.opencastproject.mediapackage.Publication in project opencast by opencast.

the class PublicationBuilderPlugin method newElement.

@Override
public MediaPackageElement newElement(Type type, MediaPackageElementFlavor flavor) {
    Publication element = new PublicationImpl();
    element.setFlavor(flavor);
    return element;
}
Also used : PublicationImpl(org.opencastproject.mediapackage.PublicationImpl) Publication(org.opencastproject.mediapackage.Publication)

Example 13 with Publication

use of org.opencastproject.mediapackage.Publication in project opencast by opencast.

the class PublicationBuilderPlugin method elementFromURI.

@Override
public MediaPackageElement elementFromURI(URI uri) throws UnsupportedElementException {
    // TODO Auto-generated method stub
    logger.trace("Creating publication element from " + uri);
    Publication publication = new PublicationImpl();
    publication.setURI(uri);
    return publication;
}
Also used : PublicationImpl(org.opencastproject.mediapackage.PublicationImpl) Publication(org.opencastproject.mediapackage.Publication)

Example 14 with Publication

use of org.opencastproject.mediapackage.Publication in project opencast by opencast.

the class EventsEndpointTest method getExamplePublications.

@Ignore
private List<Publication> getExamplePublications() throws URISyntaxException {
    List<Publication> publications = new ArrayList<Publication>();
    Publication youtubePublication = PublicationImpl.publication("youtube-pub-id", "youtube", new URI("http://youtube.com/id"), MimeType.mimeType("you", "tube"));
    publications.add(youtubePublication);
    Publication internalPublication = PublicationImpl.publication("internal-pub-id", InternalPublicationChannel.CHANNEL_ID, new URI("http://internal.com/id"), MimeType.mimeType("in", "ternal"));
    publications.add(internalPublication);
    return publications;
}
Also used : ArrayList(java.util.ArrayList) Publication(org.opencastproject.mediapackage.Publication) URI(java.net.URI) Ignore(org.junit.Ignore)

Example 15 with Publication

use of org.opencastproject.mediapackage.Publication in project opencast by opencast.

the class EventsEndpointTest method testGetEventsJsonResponse.

@Ignore
@Test
public void testGetEventsJsonResponse() throws Exception {
    String eventJson = IOUtils.toString(getClass().getResource("/events.json"));
    String acceptHeader = "application/" + ApiVersion.CURRENT_VERSION.toExternalForm() + "+" + ApiFormat.JSON;
    List<IndexObject> events = new ArrayList<IndexObject>();
    List<String> contributors = new ArrayList<String>();
    contributors.add("Physics Department");
    List<Publication> publications = getExamplePublications();
    Event event1 = new Event("e6aeb8df-a852-46cd-8128-b89de696f20e", defaultOrg.getId());
    event1.setArchiveVersion(2L);
    event1.setCreated("2015-03-12T10:38:54Z");
    event1.setCreator("Opencast Administrator");
    event1.setContributors(contributors);
    event1.setDescription("Cooling without moving parts and using only heat as an input");
    event1.setDuration(7200000L);
    event1.setHasPreview(true);
    event1.setLocation("physics-e-01");
    List<String> presenters = new ArrayList<String>();
    presenters.add("Prof. A. Einstein");
    event1.setPresenters(presenters);
    event1.setPublications(publications);
    event1.setWorkflowState(WorkflowState.SUCCEEDED);
    event1.setRecordingStartDate("2015-03-20T04:00:00Z");
    event1.setSubject("Space Final Frontier");
    event1.setTitle("Einstein refrigerator");
    events.add(event1);
    Event event2 = new Event("f5aeb8df-a852-46cd-8128-b89de696f20e", defaultOrg.getId());
    event2.setArchiveVersion(5L);
    event2.setCreated("2015-03-12T10:38:54Z");
    event2.setCreator("Opencast Administrator");
    event2.setContributors(contributors);
    event2.setDescription("The history of the universe from the big bang to black holes");
    event2.setDuration(7200000L);
    event2.setHasPreview(true);
    event2.setLocation("physics-e-02");
    presenters = new ArrayList<String>();
    presenters.add("Prof. Stephen Hawking");
    event2.setPresenters(presenters);
    event2.setPublications(publications);
    event2.setWorkflowState(WorkflowState.SUCCEEDED);
    event2.setRecordingStartDate("2015-03-20T04:00:00Z");
    event2.setSubject("Space Final Frontier, Mathematics");
    event2.setTitle("The Theory of Everything");
    events.add(event2);
    EventsEndpoint endpoint = new EventsEndpoint();
    Response result = endpoint.getJsonEvents(acceptHeader, events, false, false, false, false);
    assertTrue(result.getMetadata().get("Content-Type") != null);
    assertEquals("application/v1.0.0+json", result.getMetadata().get("Content-Type").get(0).toString().toLowerCase());
    assertThat(eventJson, SameJSONAs.sameJSONAs(result.getEntity().toString()).allowingAnyArrayOrdering());
}
Also used : Response(javax.ws.rs.core.Response) ArrayList(java.util.ArrayList) IndexObject(org.opencastproject.index.service.impl.index.IndexObject) Publication(org.opencastproject.mediapackage.Publication) Event(org.opencastproject.index.service.impl.index.event.Event) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

Publication (org.opencastproject.mediapackage.Publication)37 MediaPackage (org.opencastproject.mediapackage.MediaPackage)21 ArrayList (java.util.ArrayList)17 MediaPackageElement (org.opencastproject.mediapackage.MediaPackageElement)15 Job (org.opencastproject.job.api.Job)12 URI (java.net.URI)11 WorkflowOperationException (org.opencastproject.workflow.api.WorkflowOperationException)9 HashSet (java.util.HashSet)8 SimpleElementSelector (org.opencastproject.mediapackage.selector.SimpleElementSelector)7 PublicationException (org.opencastproject.publication.api.PublicationException)7 Test (org.junit.Test)6 MediaPackageException (org.opencastproject.mediapackage.MediaPackageException)5 Ignore (org.junit.Ignore)4 DistributionException (org.opencastproject.distribution.api.DistributionException)4 Attachment (org.opencastproject.mediapackage.Attachment)4 MediaPackageElementFlavor (org.opencastproject.mediapackage.MediaPackageElementFlavor)4 PublicationImpl (org.opencastproject.mediapackage.PublicationImpl)4 Track (org.opencastproject.mediapackage.Track)4 NotFoundException (org.opencastproject.util.NotFoundException)4 Event (org.opencastproject.index.service.impl.index.event.Event)3