Search in sources :

Example 6 with ProcessType

use of com.helger.xsds.peppol.smp1.ProcessType in project peppol-commons by phax.

the class SMPClientTest method testCRUDServiceRegistration.

@Test
public void testCRUDServiceRegistration() throws Exception {
    final SMPClient aSMPClient = new SMPClient(SMP_URI);
    aSMPClient.saveServiceGroup(MockSMPClientConfig.getParticipantID(), SMP_CREDENTIALS);
    final IParticipantIdentifier aServiceGroupID = MockSMPClientConfig.getParticipantID();
    final IDocumentTypeIdentifier aDocumentID = MockSMPClientConfig.getDocumentTypeID();
    final IProcessIdentifier aProcessID = MockSMPClientConfig.getProcessTypeID();
    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();
                    final W3CEndpointReference aEndpointReferenceType = new W3CEndpointReferenceBuilder().address("http://peppol.eu/sampleService/").build();
                    aEndpoint.setEndpointReference(aEndpointReferenceType);
                    aEndpoint.setTransportProfile(ESMPTransportProfile.TRANSPORT_PROFILE_AS2.getID());
                    // Certificate: Base64.encodeBytes (certificate.getEncoded ());
                    aEndpoint.setCertificate("1234567890");
                    aEndpoint.setServiceActivationDate(PDTFactory.getCurrentXMLOffsetDateTime());
                    aEndpoint.setServiceDescription("TEST DESCRIPTION");
                    aEndpoint.setServiceExpirationDate(PDTFactory.getCurrentXMLOffsetDateTime().plusYears(1));
                    aEndpoint.setTechnicalContactUrl("mailto:smpclient.unittest@helger.com");
                    aEndpoint.setMinimumAuthenticationLevel("2");
                    aEndpoint.setRequireBusinessLevelSignature(false);
                    aServiceEndpointList.getEndpoint().add(aEndpoint);
                }
                aProcess.setProcessIdentifier(new SimpleProcessIdentifier(aProcessID));
                aProcess.setServiceEndpointList(aServiceEndpointList);
            }
            aProcessList.getProcess().add(aProcess);
        }
        aServiceInformation.setDocumentIdentifier(new SimpleDocumentTypeIdentifier(aDocumentID));
        aServiceInformation.setParticipantIdentifier(new SimpleParticipantIdentifier(aServiceGroupID));
        aServiceInformation.setProcessList(aProcessList);
    }
    aSMPClient.saveServiceInformation(aServiceInformation, SMP_CREDENTIALS);
    final SignedServiceMetadataType aSignedServiceMetadata = aSMPClient.getServiceMetadata(aServiceGroupID, aDocumentID);
    LOGGER.info("Service aMetadata ID:" + aSignedServiceMetadata.getServiceMetadata().getServiceInformation().getParticipantIdentifier().getValue());
    aSMPClient.deleteServiceRegistration(aServiceGroupID, aDocumentID, SMP_CREDENTIALS);
    aSMPClient.deleteServiceGroup(MockSMPClientConfig.getParticipantID(), SMP_CREDENTIALS);
}
Also used : SimpleDocumentTypeIdentifier(com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) SignedServiceMetadataType(com.helger.xsds.peppol.smp1.SignedServiceMetadataType) 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) W3CEndpointReferenceBuilder(javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder) 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) Test(org.junit.Test)

Example 7 with ProcessType

use of com.helger.xsds.peppol.smp1.ProcessType in project phoss-smp by phax.

the class ServiceMetadataInterfaceTest method testCreateAndDeleteServiceInformationSMPClient.

@Test
public void testCreateAndDeleteServiceInformationSMPClient() throws SMPClientException {
    // Lower case
    final IParticipantIdentifier aPI_LC = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("9915:xxx");
    // Upper case
    final IParticipantIdentifier aPI_UC = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("9915:XXX");
    final PeppolDocumentTypeIdentifier aDT = EPredefinedDocumentTypeIdentifier.INVOICE_EN16931_PEPPOL_V30.getAsDocumentTypeIdentifier();
    final PeppolProcessIdentifier aProcID = EPredefinedProcessIdentifier.BIS3_BILLING.getAsProcessIdentifier();
    final ServiceGroupType aSG = new ServiceGroupType();
    aSG.setParticipantIdentifier(new SimpleParticipantIdentifier(aPI_LC));
    aSG.setServiceMetadataReferenceCollection(new ServiceMetadataReferenceCollectionType());
    final ServiceInformationType aSI = new ServiceInformationType();
    aSI.setParticipantIdentifier(new SimpleParticipantIdentifier(aPI_LC));
    aSI.setDocumentIdentifier(aDT);
    {
        final ProcessListType aPL = new ProcessListType();
        final ProcessType aProcess = new ProcessType();
        aProcess.setProcessIdentifier(aProcID);
        final ServiceEndpointList aSEL = new ServiceEndpointList();
        final EndpointType aEndpoint = new EndpointType();
        aEndpoint.setEndpointReference(W3CEndpointReferenceHelper.createEndpointReference("http://test.smpserver/as2"));
        aEndpoint.setRequireBusinessLevelSignature(false);
        aEndpoint.setCertificate("blacert");
        aEndpoint.setServiceDescription("Unit test service");
        aEndpoint.setTechnicalContactUrl("https://github.com/phax/phoss-smp");
        aEndpoint.setTransportProfile(ESMPTransportProfile.TRANSPORT_PROFILE_AS2.getID());
        aSEL.addEndpoint(aEndpoint);
        aProcess.setServiceEndpointList(aSEL);
        aPL.addProcess(aProcess);
        aSI.setProcessList(aPL);
    }
    final ISMPServiceGroupManager aSGMgr = SMPMetaManager.getServiceGroupMgr();
    final ISMPServiceInformationManager aSIMgr = SMPMetaManager.getServiceInformationMgr();
    final SMPClient aSMPClient = new MockSMPClient();
    assertNull(aSMPClient.getServiceGroupOrNull(aPI_LC));
    assertNull(aSMPClient.getServiceGroupOrNull(aPI_UC));
    assertFalse(aSGMgr.containsSMPServiceGroupWithID(aPI_LC));
    assertFalse(aSGMgr.containsSMPServiceGroupWithID(aPI_UC));
    try {
        // PUT ServiceGroup
        aSMPClient.saveServiceGroup(aSG, CREDENTIALS);
        // Read both
        assertNotNull(aSMPClient.getServiceGroupOrNull(aPI_LC));
        assertNotNull(aSMPClient.getServiceGroupOrNull(aPI_UC));
        assertTrue(aSGMgr.containsSMPServiceGroupWithID(aPI_LC));
        assertTrue(aSGMgr.containsSMPServiceGroupWithID(aPI_UC));
        final ISMPServiceGroup aServiceGroup = aSGMgr.getSMPServiceGroupOfID(aPI_LC);
        assertNotNull(aServiceGroup);
        final ISMPServiceGroup aServiceGroup_UC = aSGMgr.getSMPServiceGroupOfID(aPI_UC);
        assertEquals(aServiceGroup, aServiceGroup_UC);
        try {
            // PUT 1 ServiceInformation
            aSMPClient.saveServiceInformation(aSI, CREDENTIALS);
            assertNotNull(aSIMgr.getSMPServiceInformationOfServiceGroupAndDocumentType(aServiceGroup, aDT));
            // PUT 2 ServiceInformation
            aSMPClient.saveServiceInformation(aSI, CREDENTIALS);
            assertNotNull(aSIMgr.getSMPServiceInformationOfServiceGroupAndDocumentType(aServiceGroup, aDT));
            // DELETE 1 ServiceInformation
            aSMPClient.deleteServiceRegistration(aPI_LC, aDT, CREDENTIALS);
            assertNull(aSIMgr.getSMPServiceInformationOfServiceGroupAndDocumentType(aServiceGroup, aDT));
        } finally {
            // DELETE 2 ServiceInformation
            try {
                aSMPClient.deleteServiceRegistration(aPI_LC, aDT, CREDENTIALS);
            } catch (final SMPClientNotFoundException ex) {
            // Expected
            }
            assertNull(aSIMgr.getSMPServiceInformationOfServiceGroupAndDocumentType(aServiceGroup, aDT));
        }
        assertNotNull(aSMPClient.getServiceGroup(aPI_LC));
    } finally {
        // DELETE ServiceGroup
        try {
            aSMPClient.deleteServiceGroup(aPI_LC, CREDENTIALS);
        } catch (final SMPClientNotFoundException ex) {
        // Expected
        }
        assertNull(aSMPClient.getServiceGroupOrNull(aPI_LC));
        assertNull(aSMPClient.getServiceGroupOrNull(aPI_UC));
        assertFalse(aSGMgr.containsSMPServiceGroupWithID(aPI_LC));
        assertFalse(aSGMgr.containsSMPServiceGroupWithID(aPI_UC));
    }
}
Also used : ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) ISMPServiceInformationManager(com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformationManager) ServiceMetadataReferenceCollectionType(com.helger.xsds.peppol.smp1.ServiceMetadataReferenceCollectionType) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) PeppolProcessIdentifier(com.helger.peppolid.peppol.process.PeppolProcessIdentifier) ServiceInformationType(com.helger.xsds.peppol.smp1.ServiceInformationType) SimpleParticipantIdentifier(com.helger.peppolid.simple.participant.SimpleParticipantIdentifier) MockSMPClient(com.helger.phoss.smp.mock.MockSMPClient) SMPClientNotFoundException(com.helger.smpclient.exception.SMPClientNotFoundException) ProcessType(com.helger.xsds.peppol.smp1.ProcessType) SMPClient(com.helger.smpclient.peppol.SMPClient) MockSMPClient(com.helger.phoss.smp.mock.MockSMPClient) PeppolDocumentTypeIdentifier(com.helger.peppolid.peppol.doctype.PeppolDocumentTypeIdentifier) EndpointType(com.helger.xsds.peppol.smp1.EndpointType) ProcessListType(com.helger.xsds.peppol.smp1.ProcessListType) ServiceGroupType(com.helger.xsds.peppol.smp1.ServiceGroupType) ServiceEndpointList(com.helger.xsds.peppol.smp1.ServiceEndpointList) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Test(org.junit.Test)

Example 8 with ProcessType

use of com.helger.xsds.peppol.smp1.ProcessType in project phoss-smp by phax.

the class SMPProcess method getAsJAXBObjectPeppol.

@Nullable
public com.helger.xsds.peppol.smp1.ProcessType getAsJAXBObjectPeppol() {
    if (m_aEndpoints.isEmpty()) {
        // Empty ServiceEndpointList is not allowed
        return null;
    }
    final com.helger.xsds.peppol.smp1.ProcessType ret = new com.helger.xsds.peppol.smp1.ProcessType();
    // Explicit constructor call is needed here!
    ret.setProcessIdentifier(new SimpleProcessIdentifier(m_aProcessIdentifier));
    final com.helger.xsds.peppol.smp1.ServiceEndpointList aEndpointList = new com.helger.xsds.peppol.smp1.ServiceEndpointList();
    for (final ISMPEndpoint aEndpoint : m_aEndpoints.values()) aEndpointList.addEndpoint(aEndpoint.getAsJAXBObjectPeppol());
    ret.setServiceEndpointList(aEndpointList);
    ret.setExtension(getAsPeppolExtension());
    return ret;
}
Also used : ProcessType(com.helger.xsds.peppol.smp1.ProcessType) ProcessType(com.helger.xsds.peppol.smp1.ProcessType) SimpleProcessIdentifier(com.helger.peppolid.simple.process.SimpleProcessIdentifier) Nullable(javax.annotation.Nullable)

Example 9 with ProcessType

use of com.helger.xsds.peppol.smp1.ProcessType in project phoss-smp by phax.

the class SMPProcess method getAsJAXBObjectBDXR1.

@Nullable
public com.helger.xsds.bdxr.smp1.ProcessType getAsJAXBObjectBDXR1() {
    if (m_aEndpoints.isEmpty()) {
        // Empty ServiceEndpointList is not allowed
        return null;
    }
    final com.helger.xsds.bdxr.smp1.ProcessType ret = new com.helger.xsds.bdxr.smp1.ProcessType();
    // Explicit constructor call is needed here!
    ret.setProcessIdentifier(new BDXR1ProcessIdentifier(m_aProcessIdentifier));
    final com.helger.xsds.bdxr.smp1.ServiceEndpointList aEndpointList = new com.helger.xsds.bdxr.smp1.ServiceEndpointList();
    for (final ISMPEndpoint aEndpoint : m_aEndpoints.values()) aEndpointList.addEndpoint(aEndpoint.getAsJAXBObjectBDXR1());
    ret.setServiceEndpointList(aEndpointList);
    ret.setExtension(getAsBDXRExtension());
    return ret;
}
Also used : ProcessType(com.helger.xsds.peppol.smp1.ProcessType) BDXR1ProcessIdentifier(com.helger.peppolid.bdxr.smp1.process.BDXR1ProcessIdentifier) Nullable(javax.annotation.Nullable)

Example 10 with ProcessType

use of com.helger.xsds.peppol.smp1.ProcessType in project phoss-smp by phax.

the class ServiceMetadataInterfaceFillDBTest method testCreateAndDeleteServiceInformationSMPClient.

@Test
public void testCreateAndDeleteServiceInformationSMPClient() throws SMPClientException {
    final SMPClient aSMPClient = new MockSMPClient();
    final StopWatch aSW = StopWatch.createdStarted();
    int nEndpoints = 0;
    try (final WebScoped aWS = new WebScoped(new MockHttpServletRequest())) {
        final int nCount = 2_000;
        for (int i = 0; i < nCount; ++i) {
            final IParticipantIdentifier aPI_LC = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme(PID_PREFIX_9999_PHOSS + StringHelper.getLeadingZero(i, 4));
            final PeppolDocumentTypeIdentifier aDT = EPredefinedDocumentTypeIdentifier.INVOICE_EN16931_PEPPOL_V30.getAsDocumentTypeIdentifier();
            final PeppolProcessIdentifier aProcID = EPredefinedProcessIdentifier.BIS3_BILLING.getAsProcessIdentifier();
            for (final ESMPTransportProfile eTP : new ESMPTransportProfile[] { ESMPTransportProfile.TRANSPORT_PROFILE_AS2, ESMPTransportProfile.TRANSPORT_PROFILE_PEPPOL_AS4_V2 }) {
                final ServiceInformationType aSI = new ServiceInformationType();
                aSI.setParticipantIdentifier(new SimpleParticipantIdentifier(aPI_LC));
                aSI.setDocumentIdentifier(aDT);
                {
                    final ProcessListType aPL = new ProcessListType();
                    final ProcessType aProcess = new ProcessType();
                    aProcess.setProcessIdentifier(aProcID);
                    final ServiceEndpointList aSEL = new ServiceEndpointList();
                    final EndpointType aEndpoint = new EndpointType();
                    aEndpoint.setEndpointReference(W3CEndpointReferenceHelper.createEndpointReference("http://test.smpserver/" + eTP.getID()));
                    aEndpoint.setRequireBusinessLevelSignature(false);
                    aEndpoint.setCertificate("blacert");
                    aEndpoint.setServiceDescription("Unit test service");
                    aEndpoint.setTechnicalContactUrl("https://github.com/phax/phoss-smp");
                    aEndpoint.setTransportProfile(eTP.getID());
                    aSEL.addEndpoint(aEndpoint);
                    aProcess.setServiceEndpointList(aSEL);
                    aPL.addProcess(aProcess);
                    aSI.setProcessList(aPL);
                }
                aSMPClient.saveServiceInformation(aSI, CREDENTIALS);
                ++nEndpoints;
            }
        }
    }
    aSW.stop();
    LOGGER.info("Created " + nEndpoints + " ServiceInformation in " + aSW.getDuration() + " (= " + (aSW.getMillis() / nEndpoints) + " ms/entry)");
}
Also used : WebScoped(com.helger.web.scope.mgr.WebScoped) MockHttpServletRequest(com.helger.servlet.mock.MockHttpServletRequest) ESMPTransportProfile(com.helger.peppol.smp.ESMPTransportProfile) PeppolProcessIdentifier(com.helger.peppolid.peppol.process.PeppolProcessIdentifier) ServiceInformationType(com.helger.xsds.peppol.smp1.ServiceInformationType) SimpleParticipantIdentifier(com.helger.peppolid.simple.participant.SimpleParticipantIdentifier) StopWatch(com.helger.commons.timing.StopWatch) MockSMPClient(com.helger.phoss.smp.mock.MockSMPClient) ProcessType(com.helger.xsds.peppol.smp1.ProcessType) MockSMPClient(com.helger.phoss.smp.mock.MockSMPClient) SMPClient(com.helger.smpclient.peppol.SMPClient) PeppolDocumentTypeIdentifier(com.helger.peppolid.peppol.doctype.PeppolDocumentTypeIdentifier) 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) Test(org.junit.Test)

Aggregations

ProcessType (com.helger.xsds.peppol.smp1.ProcessType)12 EndpointType (com.helger.xsds.peppol.smp1.EndpointType)10 ServiceInformationType (com.helger.xsds.peppol.smp1.ServiceInformationType)10 ProcessListType (com.helger.xsds.peppol.smp1.ProcessListType)8 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)7 SimpleParticipantIdentifier (com.helger.peppolid.simple.participant.SimpleParticipantIdentifier)7 ServiceEndpointList (com.helger.xsds.peppol.smp1.ServiceEndpointList)7 PeppolDocumentTypeIdentifier (com.helger.peppolid.peppol.doctype.PeppolDocumentTypeIdentifier)5 PeppolProcessIdentifier (com.helger.peppolid.peppol.process.PeppolProcessIdentifier)5 ProcessType (org.osate.aadl2.ProcessType)5 AbstractImplementation (org.osate.aadl2.AbstractImplementation)4 AbstractType (org.osate.aadl2.AbstractType)4 BusImplementation (org.osate.aadl2.BusImplementation)4 BusType (org.osate.aadl2.BusType)4 DeviceImplementation (org.osate.aadl2.DeviceImplementation)4 DeviceType (org.osate.aadl2.DeviceType)4 MemoryImplementation (org.osate.aadl2.MemoryImplementation)4 MemoryType (org.osate.aadl2.MemoryType)4 ProcessImplementation (org.osate.aadl2.ProcessImplementation)4 ProcessorImplementation (org.osate.aadl2.ProcessorImplementation)4