View Javadoc
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  import java.util.Set;
31  
32  /**
33   * Distributes elements from MediaPackages to distribution channels.
34   */
35  public interface DownloadDistributionService extends DistributionService {
36  
37    Job distribute(String channelId, MediaPackage mediapackage, String elementId, boolean checkAvailability)
38            throws DistributionException, MediaPackageException;
39  
40    Job distribute(String channelId, MediaPackage mediapackage, Set<String> elementIds, boolean checkAvailability)
41            throws DistributionException, MediaPackageException;
42  
43    Job distribute(
44        String pubChannelId,
45        MediaPackage mediaPackage,
46        Set<String> downloadIds,
47        boolean checkAvailability,
48        boolean preserveReference
49    ) throws DistributionException, MediaPackageException;
50  
51    Job retract(String channelId, MediaPackage mediaPackage, Set<String> elementIds)
52            throws DistributionException;
53  
54    /**
55     * Distributes the given elements synchronously. This should be used rarely since load balancing will be unavailable.
56     * However, since the dispatching logic is bypassed, synchronous execution is much faster. It is useful in interactive
57     * scenarios where you synchronously wait for job execution anyway and you don't want to make the user waiting for too
58     * long.
59     *
60     * @param channelId The channel to retract from.
61     * @param mediapackage A media package holding the elements to retract.
62     * @param elementIds The IDs of the elements to retract.
63     * @param checkAvailability Whether to check if the distributed elements are available through their URI.
64     *
65     * @return The distributed elements.
66     * @throws DistributionException In case distribution fails.
67     */
68    List<MediaPackageElement> distributeSync(
69        String channelId,
70        MediaPackage mediapackage,
71        Set<String> elementIds,
72        boolean checkAvailability
73    ) throws DistributionException;
74  
75    /**
76     * Retracts the given elements synchronously. This should be used rarely since load balancing will be unavailable.
77     * However, since the dispatching logic is bypassed, synchronous execution is much faster. It is useful in interactive
78     * scenarios where you synchronously wait for job execution anyway and you don't want to make the user waiting for too
79     * long.
80     *
81     * @param channelId The channel to retract from.
82     * @param mediaPackage A media package holding the elements to retract.
83     * @param elementIds The IDs of the elements to retract.
84     *
85     * @return The retracted elements.
86     *
87     * @throws DistributionException In case retraction fails.
88     */
89    List<MediaPackageElement> retractSync(String channelId, MediaPackage mediaPackage, Set<String> elementIds)
90            throws DistributionException;
91  }