use of com.helger.smpclient.bdxr2.marshal.BDXR2ServiceGroupMarshaller in project peppol-commons by phax.
the class BDXR2Client method saveServiceGroup.
/**
* Saves a service group. The meta data references should not be set and are
* not used.
*
* @param aServiceGroup
* The service group 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.
*/
public void saveServiceGroup(@Nonnull final ServiceGroupType aServiceGroup, @Nonnull final BasicAuthClientCredentials aCredentials) throws SMPClientException {
ValueEnforcer.notNull(aServiceGroup, "ServiceGroup");
ValueEnforcer.notNull(aCredentials, "Credentials");
final String sBody = new BDXR2ServiceGroupMarshaller(isXMLSchemaValidation()).getAsString(aServiceGroup);
if (sBody == null)
throw new IllegalArgumentException("Failed to serialize ServiceGroup: " + aServiceGroup);
final String sURI = getSMPHostURI() + PATH_OASIS_BDXR_SMP_2 + CIdentifier.getURIPercentEncoded(aServiceGroup.getParticipantID());
if (LOGGER.isDebugEnabled())
LOGGER.debug("BDXR2Client saveServiceGroup@" + sURI);
final HttpPut aRequest = new HttpPut(sURI);
aRequest.addHeader(CHttpHeader.AUTHORIZATION, aCredentials.getRequestValue());
aRequest.setEntity(new StringEntity(sBody, CONTENT_TYPE_TEXT_XML));
executeGenericRequest(aRequest, new SMPHttpResponseHandlerWriteOperations());
}
use of com.helger.smpclient.bdxr2.marshal.BDXR2ServiceGroupMarshaller in project peppol-commons by phax.
the class BDXR2ClientReadOnly method getServiceGroup.
/**
* Returns a service group. A service group references to the service
* metadata. This is a specification compliant method.
*
* @param aServiceGroupID
* The service group id corresponding to the service group which one
* wants to get.
* @return The service group. Never <code>null</code>.
* @throws SMPClientException
* in case something goes wrong
* @throws SMPClientUnauthorizedException
* A HTTP Forbidden was received, should not happen.
* @throws SMPClientNotFoundException
* The service group id did not exist.
* @throws SMPClientBadRequestException
* The request was not well formed.
* @see #getServiceGroupOrNull(IParticipantIdentifier)
*/
@Nonnull
public ServiceGroupType getServiceGroup(@Nonnull final IParticipantIdentifier aServiceGroupID) throws SMPClientException {
ValueEnforcer.notNull(aServiceGroupID, "ServiceGroupID");
final String sURI = getSMPHostURI() + PATH_OASIS_BDXR_SMP_2 + aServiceGroupID.getURIPercentEncoded();
if (LOGGER.isDebugEnabled())
LOGGER.debug("BDXR2Client getServiceGroup@" + sURI);
final HttpGet aRequest = new HttpGet(sURI);
final BDXR2ServiceGroupMarshaller aMarshaller = new BDXR2ServiceGroupMarshaller(isXMLSchemaValidation());
customizeMarshaller(aMarshaller);
final ServiceGroupType ret = executeGenericRequest(aRequest, new SMPHttpResponseHandlerUnsigned<>(aMarshaller));
if (LOGGER.isDebugEnabled())
LOGGER.debug("Received response: " + ret);
return ret;
}
Aggregations