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
23 package org.opencastproject.mediapackage;
24
25 import org.opencastproject.mediapackage.identifier.Id;
26
27 import org.w3c.dom.Node;
28
29 import java.io.InputStream;
30
31 /**
32 * A media package builder provides factory methods for the creation of media packages from manifest files, packages,
33 * directories or from sratch.
34 */
35 public interface MediaPackageBuilder {
36
37 /**
38 * Creates a new media package in the temporary directory defined by the java runtime property
39 * <code>java.io.tmpdir</code>.
40 *
41 * @return the new media package
42 * @throws MediaPackageException
43 * if creation of the new media package fails
44 */
45 MediaPackage createNew() throws MediaPackageException;
46
47 /**
48 * Creates a new media package in the temporary directory defined by the java runtime property
49 * <code>java.io.tmpdir</code>.
50 * <p>
51 * The name of the media package root folder will be equal to the handle value.
52 * </p>
53 *
54 * @param identifier
55 * the media package identifier
56 * @return the new media package
57 * @throws MediaPackageException
58 * if creation of the new media package fails
59 */
60 MediaPackage createNew(Id identifier) throws MediaPackageException;
61
62 /**
63 * Loads a media package from the manifest.
64 *
65 * @param is
66 * the media package manifest input stream
67 * @return the media package
68 * @throws MediaPackageException
69 * if loading of the media package fails
70 */
71 MediaPackage loadFromXml(InputStream is) throws MediaPackageException;
72
73 /**
74 * Loads a media package from the manifest.
75 *
76 * @param xml
77 * the media package manifest as an xml string
78 * @return the media package
79 * @throws MediaPackageException
80 * if loading of the media package fails
81 */
82 MediaPackage loadFromXml(String xml) throws MediaPackageException;
83
84 /**
85 * Loads a media package from the manifest.
86 *
87 * @param xml
88 * the media package manifest as an xml node
89 * @return the media package
90 * @throws MediaPackageException
91 * if loading of the media package fails
92 */
93 MediaPackage loadFromXml(Node xml) throws MediaPackageException;
94
95 /**
96 * Sets the media package serializer that is used to resolve urls and helps in serialization and deserialization of
97 * media package elements.
98 *
99 * @param serializer
100 * the serializer
101 */
102 void setSerializer(MediaPackageSerializer serializer);
103
104 /**
105 * Returns the currently active serializer. The serializer is used to resolve urls and helps in serialization and
106 * deserialization of media package elements.
107 *
108 * @return the serializer
109 * @see #setSerializer(MediaPackageSerializer)
110 */
111 MediaPackageSerializer getSerializer();
112
113 }