Search in sources :

Example 16 with ServiceMetadataType

use of org.geotoolkit.wcs.xml.v200.ServiceMetadataType in project phoss-smp by phax.

the class ServiceMetadataInterfaceTest method testRemoveAllContentOfServiceGroup.

@Test
public void testRemoveAllContentOfServiceGroup() {
    // Lower case
    final IParticipantIdentifier aPI_LC = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("9915:xxx");
    final String sPI_LC = aPI_LC.getURIEncoded();
    final IDocumentTypeIdentifier aDT = EPredefinedDocumentTypeIdentifier.INVOICE_EN16931_PEPPOL_V30.getAsDocumentTypeIdentifier();
    final String sDT = aDT.getURIEncoded();
    final ServiceGroupType aSG = new ServiceGroupType();
    aSG.setParticipantIdentifier(new SimpleParticipantIdentifier(aPI_LC));
    aSG.setServiceMetadataReferenceCollection(new ServiceMetadataReferenceCollectionType());
    final ServiceMetadataType aSM = new ServiceMetadataType();
    aSM.setRedirect(_createRedirect());
    final ISMPServiceGroupManager aSGMgr = SMPMetaManager.getServiceGroupMgr();
    final ISMPRedirectManager aSRMgr = SMPMetaManager.getRedirectMgr();
    final WebTarget aTarget = ClientBuilder.newClient().target(m_aRule.getFullURL());
    Response aResponseMsg;
    _testResponseJerseyClient(aTarget.path(sPI_LC).request().get(), 404);
    try {
        // PUT ServiceGroup
        aResponseMsg = _addCredentials(aTarget.path(sPI_LC).request()).put(Entity.xml(m_aObjFactory.createServiceGroup(aSG)));
        _testResponseJerseyClient(aResponseMsg, 200);
        // GET ServiceGroup
        assertNotNull(aTarget.path(sPI_LC).request().get(ServiceGroupType.class));
        final ISMPServiceGroup aServiceGroup = aSGMgr.getSMPServiceGroupOfID(aPI_LC);
        assertNotNull(aServiceGroup);
        try {
            // PUT 1 ServiceInformation
            aResponseMsg = _addCredentials(aTarget.path(sPI_LC).path("services").path(sDT).request()).put(Entity.xml(m_aObjFactory.createServiceMetadata(aSM)));
            _testResponseJerseyClient(aResponseMsg, 200);
            assertNotNull(aSRMgr.getSMPRedirectOfServiceGroupAndDocumentType(aServiceGroup, aDT));
            // DELETE 1 Redirect
            aResponseMsg = _addCredentials(aTarget.path(sPI_LC).path("services").request()).delete();
            _testResponseJerseyClient(aResponseMsg, 200);
            assertNull(aSRMgr.getSMPRedirectOfServiceGroupAndDocumentType(aServiceGroup, aDT));
        } finally {
            // DELETE 2 Redirect
            aResponseMsg = _addCredentials(aTarget.path(sPI_LC).path("services").request()).delete();
            _testResponseJerseyClient(aResponseMsg, 200, 404);
            assertNull(aSRMgr.getSMPRedirectOfServiceGroupAndDocumentType(aServiceGroup, aDT));
        }
        assertNotNull(aTarget.path(sPI_LC).request().get(ServiceGroupType.class));
    } finally {
        // DELETE ServiceGroup
        aResponseMsg = _addCredentials(aTarget.path(sPI_LC).request()).delete();
        _testResponseJerseyClient(aResponseMsg, 200, 404);
        _testResponseJerseyClient(aTarget.path(sPI_LC).request().get(), 404);
        assertFalse(aSGMgr.containsSMPServiceGroupWithID(aPI_LC));
    }
}
Also used : Response(javax.ws.rs.core.Response) ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) ISMPRedirectManager(com.helger.phoss.smp.domain.redirect.ISMPRedirectManager) ServiceMetadataReferenceCollectionType(com.helger.xsds.peppol.smp1.ServiceMetadataReferenceCollectionType) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) WebTarget(javax.ws.rs.client.WebTarget) ServiceGroupType(com.helger.xsds.peppol.smp1.ServiceGroupType) ServiceMetadataType(com.helger.xsds.peppol.smp1.ServiceMetadataType) SimpleParticipantIdentifier(com.helger.peppolid.simple.participant.SimpleParticipantIdentifier) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Test(org.junit.Test)

Example 17 with ServiceMetadataType

use of org.geotoolkit.wcs.xml.v200.ServiceMetadataType in project peppol-commons by phax.

the class SMPClient method saveServiceRedirect.

/**
 * Saves a redirect data object.
 *
 * @param aServiceGroupID
 *        The service group ID to use. May not be <code>null</code>.
 * @param aDocumentTypeID
 *        The document type ID to use. May not be <code>null</code>.
 * @param aRedirect
 *        The redirect to be saved. May not be <code>null</code>.
 * @param aCredentials
 *        The user name and password to use as credentials. May not be
 *        <code>null</code>.
 * @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.
 * @see #saveServiceInformation(ServiceInformationType,
 *      BasicAuthClientCredentials)
 */
public void saveServiceRedirect(@Nonnull final IParticipantIdentifier aServiceGroupID, @Nonnull final IDocumentTypeIdentifier aDocumentTypeID, @Nonnull final RedirectType aRedirect, @Nonnull final BasicAuthClientCredentials aCredentials) throws SMPClientException {
    ValueEnforcer.notNull(aServiceGroupID, "ServiceGroupID");
    ValueEnforcer.notNull(aDocumentTypeID, "DocumentTypeID");
    ValueEnforcer.notNull(aRedirect, "Redirect");
    ValueEnforcer.notNull(aCredentials, "Credentials");
    final ServiceMetadataType aServiceMetadata = new ServiceMetadataType();
    aServiceMetadata.setRedirect(aRedirect);
    _saveServiceInformation(aServiceGroupID, aDocumentTypeID, aServiceMetadata, aCredentials);
}
Also used : ServiceMetadataType(com.helger.xsds.peppol.smp1.ServiceMetadataType) SMPMarshallerServiceMetadataType(com.helger.smpclient.peppol.marshal.SMPMarshallerServiceMetadataType)

Example 18 with ServiceMetadataType

use of org.geotoolkit.wcs.xml.v200.ServiceMetadataType in project peppol-commons by phax.

the class SMPClient method saveServiceInformation.

/**
 * Saves a service information data object.
 *
 * @param aServiceInformation
 *        The service information object to save. May not be
 *        <code>null</code>.
 * @param aCredentials
 *        The user name and password to use as credentials. May not be
 *        <code>null</code>.
 * @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.
 * @see #saveServiceRedirect(IParticipantIdentifier, IDocumentTypeIdentifier,
 *      RedirectType, BasicAuthClientCredentials)
 */
public void saveServiceInformation(@Nonnull final ServiceInformationType aServiceInformation, @Nonnull final BasicAuthClientCredentials aCredentials) throws SMPClientException {
    ValueEnforcer.notNull(aServiceInformation, "ServiceMetadata.ServiceInformation");
    ValueEnforcer.notNull(aServiceInformation.getParticipantIdentifier(), "ServiceMetadata.ServiceInformation.ParticipantIdentifier");
    ValueEnforcer.notNull(aServiceInformation.getDocumentIdentifier(), "ServiceMetadata.ServiceInformation.DocumentIdentifier");
    ValueEnforcer.notNull(aCredentials, "Credentials");
    final ServiceMetadataType aServiceMetadata = new ServiceMetadataType();
    aServiceMetadata.setServiceInformation(aServiceInformation);
    _saveServiceInformation(SimpleParticipantIdentifier.wrap(aServiceInformation.getParticipantIdentifier()), SimpleDocumentTypeIdentifier.wrap(aServiceInformation.getDocumentIdentifier()), aServiceMetadata, aCredentials);
}
Also used : ServiceMetadataType(com.helger.xsds.peppol.smp1.ServiceMetadataType) SMPMarshallerServiceMetadataType(com.helger.smpclient.peppol.marshal.SMPMarshallerServiceMetadataType)

Example 19 with ServiceMetadataType

use of org.geotoolkit.wcs.xml.v200.ServiceMetadataType in project peppol-commons by phax.

the class BDXRClient method saveServiceInformation.

/**
 * Saves a service information data object.
 *
 * @param aServiceInformation
 *        The service information object to save. May not be
 *        <code>null</code>.
 * @param aCredentials
 *        The user name and password to use as credentials. May not be
 *        <code>null</code>.
 * @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.
 * @see #saveServiceRedirect(ParticipantIdentifierType,
 *      DocumentIdentifierType, RedirectType, BasicAuthClientCredentials)
 */
public void saveServiceInformation(@Nonnull final ServiceInformationType aServiceInformation, @Nonnull final BasicAuthClientCredentials aCredentials) throws SMPClientException {
    ValueEnforcer.notNull(aServiceInformation, "ServiceMetadata.ServiceInformation");
    ValueEnforcer.notNull(aServiceInformation.getParticipantIdentifier(), "ServiceMetadata.ServiceInformation.ParticipantIdentifier");
    ValueEnforcer.notNull(aServiceInformation.getDocumentIdentifier(), "ServiceMetadata.ServiceInformation.DocumentIdentifier");
    ValueEnforcer.notNull(aCredentials, "Credentials");
    final ServiceMetadataType aServiceMetadata = new ServiceMetadataType();
    aServiceMetadata.setServiceInformation(aServiceInformation);
    _saveServiceInformation(aServiceInformation.getParticipantIdentifier(), aServiceInformation.getDocumentIdentifier(), aServiceMetadata, aCredentials);
}
Also used : BDXR1MarshallerServiceMetadataType(com.helger.smpclient.bdxr1.marshal.BDXR1MarshallerServiceMetadataType) ServiceMetadataType(com.helger.xsds.bdxr.smp1.ServiceMetadataType)

Example 20 with ServiceMetadataType

use of org.geotoolkit.wcs.xml.v200.ServiceMetadataType in project peppol-commons by phax.

the class BDXRClient method saveServiceRedirect.

/**
 * Saves a redirect data object.
 *
 * @param aServiceGroupID
 *        The service group ID to use. May not be <code>null</code>.
 * @param aDocumentTypeID
 *        The document type ID to use. May not be <code>null</code>.
 * @param aRedirect
 *        The redirect to be saved. May not be <code>null</code>.
 * @param aCredentials
 *        The user name and password to use as credentials. May not be
 *        <code>null</code>.
 * @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.
 * @see #saveServiceInformation(ServiceInformationType,
 *      BasicAuthClientCredentials)
 */
public void saveServiceRedirect(@Nonnull final ParticipantIdentifierType aServiceGroupID, @Nonnull final DocumentIdentifierType aDocumentTypeID, @Nonnull final RedirectType aRedirect, @Nonnull final BasicAuthClientCredentials aCredentials) throws SMPClientException {
    ValueEnforcer.notNull(aServiceGroupID, "ServiceGroupID");
    ValueEnforcer.notNull(aDocumentTypeID, "DocumentTypeID");
    ValueEnforcer.notNull(aRedirect, "Redirect");
    ValueEnforcer.notNull(aCredentials, "Credentials");
    final ServiceMetadataType aServiceMetadata = new ServiceMetadataType();
    aServiceMetadata.setRedirect(aRedirect);
    _saveServiceInformation(aServiceGroupID, aDocumentTypeID, aServiceMetadata, aCredentials);
}
Also used : BDXR1MarshallerServiceMetadataType(com.helger.smpclient.bdxr1.marshal.BDXR1MarshallerServiceMetadataType) ServiceMetadataType(com.helger.xsds.bdxr.smp1.ServiceMetadataType)

Aggregations

ServiceMetadataType (com.helger.xsds.peppol.smp1.ServiceMetadataType)11 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)8 ISMPServiceGroup (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup)7 IDocumentTypeIdentifier (com.helger.peppolid.IDocumentTypeIdentifier)6 SimpleParticipantIdentifier (com.helger.peppolid.simple.participant.SimpleParticipantIdentifier)5 ISMPServiceGroupManager (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager)5 ISMPServiceInformationManager (com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformationManager)5 ServiceMetadataType (com.helger.xsds.bdxr.smp1.ServiceMetadataType)5 Nonnull (javax.annotation.Nonnull)5 Response (javax.ws.rs.core.Response)5 Test (org.junit.Test)5 IIdentifierFactory (com.helger.peppolid.factory.IIdentifierFactory)4 ISMPRedirectManager (com.helger.phoss.smp.domain.redirect.ISMPRedirectManager)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 ServiceMetadataType (com.helger.xsds.bdxr.smp2.ServiceMetadataType)4 PeppolDocumentTypeIdentifier (com.helger.peppolid.peppol.doctype.PeppolDocumentTypeIdentifier)3 PeppolProcessIdentifier (com.helger.peppolid.peppol.process.PeppolProcessIdentifier)3 EndpointType (com.helger.xsds.peppol.smp1.EndpointType)3