Search in sources :

Example 1 with CompleteServiceGroupType

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

the class SMPClientTest method testGetServiceGroupReferenceList.

@Test
public void testGetServiceGroupReferenceList() throws SMPClientException {
    final SMPClient aSMPClient = new SMPClient(SMP_URI);
    final ServiceGroupReferenceListType aServiceGroupReferenceList = aSMPClient.getServiceGroupReferenceList(SMP_USERNAME, SMP_CREDENTIALS);
    assertNotNull(aServiceGroupReferenceList);
    for (final ServiceGroupReferenceType aServiceGroupReference : aServiceGroupReferenceList.getServiceGroupReference()) {
        final CompleteServiceGroupType aCSG = aSMPClient.getCompleteServiceGroup(aServiceGroupReference.getHref());
        assertNotNull(aCSG);
    }
}
Also used : CompleteServiceGroupType(com.helger.xsds.peppol.smp1.CompleteServiceGroupType) ServiceGroupReferenceListType(com.helger.xsds.peppol.smp1.ServiceGroupReferenceListType) ServiceGroupReferenceType(com.helger.xsds.peppol.smp1.ServiceGroupReferenceType) Test(org.junit.Test)

Example 2 with CompleteServiceGroupType

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

the class MainSMPServiceGroupCompleteList method main.

public static void main(final String[] args) throws Exception {
    final URI SMP_URI = MockSMPClientConfig.getSMPURI();
    final IParticipantIdentifier PARTICIPANT_ID = MockSMPClientConfig.getParticipantID();
    // The main SMP client
    final SMPClient aClient = new SMPClient(SMP_URI);
    // Get the service group reference list
    final CompleteServiceGroupType aCompleteServiceGroup = aClient.getCompleteServiceGroupOrNull(PARTICIPANT_ID);
    if (aCompleteServiceGroup == null)
        LOGGER.error("Failed to get complete service group for " + PARTICIPANT_ID);
    else {
        LOGGER.info(SMPDebugHelper.getAsString(aCompleteServiceGroup.getServiceGroup()));
        for (final ServiceMetadataType aServiceMetadata : aCompleteServiceGroup.getServiceMetadata()) LOGGER.info(SMPDebugHelper.getAsString(aServiceMetadata));
    }
    LOGGER.info("Done");
}
Also used : CompleteServiceGroupType(com.helger.xsds.peppol.smp1.CompleteServiceGroupType) SMPClient(com.helger.smpclient.peppol.SMPClient) URI(java.net.URI) ServiceMetadataType(com.helger.xsds.peppol.smp1.ServiceMetadataType) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier)

Example 3 with CompleteServiceGroupType

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

the class SMPServerAPI method getCompleteServiceGroup.

@Nonnull
public CompleteServiceGroupType getCompleteServiceGroup(final String sPathServiceGroupID) throws SMPServerException {
    final String sLog = LOG_PREFIX + "GET /complete/" + sPathServiceGroupID;
    final String sAction = "getCompleteServiceGroup";
    if (LOGGER.isInfoEnabled())
        LOGGER.info(sLog);
    STATS_COUNTER_INVOCATION.increment(sAction);
    try {
        final IIdentifierFactory aIdentifierFactory = SMPMetaManager.getIdentifierFactory();
        final IParticipantIdentifier aPathServiceGroupID = aIdentifierFactory.parseParticipantIdentifier(sPathServiceGroupID);
        if (aPathServiceGroupID == null) {
            // Invalid identifier
            throw SMPBadRequestException.failedToParseSG(sPathServiceGroupID, m_aAPIDataProvider.getCurrentURI());
        }
        final ISMPServiceGroupManager aServiceGroupMgr = SMPMetaManager.getServiceGroupMgr();
        final ISMPServiceInformationManager aServiceInfoMgr = SMPMetaManager.getServiceInformationMgr();
        final ISMPServiceGroup aServiceGroup = aServiceGroupMgr.getSMPServiceGroupOfID(aPathServiceGroupID);
        if (aServiceGroup == null) {
            // No such service group
            throw new SMPNotFoundException("Unknown Service Group ID '" + sPathServiceGroupID + "'", m_aAPIDataProvider.getCurrentURI());
        }
        // Then add the service metadata references
        final ServiceMetadataReferenceCollectionType aRefCollection = new ServiceMetadataReferenceCollectionType();
        for (final IDocumentTypeIdentifier aDocTypeID : aServiceInfoMgr.getAllSMPDocumentTypesOfServiceGroup(aServiceGroup)) {
            // Ignore all service information without endpoints
            final ISMPServiceInformation aServiceInfo = aServiceInfoMgr.getSMPServiceInformationOfServiceGroupAndDocumentType(aServiceGroup, aDocTypeID);
            if (aServiceInfo != null && aServiceInfo.getTotalEndpointCount() > 0) {
                final ServiceMetadataReferenceType aMetadataReference = new ServiceMetadataReferenceType();
                aMetadataReference.setHref(m_aAPIDataProvider.getServiceMetadataReferenceHref(aPathServiceGroupID, aDocTypeID));
                aRefCollection.addServiceMetadataReference(aMetadataReference);
            }
        }
        final ServiceGroupType aSG = aServiceGroup.getAsJAXBObjectPeppol();
        aSG.setServiceMetadataReferenceCollection(aRefCollection);
        // a CompleteSG may be empty
        final CompleteServiceGroupType aCompleteServiceGroup = new CompleteServiceGroupType();
        aCompleteServiceGroup.setServiceGroup(aSG);
        for (final ISMPServiceInformation aServiceInfo : aServiceInfoMgr.getAllSMPServiceInformationOfServiceGroup(aServiceGroup)) {
            final ServiceMetadataType aSM = aServiceInfo.getAsJAXBObjectPeppol();
            if (aSM != null)
                aCompleteServiceGroup.addServiceMetadata(aSM);
        }
        if (LOGGER.isInfoEnabled())
            LOGGER.info(sLog + " SUCCESS");
        STATS_COUNTER_SUCCESS.increment(sAction);
        return aCompleteServiceGroup;
    } catch (final SMPServerException ex) {
        if (LOGGER.isWarnEnabled())
            LOGGER.warn(sLog + " ERROR - " + ex.getMessage());
        STATS_COUNTER_ERROR.increment(sAction);
        throw ex;
    }
}
Also used : CompleteServiceGroupType(com.helger.xsds.peppol.smp1.CompleteServiceGroupType) 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) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) ISMPServiceInformation(com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation) SMPNotFoundException(com.helger.phoss.smp.exception.SMPNotFoundException) ServiceMetadataReferenceType(com.helger.xsds.peppol.smp1.ServiceMetadataReferenceType) IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory) ServiceGroupType(com.helger.xsds.peppol.smp1.ServiceGroupType) CompleteServiceGroupType(com.helger.xsds.peppol.smp1.CompleteServiceGroupType) SignedServiceMetadataType(com.helger.xsds.peppol.smp1.SignedServiceMetadataType) ServiceMetadataType(com.helger.xsds.peppol.smp1.ServiceMetadataType) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) SMPServerException(com.helger.phoss.smp.exception.SMPServerException) Nonnull(javax.annotation.Nonnull)

Example 4 with CompleteServiceGroupType

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

the class BDXR1ServerAPI method getCompleteServiceGroup.

@Nonnull
public CompleteServiceGroupType getCompleteServiceGroup(final String sPathServiceGroupID) throws SMPServerException {
    final String sLog = LOG_PREFIX + "GET /complete/" + sPathServiceGroupID;
    final String sAction = "getCompleteServiceGroup";
    if (LOGGER.isInfoEnabled())
        LOGGER.info(sLog);
    STATS_COUNTER_INVOCATION.increment(sAction);
    try {
        final IIdentifierFactory aIdentifierFactory = SMPMetaManager.getIdentifierFactory();
        final IParticipantIdentifier aPathServiceGroupID = aIdentifierFactory.parseParticipantIdentifier(sPathServiceGroupID);
        if (aPathServiceGroupID == null) {
            // Invalid identifier
            throw SMPBadRequestException.failedToParseSG(sPathServiceGroupID, m_aAPIDataProvider.getCurrentURI());
        }
        final ISMPServiceGroupManager aServiceGroupMgr = SMPMetaManager.getServiceGroupMgr();
        final ISMPServiceInformationManager aServiceInfoMgr = SMPMetaManager.getServiceInformationMgr();
        final ISMPServiceGroup aServiceGroup = aServiceGroupMgr.getSMPServiceGroupOfID(aPathServiceGroupID);
        if (aServiceGroup == null) {
            // No such service group
            throw new SMPNotFoundException("Unknown Service Group ID '" + sPathServiceGroupID + "'", m_aAPIDataProvider.getCurrentURI());
        }
        // Then add the service metadata references
        final ServiceMetadataReferenceCollectionType aRefCollection = new ServiceMetadataReferenceCollectionType();
        for (final IDocumentTypeIdentifier aDocTypeID : aServiceInfoMgr.getAllSMPDocumentTypesOfServiceGroup(aServiceGroup)) {
            // Ignore all service information without endpoints
            final ISMPServiceInformation aServiceInfo = aServiceInfoMgr.getSMPServiceInformationOfServiceGroupAndDocumentType(aServiceGroup, aDocTypeID);
            if (aServiceInfo != null && aServiceInfo.getTotalEndpointCount() > 0) {
                final ServiceMetadataReferenceType aMetadataReference = new ServiceMetadataReferenceType();
                aMetadataReference.setHref(m_aAPIDataProvider.getServiceMetadataReferenceHref(aPathServiceGroupID, aDocTypeID));
                aRefCollection.addServiceMetadataReference(aMetadataReference);
            }
        }
        final ServiceGroupType aSG = aServiceGroup.getAsJAXBObjectBDXR1();
        aSG.setServiceMetadataReferenceCollection(aRefCollection);
        // a CompleteSG may be empty
        final CompleteServiceGroupType aCompleteServiceGroup = new CompleteServiceGroupType();
        aCompleteServiceGroup.setServiceGroup(aSG);
        for (final ISMPServiceInformation aServiceInfo : aServiceInfoMgr.getAllSMPServiceInformationOfServiceGroup(aServiceGroup)) {
            final ServiceMetadataType aSM = aServiceInfo.getAsJAXBObjectBDXR1();
            if (aSM != null)
                aCompleteServiceGroup.addServiceMetadata(aSM);
        }
        if (LOGGER.isInfoEnabled())
            LOGGER.info(sLog + " SUCCESS");
        STATS_COUNTER_SUCCESS.increment(sAction);
        return aCompleteServiceGroup;
    } catch (final SMPServerException ex) {
        if (LOGGER.isWarnEnabled())
            LOGGER.warn(sLog + " ERROR - " + ex.getMessage());
        STATS_COUNTER_ERROR.increment(sAction);
        throw ex;
    }
}
Also used : CompleteServiceGroupType(com.helger.xsds.bdxr.smp1.CompleteServiceGroupType) ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) ISMPServiceInformationManager(com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformationManager) ServiceMetadataReferenceCollectionType(com.helger.xsds.bdxr.smp1.ServiceMetadataReferenceCollectionType) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) ISMPServiceInformation(com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation) SMPNotFoundException(com.helger.phoss.smp.exception.SMPNotFoundException) ServiceMetadataReferenceType(com.helger.xsds.bdxr.smp1.ServiceMetadataReferenceType) IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory) ServiceGroupType(com.helger.xsds.bdxr.smp1.ServiceGroupType) CompleteServiceGroupType(com.helger.xsds.bdxr.smp1.CompleteServiceGroupType) SignedServiceMetadataType(com.helger.xsds.bdxr.smp1.SignedServiceMetadataType) ServiceMetadataType(com.helger.xsds.bdxr.smp1.ServiceMetadataType) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) SMPServerException(com.helger.phoss.smp.exception.SMPServerException) Nonnull(javax.annotation.Nonnull)

Aggregations

IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)3 CompleteServiceGroupType (com.helger.xsds.peppol.smp1.CompleteServiceGroupType)3 IDocumentTypeIdentifier (com.helger.peppolid.IDocumentTypeIdentifier)2 IIdentifierFactory (com.helger.peppolid.factory.IIdentifierFactory)2 ISMPServiceGroup (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup)2 ISMPServiceGroupManager (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager)2 ISMPServiceInformation (com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation)2 ISMPServiceInformationManager (com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformationManager)2 SMPNotFoundException (com.helger.phoss.smp.exception.SMPNotFoundException)2 SMPServerException (com.helger.phoss.smp.exception.SMPServerException)2 ServiceMetadataType (com.helger.xsds.peppol.smp1.ServiceMetadataType)2 Nonnull (javax.annotation.Nonnull)2 SMPClient (com.helger.smpclient.peppol.SMPClient)1 CompleteServiceGroupType (com.helger.xsds.bdxr.smp1.CompleteServiceGroupType)1 ServiceGroupType (com.helger.xsds.bdxr.smp1.ServiceGroupType)1 ServiceMetadataReferenceCollectionType (com.helger.xsds.bdxr.smp1.ServiceMetadataReferenceCollectionType)1 ServiceMetadataReferenceType (com.helger.xsds.bdxr.smp1.ServiceMetadataReferenceType)1 ServiceMetadataType (com.helger.xsds.bdxr.smp1.ServiceMetadataType)1 SignedServiceMetadataType (com.helger.xsds.bdxr.smp1.SignedServiceMetadataType)1 ServiceGroupReferenceListType (com.helger.xsds.peppol.smp1.ServiceGroupReferenceListType)1