use of org.mycore.common.config.MCRConfiguration in project mycore by MyCoRe-Org.
the class MCRQLSearchServlet method init.
@Override
public void init() throws ServletException {
super.init();
MCRConfiguration config = MCRConfiguration.instance();
String prefix = "MCR.SearchServlet.";
defaultSearchField = config.getString(prefix + "DefaultSearchField", "allMeta");
}
use of org.mycore.common.config.MCRConfiguration in project mycore by MyCoRe-Org.
the class MCRPIRegistrationService method getMetadataManager.
public MCRPersistentIdentifierMetadataManager<T> getMetadataManager() {
Map<String, String> properties = getProperties();
MCRConfiguration configuration = MCRConfiguration.instance();
String metadataManager;
if (properties.containsKey(METADATA_MANAGER_PROPERTY_KEY)) {
metadataManager = properties.get(METADATA_MANAGER_PROPERTY_KEY);
} else if (properties.containsKey(METADATA_MANAGER_DEPRECATED_PROPERTY_KEY)) {
LOGGER.warn(MessageFormat.format("You should use {0}{1}.{2} instead of {3}{4}.{5}", REGISTRATION_CONFIG_PREFIX, getRegistrationServiceID(), METADATA_MANAGER_PROPERTY_KEY, REGISTRATION_CONFIG_PREFIX, getRegistrationServiceID(), METADATA_MANAGER_DEPRECATED_PROPERTY_KEY));
metadataManager = properties.get(METADATA_MANAGER_DEPRECATED_PROPERTY_KEY);
} else {
throw new MCRConfigurationException(getRegistrationServiceID() + " has no MetadataManager(or legacy Inscriber)!");
}
String className;
String metadataManagerPropertyKey;
metadataManagerPropertyKey = METADATA_MANAGER_CONFIG_PREFIX + metadataManager;
className = configuration.getString(metadataManagerPropertyKey, null);
if (className == null) {
metadataManagerPropertyKey = METADATA_MANAGER_DEPRECATED_CONFIG_PREFIX + metadataManager;
className = configuration.getString(metadataManagerPropertyKey, null);
if (className == null) {
throw new MCRConfigurationException("Missing property: " + METADATA_MANAGER_CONFIG_PREFIX + metadataManager + " or " + metadataManagerPropertyKey);
}
LOGGER.warn("You should use {} instead of {}", METADATA_MANAGER_CONFIG_PREFIX + metadataManager, METADATA_MANAGER_DEPRECATED_PROPERTY_KEY + metadataManager);
}
className = repairDeprecatedClassNames(className, metadataManagerPropertyKey);
try {
@SuppressWarnings("unchecked") Class<MCRPersistentIdentifierMetadataManager<T>> classObject = (Class<MCRPersistentIdentifierMetadataManager<T>>) Class.forName(className);
Constructor<MCRPersistentIdentifierMetadataManager<T>> constructor = classObject.getConstructor(String.class);
return constructor.newInstance(metadataManager);
} catch (ClassNotFoundException e) {
throw new MCRConfigurationException("Configurated class (" + metadataManagerPropertyKey + ") not found: " + className, e);
} catch (NoSuchMethodException e) {
throw new MCRConfigurationException("Configurated class (" + metadataManagerPropertyKey + ") needs a string constructor: " + className);
} catch (IllegalAccessException | InstantiationException | InvocationTargetException e) {
throw new MCRException(e);
}
}
use of org.mycore.common.config.MCRConfiguration in project mycore by MyCoRe-Org.
the class MCROAIQuerySetResolver method getQuery.
private SolrQuery getQuery() {
SolrQuery solrQuery = new SolrQuery();
MCRConfiguration config = MCRConfiguration.instance();
// query
String idQuery = getResult().stream().map(getIdentifier()).map(MCRSolrUtils::escapeSearchValue).collect(Collectors.joining(" OR ", "id:(", ")"));
solrQuery.setQuery(idQuery);
solrQuery.setFilterQueries(query);
solrQuery.setFields("id");
solrQuery.setRows(getResult().size());
// request handler
solrQuery.setRequestHandler(config.getString(getConfigPrefix() + "Search.RequestHandler", "/select"));
return solrQuery;
}
use of org.mycore.common.config.MCRConfiguration in project mycore by MyCoRe-Org.
the class MCROAIQueryToSetHandler method getSetFilterQuery.
private String getSetFilterQuery(String setId) {
MCRConfiguration config = MCRConfiguration.instance();
String queryProperty = getConfigPrefix() + "Sets." + setId + ".Query";
String configQuery;
try {
configQuery = config.getString(queryProperty);
} catch (MCRConfigurationException e) {
String deprecatedProperty = getConfigPrefix() + "MapSetToQuery." + setId;
configQuery = config.getString(deprecatedProperty, null);
if (configQuery == null) {
throw e;
}
LogManager.getLogger().warn("Property '{}' is deprecated and support will be removed. Please rename to '{}' soon!", deprecatedProperty, queryProperty);
}
return configQuery;
}
use of org.mycore.common.config.MCRConfiguration in project mycore by MyCoRe-Org.
the class MCROAIDataProvider method getOAIAdapter.
private OAIAdapter getOAIAdapter() {
String oaiAdapterKey = getServletName();
MCROAIAdapter oaiAdapter = mcrOAIAdapterMap.get(oaiAdapterKey);
if (oaiAdapter == null) {
synchronized (this) {
// double check because of synchronize block
oaiAdapter = mcrOAIAdapterMap.get(oaiAdapterKey);
if (oaiAdapter == null) {
MCRConfiguration config = MCRConfiguration.instance();
String adapter = MCROAIAdapter.PREFIX + oaiAdapterKey + ".Adapter";
oaiAdapter = config.getInstanceOf(adapter, MCROAIAdapter.class.getName());
oaiAdapter.init(this.myBaseURL, oaiAdapterKey);
mcrOAIAdapterMap.put(oaiAdapterKey, oaiAdapter);
}
}
}
return oaiAdapter;
}
Aggregations