Search in sources :

Example 1 with InternalErrorBuilder

use of com.helger.photon.core.interror.InternalErrorBuilder in project phoss-directory by phax.

the class PDMetaManager method onAfterInstantiation.

@Override
protected void onAfterInstantiation(@Nonnull final IScope aScope) {
    try {
        m_aLucene = new PDLucene();
        m_aStorageMgr = new PDStorageManager(m_aLucene);
        m_aIndexerMgr = new PDIndexerManager(m_aStorageMgr);
        LOGGER.info(ClassHelper.getClassLocalName(this) + " was initialized");
    } catch (final Exception ex) {
        if (GlobalDebug.isProductionMode()) {
            new InternalErrorBuilder().setThrowable(ex).addErrorMessage(ClassHelper.getClassLocalName(this) + " init failed").handle();
        }
        throw new InitializationException("Failed to init " + ClassHelper.getClassLocalName(this), ex);
    }
}
Also used : PDLucene(com.helger.pd.indexer.lucene.PDLucene) InternalErrorBuilder(com.helger.photon.core.interror.InternalErrorBuilder) InitializationException(com.helger.commons.exception.InitializationException) PDStorageManager(com.helger.pd.indexer.storage.PDStorageManager) InitializationException(com.helger.commons.exception.InitializationException)

Example 2 with InternalErrorBuilder

use of com.helger.photon.core.interror.InternalErrorBuilder in project phoss-directory by phax.

the class PDPMetaManager method onAfterInstantiation.

@Override
protected void onAfterInstantiation(@Nonnull final IScope aScope) {
    try {
        m_aSMLInfoMgr = new SMLInfoManager(SML_INFO_XML);
        final URI aFixedSMPURI = PDServerConfiguration.getFixedSMPURI();
        if (aFixedSMPURI != null) {
            // Use only the configured SMP
            PDMetaManager.setBusinessCardProvider(SMPBusinessCardProvider.createForFixedSMP(PDServerConfiguration.getSMPMode(), aFixedSMPURI));
        } else {
            // Auto detect SMLs
            PDMetaManager.setBusinessCardProvider(SMPBusinessCardProvider.createWithSMLAutoDetect(PDServerConfiguration.getSMPMode(), PDServerConfiguration.getURLProvider(), m_aSMLInfoMgr::getAllSorted));
        }
        LOGGER.info(ClassHelper.getClassLocalName(this) + " was initialized");
    } catch (final Exception ex) {
        if (GlobalDebug.isProductionMode()) {
            new InternalErrorBuilder().setThrowable(ex).addErrorMessage(ClassHelper.getClassLocalName(this) + " init failed").handle();
        }
        throw new InitializationException("Failed to init " + ClassHelper.getClassLocalName(this), ex);
    }
}
Also used : InternalErrorBuilder(com.helger.photon.core.interror.InternalErrorBuilder) InitializationException(com.helger.commons.exception.InitializationException) URI(java.net.URI) InitializationException(com.helger.commons.exception.InitializationException)

Example 3 with InternalErrorBuilder

use of com.helger.photon.core.interror.InternalErrorBuilder in project phoss-smp by phax.

the class SMPLayoutHTMLProvider method fillBody.

@Override
protected void fillBody(@Nonnull final ISimpleWebExecutionContext aSWEC, @Nonnull final HCHtml aHtml) {
    final IRequestWebScopeWithoutResponse aRequestScope = aSWEC.getRequestScope();
    final Locale aDisplayLocale = aSWEC.getDisplayLocale();
    final IMenuItemPage aMenuItem = RequestSettings.getMenuItem(aRequestScope);
    final LayoutExecutionContext aLEC = new LayoutExecutionContext(aSWEC, aMenuItem);
    final HCHead aHead = aHtml.head();
    final HCBody aBody = aHtml.body();
    // Add menu item in page title
    aHead.setPageTitle(StringHelper.getConcatenatedOnDemand(CSMP.getApplicationTitle(), " - ", aMenuItem.getDisplayText(aDisplayLocale)));
    try {
        final IHCNode aNode = m_aFactory.apply(aLEC);
        aBody.addChild(aNode);
    } catch (final ForcedRedirectException ex) {
        throw ex;
    } catch (final RuntimeException ex) {
        new InternalErrorBuilder().setDisplayLocale(aDisplayLocale).setRequestScope(aRequestScope).setThrowable(ex).setUIErrorHandlerFor(aBody).handle();
    }
}
Also used : Locale(java.util.Locale) IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) LayoutExecutionContext(com.helger.photon.core.execcontext.LayoutExecutionContext) HCBody(com.helger.html.hc.html.sections.HCBody) InternalErrorBuilder(com.helger.photon.core.interror.InternalErrorBuilder) HCHead(com.helger.html.hc.html.metadata.HCHead) IMenuItemPage(com.helger.photon.core.menu.IMenuItemPage) ForcedRedirectException(com.helger.xservlet.forcedredirect.ForcedRedirectException) IHCNode(com.helger.html.hc.IHCNode)

Example 4 with InternalErrorBuilder

use of com.helger.photon.core.interror.InternalErrorBuilder in project phoss-smp by phax.

the class SMPInternalErrorHandler method createInternalErrorBuilder.

@Nonnull
public static InternalErrorBuilder createInternalErrorBuilder() {
    final InternalErrorBuilder ret = new InternalErrorBuilder();
    ret.setDisplayLocale(CSMPServer.DEFAULT_LOCALE);
    return ret;
}
Also used : InternalErrorBuilder(com.helger.photon.core.interror.InternalErrorBuilder) Nonnull(javax.annotation.Nonnull)

Aggregations

InternalErrorBuilder (com.helger.photon.core.interror.InternalErrorBuilder)4 InitializationException (com.helger.commons.exception.InitializationException)2 IHCNode (com.helger.html.hc.IHCNode)1 HCHead (com.helger.html.hc.html.metadata.HCHead)1 HCBody (com.helger.html.hc.html.sections.HCBody)1 PDLucene (com.helger.pd.indexer.lucene.PDLucene)1 PDStorageManager (com.helger.pd.indexer.storage.PDStorageManager)1 LayoutExecutionContext (com.helger.photon.core.execcontext.LayoutExecutionContext)1 IMenuItemPage (com.helger.photon.core.menu.IMenuItemPage)1 IRequestWebScopeWithoutResponse (com.helger.web.scope.IRequestWebScopeWithoutResponse)1 ForcedRedirectException (com.helger.xservlet.forcedredirect.ForcedRedirectException)1 URI (java.net.URI)1 Locale (java.util.Locale)1 Nonnull (javax.annotation.Nonnull)1