use of com.helger.smpclient.url.SMPDNSResolutionException in project phoss-directory by phax.
the class SMPBusinessCardProvider method getBusinessCard.
@Nullable
public PDExtendedBusinessCard getBusinessCard(@Nonnull final IParticipantIdentifier aParticipantID) {
final HttpClientSettings aHCS = new HttpClientSettings().setProxyHost(_getHttpProxy()).setProxyCredentials(_getHttpProxyCredentials());
PDExtendedBusinessCard aBC;
if (m_aSMPURI != null) {
// Use a preselected SMP URI
switch(m_eSMPMode) {
case PEPPOL:
{
final SMPClientReadOnly aSMPClient = new SMPClientReadOnly(m_aSMPURI);
_configureSMPClient(aSMPClient);
aBC = getBusinessCardPeppolSMP(aParticipantID, aSMPClient, aHCS);
break;
}
case OASIS_BDXR_V1:
{
final BDXRClientReadOnly aSMPClient = new BDXRClientReadOnly(m_aSMPURI);
_configureSMPClient(aSMPClient);
aBC = getBusinessCardBDXR1(aParticipantID, aSMPClient, aHCS);
break;
}
case OASIS_BDXR_V2:
{
final BDXR2ClientReadOnly aSMPClient = new BDXR2ClientReadOnly(m_aSMPURI);
_configureSMPClient(aSMPClient);
aBC = getBusinessCardBDXR2(aParticipantID, aSMPClient, aHCS);
break;
}
default:
throw new IllegalStateException("Unsupported SMP mode " + m_eSMPMode);
}
} else {
// SML auto detect
aBC = null;
for (final ISMLInfo aSML : m_aSMLInfoProvider.get()) {
// Create SMP client and query SMP
switch(m_eSMPMode) {
case PEPPOL:
{
try {
final SMPClientReadOnly aSMPClient = new SMPClientReadOnly(m_aURLProvider, aParticipantID, aSML);
_configureSMPClient(aSMPClient);
aBC = getBusinessCardPeppolSMP(aParticipantID, aSMPClient, aHCS);
} catch (final SMPDNSResolutionException ex) {
// Happens if a non-existing URL is queried
}
break;
}
case OASIS_BDXR_V1:
{
try {
final BDXRClientReadOnly aSMPClient = new BDXRClientReadOnly(m_aURLProvider, aParticipantID, aSML);
_configureSMPClient(aSMPClient);
aBC = getBusinessCardBDXR1(aParticipantID, aSMPClient, aHCS);
} catch (final SMPDNSResolutionException ex) {
// Happens if a non-existing URL is queried
}
break;
}
case OASIS_BDXR_V2:
{
try {
final BDXR2ClientReadOnly aSMPClient = new BDXR2ClientReadOnly(m_aURLProvider, aParticipantID, aSML);
_configureSMPClient(aSMPClient);
aBC = getBusinessCardBDXR2(aParticipantID, aSMPClient, aHCS);
} catch (final SMPDNSResolutionException ex) {
// Happens if a non-existing URL is queried
}
break;
}
default:
throw new IllegalStateException("Unsupported SMP mode " + m_eSMPMode);
}
// Found one?
if (aBC != null)
break;
}
}
if (aBC != null)
LOGGER.info("Found BusinessCard for '" + aParticipantID.getURIEncoded() + "' with " + aBC.getBusinessCard().businessEntities().size() + " entities and " + aBC.getDocumentTypeCount() + " document types");
return aBC;
}
use of com.helger.smpclient.url.SMPDNSResolutionException 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;
}
use of com.helger.smpclient.url.SMPDNSResolutionException 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)));
}
Aggregations