use of com.helger.peppolid.IDocumentTypeIdentifier in project phoss-smp by phax.
the class SMPRedirectTest method testCaseSensitivity.
@Test
public void testCaseSensitivity() {
final IParticipantIdentifier aPI = new SimpleParticipantIdentifier(PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME, "0088:UpperCase");
final IDocumentTypeIdentifier aDocTypeID = new SimpleDocumentTypeIdentifier(PeppolIdentifierHelper.DOCUMENT_TYPE_SCHEME_BUSDOX_DOCID_QNS, "testDocType");
final SMPServiceGroup aSG = new SMPServiceGroup(CSecurity.USER_ADMINISTRATOR_ID, aPI, null);
// Create new one
final ISMPRedirect aRedirect = new SMPRedirect(aSG, aDocTypeID, "target", "suid", null, "<extredirect/>");
assertSame(aSG, aRedirect.getServiceGroup());
assertEquals(aDocTypeID, aRedirect.getDocumentTypeIdentifier());
assertEquals("target", aRedirect.getTargetHref());
assertEquals("suid", aRedirect.getSubjectUniqueIdentifier());
assertNull(aRedirect.getCertificate());
assertFalse(aRedirect.hasCertificate());
assertEquals("[{\"Any\":\"<extredirect />\"}]", aRedirect.getExtensionsAsString());
}
use of com.helger.peppolid.IDocumentTypeIdentifier in project phoss-smp by phax.
the class SMPServiceInformationTest method testBasic.
@Test
public void testBasic() {
final IParticipantIdentifier aPI = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("0088:dummy");
final ISMPServiceGroup aSG = new SMPServiceGroup(CSecurity.USER_ADMINISTRATOR_ID, aPI, null);
final XMLOffsetDateTime aStartDT = PDTFactory.getCurrentXMLOffsetDateTime();
final XMLOffsetDateTime aEndDT = aStartDT.plusYears(1);
final SMPEndpoint aEP = new SMPEndpoint("tp", "http://localhost/as2", false, "minauth", aStartDT, aEndDT, "cert", "sd", "tc", "ti", "<extep/>");
assertEquals("tp", aEP.getTransportProfile());
assertEquals("http://localhost/as2", aEP.getEndpointReference());
assertFalse(aEP.isRequireBusinessLevelSignature());
assertEquals("minauth", aEP.getMinimumAuthenticationLevel());
assertEquals(aStartDT, aEP.getServiceActivationDateTime());
assertEquals(aEndDT, aEP.getServiceExpirationDateTime());
assertEquals("cert", aEP.getCertificate());
assertEquals("sd", aEP.getServiceDescription());
assertEquals("tc", aEP.getTechnicalContactUrl());
assertEquals("ti", aEP.getTechnicalInformationUrl());
assertEquals("[{\"Any\":\"<extep />\"}]", aEP.getExtensionsAsString());
final IProcessIdentifier aProcessID = new SimpleProcessIdentifier(PeppolIdentifierHelper.DEFAULT_PROCESS_SCHEME, "testproc");
final SMPProcess aProcess = new SMPProcess(aProcessID, CollectionHelper.newList(aEP), "<extproc/>");
assertEquals(aProcessID, aProcess.getProcessIdentifier());
assertEquals(1, aProcess.getAllEndpoints().size());
assertEquals("[{\"Any\":\"<extproc />\"}]", aProcess.getExtensionsAsString());
final IDocumentTypeIdentifier aDocTypeID = new SimpleDocumentTypeIdentifier(PeppolIdentifierHelper.DOCUMENT_TYPE_SCHEME_BUSDOX_DOCID_QNS, "testdoctype");
final SMPServiceInformation aSI = new SMPServiceInformation(aSG, aDocTypeID, CollectionHelper.newList(aProcess), "<extsi/>");
assertSame(aSG, aSI.getServiceGroup());
assertEquals(aDocTypeID, aSI.getDocumentTypeIdentifier());
assertEquals(1, aSI.getAllProcesses().size());
assertEquals("[{\"Any\":\"<extsi />\"}]", aSI.getExtensionsAsString());
}
use of com.helger.peppolid.IDocumentTypeIdentifier in project phoss-directory by phax.
the class AbstractPagePublicSearch method createParticipantDetails.
@Nonnull
protected HCNodeList createParticipantDetails(@Nonnull final Locale aDisplayLocale, @Nonnull final String sParticipantID, @Nonnull final IParticipantIdentifier aParticipantID, final boolean bIsLoggedInUserAdministrator) {
final HCNodeList aDetails = new HCNodeList();
// Search document matching participant ID
final ICommonsList<PDStoredBusinessEntity> aResultDocs = PDMetaManager.getStorageMgr().getAllDocumentsOfParticipant(aParticipantID);
// Group by participant ID
final ICommonsMap<IParticipantIdentifier, ICommonsList<PDStoredBusinessEntity>> aGroupedDocs = PDStorageManager.getGroupedByParticipantID(aResultDocs);
if (aGroupedDocs.isEmpty())
LOGGER.error("No stored document matches participant identifier '" + sParticipantID + "' - cannot show details");
else {
if (aGroupedDocs.size() > 1)
LOGGER.warn("Found " + aGroupedDocs.size() + " entries for participant identifier '" + sParticipantID + "' - weird");
// Get the first one
final ICommonsList<PDStoredBusinessEntity> aStoredEntities = aGroupedDocs.getFirstValue();
// Details header
{
IHCNode aDetailsHeader = null;
final boolean bIsPeppolDefault = aParticipantID.hasScheme(PeppolIdentifierFactory.INSTANCE.getDefaultParticipantIdentifierScheme());
if (bIsPeppolDefault) {
final IParticipantIdentifierScheme aIIA = ParticipantIdentifierSchemeManager.getSchemeOfIdentifier(aParticipantID);
if (aIIA != null) {
final HCH1 aH1 = h1("Details for: " + aParticipantID.getValue());
if (StringHelper.hasText(aIIA.getSchemeAgency()))
aH1.addChild(small(" (" + aIIA.getSchemeAgency() + ")"));
aDetailsHeader = new BootstrapPageHeader().addChild(aH1);
}
}
if (aDetailsHeader == null) {
// Fallback
aDetailsHeader = BootstrapWebPageUIHandler.INSTANCE.createPageHeader("Details for " + sParticipantID);
}
aDetails.addChild(aDetailsHeader);
}
final BootstrapTabBox aTabBox = new BootstrapTabBox();
// Business information
{
final HCNodeList aOL = new HCNodeList();
int nIndex = 1;
for (final PDStoredBusinessEntity aStoredEntity : aStoredEntities) {
final BootstrapCard aCard = aOL.addAndReturnChild(new BootstrapCard());
aCard.addClass(CSS_CLASS_RESULT_PANEL);
if (aStoredEntities.size() > 1)
aCard.createAndAddHeader().addChild("Business information entity " + nIndex);
final BootstrapViewForm aViewForm = PDCommonUI.showBusinessInfoDetails(aStoredEntity, aDisplayLocale);
aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Full Peppol participant ID").setCtrl(code(sParticipantID)));
if (GlobalDebug.isDebugMode() || bIsLoggedInUserAdministrator) {
aViewForm.addChild(new HCHR());
aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("[Debug] Creation DT").setCtrl(PDTToString.getAsString(aStoredEntity.getMetaData().getCreationDT(), aDisplayLocale)));
aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("[Debug] Owner ID").setCtrl(code(aStoredEntity.getMetaData().getOwnerID())));
aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("[Debug] Requesting Host").setCtrl(code(aStoredEntity.getMetaData().getRequestingHost())));
}
aCard.createAndAddBody().addChild(aViewForm);
++nIndex;
}
// Add whole list or just the first item?
final IHCNode aTabLabel = span("Business information ").addChild(badgePrimary(aStoredEntities.size()));
aTabBox.addTab("businessinfo", aTabLabel, aOL, true);
}
// Document types
{
final HCNodeList aDocTypeCtrl = new HCNodeList();
final ICommonsList<String> aNames = new CommonsArrayList<>();
for (final PDStoredBusinessEntity aStoredEntity : aStoredEntities) aNames.addAllMapped(aStoredEntity.names(), PDStoredMLName::getName);
aDocTypeCtrl.addChild(info("The following document types are supported by " + _getImplodedMapped(", ", " and ", aNames, x -> "'" + x + "'") + ":"));
HCOL aDocTypeOL = null;
final ICommonsList<IDocumentTypeIdentifier> aDocTypeIDs = aResultDocs.getFirst().documentTypeIDs().getSorted(IDocumentTypeIdentifier.comparator());
for (final IDocumentTypeIdentifier aDocTypeID : aDocTypeIDs) {
if (aDocTypeOL == null)
aDocTypeOL = aDocTypeCtrl.addAndReturnChild(new HCOL());
final HCLI aLI = aDocTypeOL.addItem();
aLI.addChild(NiceNameUI.getDocumentTypeID(aDocTypeID));
}
if (aDocTypeOL == null)
aDocTypeCtrl.addChild(warn("This participant does not support any document types!"));
aTabBox.addTab("doctypes", span("Supported document types ").addChild(badgePrimary(aDocTypeIDs.size())), aDocTypeCtrl, false);
}
aDetails.addChild(aTabBox);
}
return aDetails;
}
use of com.helger.peppolid.IDocumentTypeIdentifier in project phoss-directory by phax.
the class ExportHelper method getAsXML.
@Nonnull
public static IMicroDocument getAsXML(@Nonnull final ICommonsOrderedMap<IParticipantIdentifier, ICommonsList<PDStoredBusinessEntity>> aMap, final boolean bIncludeDocTypes) {
// XML root
final IMicroDocument aDoc = new MicroDocument();
final IMicroElement aRoot = aDoc.appendElement(XML_EXPORT_NS_URI, "root");
aRoot.setAttribute("version", "2");
aRoot.setAttribute("creationdt", PDTWebDateHelper.getAsStringXSD(PDTFactory.getCurrentZonedDateTimeUTC()));
// For all BCs
for (final Map.Entry<IParticipantIdentifier, ICommonsList<PDStoredBusinessEntity>> aEntry : aMap.entrySet()) {
final IParticipantIdentifier aParticipantID = aEntry.getKey();
final PDBusinessCard aBC = new PDBusinessCard();
aBC.setParticipantIdentifier(new PDIdentifier(aParticipantID.getScheme(), aParticipantID.getValue()));
for (final PDStoredBusinessEntity aSBE : aEntry.getValue()) aBC.businessEntities().add(aSBE.getAsBusinessEntity());
final IMicroElement eBC = aBC.getAsMicroXML(XML_EXPORT_NS_URI, "businesscard");
// New in v2 - add all Document types
if (bIncludeDocTypes && aEntry.getValue().isNotEmpty())
for (final IDocumentTypeIdentifier aDocTypeID : aEntry.getValue().getFirst().documentTypeIDs()) eBC.appendChild(_createMicroElement(aDocTypeID));
aRoot.appendChild(eBC);
}
return aDoc;
}
use of com.helger.peppolid.IDocumentTypeIdentifier in project phoss-directory by phax.
the class PDStoredBusinessEntity method create.
/**
* Convert a stored Lucene {@link Document} to a
* {@link PDStoredBusinessEntity}. This method resolves all Lucene fields to
* Java fields.
*
* @param aDoc
* Source Lucene document. May not be <code>null</code>.
* @return The new {@link PDStoredBusinessEntity}.
*/
@Nonnull
@ReturnsMutableCopy
public static PDStoredBusinessEntity create(@Nonnull final Document aDoc) {
if (LOGGER.isDebugEnabled())
LOGGER.debug("Creating PDStoredDocument from " + aDoc);
final PDStoredBusinessEntity ret = new PDStoredBusinessEntity();
ret.setParticipantID(PDField.PARTICIPANT_ID.getDocValue(aDoc));
for (final IDocumentTypeIdentifier aDocTypeID : PDField.DOCTYPE_ID.getDocValues(aDoc)) if (aDocTypeID != null)
ret.documentTypeIDs().add(aDocTypeID);
ret.setCountryCode(PDField.COUNTRY_CODE.getDocValue(aDoc));
ret.setRegistrationDate(PDTWebDateHelper.getLocalDateFromXSD(PDField.REGISTRATION_DATE.getDocValue(aDoc)));
{
final String sSingleName = PDField.NAME.getDocValue(aDoc);
if (sSingleName != null) {
// No language
ret.names().add(new PDStoredMLName(sSingleName));
} else {
// Multilingual name
final ICommonsList<String> aMLNames = PDField.ML_NAME.getDocValues(aDoc);
final ICommonsList<String> aMLLanguages = PDField.ML_LANGUAGE.getDocValues(aDoc);
if (aMLNames.size() != aMLLanguages.size())
throw new IllegalStateException("Different number of ML names and languages");
for (int i = 0; i < aMLNames.size(); ++i) {
String sLang = aMLLanguages.get(i);
if ("".equals(sLang)) {
// Work around internal error
sLang = null;
}
ret.names().add(new PDStoredMLName(aMLNames.get(i), sLang));
}
}
}
ret.setGeoInfo(PDField.GEO_INFO.getDocValue(aDoc));
{
final ICommonsList<String> aIDTypes = PDField.IDENTIFIER_SCHEME.getDocValues(aDoc);
final ICommonsList<String> aIDValues = PDField.IDENTIFIER_VALUE.getDocValues(aDoc);
if (aIDTypes.size() != aIDValues.size())
throw new IllegalStateException("Different number of identifier types and values");
for (int i = 0; i < aIDTypes.size(); ++i) ret.identifiers().add(new PDStoredIdentifier(aIDTypes.get(i), aIDValues.get(i)));
}
for (final String sWebSite : PDField.WEBSITE_URI.getDocValues(aDoc)) ret.websiteURIs().add(sWebSite);
{
final ICommonsList<String> aBCTypes = PDField.CONTACT_TYPE.getDocValues(aDoc);
final ICommonsList<String> aBCName = PDField.CONTACT_NAME.getDocValues(aDoc);
final ICommonsList<String> aBCPhone = PDField.CONTACT_PHONE.getDocValues(aDoc);
final ICommonsList<String> aBCEmail = PDField.CONTACT_EMAIL.getDocValues(aDoc);
if (aBCTypes.size() != aBCName.size())
throw new IllegalStateException("Different number of business contact types and names");
if (aBCTypes.size() != aBCPhone.size())
throw new IllegalStateException("Different number of business contact types and phones");
if (aBCTypes.size() != aBCEmail.size())
throw new IllegalStateException("Different number of business contact types and emails");
for (int i = 0; i < aBCTypes.size(); ++i) ret.contacts().add(new PDStoredContact(aBCTypes.get(i), aBCName.get(i), aBCPhone.get(i), aBCEmail.get(i)));
}
{
final PDStoredMetaData aMetaData = new PDStoredMetaData(PDField.METADATA_CREATIONDT.getDocValue(aDoc), PDField.METADATA_OWNERID.getDocValue(aDoc), PDField.METADATA_REQUESTING_HOST.getDocValue(aDoc));
ret.setMetaData(aMetaData);
}
ret.setAdditionalInformation(PDField.ADDITIONAL_INFO.getDocValue(aDoc));
return ret;
}
Aggregations