Search in sources :

Example 26 with IRequestablePage

use of org.apache.wicket.request.component.IRequestablePage in project wicket by apache.

the class TestMapperContext method getPageInstance.

@Override
public IRequestablePage getPageInstance(int pageId) {
    IRequestablePage requestablePage = (IRequestablePage) pageManager.getPage(pageId);
    if (requestablePage == null && createMockPageIfInstanceNotFound) {
        MockPage page = new MockPage();
        page.setPageId(pageId);
        page.setBookmarkable(bookmarkable);
        page.setCreatedBookmarkable(createdBookmarkable);
        page.setRenderCount(nextPageRenderCount);
        requestablePage = page;
    }
    return requestablePage;
}
Also used : IRequestablePage(org.apache.wicket.request.component.IRequestablePage) MockPage(org.apache.wicket.MockPage)

Example 27 with IRequestablePage

use of org.apache.wicket.request.component.IRequestablePage in project wicket by apache.

the class DefaultMapperContext method getPageInstance.

@Override
public IRequestablePage getPageInstance(final int pageId) {
    IManageablePage manageablePage = Session.get().getPageManager().getPage(pageId);
    IRequestablePage requestablePage = null;
    if (manageablePage instanceof IRequestablePage) {
        requestablePage = (IRequestablePage) manageablePage;
    }
    return requestablePage;
}
Also used : IRequestablePage(org.apache.wicket.request.component.IRequestablePage) IManageablePage(org.apache.wicket.page.IManageablePage)

Example 28 with IRequestablePage

use of org.apache.wicket.request.component.IRequestablePage in project wicket by apache.

the class BookmarkableMapper method parseRequest.

@Override
protected UrlInfo parseRequest(Request request) {
    if (Application.exists()) {
        if (Application.get().getSecuritySettings().getEnforceMounts()) {
            return null;
        }
    }
    if (matches(request)) {
        Url url = request.getUrl();
        // try to extract page and component information from URL
        PageComponentInfo info = getPageComponentInfo(url);
        List<String> segments = url.getSegments();
        // load the page class
        String className;
        if (segments.size() >= 3) {
            className = segments.get(2);
        } else {
            className = segments.get(1);
        }
        if (Strings.isEmpty(className)) {
            return null;
        }
        Class<? extends IRequestablePage> pageClass = getPageClass(className);
        if (pageClass != null && IRequestablePage.class.isAssignableFrom(pageClass)) {
            // extract the PageParameters from URL if there are any
            PageParameters pageParameters = extractPageParameters(request, 3, pageParametersEncoder);
            if (pageParameters != null) {
                pageParameters.setLocale(resolveLocale());
            }
            return new UrlInfo(info, pageClass, pageParameters);
        }
    }
    return null;
}
Also used : IRequestablePage(org.apache.wicket.request.component.IRequestablePage) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) Url(org.apache.wicket.request.Url) PageComponentInfo(org.apache.wicket.request.mapper.info.PageComponentInfo)

Example 29 with IRequestablePage

use of org.apache.wicket.request.component.IRequestablePage in project wicket by apache.

the class MountedMapper method mapHandler.

@Override
public Url mapHandler(IRequestHandler requestHandler) {
    Url url = super.mapHandler(requestHandler);
    if (url == null && requestHandler instanceof ListenerRequestHandler && getRecreateMountedPagesAfterExpiry()) {
        ListenerRequestHandler handler = (ListenerRequestHandler) requestHandler;
        IRequestablePage page = handler.getPage();
        if (checkPageInstance(page)) {
            Integer renderCount = null;
            if (handler.includeRenderCount()) {
                renderCount = page.getRenderCount();
            }
            String componentPath = handler.getComponentPath();
            PageInfo pageInfo = getPageInfo(handler);
            ComponentInfo componentInfo = new ComponentInfo(renderCount, componentPath, handler.getBehaviorIndex());
            PageComponentInfo pageComponentInfo = new PageComponentInfo(pageInfo, componentInfo);
            PageParameters parameters = newPageParameters();
            parameters.mergeWith(page.getPageParameters());
            UrlInfo urlInfo = new UrlInfo(pageComponentInfo, page.getClass(), parameters.mergeWith(handler.getPageParameters()));
            url = buildUrl(urlInfo);
        }
    }
    return url;
}
Also used : PageInfo(org.apache.wicket.request.mapper.info.PageInfo) IRequestablePage(org.apache.wicket.request.component.IRequestablePage) ListenerRequestHandler(org.apache.wicket.core.request.handler.ListenerRequestHandler) ComponentInfo(org.apache.wicket.request.mapper.info.ComponentInfo) PageComponentInfo(org.apache.wicket.request.mapper.info.PageComponentInfo) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) Url(org.apache.wicket.request.Url) PageComponentInfo(org.apache.wicket.request.mapper.info.PageComponentInfo)

Example 30 with IRequestablePage

use of org.apache.wicket.request.component.IRequestablePage in project syncope by apache.

the class SyncopeConsoleRequestCycleListener method onException.

@Override
public IRequestHandler onException(final RequestCycle cycle, final Exception e) {
    LOG.error("Exception found", e);
    PageParameters errorParameters = new PageParameters();
    IRequestablePage errorPage = null;
    if (instanceOf(e, UnauthorizedInstantiationException.class) != null) {
        errorParameters.add("errorMessage", MISSING_AUTHORIZATION);
        errorPage = new Login(errorParameters);
    } else if (instanceOf(e, AccessControlException.class) != null) {
        if (instanceOf(e, AccessControlException.class).getMessage().contains("expired")) {
            errorParameters.add("errorMessage", PAGE_EXPIRED);
        } else {
            errorParameters.add("errorMessage", MISSING_AUTHORIZATION_CORE);
        }
        errorPage = new Login(errorParameters);
    } else if (instanceOf(e, PageExpiredException.class) != null || !SyncopeConsoleSession.get().isSignedIn()) {
        errorParameters.add("errorMessage", PAGE_EXPIRED);
        errorPage = new Login(errorParameters);
    } else if (instanceOf(e, BadRequestException.class) != null || instanceOf(e, WebServiceException.class) != null || instanceOf(e, SyncopeClientException.class) != null) {
        errorParameters.add("errorMessage", REST);
        errorPage = new Login(errorParameters);
    } else {
        Throwable cause = instanceOf(e, ForbiddenException.class);
        if (cause == null) {
            // redirect to default Wicket error page
            errorPage = new ExceptionErrorPage(e, null);
        } else {
            errorParameters.add("errorMessage", cause.getMessage());
            errorPage = new Login(errorParameters);
        }
    }
    if (errorPage instanceof Login) {
        try {
            SyncopeConsoleSession.get().cleanup();
            SyncopeConsoleSession.get().invalidateNow();
        } catch (Throwable t) {
            // ignore
            LOG.debug("Unexpected error while forcing logout after error", t);
        }
    }
    return new RenderPageRequestHandler(new PageProvider(errorPage));
}
Also used : ForbiddenException(javax.ws.rs.ForbiddenException) ExceptionErrorPage(org.apache.wicket.markup.html.pages.ExceptionErrorPage) RenderPageRequestHandler(org.apache.wicket.core.request.handler.RenderPageRequestHandler) PageProvider(org.apache.wicket.core.request.handler.PageProvider) IRequestablePage(org.apache.wicket.request.component.IRequestablePage) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) AccessControlException(java.security.AccessControlException) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) Login(org.apache.syncope.client.console.pages.Login) UnauthorizedInstantiationException(org.apache.wicket.authorization.UnauthorizedInstantiationException)

Aggregations

IRequestablePage (org.apache.wicket.request.component.IRequestablePage)59 Url (org.apache.wicket.request.Url)50 IRequestHandler (org.apache.wicket.request.IRequestHandler)47 Test (org.junit.Test)46 RenderPageRequestHandler (org.apache.wicket.core.request.handler.RenderPageRequestHandler)31 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)18 ListenerRequestHandler (org.apache.wicket.core.request.handler.ListenerRequestHandler)15 BookmarkableListenerRequestHandler (org.apache.wicket.core.request.handler.BookmarkableListenerRequestHandler)14 IPageRequestHandler (org.apache.wicket.core.request.handler.IPageRequestHandler)6 Request (org.apache.wicket.request.Request)6 PageComponentInfo (org.apache.wicket.request.mapper.info.PageComponentInfo)5 PageProvider (org.apache.wicket.core.request.handler.PageProvider)4 PageInfo (org.apache.wicket.request.mapper.info.PageInfo)4 IPageProvider (org.apache.wicket.core.request.handler.IPageProvider)3 ComponentInfo (org.apache.wicket.request.mapper.info.ComponentInfo)3 Page (org.apache.wicket.Page)2 AccessControlException (java.security.AccessControlException)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 ForbiddenException (javax.ws.rs.ForbiddenException)1 Login (org.apache.syncope.client.console.pages.Login)1