use of org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver in project deltaspike by apache.
the class ViewConfigPathTest method testNamesWizard14.
@Test(expected = IllegalStateException.class)
public void testNamesWizard14() {
this.viewConfigExtension.addPageDefinition(Pages.Wizard14.Step1.class);
ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();
viewConfigResolver.getViewConfigDescriptor(Pages.Wizard14.Step1.class);
}
use of org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver in project deltaspike by apache.
the class ViewConfigTest method testSimpleViewConfigWithViewControllerCallback.
@Test
public void testSimpleViewConfigWithViewControllerCallback() {
this.viewConfigExtension.addPageDefinition(SimplePageConfig.class);
ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();
ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(SimplePageConfig.class);
Assert.assertNotNull(viewConfigDescriptor);
Assert.assertNotNull(viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, PreRenderView.class));
Assert.assertEquals(PageBean001.class, viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, PreRenderView.class).getCallbackMethods().keySet().iterator().next());
Assert.assertEquals("preRenderViewCallbackMethod", ((List<Method>) viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, PreRenderView.class).getCallbackMethods().values().iterator().next()).iterator().next().getName());
}
use of org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver in project deltaspike by apache.
the class ViewConfigTest method testViewConfigWithRandomOrder.
@Test
public void testViewConfigWithRandomOrder() {
this.viewConfigExtension.addPageDefinition(Pages.Index.class);
// simulates random processing-order
this.viewConfigExtension.addPageDefinition(Pages.class);
ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();
ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Index.class);
Assert.assertEquals("/pages/index.xhtml", viewConfigDescriptor.getViewId());
Assert.assertEquals(View.ViewParameterMode.EXCLUDE, viewConfigDescriptor.getMetaData(View.class).iterator().next().viewParams());
}
use of org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver in project deltaspike by apache.
the class SecurityAwareViewHandler method createView.
@Override
public UIViewRoot createView(FacesContext context, String viewId) {
UIViewRoot result = this.wrapped.createView(context, viewId);
if (!this.activated) {
return result;
}
if (this.securityModuleActivated == null) {
lazyInit();
}
if (!this.securityModuleActivated) {
return result;
}
UIViewRoot originalViewRoot = context.getViewRoot();
Map<String, Object> viewMap = null;
if (originalViewRoot != null) {
Map<String, Object> originalViewMap = originalViewRoot.getViewMap(false);
if (originalViewMap != null && !originalViewMap.isEmpty()) {
viewMap = new HashMap<String, Object>();
viewMap.putAll(originalViewMap);
}
}
// workaround for PreDestroyViewMapEvent which would be caused by the security check
deactivatePreDestroyViewMapEvent(context);
// we have to use it as current view if an AccessDecisionVoter uses the JSF API to check access to the view-id
context.setViewRoot(result);
try {
ViewRootAccessHandler viewRootAccessHandler = BeanProvider.getContextualReference(ViewRootAccessHandler.class);
viewRootAccessHandler.checkAccessTo(result);
} catch (ErrorViewAwareAccessDeniedException accessDeniedException) {
ViewConfigResolver viewConfigResolver = BeanProvider.getContextualReference(ViewConfigResolver.class);
ViewConfigDescriptor errorViewDescriptor = viewConfigResolver.getViewConfigDescriptor(accessDeniedException.getErrorView());
try {
if (errorViewDescriptor != null && View.NavigationMode.REDIRECT == errorViewDescriptor.getMetaData(View.class).iterator().next().navigation() && /*always available*/
BeanProvider.getContextualReference(JsfModuleConfig.class).isAlwaysUseNavigationHandlerOnSecurityViolation()) {
SecurityUtils.tryToHandleSecurityViolation(accessDeniedException);
} else {
SecurityUtils.handleSecurityViolationWithoutNavigation(accessDeniedException);
}
} finally {
broadcastAccessDeniedException(accessDeniedException);
}
if (errorViewDescriptor != null) {
return this.wrapped.createView(context, errorViewDescriptor.getViewId());
} else {
// the previous page (including the error message)
if (!context.isPostback() && context.getViewRoot() != null) {
context.getViewRoot().setViewId(null);
}
}
// security exception without error-view
throw accessDeniedException;
} finally {
activatePreDestroyViewMapEvent(context);
if (originalViewRoot != null) {
context.setViewRoot(originalViewRoot);
if (viewMap != null) {
originalViewRoot.getViewMap().putAll(viewMap);
}
}
}
return result;
}
use of org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver in project deltaspike by apache.
the class ViewConfigTest method testSimpleViewConfigWithCustomMetaData.
@Test
public void testSimpleViewConfigWithCustomMetaData() {
this.viewConfigExtension.addPageDefinition(SimplePageConfig.class);
ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();
ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(SimplePageConfig.class);
Assert.assertNotNull(viewConfigDescriptor);
Assert.assertNotNull(viewConfigDescriptor.getMetaData());
Assert.assertEquals(2, viewConfigDescriptor.getMetaData().size());
Assert.assertEquals(1, viewConfigDescriptor.getMetaData(View.class).size());
Assert.assertEquals(1, viewConfigDescriptor.getMetaData(TestEntryPoint.class).size());
}
Aggregations