Search in sources :

Example 1 with ServiceGroupType

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

the class SMPClientTest method testCRUDServiceGroup.

@Test
public void testCRUDServiceGroup() throws SMPClientException {
    final String sContent = "Test";
    final String sElement = "TestElement";
    final String sExtensionXML = "<" + sElement + ">" + sContent + "</" + sElement + ">";
    final SMPClient aSMPClient = new SMPClient(SMP_URI);
    final ServiceGroupType aServiceGroupCreate = aSMPClient.saveServiceGroup(MockSMPClientConfig.getParticipantID(), SMP_CREDENTIALS);
    aServiceGroupCreate.setExtension(SMPExtensionConverter.convert(sExtensionXML));
    aSMPClient.saveServiceGroup(aServiceGroupCreate, SMP_CREDENTIALS);
    final ParticipantIdentifierType aServiceGroupID = aServiceGroupCreate.getParticipantIdentifier();
    final ServiceGroupType aServiceGroupRead = aSMPClient.getServiceGroup(SimpleParticipantIdentifier.wrap(aServiceGroupID));
    assertNotNull(aServiceGroupRead);
    assertNotNull(aServiceGroupRead.getExtension());
    assertNotNull(aServiceGroupRead.getExtension().getAny());
    assertEquals(sContent, aServiceGroupRead.getExtension().getAny().getTextContent());
    assertEquals(sElement, aServiceGroupRead.getExtension().getAny().getLocalName());
    aSMPClient.deleteServiceGroup(MockSMPClientConfig.getParticipantID(), SMP_CREDENTIALS);
}
Also used : ServiceGroupType(com.helger.xsds.peppol.smp1.ServiceGroupType) CompleteServiceGroupType(com.helger.xsds.peppol.smp1.CompleteServiceGroupType) ParticipantIdentifierType(com.helger.xsds.peppol.id1.ParticipantIdentifierType) Test(org.junit.Test)

Example 2 with ServiceGroupType

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

the class SMPClientWithDNSFuncTest method testGetByDNS.

@Test
public void testGetByDNS() throws Exception {
    // Make sure that the dns exists.
    final String sParticipantID = "0088:5798000000001";
    final String sDocumentID = "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2::InvoiceDisputeDisputeInvoice##UBL-2.0";
    final IParticipantIdentifier aServiceGroupID = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme(sParticipantID);
    final IDocumentTypeIdentifier aDocumentTypeID = PeppolIdentifierFactory.INSTANCE.createDocumentTypeIdentifierWithDefaultScheme(sDocumentID);
    final ServiceGroupType aGroup = SMPClientReadOnly.getServiceGroupByDNS(URL_PROVIDER, SML_INFO, aServiceGroupID);
    assertNotNull(aGroup);
    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) ServiceGroupType(com.helger.xsds.peppol.smp1.ServiceGroupType) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Test(org.junit.Test)

Example 3 with ServiceGroupType

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

the class MainCheckIfSMPIsWorking 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();
    // The main SMP client
    final SMPClient aClient = new SMPClient(SMP_URI);
    // Ensure that the service group does not exist
    LOGGER.info("Ensuring that the service group is not existing!");
    if (aClient.getServiceGroupOrNull(PARTICIPANT_ID) != null) {
        LOGGER.info("Deleting existing service group for init");
        aClient.deleteServiceGroup(PARTICIPANT_ID, SMP_CREDENTIALS);
        LOGGER.info("Finished deletion of service group");
    }
    // Create, read and delete the service group
    LOGGER.info("Creating the new service group");
    aClient.saveServiceGroup(PARTICIPANT_ID, SMP_CREDENTIALS);
    LOGGER.info("Retrieving the service group");
    final ServiceGroupType aSGT = aClient.getServiceGroup(PARTICIPANT_ID);
    if (!SimpleParticipantIdentifier.wrap(aSGT.getParticipantIdentifier()).equals(PARTICIPANT_ID))
        throw new IllegalStateException("Participant identifiers are not equal!");
    LOGGER.info("Deleting the service group again");
    aClient.deleteServiceGroup(PARTICIPANT_ID, SMP_CREDENTIALS);
    LOGGER.info("Checking if the service group is really deleted");
    if (aClient.getServiceGroupOrNull(PARTICIPANT_ID) != null)
        throw new IllegalStateException("Deletion of the service group failed!");
    LOGGER.info("Seems like the SMP is working as expected!");
}
Also used : BasicAuthClientCredentials(com.helger.http.basicauth.BasicAuthClientCredentials) SMPClient(com.helger.smpclient.peppol.SMPClient) URI(java.net.URI) ServiceGroupType(com.helger.xsds.peppol.smp1.ServiceGroupType) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier)

Example 4 with ServiceGroupType

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

the class BDXRClient method saveServiceGroup.

/**
 * Saves a service group. The meta data references should not be set and are
 * not used.
 *
 * @param aParticipantID
 *        The participant identifier for which the service group is to save.
 * @param aCredentials
 *        The user name and password to use as credentials.
 * @return The created {@link ServiceGroupType} object.
 * @throws SMPClientException
 *         in case something goes wrong
 * @throws SMPClientUnauthorizedException
 *         The user name or password was not correct.
 * @throws SMPClientNotFoundException
 *         A HTTP Not Found was received. This can happen if the service was
 *         not found.
 * @throws SMPClientBadRequestException
 *         The request was not well formed.
 */
@Nonnull
public ServiceGroupType saveServiceGroup(@Nonnull final IParticipantIdentifier aParticipantID, @Nonnull final BasicAuthClientCredentials aCredentials) throws SMPClientException {
    ValueEnforcer.notNull(aParticipantID, "ParticipantID");
    ValueEnforcer.notNull(aCredentials, "Credentials");
    final ServiceGroupType aServiceGroup = new ServiceGroupType();
    // Explicit constructor call is needed here!
    aServiceGroup.setParticipantIdentifier(new BDXR1ParticipantIdentifier(aParticipantID));
    // Mandatory element, but can be empty
    aServiceGroup.setServiceMetadataReferenceCollection(new ServiceMetadataReferenceCollectionType());
    saveServiceGroup(aServiceGroup, aCredentials);
    return aServiceGroup;
}
Also used : ServiceMetadataReferenceCollectionType(com.helger.xsds.bdxr.smp1.ServiceMetadataReferenceCollectionType) BDXR1ParticipantIdentifier(com.helger.peppolid.bdxr.smp1.participant.BDXR1ParticipantIdentifier) ServiceGroupType(com.helger.xsds.bdxr.smp1.ServiceGroupType) BDXR1MarshallerServiceGroupType(com.helger.smpclient.bdxr1.marshal.BDXR1MarshallerServiceGroupType) Nonnull(javax.annotation.Nonnull)

Example 5 with ServiceGroupType

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

the class SMPClient method saveServiceGroup.

/**
 * Saves a service group. The meta data references should not be set and are
 * not used.
 *
 * @param aParticipantID
 *        The participant identifier for which the service group is to save.
 * @param aCredentials
 *        The user name and password to use as credentials.
 * @return The created {@link ServiceGroupType} object.
 * @throws SMPClientException
 *         in case something goes wrong
 * @throws SMPClientUnauthorizedException
 *         The user name or password was not correct.
 * @throws SMPClientNotFoundException
 *         A HTTP Not Found was received. This can happen if the service was
 *         not found.
 * @throws SMPClientBadRequestException
 *         The request was not well formed.
 */
@Nonnull
public ServiceGroupType saveServiceGroup(@Nonnull final IParticipantIdentifier aParticipantID, @Nonnull final BasicAuthClientCredentials aCredentials) throws SMPClientException {
    ValueEnforcer.notNull(aParticipantID, "ParticipantID");
    ValueEnforcer.notNull(aCredentials, "Credentials");
    final ServiceGroupType aServiceGroup = new ServiceGroupType();
    // Explicit constructor call is needed here!
    aServiceGroup.setParticipantIdentifier(new SimpleParticipantIdentifier(aParticipantID));
    // Mandatory element, but can be empty
    aServiceGroup.setServiceMetadataReferenceCollection(new ServiceMetadataReferenceCollectionType());
    saveServiceGroup(aServiceGroup, aCredentials);
    return aServiceGroup;
}
Also used : ServiceMetadataReferenceCollectionType(com.helger.xsds.peppol.smp1.ServiceMetadataReferenceCollectionType) ServiceGroupType(com.helger.xsds.peppol.smp1.ServiceGroupType) SMPMarshallerServiceGroupType(com.helger.smpclient.peppol.marshal.SMPMarshallerServiceGroupType) SimpleParticipantIdentifier(com.helger.peppolid.simple.participant.SimpleParticipantIdentifier) Nonnull(javax.annotation.Nonnull)

Aggregations

ServiceGroupType (com.helger.xsds.peppol.smp1.ServiceGroupType)21 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)19 ServiceMetadataReferenceCollectionType (com.helger.xsds.peppol.smp1.ServiceMetadataReferenceCollectionType)16 ISMPServiceGroupManager (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager)14 Test (org.junit.Test)14 SimpleParticipantIdentifier (com.helger.peppolid.simple.participant.SimpleParticipantIdentifier)12 Nonnull (javax.annotation.Nonnull)11 IDocumentTypeIdentifier (com.helger.peppolid.IDocumentTypeIdentifier)9 ISMPServiceGroup (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup)9 Response (javax.ws.rs.core.Response)9 WebTarget (javax.ws.rs.client.WebTarget)7 ISMPServiceInformationManager (com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformationManager)6 SMPClient (com.helger.smpclient.peppol.SMPClient)5 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 ServiceGroupType (com.helger.xsds.bdxr.smp1.ServiceGroupType)4 CompleteServiceGroupType (com.helger.xsds.peppol.smp1.CompleteServiceGroupType)4