Search in sources :

Example 11 with MCRConfiguration

use of org.mycore.common.config.MCRConfiguration in project mycore by MyCoRe-Org.

the class MCRTestCaseHelper method before.

public static void before(Map<String, String> testProperties) {
    String mcrComp = MCRRuntimeComponentDetector.getMyCoReComponents().stream().map(MCRComponent::toString).collect(Collectors.joining(", "));
    String appMod = MCRRuntimeComponentDetector.getApplicationModules().stream().map(MCRComponent::toString).collect(Collectors.joining(", "));
    System.out.printf("MyCoRe components detected: %s\nApplications modules detected: %s\n", mcrComp.isEmpty() ? "'none'" : mcrComp, appMod.isEmpty() ? "'none'" : appMod);
    MCRConfiguration config = MCRConfiguration.instance();
    MCRConfigurationLoader configurationLoader = MCRConfigurationLoaderFactory.getConfigurationLoader();
    HashMap<String, String> baseProperties = new HashMap<>(configurationLoader.load());
    baseProperties.putAll(testProperties);
    config.initialize(baseProperties, true);
}
Also used : MCRConfigurationLoader(org.mycore.common.config.MCRConfigurationLoader) MCRConfiguration(org.mycore.common.config.MCRConfiguration) HashMap(java.util.HashMap)

Example 12 with MCRConfiguration

use of org.mycore.common.config.MCRConfiguration in project mycore by MyCoRe-Org.

the class MCRCStoreIFS2 method init.

@Override
public void init(String storeID) {
    super.init(storeID);
    MCRConfiguration config = MCRConfiguration.instance();
    baseDir = config.getString(storeConfigPrefix + "BaseDir");
    LOGGER.info("Base directory for store {} is {}", storeID, baseDir);
    String pattern = config.getString("MCR.Metadata.ObjectID.NumberPattern", "0000000000");
    slotLayout = pattern.length() - 4 + "-2-2";
    slotLayout = config.getString(storeConfigPrefix + "SlotLayout", slotLayout);
    LOGGER.info("Default slot layout for store {} is {}", storeID, slotLayout);
    ignoreOwnerBase = config.getBoolean(storeConfigPrefix + "IgnoreOwnerBase", false);
}
Also used : MCRConfiguration(org.mycore.common.config.MCRConfiguration)

Example 13 with MCRConfiguration

use of org.mycore.common.config.MCRConfiguration in project mycore by MyCoRe-Org.

the class MCRCASServlet method init.

@Override
public void init() throws ServletException {
    super.init();
    MCRConfiguration config = MCRConfiguration.instance();
    clientURL = config.getString(MCRUser2Constants.CONFIG_PREFIX + "CAS.ClientURL");
    serverURL = config.getString(MCRUser2Constants.CONFIG_PREFIX + "CAS.ServerURL");
    realmID = config.getString(MCRUser2Constants.CONFIG_PREFIX + "CAS.RealmID");
    // Set properties to enable SSL connection to CAS and accept certificates
    String trustStore = config.getString(MCRUser2Constants.CONFIG_PREFIX + "CAS.SSL.TrustStore");
    String trustStorePassword = config.getString(MCRUser2Constants.CONFIG_PREFIX + "CAS.SSL.TrustStore.Password");
    System.setProperty("javax.net.ssl.trustStore", trustStore);
    System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
}
Also used : MCRConfiguration(org.mycore.common.config.MCRConfiguration)

Example 14 with MCRConfiguration

use of org.mycore.common.config.MCRConfiguration in project mycore by MyCoRe-Org.

the class MCRRoleServlet method init.

/* (non-Javadoc)
     * @see org.mycore.frontend.servlets.MCRServlet#init()
     */
@Override
public void init() throws ServletException {
    super.init();
    roleClassificationsDefined = false;
    roleCategories = new ArrayList<>();
    roleCategories.add(MCRUser2Constants.ROLE_CLASSID);
    MCRConfiguration config = MCRConfiguration.instance();
    String roleCategoriesValue = config.getString(MCRUser2Constants.CONFIG_PREFIX + "RoleCategories", null);
    if (roleCategoriesValue == null) {
        return;
    }
    String[] roleCategoriesSplitted = roleCategoriesValue.split(",");
    for (String roleID : roleCategoriesSplitted) {
        String categoryId = roleID.trim();
        if (categoryId.length() > 0) {
            roleCategories.add(MCRCategoryID.fromString(categoryId));
        }
    }
    roleClassificationsDefined = roleCategories.size() > 1;
    categoryDao = MCRCategoryDAOFactory.getInstance();
}
Also used : MCRConfiguration(org.mycore.common.config.MCRConfiguration)

Example 15 with MCRConfiguration

use of org.mycore.common.config.MCRConfiguration in project mycore by MyCoRe-Org.

the class MCRViewerMetsConfiguration method setup.

@Override
public MCRViewerConfiguration setup(HttpServletRequest request) {
    super.setup(request);
    // properties
    setProperty("metsURL", MCRServlet.getServletBaseURL() + "MCRMETSServlet/" + getDerivate(request));
    // Parameter can be used to provide multiple urls
    String imageXmlPath = MCRConfiguration.instance().getString("MCR.Viewer.BaseURL", null);
    if (imageXmlPath == null || imageXmlPath.isEmpty()) {
        imageXmlPath = MCRServlet.getServletBaseURL() + "MCRTileServlet/";
    }
    setProperty("tileProviderPath", imageXmlPath);
    if (imageXmlPath.contains(",")) {
        imageXmlPath = imageXmlPath.split(",")[0];
    }
    setProperty("imageXmlPath", imageXmlPath);
    setProperty("pdfCreatorStyle", MCRConfiguration.instance().getString("MCR.Viewer.PDFCreatorStyle", null));
    setProperty("pdfCreatorURI", MCRConfiguration.instance().getString("MCR.Viewer.PDFCreatorURI", null));
    setProperty("text.enabled", MCRConfiguration.instance().getString("MCR.Viewer.text.enabled", "false"));
    MCRConfiguration configuration = MCRConfiguration.instance();
    setProperty("pdfCreatorFormatString", configuration.getString("MCR.Viewer.PDFCreatorFormatString", null));
    setProperty("pdfCreatorRestrictionFormatString", configuration.getString("MCR.Viewer.PDFCreatorRestrictionFormatString", null));
    // script
    addLocalScript("iview-client-mets.js", isDebugParameterSet(request));
    return this;
}
Also used : MCRConfiguration(org.mycore.common.config.MCRConfiguration)

Aggregations

MCRConfiguration (org.mycore.common.config.MCRConfiguration)26 File (java.io.File)3 ArrayList (java.util.ArrayList)3 MCRConfigurationException (org.mycore.common.config.MCRConfigurationException)3 URI (java.net.URI)2 Hashtable (java.util.Hashtable)2 Test (org.junit.Test)2 CategoryDAOMock (org.mycore.frontend.classeditor.mocks.CategoryDAOMock)2 Gson (com.google.gson.Gson)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 URISyntaxException (java.net.URISyntaxException)1 URLConnection (java.net.URLConnection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 StringTokenizer (java.util.StringTokenizer)1 Pattern (java.util.regex.Pattern)1 Collectors (java.util.stream.Collectors)1