use of org.opencastproject.util.ConfigurationException in project opencast by opencast.
the class HandleBuilderFactory method newHandleBuilder.
/**
* Factory method that returns an instance of a handle builder.
* <p>
* It uses the following ordered lookup procedure to determine which implementation of the {@link HandleBuilder}
* interface to use:
* <ul>
* <li>Implementation specified using the <code>opencast.handlebuilder</code> system property</li>
* <li>Platform default implementation</li>
* </ul>
*
* @return the handle builder
* @throws ConfigurationException
* If the builder cannot be instantiated
*/
public HandleBuilder newHandleBuilder() throws ConfigurationException {
if (builder == null) {
try {
Class<?> builderClass = Class.forName(builderClassName);
builder = (HandleBuilder) builderClass.newInstance();
} catch (ClassNotFoundException e) {
throw new ConfigurationException("Class not found while creating handle builder: " + e.getMessage(), e);
} catch (InstantiationException e) {
throw new ConfigurationException("Instantiation exception while creating handle builder: " + e.getMessage(), e);
} catch (IllegalAccessException e) {
throw new ConfigurationException("Access exception while creating handle builder: " + e.getMessage(), e);
}
}
return builder;
}
use of org.opencastproject.util.ConfigurationException in project opencast by opencast.
the class MediaPackageReferenceTest method testMediaPackageReference.
/**
* Test method for {@link org.opencastproject.mediapackage.MediaPackageImpl#add(java.net.URI)}.
*/
@Test
public void testMediaPackageReference() {
try {
// Add first catalog without any reference
URI catalogXTestFile = MediaPackageReferenceTest.class.getResource("/dublincore.xml").toURI();
MediaPackageElement catalogX = mediaPackage.add(catalogXTestFile);
catalogX.setIdentifier("catalog-x");
// Add second catalog with media package reference
URI catalogYTestFile = MediaPackageReferenceTest.class.getResource("/dublincore.xml").toURI();
MediaPackageElement catalogY = mediaPackage.add(catalogYTestFile);
catalogY.referTo(new MediaPackageReferenceImpl(mediaPackage));
catalogY.setIdentifier("catalog-y");
// Add third catalog with track reference
URI catalogZTestFile = MediaPackageReferenceTest.class.getResource("/dublincore.xml").toURI();
MediaPackageElement catalogZ = mediaPackage.add(catalogZTestFile);
catalogZ.referTo(new MediaPackageReferenceImpl("track", "track-1"));
catalogZ.setIdentifier("catalog-z");
} catch (UnsupportedElementException e) {
fail("Adding of catalog failed: " + e.getMessage());
} catch (URISyntaxException e) {
fail("Adding of catalog failed: " + e.getMessage());
}
// Re-read the media package and test the references
try {
MediaPackageElement catalogX = mediaPackage.getElementById("catalog-x");
assertTrue(catalogX.getReference() == null);
MediaPackageElement catalogY = mediaPackage.getElementById("catalog-y");
assertNotNull(catalogY.getReference());
MediaPackageElement catalogZ = mediaPackage.getElementById("catalog-z");
assertNotNull(catalogZ.getReference());
assertTrue(catalogZ.getReference().matches(new MediaPackageReferenceImpl("track", "track-1")));
} catch (ConfigurationException e) {
fail("Configuration error while loading media package from manifest: " + e.getMessage());
}
}
use of org.opencastproject.util.ConfigurationException in project opencast by opencast.
the class MediaPackageSerializerTest method testRelativeNativePaths.
@Test
public void testRelativeNativePaths() {
try {
XPath xPath = XPathFactory.newInstance().newXPath();
// Create a media package and add an element
MediaPackage mediaPackage = mediaPackageBuilder.createNew();
mediaPackage.add(dcFile.toURI());
// Test relative path, using serializer
MediaPackageSerializer serializer = null;
serializer = new DefaultMediaPackageSerializerImpl(manifestFile.getParentFile());
Document xml = MediaPackageParser.getAsXml(mediaPackage, serializer);
// Test linux file relative to media package root
String expected = dcFile.getAbsolutePath().substring(packageDir.getAbsolutePath().length() + 1);
assertEquals(expected, xPath.evaluate("//url", xml));
} catch (MediaPackageException e) {
fail("Media package excpetion while reading media package from manifest: " + e.getMessage());
} catch (ConfigurationException e) {
fail("Configuration exception while reading media package from manifest: " + e.getMessage());
} catch (MalformedURLException e) {
fail("Exception while creating url: " + e.getMessage());
} catch (UnsupportedElementException e) {
fail("Error while creating media package: " + e.getMessage());
} catch (XPathExpressionException e) {
fail("Selecting node form xml document failed: " + e.getMessage());
}
}
use of org.opencastproject.util.ConfigurationException in project opencast by opencast.
the class MediaPackageBuilderFactory method newMediaPackageBuilder.
/**
* Factory method that returns an instance of a media package builder.
* <p>
* It uses the following ordered lookup procedure to determine which implementation of the {@link MediaPackageBuilder}
* interface to use:
* <ul>
* <li>Implementation specified using the <code>org.opencastproject.mediapackage.builder</code> system property</li>
* <li>Platform default implementation</li>
* </ul>
*
* @return the media package builder
* @throws ConfigurationException
* If the builder cannot be instantiated
*/
public MediaPackageBuilder newMediaPackageBuilder() throws ConfigurationException {
MediaPackageBuilder builder = null;
try {
Class<?> builderClass = Class.forName(builderClassName);
builder = (MediaPackageBuilder) builderClass.newInstance();
} catch (ClassNotFoundException e) {
throw new ConfigurationException("Class not found while creating media package builder: " + e.getMessage(), e);
} catch (InstantiationException e) {
throw new ConfigurationException("Instantiation exception while creating media package builder: " + e.getMessage(), e);
} catch (IllegalAccessException e) {
throw new ConfigurationException("Access exception while creating media package builder: " + e.getMessage(), e);
}
return builder;
}
use of org.opencastproject.util.ConfigurationException in project opencast by opencast.
the class MediaPackageElementBuilderFactory method newElementBuilder.
/**
* Factory method that returns an instance of a media package element builder.
* <p>
* It uses the following ordered lookup procedure to determine which implementation of the
* {@link MediaPackageElementBuilder} interface to use:
* <ul>
* <li>Implementation specified using the <code>org.opencastproject.mediapackage.elementbuilder</code> system property
* </li>
* <li>Platform default implementation</li>
* </ul>
*
* @return the media package element builder
* @throws ConfigurationException
* If the builder cannot be instantiated
*/
public MediaPackageElementBuilder newElementBuilder() throws ConfigurationException {
if (builder == null) {
try {
Class<?> builderClass = Class.forName(builderClassName, true, MediaPackageElementBuilderFactory.class.getClassLoader());
builder = (MediaPackageElementBuilder) builderClass.newInstance();
} catch (ClassNotFoundException e) {
throw new ConfigurationException("Class not found while creating element builder: " + e.getMessage(), e);
} catch (InstantiationException e) {
throw new ConfigurationException("Instantiation exception while creating element builder: " + e.getMessage(), e);
} catch (IllegalAccessException e) {
throw new ConfigurationException("Access exception while creating element builder: " + e.getMessage(), e);
} catch (Exception e) {
throw new ConfigurationException("Exception while creating element builder: " + e.getMessage(), e);
}
}
return builder;
}
Aggregations