use of com.helger.xsds.bdxr.smp2.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));
}
}
use of com.helger.xsds.bdxr.smp2.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);
}
use of com.helger.xsds.bdxr.smp2.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);
}
use of com.helger.xsds.bdxr.smp2.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);
}
use of com.helger.xsds.bdxr.smp2.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);
}
Aggregations