Search in sources :

Example 11 with ProcessType

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

the class MainCreate1MillionEndpoints method main.

public static void main(final String[] args) throws Throwable {
    final SMPServerRESTTestRule aRule = new SMPServerRESTTestRule(ClassPathResource.getAsFile("test-smp-server-mongodb.properties").getAbsolutePath());
    aRule.before();
    try {
        // Set the special PhotonSecurityManager factory
        PhotonSecurityManager.setFactory(new PhotonSecurityManagerFactoryMongoDB());
        final ObjectFactory aObjFactory = new ObjectFactory();
        final PeppolDocumentTypeIdentifier aDT = EPredefinedDocumentTypeIdentifier.INVOICE_EN16931_PEPPOL_V30.getAsDocumentTypeIdentifier();
        final String sDT = aDT.getURIEncoded();
        final PeppolProcessIdentifier aProcID = EPredefinedProcessIdentifier.BIS3_BILLING.getAsProcessIdentifier();
        final StopWatch aSWOverall = StopWatch.createdStarted();
        for (int i = 639276; i < 1_000_000; ++i) {
            final StopWatch aSW = StopWatch.createdStarted();
            final PeppolParticipantIdentifier aPI = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("9999:test-philip-" + StringHelper.getLeadingZero(i, 7));
            final String sPI = aPI.getURIEncoded();
            final ServiceMetadataType aSM = new ServiceMetadataType();
            final ServiceInformationType aSI = new ServiceInformationType();
            aSI.setParticipantIdentifier(new SimpleParticipantIdentifier(aPI));
            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);
            }
            aSM.setServiceInformation(aSI);
            try (final WebScoped aWS = new WebScoped(new MockHttpServletRequest())) {
                // Delete old - don't care about the result
                if (false)
                    ClientBuilder.newClient().target(aRule.getFullURL()).path(sPI).path("services").path(sDT).request().header(CHttpHeader.AUTHORIZATION, CREDENTIALS.getRequestValue()).delete();
                // Create a new
                final Response aResponseMsg = ClientBuilder.newClient().target(aRule.getFullURL()).path(sPI).path("services").path(sDT).request().header(CHttpHeader.AUTHORIZATION, CREDENTIALS.getRequestValue()).put(Entity.xml(aObjFactory.createServiceMetadata(aSM)));
                _testResponseJerseyClient(aResponseMsg, 200);
            }
            aSW.stop();
            LOGGER.info(sPI + " took " + aSW.getMillis() + " ms");
        }
        aSWOverall.stop();
        LOGGER.info("Overall process took " + aSWOverall.getMillis() + " ms or " + aSWOverall.getDuration());
    } finally {
        aRule.after();
    }
}
Also used : WebScoped(com.helger.web.scope.mgr.WebScoped) PhotonSecurityManagerFactoryMongoDB(com.helger.phoss.smp.backend.mongodb.PhotonSecurityManagerFactoryMongoDB) MockHttpServletRequest(com.helger.servlet.mock.MockHttpServletRequest) PeppolProcessIdentifier(com.helger.peppolid.peppol.process.PeppolProcessIdentifier) ServiceInformationType(com.helger.xsds.peppol.smp1.ServiceInformationType) SimpleParticipantIdentifier(com.helger.peppolid.simple.participant.SimpleParticipantIdentifier) SMPServerRESTTestRule(com.helger.phoss.smp.mock.SMPServerRESTTestRule) StopWatch(com.helger.commons.timing.StopWatch) PeppolParticipantIdentifier(com.helger.peppolid.peppol.participant.PeppolParticipantIdentifier) Response(javax.ws.rs.core.Response) ProcessType(com.helger.xsds.peppol.smp1.ProcessType) ObjectFactory(com.helger.xsds.peppol.smp1.ObjectFactory) PeppolDocumentTypeIdentifier(com.helger.peppolid.peppol.doctype.PeppolDocumentTypeIdentifier) EndpointType(com.helger.xsds.peppol.smp1.EndpointType) ProcessListType(com.helger.xsds.peppol.smp1.ProcessListType) ServiceMetadataType(com.helger.xsds.peppol.smp1.ServiceMetadataType) ServiceEndpointList(com.helger.xsds.peppol.smp1.ServiceEndpointList)

Example 12 with ProcessType

use of com.helger.xsds.bdxr.smp1.ProcessType in project arctic-sea by 52North.

the class ProcessTypeEncoder method createProcess.

protected ProcessType createProcess(Process process) throws EncodingException {
    if (process.isSetXml()) {
        XmlObject encodedObject = null;
        try {
            encodedObject = XmlObject.Factory.parse(process.getXml());
            if (encodedObject instanceof ProcessType) {
                ProcessType pt = (ProcessType) encodedObject;
                checkForInspireId(pt, process);
                return pt;
            } else if (encodedObject instanceof ProcessDocument) {
                return ((ProcessDocument) encodedObject).getProcess();
            } else if (encodedObject instanceof ProcessPropertyType) {
                return ((ProcessPropertyType) encodedObject).getProcess();
            } else {
                throw new UnsupportedEncoderInputException(this, process);
            }
        } catch (final XmlException xmle) {
            throw new EncodingException(xmle);
        }
    } else {
        ProcessType pt = ProcessType.Factory.newInstance();
        if (!process.isSetGmlID()) {
            process.setGmlId("p_" + IdGenerator.generate(process.toString()));
        }
        pt.setId(process.getGmlId());
        addInspireId(pt, process);
        addName(pt, process);
        addType(pt, process);
        addDocumentation(pt, process);
        addProcessParameter(pt, process);
        addResponsibleParty(pt, process);
        return pt;
    }
}
Also used : ProcessType(eu.europa.ec.inspire.schemas.ompr.x30.ProcessType) EncodingException(org.n52.svalbard.encode.exception.EncodingException) XmlException(org.apache.xmlbeans.XmlException) ProcessPropertyType(eu.europa.ec.inspire.schemas.ompr.x30.ProcessPropertyType) XmlObject(org.apache.xmlbeans.XmlObject) ProcessDocument(eu.europa.ec.inspire.schemas.ompr.x30.ProcessDocument) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)

Example 13 with ProcessType

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

the class SMPClientReadOnly method getEndpoint.

/**
 * Extract the Endpoint from the ServiceMetadata that matches the passed
 * process ID and the optional required transport profile.
 *
 * @param aServiceMetadata
 *        The unsigned service meta data object. May not be <code>null</code>.
 * @param aProcessID
 *        The process identifier to be looked up. May not be <code>null</code>
 *        .
 * @param aTransportProfile
 *        The required transport profile to be used. May not be
 *        <code>null</code>.
 * @return <code>null</code> if no matching endpoint was found
 * @since 8.2.6
 */
@Nullable
public static EndpointType getEndpoint(@Nonnull final ServiceMetadataType aServiceMetadata, @Nonnull final IProcessIdentifier aProcessID, @Nonnull final ISMPTransportProfile aTransportProfile) {
    ValueEnforcer.notNull(aServiceMetadata, "ServiceMetadata");
    final ServiceInformationType aServiceInformation = aServiceMetadata.getServiceInformation();
    if (aServiceInformation == null) {
        // It seems to be a redirect and not service information
        return null;
    }
    ValueEnforcer.notNull(aServiceInformation.getProcessList(), "ServiceMetadata.ServiceInformation.ProcessList");
    ValueEnforcer.notNull(aProcessID, "ProcessID");
    ValueEnforcer.notNull(aTransportProfile, "TransportProfile");
    // Iterate all processes
    for (final ProcessType aProcessType : aServiceInformation.getProcessList().getProcess()) {
        // Matches the requested one?
        if (_hasSameContent(aProcessType.getProcessIdentifier(), aProcessID)) {
            // Filter all endpoints by required transport profile
            final ICommonsList<EndpointType> aRelevantEndpoints = new CommonsArrayList<>();
            for (final EndpointType aEndpoint : aProcessType.getServiceEndpointList().getEndpoint()) if (aTransportProfile.getID().equals(aEndpoint.getTransportProfile()))
                aRelevantEndpoints.add(aEndpoint);
            if (aRelevantEndpoints.size() != 1) {
                if (LOGGER.isWarnEnabled())
                    LOGGER.warn("Found " + aRelevantEndpoints.size() + " endpoints for process " + aProcessID + " and transport profile " + aTransportProfile.getID() + (aRelevantEndpoints.isEmpty() ? "" : ": " + aRelevantEndpoints.toString() + " - using the first one"));
            }
            // Use the first endpoint or null
            final EndpointType ret = aRelevantEndpoints.getFirst();
            if (LOGGER.isDebugEnabled())
                LOGGER.debug("Found matching endpoint: " + ret);
            return ret;
        }
    }
    if (LOGGER.isDebugEnabled())
        LOGGER.debug("Found no matching SMP endpoint");
    return null;
}
Also used : ProcessType(com.helger.xsds.peppol.smp1.ProcessType) EndpointType(com.helger.xsds.peppol.smp1.EndpointType) ServiceInformationType(com.helger.xsds.peppol.smp1.ServiceInformationType) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) Nullable(javax.annotation.Nullable)

Example 14 with ProcessType

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

the class SMPDebugHelper method getAsString.

@Nonnull
public static String getAsString(@Nonnull final ServiceMetadataType aServiceMetadata) {
    final StringBuilder aSB = new StringBuilder();
    aSB.append("Service meta data:\n");
    final ServiceInformationType aServiceInformation = aServiceMetadata.getServiceInformation();
    if (aServiceInformation != null) {
        aSB.append("  Service information:\n");
        aSB.append("    Participant: ").append(CIdentifier.getURIEncoded(aServiceInformation.getParticipantIdentifier())).append('\n');
        aSB.append("    Document type: ").append(CIdentifier.getURIEncoded(aServiceInformation.getDocumentIdentifier())).append('\n');
        for (final ProcessType aProcess : aServiceInformation.getProcessList().getProcess()) {
            aSB.append("      Process: ").append(CIdentifier.getURIEncoded(aProcess.getProcessIdentifier())).append('\n');
            for (final EndpointType aEndpoint : aProcess.getServiceEndpointList().getEndpoint()) {
                aSB.append("        Endpoint: ").append(W3CEndpointReferenceHelper.getAddress(aEndpoint.getEndpointReference())).append('\n');
                aSB.append("        Transport profile: ").append(aEndpoint.getTransportProfile()).append('\n');
                aSB.append("        Business level signature: ").append(aEndpoint.isRequireBusinessLevelSignature()).append('\n');
                aSB.append("        Min auth level: ").append(aEndpoint.getMinimumAuthenticationLevel()).append('\n');
                if (aEndpoint.getServiceActivationDate() != null)
                    aSB.append("        Valid from: ").append(aEndpoint.getServiceActivationDate()).append('\n');
                if (aEndpoint.getServiceExpirationDate() != null)
                    aSB.append("        Valid to: ").append(aEndpoint.getServiceExpirationDate()).append('\n');
                aSB.append("        Certficiate string: ").append(aEndpoint.getCertificate()).append('\n');
                aSB.append("        Service description: ").append(aEndpoint.getServiceDescription()).append('\n');
                aSB.append("        Contact URL: ").append(aEndpoint.getTechnicalContactUrl()).append('\n');
                aSB.append("        Info URL: ").append(aEndpoint.getTechnicalInformationUrl()).append('\n');
            }
        }
    }
    final RedirectType aRedirect = aServiceMetadata.getRedirect();
    if (aRedirect != null) {
        aSB.append("  Service redirect:\n");
        aSB.append("    Certificate UID: ").append(aRedirect.getCertificateUID()).append('\n');
        aSB.append("    Href: ").append(aRedirect.getHref()).append('\n');
    }
    return aSB.toString();
}
Also used : ProcessType(com.helger.xsds.peppol.smp1.ProcessType) EndpointType(com.helger.xsds.peppol.smp1.EndpointType) ServiceInformationType(com.helger.xsds.peppol.smp1.ServiceInformationType) RedirectType(com.helger.xsds.peppol.smp1.RedirectType) Nonnull(javax.annotation.Nonnull)

Example 15 with ProcessType

use of com.helger.xsds.bdxr.smp1.ProcessType 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)

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