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;
}
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;
}
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;
}
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;
}
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));
}
Aggregations