Search in sources :

Example 11 with ServiceMetadataReferenceCollectionType

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

the class SMPDebugHelper method getAsString.

@Nonnull
public static String getAsString(@Nonnull final ServiceGroupType aServiceGroup) {
    final StringBuilder aSB = new StringBuilder();
    aSB.append("ServiceGroup information:\n");
    aSB.append("ParticipantIdentifier: ").append(CIdentifier.getURIEncoded(aServiceGroup.getParticipantIdentifier())).append('\n');
    // References
    final ServiceMetadataReferenceCollectionType aSMRC = aServiceGroup.getServiceMetadataReferenceCollection();
    if (aSMRC != null && !aSMRC.getServiceMetadataReference().isEmpty()) {
        aSB.append("ServiceMetadataReferenceCollection:\n");
        for (final ServiceMetadataReferenceType aSMR : aSMRC.getServiceMetadataReference()) aSB.append("  ").append(aSMR.getHref()).append('\n');
    }
    // Extension
    final ExtensionType aExt = aServiceGroup.getExtension();
    if (aExt != null && aExt.getAny() != null) {
        aSB.append("Extension:\n");
        aSB.append("  Class = ").append(aExt.getAny().getClass().getName()).append('\n');
        aSB.append("  Value = ").append(aExt.getAny()).append('\n');
    }
    return aSB.toString();
}
Also used : ServiceMetadataReferenceCollectionType(com.helger.xsds.peppol.smp1.ServiceMetadataReferenceCollectionType) ServiceMetadataReferenceType(com.helger.xsds.peppol.smp1.ServiceMetadataReferenceType) ExtensionType(com.helger.xsds.peppol.smp1.ExtensionType) Nonnull(javax.annotation.Nonnull)

Example 12 with ServiceMetadataReferenceCollectionType

use of com.helger.xsds.peppol.smp1.ServiceMetadataReferenceCollectionType 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 13 with ServiceMetadataReferenceCollectionType

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

the class SMPServerAPI method getServiceGroup.

@Nonnull
public ServiceGroupType getServiceGroup(final String sPathServiceGroupID) throws SMPServerException {
    final String sLog = LOG_PREFIX + "GET /" + sPathServiceGroupID;
    final String sAction = "getServiceGroup";
    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();
        // Retrieve the service group
        final ISMPServiceGroup aServiceGroup = aServiceGroupMgr.getSMPServiceGroupOfID(aPathServiceGroupID);
        if (aServiceGroup == null) {
            // No such service group
            throw new SMPNotFoundException("Unknown Service Group '" + sPathServiceGroupID + "'", m_aAPIDataProvider.getCurrentURI());
        }
        // Then add the service metadata references
        final ServiceGroupType aSG = aServiceGroup.getAsJAXBObjectPeppol();
        final ServiceMetadataReferenceCollectionType aCollectionType = 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));
                aCollectionType.addServiceMetadataReference(aMetadataReference);
            }
        }
        aSG.setServiceMetadataReferenceCollection(aCollectionType);
        if (LOGGER.isInfoEnabled())
            LOGGER.info(sLog + " SUCCESS");
        STATS_COUNTER_SUCCESS.increment(sAction);
        return aSG;
    } catch (final SMPServerException ex) {
        if (LOGGER.isWarnEnabled())
            LOGGER.warn(sLog + " ERROR - " + ex.getMessage());
        STATS_COUNTER_ERROR.increment(sAction);
        throw ex;
    }
}
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) 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) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) SMPServerException(com.helger.phoss.smp.exception.SMPServerException) Nonnull(javax.annotation.Nonnull)

Example 14 with ServiceMetadataReferenceCollectionType

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

the class BDXR1ServerAPI method getServiceGroup.

@Nonnull
public ServiceGroupType getServiceGroup(final String sPathServiceGroupID) throws SMPServerException {
    final String sLog = LOG_PREFIX + "GET /" + sPathServiceGroupID;
    final String sAction = "getServiceGroup";
    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();
        // Retrieve the service group
        final ISMPServiceGroup aServiceGroup = aServiceGroupMgr.getSMPServiceGroupOfID(aPathServiceGroupID);
        if (aServiceGroup == null) {
            // No such service group
            throw new SMPNotFoundException("Unknown Service Group '" + sPathServiceGroupID + "'", m_aAPIDataProvider.getCurrentURI());
        }
        // Then add the service metadata references
        final ServiceGroupType aSG = aServiceGroup.getAsJAXBObjectBDXR1();
        final ServiceMetadataReferenceCollectionType aCollectionType = 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));
                aCollectionType.addServiceMetadataReference(aMetadataReference);
            }
        }
        aSG.setServiceMetadataReferenceCollection(aCollectionType);
        if (LOGGER.isInfoEnabled())
            LOGGER.info(sLog + " SUCCESS");
        STATS_COUNTER_SUCCESS.increment(sAction);
        return aSG;
    } catch (final SMPServerException ex) {
        if (LOGGER.isWarnEnabled())
            LOGGER.warn(sLog + " ERROR - " + ex.getMessage());
        STATS_COUNTER_ERROR.increment(sAction);
        throw ex;
    }
}
Also used : 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) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) SMPServerException(com.helger.phoss.smp.exception.SMPServerException) Nonnull(javax.annotation.Nonnull)

Example 15 with ServiceMetadataReferenceCollectionType

use of com.helger.xsds.peppol.smp1.ServiceMetadataReferenceCollectionType 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

ServiceMetadataReferenceCollectionType (com.helger.xsds.peppol.smp1.ServiceMetadataReferenceCollectionType)17 ServiceGroupType (com.helger.xsds.peppol.smp1.ServiceGroupType)16 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)15 ISMPServiceGroupManager (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager)14 SimpleParticipantIdentifier (com.helger.peppolid.simple.participant.SimpleParticipantIdentifier)12 Test (org.junit.Test)11 ISMPServiceGroup (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup)9 Response (javax.ws.rs.core.Response)9 IDocumentTypeIdentifier (com.helger.peppolid.IDocumentTypeIdentifier)7 Nonnull (javax.annotation.Nonnull)7 WebTarget (javax.ws.rs.client.WebTarget)7 ISMPServiceInformationManager (com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformationManager)6 IIdentifierFactory (com.helger.peppolid.factory.IIdentifierFactory)4 ISMPServiceInformation (com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation)4 SMPNotFoundException (com.helger.phoss.smp.exception.SMPNotFoundException)4 SMPServerException (com.helger.phoss.smp.exception.SMPServerException)4 MockSMPClient (com.helger.phoss.smp.mock.MockSMPClient)4 SMPClient (com.helger.smpclient.peppol.SMPClient)4 ServiceMetadataType (com.helger.xsds.peppol.smp1.ServiceMetadataType)4 StopWatch (com.helger.commons.timing.StopWatch)3