use of org.mycore.common.config.MCRConfigurationException in project mycore by MyCoRe-Org.
the class MCRXSL2JAXBTransformer method init.
@Override
public void init(String id) {
super.init(id);
String property = "MCR.ContentTransformer." + id + ".Context";
String contextPath = MCRConfiguration.instance().getString(property);
try {
JAXBContext context = JAXBContext.newInstance(contextPath, getClass().getClassLoader());
setContext(context);
} catch (JAXBException e) {
throw new MCRConfigurationException("Error while creating JAXBContext.", e);
}
}
use of org.mycore.common.config.MCRConfigurationException in project mycore by MyCoRe-Org.
the class MCRIIIFImageImpl method getInstance.
public static synchronized MCRIIIFImageImpl getInstance(String implName) {
if (implHolder.containsKey(implName)) {
return implHolder.get(implName);
}
String classPropertyName = MCR_IIIF_IMAGE_CONFIG_PREFIX + implName;
Class<? extends MCRIIIFImageImpl> classObject = MCRConfiguration.instance().getClass(classPropertyName);
try {
Constructor<? extends MCRIIIFImageImpl> constructor = classObject.getConstructor(String.class);
MCRIIIFImageImpl imageImpl = constructor.newInstance(implName);
implHolder.put(implName, imageImpl);
return imageImpl;
} catch (NoSuchMethodException e) {
throw new MCRConfigurationException("Configurated class (" + classObject.getName() + ") needs a string constructor: " + classPropertyName);
} catch (IllegalAccessException | InstantiationException | InvocationTargetException e) {
throw new MCRException(e);
}
}
use of org.mycore.common.config.MCRConfigurationException in project mycore by MyCoRe-Org.
the class MCRIIIFPresentationImpl method getInstance.
public static synchronized MCRIIIFPresentationImpl getInstance(String implName) {
if (implHolder.containsKey(implName)) {
return implHolder.get(implName);
}
String classPropertyName = MCR_IIIF_PRESENTATION_CONFIG_PREFIX + implName;
Class<? extends MCRIIIFPresentationImpl> classObject = MCRConfiguration.instance().getClass(classPropertyName);
try {
Constructor<? extends MCRIIIFPresentationImpl> constructor = classObject.getConstructor(String.class);
MCRIIIFPresentationImpl presentationImpl = constructor.newInstance(implName);
implHolder.put(implName, presentationImpl);
return presentationImpl;
} catch (NoSuchMethodException e) {
throw new MCRConfigurationException("Configurated class (" + classObject.getName() + ") needs a string constructor: " + classPropertyName);
} catch (IllegalAccessException | InstantiationException | InvocationTargetException e) {
throw new MCRException(e);
}
}
use of org.mycore.common.config.MCRConfigurationException in project mycore by MyCoRe-Org.
the class MCRVersioningMetadataStore method setupSVN.
private void setupSVN(String type) {
URI repositoryURI;
String repositoryURIString = MCRConfiguration.instance().getString("MCR.IFS2.Store." + type + ".SVNRepositoryURL");
try {
repositoryURI = new URI(repositoryURIString);
} catch (URISyntaxException e) {
String msg = "Syntax error in MCR.IFS2.Store." + type + ".SVNRepositoryURL property: " + repositoryURIString;
throw new MCRConfigurationException(msg, e);
}
try {
LOGGER.info("Versioning metadata store {} repository URL: {}", type, repositoryURI);
repURL = SVNURL.create(repositoryURI.getScheme(), repositoryURI.getUserInfo(), repositoryURI.getHost(), repositoryURI.getPort(), repositoryURI.getPath(), true);
LOGGER.info("repURL: {}", repURL);
File dir = new File(repURL.getPath());
if (!dir.exists() || (dir.isDirectory() && dir.list().length == 0)) {
LOGGER.info("Repository does not exist, creating new SVN repository at {}", repositoryURI);
repURL = SVNRepositoryFactory.createLocalRepository(dir, true, false);
}
} catch (SVNException ex) {
String msg = "Error initializing SVN repository at URL " + repositoryURI;
throw new MCRConfigurationException(msg, ex);
}
}
use of org.mycore.common.config.MCRConfigurationException in project mycore by MyCoRe-Org.
the class MCRStore method init.
protected void init(final MCRStoreConfig config) {
setStoreConfig(config);
idLength = 0;
final StringTokenizer st = new StringTokenizer(getStoreConfig().getSlotLayout(), "-");
slotLength = new int[st.countTokens() - 1];
int i = 0;
while (st.countTokens() > 1) {
slotLength[i] = Integer.parseInt(st.nextToken());
idLength += slotLength[i++];
}
idLength += Integer.parseInt(st.nextToken());
try {
baseDirectory = VFS.getManager().resolveFile(getStoreConfig().getBaseDir());
if (!baseDirectory.exists()) {
baseDirectory.createFolder();
} else {
if (!baseDirectory.isReadable()) {
final String msg = "Store directory " + getStoreConfig().getBaseDir() + " is not readable";
throw new MCRConfigurationException(msg);
}
if (baseDirectory.getType() != FileType.FOLDER) {
final String msg = "Store " + getStoreConfig().getBaseDir() + " is a file, not a directory";
throw new MCRConfigurationException(msg);
}
}
} catch (final FileSystemException e) {
e.printStackTrace();
}
}
Aggregations