Search in sources :

Example 36 with ViewConfigResolver

use of org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver in project deltaspike by apache.

the class ViewConfigPathTest method testNamesWizard3.

@Test
public void testNamesWizard3() {
    this.viewConfigExtension.addPageDefinition(Pages.Wizard3.Step1.class);
    this.viewConfigExtension.addPageDefinition(Pages.Wizard3.Step2.class);
    ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();
    ViewConfigDescriptor viewConfigDescriptor;
    viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard3.Step1.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/pages/wizard3/step1.xhtml", viewConfigDescriptor.getViewId());
    viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard3.Step2.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/step2.xhtml", viewConfigDescriptor.getViewId());
}
Also used : ViewConfigDescriptor(org.apache.deltaspike.core.api.config.view.metadata.ViewConfigDescriptor) ViewConfigResolver(org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver) Test(org.junit.Test)

Example 37 with ViewConfigResolver

use of org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver in project deltaspike by apache.

the class ViewConfigPathTest method testNamesWizard8.

@Test
public void testNamesWizard8() {
    this.viewConfigExtension.addPageDefinition(Pages.Wizard8.Step1.class);
    ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();
    ViewConfigDescriptor viewConfigDescriptor;
    viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard8.Step1.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/pages/w8/step1.xhtml", viewConfigDescriptor.getViewId());
}
Also used : ViewConfigDescriptor(org.apache.deltaspike.core.api.config.view.metadata.ViewConfigDescriptor) ViewConfigResolver(org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver) Test(org.junit.Test)

Example 38 with ViewConfigResolver

use of org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver in project deltaspike by apache.

the class ViewConfigResolverProducer method createViewConfigResolver.

@Produces
@ApplicationScoped
public ViewConfigResolver createViewConfigResolver() {
    if (!viewConfigExtension.isActivated()) {
        return createEmptyDefaultViewConfigResolver();
    }
    if (// esp. for easier unit-tests
    !viewConfigExtension.isTransformed()) {
        viewConfigExtension.transformMetaDataTree();
    }
    ViewConfigResolver viewConfigResolver = viewConfigExtension.getViewConfigResolver();
    if (viewConfigResolver == null) {
        LOG.warning("It wasn't possible to create a ViewConfigResolver");
        viewConfigResolver = createEmptyDefaultViewConfigResolver();
    }
    return viewConfigResolver;
}
Also used : ViewConfigResolver(org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver) Produces(javax.enterprise.inject.Produces) ApplicationScoped(javax.enterprise.context.ApplicationScoped)

Example 39 with ViewConfigResolver

use of org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver in project deltaspike by apache.

the class ViewConfigPathValidator method contextInitialized.

@Override
public void contextInitialized(ServletContextEvent sce) {
    if (ClassDeactivationUtils.isActivated(getClass())) {
        ViewConfigResolver viewConfigResolver;
        try {
            viewConfigResolver = BeanProvider.getContextualReference(ViewConfigResolver.class);
        } catch (Exception e) {
            LOGGER.log(Level.WARNING, "Container issue detected -> can't validate view-configs. " + "This exception is usually the effect (but not the reason) of a failed startup. " + "You can deactivate " + getClass().getName() + " via a custom " + ClassDeactivator.class.getName() + " to verify it.", e);
            return;
        }
        List<String> supportedExtensions = new ArrayList<String>();
        supportedExtensions.add(View.Extension.XHTML);
        supportedExtensions.add(View.Extension.JSP);
        validateViewConfigPaths(sce, viewConfigResolver, supportedExtensions);
    }
}
Also used : ArrayList(java.util.ArrayList) MalformedURLException(java.net.MalformedURLException) ViewConfigResolver(org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver)

Example 40 with ViewConfigResolver

use of org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver in project deltaspike by apache.

the class SecurityUtils method tryToHandleSecurityViolation.

private static void tryToHandleSecurityViolation(RuntimeException runtimeException, boolean allowNavigation) {
    ErrorViewAwareAccessDeniedException exception = extractException(runtimeException);
    if (exception == null) {
        throw runtimeException;
    }
    Class<? extends ViewConfig> errorView = null;
    Class<? extends ViewConfig> inlineErrorView = exception.getErrorView();
    if (inlineErrorView != null && !DefaultErrorView.class.getName().equals(inlineErrorView.getName())) {
        errorView = inlineErrorView;
    }
    if (errorView == null) {
        ViewConfigResolver viewConfigResolver = BeanProvider.getContextualReference(ViewConfigResolver.class);
        ViewConfigDescriptor errorPageDescriptor = viewConfigResolver.getDefaultErrorViewConfigDescriptor();
        if (errorPageDescriptor != null) {
            errorView = errorPageDescriptor.getConfigClass();
        }
    }
    if (errorView == null && allowNavigation) {
        throw exception;
    }
    processApplicationSecurityException(exception, errorView, allowNavigation);
}
Also used : DefaultErrorView(org.apache.deltaspike.core.api.config.view.DefaultErrorView) ErrorViewAwareAccessDeniedException(org.apache.deltaspike.security.api.authorization.ErrorViewAwareAccessDeniedException) ViewConfigDescriptor(org.apache.deltaspike.core.api.config.view.metadata.ViewConfigDescriptor) ViewConfigResolver(org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver)

Aggregations

ViewConfigResolver (org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver)44 Test (org.junit.Test)37 ViewConfigDescriptor (org.apache.deltaspike.core.api.config.view.metadata.ViewConfigDescriptor)36 ArrayList (java.util.ArrayList)5 Method (java.lang.reflect.Method)3 ViewControllerRef (org.apache.deltaspike.core.api.config.view.controller.ViewControllerRef)3 View (org.apache.deltaspike.jsf.api.config.view.View)3 DefaultErrorView (org.apache.deltaspike.core.api.config.view.DefaultErrorView)2 ViewConfig (org.apache.deltaspike.core.api.config.view.ViewConfig)2 PreRenderView (org.apache.deltaspike.core.api.config.view.controller.PreRenderView)2 JsfModuleConfig (org.apache.deltaspike.jsf.api.config.JsfModuleConfig)2 ErrorViewAwareAccessDeniedException (org.apache.deltaspike.security.api.authorization.ErrorViewAwareAccessDeniedException)2 MalformedURLException (java.net.MalformedURLException)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Produces (javax.enterprise.inject.Produces)1 ConfigurableNavigationHandler (javax.faces.application.ConfigurableNavigationHandler)1 NavigationCase (javax.faces.application.NavigationCase)1 ProjectStage (javax.faces.application.ProjectStage)1