use of com.helger.peppolid.IDocumentTypeIdentifier in project peppol-commons by phax.
the class PeppolDocumentTypeIdentifierTest method testValue.
@Test
public void testValue() throws Exception {
final IIdentifierFactory aIF = PeppolIdentifierFactory.INSTANCE;
final String documentIdAsText = "urn:oasis:names:specification:ubl:schema:xsd:ApplicationResponse-2::ApplicationResponse##urn:www.cenbii.eu:transaction:biicoretrdm057:ver1.0:#urn:www.peppol.eu:bis:peppol1a:ver1.0::2.0";
final IDocumentTypeIdentifier documentTypeIdentifier = aIF.createDocumentTypeIdentifierWithDefaultScheme(documentIdAsText);
assertEquals(documentTypeIdentifier.getValue(), documentIdAsText);
assertTrue(documentTypeIdentifier.hasValue(documentIdAsText));
}
use of com.helger.peppolid.IDocumentTypeIdentifier in project peppol-commons by phax.
the class SMPClientReadOnly method getAllDocumentTypes.
/**
* Extract all parsable document types from the passed Service group. This
* method always uses {@link PeppolIdentifierFactory} to parse the document
* type identifiers.
*
* @param aSG
* The service group to parse. May be <code>null</code>.
* @param aIdentifierFactory
* The identifier factory to be used. May not be <code>null</code>.
* @param aUnhandledHrefHandler
* An optional consumer for Hrefs that could not be parsed into a
* document type identifier. May be <code>null</code>.
* @return Never <code>null</code> but a maybe empty list.
* @since 8.0.4
*/
@Nonnull
public static ICommonsList<IDocumentTypeIdentifier> getAllDocumentTypes(@Nullable final ServiceGroupType aSG, @Nonnull final IIdentifierFactory aIdentifierFactory, @Nullable final Consumer<String> aUnhandledHrefHandler) {
ValueEnforcer.notNull(aIdentifierFactory, "IdentifierFactory");
final ICommonsList<IDocumentTypeIdentifier> ret = new CommonsArrayList<>();
if (aSG != null && aSG.getParticipantIdentifier() != null && aSG.getServiceMetadataReferenceCollection() != null) {
final String sPathStart = "/" + CIdentifier.getURIEncoded(aSG.getParticipantIdentifier()) + "/" + URL_PART_SERVICES + "/";
for (final ServiceMetadataReferenceType aSMR : aSG.getServiceMetadataReferenceCollection().getServiceMetadataReference()) {
final String sOriginalHref = aSMR.getHref();
// Decoded href is important for unification
final String sHref = CIdentifier.createPercentDecoded(sOriginalHref);
boolean bSuccess = false;
// Case insensitive "indexOf" here
final int nPathStart = StringHelper.getIndexOfIgnoreCase(sHref, sPathStart, Locale.US);
if (nPathStart >= 0) {
final String sDocType = sHref.substring(nPathStart + sPathStart.length());
final IDocumentTypeIdentifier aDocType = aIdentifierFactory.parseDocumentTypeIdentifier(sDocType);
if (aDocType != null) {
// Found a document type
ret.add(aDocType);
bSuccess = true;
}
}
if (!bSuccess) {
// Failed to parse as doc type
if (aUnhandledHrefHandler != null)
aUnhandledHrefHandler.accept(sOriginalHref);
}
}
}
return ret;
}
use of com.helger.peppolid.IDocumentTypeIdentifier in project peppol-commons by phax.
the class SMPClientWithDNSFuncTest method testRedirect.
@Test
public void testRedirect() throws Exception {
final String sParticipantID = "0088:5798000009997";
final String sDocumentID = "urn:oasis:names:specification:ubl:schema:xsd:SubmitCatalogue-2::SubmitCatalogue##UBL-2.0";
final IParticipantIdentifier aServiceGroupID = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme(sParticipantID);
final IDocumentTypeIdentifier aDocumentTypeID = PeppolIdentifierFactory.INSTANCE.createDocumentTypeIdentifierWithDefaultScheme(sDocumentID);
final SignedServiceMetadataType aMetadata = SMPClientReadOnly.getServiceRegistrationByDNS(URL_PROVIDER, SML_INFO, aServiceGroupID, aDocumentTypeID);
assertNotNull(aMetadata);
}
use of com.helger.peppolid.IDocumentTypeIdentifier in project peppol-commons by phax.
the class MainSMPServiceRegistrationCreate method main.
public static void main(final String[] args) throws Exception {
final URI SMP_URI = MockSMPClientConfig.getSMPURI();
final BasicAuthClientCredentials SMP_CREDENTIALS = MockSMPClientConfig.getSMPCredentials();
final IParticipantIdentifier PARTICIPANT_ID = MockSMPClientConfig.getParticipantID();
final IDocumentTypeIdentifier DOCUMENT_ID = MockSMPClientConfig.getDocumentTypeID();
final IProcessIdentifier PROCESS_ID = MockSMPClientConfig.getProcessTypeID();
final W3CEndpointReference START_AP_ENDPOINTREF = MockSMPClientConfig.getAPEndpointRef();
final String AP_CERT_STRING = MockSMPClientConfig.getAPCert();
final String AP_SERVICE_DESCRIPTION = MockSMPClientConfig.getAPServiceDescription();
final String AP_CONTACT_URL = MockSMPClientConfig.getAPContact();
final String AP_INFO_URL = MockSMPClientConfig.getAPInfo();
// The main SMP client
final SMPClient aClient = new SMPClient(SMP_URI);
// Create the service registration
final ServiceInformationType aServiceInformation = new ServiceInformationType();
{
final ProcessListType aProcessList = new ProcessListType();
{
final ProcessType aProcess = new ProcessType();
{
final ServiceEndpointList aServiceEndpointList = new ServiceEndpointList();
{
final EndpointType aEndpoint = new EndpointType();
aEndpoint.setEndpointReference(START_AP_ENDPOINTREF);
aEndpoint.setTransportProfile(ESMPTransportProfile.TRANSPORT_PROFILE_AS2.getID());
aEndpoint.setCertificate(AP_CERT_STRING);
aEndpoint.setServiceActivationDate(PDTFactory.createXMLOffsetDateTime(2011, Month.JANUARY, 1));
aEndpoint.setServiceExpirationDate(PDTFactory.createXMLOffsetDateTime(2020, Month.DECEMBER, 31));
aEndpoint.setServiceDescription(AP_SERVICE_DESCRIPTION);
aEndpoint.setTechnicalContactUrl(AP_CONTACT_URL);
aEndpoint.setTechnicalInformationUrl(AP_INFO_URL);
aEndpoint.setMinimumAuthenticationLevel("1");
aEndpoint.setRequireBusinessLevelSignature(false);
aServiceEndpointList.getEndpoint().add(aEndpoint);
}
aProcess.setProcessIdentifier(new SimpleProcessIdentifier(PROCESS_ID));
aProcess.setServiceEndpointList(aServiceEndpointList);
}
aProcessList.getProcess().add(aProcess);
}
aServiceInformation.setDocumentIdentifier(new SimpleDocumentTypeIdentifier(DOCUMENT_ID));
aServiceInformation.setParticipantIdentifier(new SimpleParticipantIdentifier(PARTICIPANT_ID));
aServiceInformation.setProcessList(aProcessList);
}
aClient.saveServiceInformation(aServiceInformation, SMP_CREDENTIALS);
LOGGER.info("Done");
}
use of com.helger.peppolid.IDocumentTypeIdentifier in project peppol-commons by phax.
the class MainSMPServiceRegistrationDelete method main.
public static void main(final String[] args) throws Exception {
final URI SMP_URI = MockSMPClientConfig.getSMPURI();
final BasicAuthClientCredentials SMP_CREDENTIALS = MockSMPClientConfig.getSMPCredentials();
final IParticipantIdentifier PARTICIPANT_ID = MockSMPClientConfig.getParticipantID();
final IDocumentTypeIdentifier DOCUMENT_ID = MockSMPClientConfig.getDocumentTypeID();
// The main SMP client
final SMPClient aClient = new SMPClient(SMP_URI);
aClient.deleteServiceRegistration(PARTICIPANT_ID, DOCUMENT_ID, SMP_CREDENTIALS);
LOGGER.info("Done");
}
Aggregations