public boolean isMetaModelValid() { return IsisContext.getMetaModelInvalidExceptionIfAny() == null; } //endregion
private static void ensureMetamodelIsValid() { final MetaModelInvalidException ex = IsisContext.getMetaModelInvalidExceptionIfAny(); if(ex != null) { final Set<String> validationErrors = ex.getValidationErrors(); final StringBuilder buf = new StringBuilder(); for (String validationError : validationErrors) { buf.append(validationError).append("\n"); } throw new IllegalStateException("Metamodel validation errors: \n" + buf.toString()); } }
@Override void shutdown() { if(IsisContext.getMetaModelInvalidExceptionIfAny() != null) { // suppress logging translations return; } logTranslations(); }
@Override public void onRequestHandlerResolved(final RequestCycle cycle, final IRequestHandler handler) { final MetaModelInvalidException mmie = IsisContext.getMetaModelInvalidExceptionIfAny(); if(mmie != null) { if(handler instanceof RenderPageRequestHandler) { RenderPageRequestHandler requestHandler = (RenderPageRequestHandler) handler; final IRequestablePage nextPage = requestHandler.getPage(); if(nextPage instanceof ErrorPage || nextPage instanceof MmvErrorPage) { // do nothing return; } throw mmie; } // can't figure out where we're heading, so continue anyway and let things turn out as they will. } }
protected IRequestablePage errorPageFor(Exception ex) { List<ExceptionRecognizer> exceptionRecognizers = Lists.newArrayList(); exceptionRecognizers.add(pageExpiredExceptionRecognizer); if(inIsisSession()) { exceptionRecognizers.addAll(getServicesInjector().lookupServices(ExceptionRecognizer.class)); } else { final MetaModelInvalidException mmie = IsisContext.getMetaModelInvalidExceptionIfAny(); if(mmie != null) { Set<String> validationErrors = mmie.getValidationErrors(); return new MmvErrorPage(validationErrors); } // not sure whether this can ever happen now... LOG.warn("Unable to obtain exceptionRecognizers (no session), will be treated as unrecognized exception", ex); } String recognizedMessageIfAny = new ExceptionRecognizerComposite(exceptionRecognizers).recognize(ex); ExceptionModel exceptionModel = ExceptionModel.create(recognizedMessageIfAny, ex); return isSignedIn() ? new ErrorPage(exceptionModel) : newSignInPage(exceptionModel); }
protected void initIfRequiredThenOpenSession() throws Exception { final MetaModelInvalidException mmie = IsisContext.getMetaModelInvalidExceptionIfAny(); if(mmie != null) { final Set<String> validationErrors = mmie.getValidationErrors(); final MetaModelInvalidException ex = IsisContext.getMetaModelInvalidExceptionIfAny(); if (ex != null) {
private void initIfRequiredThenOpenSession(FireListeners fireListeners) throws Exception { final MetaModelInvalidException mmie = IsisContext.getMetaModelInvalidExceptionIfAny(); if(mmie != null) { final Set<String> validationErrors = mmie.getValidationErrors(); final MetaModelInvalidException ex = IsisContext.getMetaModelInvalidExceptionIfAny(); if (ex != null) {
@Override public IRequestHandler onException(RequestCycle cycle, Exception ex) { final MetaModelInvalidException mmie = IsisContext.getMetaModelInvalidExceptionIfAny(); if(mmie != null) { final Set<String> validationErrors = mmie.getValidationErrors(); final MmvErrorPage mmvErrorPage = new MmvErrorPage(validationErrors); return new RenderPageRequestHandler(new PageProvider(mmvErrorPage), RedirectPolicy.ALWAYS_REDIRECT); } PageProvider errorPageProvider = errorPageProviderFor(ex); // avoid infinite redirect loops RedirectPolicy redirectPolicy = ex instanceof PageExpiredException ? RedirectPolicy.NEVER_REDIRECT : RedirectPolicy.ALWAYS_REDIRECT; return errorPageProvider != null ? new RenderPageRequestHandler(errorPageProvider, redirectPolicy) : null; }
SharedResources sharedResources = getSharedResources(); final MetaModelInvalidException mmie = IsisContext.getMetaModelInvalidExceptionIfAny(); if(mmie != null) { log(mmie.getValidationErrors());