Search in sources :

Example 51 with IDocumentTypeIdentifier

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));
}
Also used : IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory) Test(org.junit.Test)

Example 52 with IDocumentTypeIdentifier

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;
}
Also used : ServiceMetadataReferenceType(com.helger.xsds.peppol.smp1.ServiceMetadataReferenceType) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) Nonnull(javax.annotation.Nonnull)

Example 53 with IDocumentTypeIdentifier

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);
}
Also used : IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) SignedServiceMetadataType(com.helger.xsds.peppol.smp1.SignedServiceMetadataType) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Test(org.junit.Test)

Example 54 with IDocumentTypeIdentifier

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");
}
Also used : SimpleDocumentTypeIdentifier(com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) URI(java.net.URI) ServiceInformationType(com.helger.xsds.peppol.smp1.ServiceInformationType) IProcessIdentifier(com.helger.peppolid.IProcessIdentifier) SimpleParticipantIdentifier(com.helger.peppolid.simple.participant.SimpleParticipantIdentifier) ProcessType(com.helger.xsds.peppol.smp1.ProcessType) BasicAuthClientCredentials(com.helger.http.basicauth.BasicAuthClientCredentials) SMPClient(com.helger.smpclient.peppol.SMPClient) SimpleProcessIdentifier(com.helger.peppolid.simple.process.SimpleProcessIdentifier) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) EndpointType(com.helger.xsds.peppol.smp1.EndpointType) ProcessListType(com.helger.xsds.peppol.smp1.ProcessListType) ServiceEndpointList(com.helger.xsds.peppol.smp1.ServiceEndpointList) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier)

Example 55 with IDocumentTypeIdentifier

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");
}
Also used : BasicAuthClientCredentials(com.helger.http.basicauth.BasicAuthClientCredentials) SMPClient(com.helger.smpclient.peppol.SMPClient) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) URI(java.net.URI) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier)

Aggregations

IDocumentTypeIdentifier (com.helger.peppolid.IDocumentTypeIdentifier)89 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)62 ISMPServiceGroup (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup)36 Nonnull (javax.annotation.Nonnull)36 IIdentifierFactory (com.helger.peppolid.factory.IIdentifierFactory)32 Test (org.junit.Test)30 ISMPServiceGroupManager (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager)27 ISMPServiceInformationManager (com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformationManager)20 ISMPServiceInformation (com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation)19 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)18 IProcessIdentifier (com.helger.peppolid.IProcessIdentifier)18 ICommonsList (com.helger.commons.collection.impl.ICommonsList)16 ISMPRedirectManager (com.helger.phoss.smp.domain.redirect.ISMPRedirectManager)16 Nullable (javax.annotation.Nullable)13 ESuccess (com.helger.commons.state.ESuccess)11 StringHelper (com.helger.commons.string.StringHelper)11 SimpleDocumentTypeIdentifier (com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier)11 SimpleParticipantIdentifier (com.helger.peppolid.simple.participant.SimpleParticipantIdentifier)11 ISMPProcess (com.helger.phoss.smp.domain.serviceinfo.ISMPProcess)11 ISMPRedirect (com.helger.phoss.smp.domain.redirect.ISMPRedirect)10