Search in sources :

Example 1 with ISMPURLProvider

use of com.helger.smpclient.url.ISMPURLProvider in project phoss-smp by phax.

the class SMPRestDataProvider method _getDynamicParticipantURLHostName.

@Nonnull
private String _getDynamicParticipantURLHostName() {
    String ret = null;
    final ISMPURLProvider aURLProvider = SMPMetaManager.getSMPURLProvider();
    try {
        if (aURLProvider instanceof IPeppolURLProvider)
            ret = ((IPeppolURLProvider) aURLProvider).getDNSNameOfParticipant(m_aParticipantID, m_sSMLZoneName);
        else if (aURLProvider instanceof IBDXLURLProvider) {
            // Fallback by not resolving the NAPTR
            ret = ((IBDXLURLProvider) aURLProvider).getDNSNameOfParticipant(m_aParticipantID, m_sSMLZoneName);
        }
    } catch (final SMPDNSResolutionException ex) {
    // Ignore
    }
    if (ret == null)
        throw new IllegalStateException("Failed to resolve host name for '" + m_aParticipantID.getURIEncoded() + "' and SML zone name '" + m_sSMLZoneName + "'");
    return ret;
}
Also used : ISMPURLProvider(com.helger.smpclient.url.ISMPURLProvider) SMPDNSResolutionException(com.helger.smpclient.url.SMPDNSResolutionException) IPeppolURLProvider(com.helger.smpclient.url.IPeppolURLProvider) IBDXLURLProvider(com.helger.smpclient.url.IBDXLURLProvider) Nonnull(javax.annotation.Nonnull)

Example 2 with ISMPURLProvider

use of com.helger.smpclient.url.ISMPURLProvider in project phoss-directory by phax.

the class AbstractPageSecureReIndex method showSelectedObject.

@Override
protected void showSelectedObject(@Nonnull final WebPageExecutionContext aWPEC, @Nonnull final IReIndexWorkItem aSelectedObject) {
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    final ISMPURLProvider aURLProvider = PDServerConfiguration.getURLProvider();
    final IIndexerWorkItem aWorkItem = aSelectedObject.getWorkItem();
    final IParticipantIdentifier aParticipantID = aWorkItem.getParticipantID();
    final BootstrapViewForm aViewForm = aNodeList.addAndReturnChild(new BootstrapViewForm());
    aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Creation datetime").setCtrl(PDTToString.getAsString(aWorkItem.getCreationDateTime(), aDisplayLocale)));
    aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Participant ID").setCtrl(aParticipantID.getURIEncoded()));
    final String sBCSuffix = "/businesscard/" + aParticipantID.getURIPercentEncoded();
    {
        final HCNodeList aURLs = new HCNodeList();
        for (final ISMLInfo aSMLInfo : PDPMetaManager.getSMLInfoMgr().getAll()) {
            if (aURLs.hasChildren())
                aURLs.addChild(div("or"));
            try {
                aURLs.addChild(div(HCA.createLinkedWebsite(aURLProvider.getSMPURIOfParticipant(aParticipantID, aSMLInfo).toString() + sBCSuffix)));
            } catch (final SMPDNSResolutionException ex) {
                // Non existing participant!
                aURLs.addChild(div(aParticipantID.getURIPercentEncoded() + " on " + aSMLInfo.getDisplayName() + " @ " + sBCSuffix + " [" + ex.getMessage() + "]"));
            }
        }
        aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Business Card URL").setCtrl(aURLs));
    }
    aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Action type").setCtrl(aWorkItem.getType().getDisplayName()));
    aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Owner").setCtrl(aWorkItem.getOwnerID()));
    aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Requesting host").setCtrl(aWorkItem.getRequestingHost()));
    aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Retries so far").setCtrl(Integer.toString(aSelectedObject.getRetryCount())));
    if (aSelectedObject.hasPreviousRetryDT())
        aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Previous retry").setCtrl(PDTToString.getAsString(aSelectedObject.getPreviousRetryDT(), aDisplayLocale)));
    if (!m_bDeadIndex)
        aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Next retry").setCtrl(PDTToString.getAsString(aSelectedObject.getNextRetryDT(), aDisplayLocale)));
    aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Last retry").setCtrl(PDTToString.getAsString(aSelectedObject.getMaxRetryDT(), aDisplayLocale)));
}
Also used : Locale(java.util.Locale) IIndexerWorkItem(com.helger.pd.indexer.index.IIndexerWorkItem) HCNodeList(com.helger.html.hc.impl.HCNodeList) ISMLInfo(com.helger.peppol.sml.ISMLInfo) ISMPURLProvider(com.helger.smpclient.url.ISMPURLProvider) BootstrapViewForm(com.helger.photon.bootstrap4.form.BootstrapViewForm) PDTToString(com.helger.commons.datetime.PDTToString) BootstrapFormGroup(com.helger.photon.bootstrap4.form.BootstrapFormGroup) SMPDNSResolutionException(com.helger.smpclient.url.SMPDNSResolutionException) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier)

Aggregations

ISMPURLProvider (com.helger.smpclient.url.ISMPURLProvider)2 SMPDNSResolutionException (com.helger.smpclient.url.SMPDNSResolutionException)2 PDTToString (com.helger.commons.datetime.PDTToString)1 HCNodeList (com.helger.html.hc.impl.HCNodeList)1 IIndexerWorkItem (com.helger.pd.indexer.index.IIndexerWorkItem)1 ISMLInfo (com.helger.peppol.sml.ISMLInfo)1 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)1 BootstrapFormGroup (com.helger.photon.bootstrap4.form.BootstrapFormGroup)1 BootstrapViewForm (com.helger.photon.bootstrap4.form.BootstrapViewForm)1 IBDXLURLProvider (com.helger.smpclient.url.IBDXLURLProvider)1 IPeppolURLProvider (com.helger.smpclient.url.IPeppolURLProvider)1 Locale (java.util.Locale)1 Nonnull (javax.annotation.Nonnull)1