1 /*
2 * Licensed to The Apereo Foundation under one or more contributor license
3 * agreements. See the NOTICE file distributed with this work for additional
4 * information regarding copyright ownership.
5 *
6 *
7 * The Apereo Foundation licenses this file to you under the Educational
8 * Community License, Version 2.0 (the "License"); you may not use this file
9 * except in compliance with the License. You may obtain a copy of the License
10 * at:
11 *
12 * http://opensource.org/licenses/ecl2.txt
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17 * License for the specific language governing permissions and limitations under
18 * the License.
19 *
20 */
21
22 package org.opencastproject.distribution.api;
23
24 import org.opencastproject.job.api.Job;
25 import org.opencastproject.mediapackage.MediaPackage;
26 import org.opencastproject.mediapackage.MediaPackageElement;
27 import org.opencastproject.mediapackage.MediaPackageException;
28
29 import java.util.List;
30
31 /**
32 * Distributes elements from MediaPackages to distribution channels.
33 */
34 public interface DistributionService {
35
36 /**
37 * A prefix used by distribution service implementations to indicate the types of distribution channels they manage.
38 */
39 String JOB_TYPE_PREFIX = "org.opencastproject.distribution.";
40
41 String CONFIG_KEY_STORE_TYPE = "distribution.channel";
42
43 /**
44 * Distribute a media package element.
45 *
46 * @param mediapackage
47 * the media package
48 * @param elementId
49 * the element in the media package to distribute
50 *
51 * @return The job
52 * @throws DistributionException
53 * if there was a problem distributing the media
54 * @throws MediaPackageException
55 * if there was a problem with the mediapackage element
56 */
57 Job distribute(String channelId, MediaPackage mediapackage, String elementId)
58 throws DistributionException, MediaPackageException;
59
60 /**
61 * Distributes a media package element synchronously, bypassing the Opencast job system.
62 *
63 * @param mediapackage
64 * the media package
65 * @param elementId
66 * the element in the media package to distribute
67 *
68 * @return list of distributed media package elements
69 * @throws DistributionException
70 * if there was a problem distributing the media
71 * @throws MediaPackageException
72 * if there was a problem with the mediapackage element
73 */
74 List<MediaPackageElement> distributeSync(String channelId, MediaPackage mediapackage, String elementId)
75 throws DistributionException, MediaPackageException;
76
77 /**
78 * Retract a media package element from the distribution channel.
79 *
80 * @param mediaPackage
81 * the media package
82 * @param elementId
83 * the media package element to retract
84 * @throws DistributionException
85 * if there was a problem retracting the mediapackage
86 */
87 Job retract(String channelId, MediaPackage mediaPackage, String elementId) throws DistributionException;
88
89 /**
90 * Retract a media package element from the distribution channel synchronously, bypassing the Opencast job system.
91 *
92 * @return list of retracted media package elements
93 * @param mediaPackage
94 * the media package
95 * @param elementId
96 * the media package element to retract
97 * @throws DistributionException
98 * if there was a problem retracting the mediapackage
99 */
100 List<MediaPackageElement> retractSync(String channelId, MediaPackage mediaPackage, String elementId)
101 throws DistributionException, MediaPackageException;
102
103 /**
104 * Returns the distribution type for this service.
105 * This type should be unique within an Opencast instance, and is used to select where file distribution happens.
106 *
107 * @return The distribution type. A string like "download", or "streaming"
108 */
109 String getDistributionType();
110 }