Search in sources :

Example 1 with DescriptorLoader

use of com.evolveum.midpoint.web.application.DescriptorLoader in project midpoint by Evolveum.

the class MidPointApplication method init.

@Override
public void init() {
    super.init();
    getJavaScriptLibrarySettings().setJQueryReference(new PackageResourceReference(MidPointApplication.class, "../../../../../webjars/adminlte/2.3.11/plugins/jQuery/jquery-2.2.3.min.js"));
    GuiComponents.init();
    getComponentInstantiationListeners().add(new SpringComponentInjector(this));
    ResourceSettings resourceSettings = getResourceSettings();
    resourceSettings.setParentFolderPlaceholder("$-$");
    resourceSettings.setHeaderItemComparator(new PriorityFirstComparator(true));
    SecurePackageResourceGuard guard = (SecurePackageResourceGuard) resourceSettings.getPackageResourceGuard();
    guard.addPattern("+*.woff2");
    List<IStringResourceLoader> resourceLoaders = resourceSettings.getStringResourceLoaders();
    resourceLoaders.add(0, new Utf8BundleStringResourceLoader("localization/Midpoint"));
    resourceLoaders.add(1, new Utf8BundleStringResourceLoader(SchemaConstants.SCHEMA_LOCALIZATION_PROPERTIES_RESOURCE_BASE_PATH));
    resourceSettings.setThrowExceptionOnMissingResource(false);
    getMarkupSettings().setStripWicketTags(true);
    if (RuntimeConfigurationType.DEVELOPMENT.equals(getConfigurationType())) {
        getDebugSettings().setAjaxDebugModeEnabled(true);
        getDebugSettings().setDevelopmentUtilitiesEnabled(true);
    }
    //pretty url for resources (e.g. images)
    mountFiles(ImgResources.BASE_PATH, ImgResources.class);
    //exception handling an error pages
    ApplicationSettings appSettings = getApplicationSettings();
    appSettings.setAccessDeniedPage(PageError401.class);
    appSettings.setInternalErrorPage(PageError.class);
    appSettings.setPageExpiredErrorPage(PageError.class);
    mount(new MountedMapper("/error", PageError.class, new PageParametersEncoder()));
    mount(new MountedMapper("/error/401", PageError401.class, new PageParametersEncoder()));
    mount(new MountedMapper("/error/403", PageError403.class, new PageParametersEncoder()));
    mount(new MountedMapper("/error/404", PageError404.class, new PageParametersEncoder()));
    mount(new MountedMapper("/error/410", PageError410.class, new PageParametersEncoder()));
    getRequestCycleListeners().add(new LoggingRequestCycleListener(this));
    //descriptor loader, used for customization
    new DescriptorLoader().loadData(this);
}
Also used : MountedMapper(org.apache.wicket.core.request.mapper.MountedMapper) PriorityFirstComparator(org.apache.wicket.markup.head.PriorityFirstComparator) DescriptorLoader(com.evolveum.midpoint.web.application.DescriptorLoader) ApplicationSettings(org.apache.wicket.settings.ApplicationSettings) SecurePackageResourceGuard(org.apache.wicket.markup.html.SecurePackageResourceGuard) PackageResourceReference(org.apache.wicket.request.resource.PackageResourceReference) ResourceSettings(org.apache.wicket.settings.ResourceSettings) IStringResourceLoader(org.apache.wicket.resource.loader.IStringResourceLoader) Utf8BundleStringResourceLoader(com.evolveum.midpoint.web.util.Utf8BundleStringResourceLoader) PageParametersEncoder(org.apache.wicket.request.mapper.parameter.PageParametersEncoder) SpringComponentInjector(org.apache.wicket.spring.injection.annot.SpringComponentInjector)

Example 2 with DescriptorLoader

use of com.evolveum.midpoint.web.application.DescriptorLoader in project midpoint by Evolveum.

the class TestDescriptorLoader method testDescriptorLoader.

@Test(enabled = false)
public void testDescriptorLoader() {
    final String TEST_NAME = "testDescriptorLoader";
    TestUtil.displayTestTile(TEST_NAME);
    MidPointApplication midPointApplication = new MidPointApplication();
    ServletContext mockServletContext = new ServletContext() {

        @Override
        public void setAttribute(String arg0, Object arg1) {
        }

        @Override
        public void removeAttribute(String arg0) {
        }

        @Override
        public void log(String msg, Throwable e) {
            LOGGER.error("{}", msg, e);
        }

        @Override
        public void log(Exception e, String msg) {
            LOGGER.error("{}", msg, e);
        }

        @Override
        public void log(String msg) {
            LOGGER.trace("{}", msg);
        }

        @Override
        public Enumeration getServlets() {
            return null;
        }

        @Override
        public Enumeration getServletNames() {
            return null;
        }

        @Override
        public String getServletContextName() {
            return "mock";
        }

        @Override
        public Servlet getServlet(String arg0) throws ServletException {
            return null;
        }

        @Override
        public String getServerInfo() {
            return null;
        }

        @Override
        public Set getResourcePaths(String arg0) {
            return null;
        }

        @Override
        public InputStream getResourceAsStream(String name) {
            return this.getClass().getClassLoader().getResourceAsStream(name);
        }

        @Override
        public URL getResource(String name) throws MalformedURLException {
            return this.getClass().getClassLoader().getResource(name);
        }

        @Override
        public RequestDispatcher getRequestDispatcher(String arg0) {
            return null;
        }

        @Override
        public String getRealPath(String arg0) {
            return null;
        }

        @Override
        public RequestDispatcher getNamedDispatcher(String arg0) {
            return null;
        }

        @Override
        public int getMinorVersion() {
            return 2;
        }

        @Override
        public String getMimeType(String arg0) {
            return null;
        }

        @Override
        public int getMajorVersion() {
            return 4;
        }

        @Override
        public Enumeration getInitParameterNames() {
            return null;
        }

        @Override
        public String getInitParameter(String arg0) {
            return null;
        }

        @Override
        public String getContextPath() {
            return null;
        }

        @Override
        public ServletContext getContext(String arg0) {
            return this;
        }

        @Override
        public Enumeration getAttributeNames() {
            return null;
        }

        @Override
        public Object getAttribute(String arg0) {
            return null;
        }
    };
    midPointApplication.setServletContext(mockServletContext);
    DescriptorLoader descriptorLoader = new DescriptorLoader();
    // TODO: this test does not really work. This needs to be cleaned up
    // to make it testable
    // WHEN
    descriptorLoader.loadData(midPointApplication);
    // THEN
    display("initialized loader", descriptorLoader);
}
Also used : MidPointApplication(com.evolveum.midpoint.web.security.MidPointApplication) ServletContext(javax.servlet.ServletContext) MalformedURLException(java.net.MalformedURLException) ServletException(javax.servlet.ServletException) DescriptorLoader(com.evolveum.midpoint.web.application.DescriptorLoader) Test(org.testng.annotations.Test)

Aggregations

DescriptorLoader (com.evolveum.midpoint.web.application.DescriptorLoader)2 MidPointApplication (com.evolveum.midpoint.web.security.MidPointApplication)1 Utf8BundleStringResourceLoader (com.evolveum.midpoint.web.util.Utf8BundleStringResourceLoader)1 MalformedURLException (java.net.MalformedURLException)1 ServletContext (javax.servlet.ServletContext)1 ServletException (javax.servlet.ServletException)1 MountedMapper (org.apache.wicket.core.request.mapper.MountedMapper)1 PriorityFirstComparator (org.apache.wicket.markup.head.PriorityFirstComparator)1 SecurePackageResourceGuard (org.apache.wicket.markup.html.SecurePackageResourceGuard)1 PageParametersEncoder (org.apache.wicket.request.mapper.parameter.PageParametersEncoder)1 PackageResourceReference (org.apache.wicket.request.resource.PackageResourceReference)1 IStringResourceLoader (org.apache.wicket.resource.loader.IStringResourceLoader)1 ApplicationSettings (org.apache.wicket.settings.ApplicationSettings)1 ResourceSettings (org.apache.wicket.settings.ResourceSettings)1 SpringComponentInjector (org.apache.wicket.spring.injection.annot.SpringComponentInjector)1 Test (org.testng.annotations.Test)1