use of org.mycore.sword.application.MCRSwordLifecycleConfiguration in project mycore by MyCoRe-Org.
the class MCRSword method initConfig.
private static void initConfig() {
if (collections == null) {
collections = new Hashtable<>();
workspaceCollectionTable = new Hashtable<>();
final MCRConfiguration mcrConfiguration = MCRConfiguration.instance();
Map<String, String> propertiesMap = mcrConfiguration.getPropertiesMap();
final int lenghtOfPropertyPrefix = MCRSwordConstants.MCR_SWORD_COLLECTION_PREFIX.length();
LOGGER.info("--- INITIALIZE SWORD SERVER ---");
propertiesMap.keySet().stream().filter(// remove all which are not collections
prop -> prop.startsWith(MCRSwordConstants.MCR_SWORD_COLLECTION_PREFIX)).filter(// remove all which have no suffix
prop -> !prop.trim().equals(MCRSwordConstants.MCR_SWORD_COLLECTION_PREFIX)).map(// remove MCR_SWORD_COLLECTION_PREFIX
prop -> prop.substring(lenghtOfPropertyPrefix)).map(// split to workspace name and collection name
prop -> prop.split(Pattern.quote("."), 2)).filter(// remove all whith no workspace or collection name
prop -> prop.length == 2).forEach(workspaceCollectionEntry -> {
final String collection = workspaceCollectionEntry[1];
final String workspace = workspaceCollectionEntry[0];
LOGGER.info("Found collection: {} in workspace {}", collection, workspace);
String name = MCRSwordConstants.MCR_SWORD_COLLECTION_PREFIX + workspace + "." + collection;
LOGGER.info("Try to init : {}", name);
MCRSwordCollectionProvider collectionProvider = mcrConfiguration.getInstanceOf(name);
collections.put(collection, collectionProvider);
final MCRSwordLifecycleConfiguration lifecycleConfiguration = new MCRSwordLifecycleConfiguration(collection);
collectionProvider.init(lifecycleConfiguration);
// This Map is needed to speed up the build of the {@link org.mycore.mir.sword2.manager.MCRServiceDocumentManager}
List<String> collectionsOfWorkspace;
if (workspaceCollectionTable.containsKey(workspace)) {
collectionsOfWorkspace = workspaceCollectionTable.get(workspace);
} else {
collectionsOfWorkspace = new ArrayList<>();
workspaceCollectionTable.put(workspace, collectionsOfWorkspace);
}
collectionsOfWorkspace.add(collection);
});
addCollectionShutdownHook();
}
}
Aggregations