Search in sources :

Example 1 with SMPHttpResponseHandlerWriteOperations

use of com.helger.smpclient.httpclient.SMPHttpResponseHandlerWriteOperations in project peppol-commons by phax.

the class BDXRClient method deleteServiceGroup.

/**
 * Deletes a service group given by its service group id.
 *
 * @param aServiceGroupID
 *        The service group id of the service group to delete. 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 SMPClientNotFoundException
 *         The service group id did not exist.
 * @throws SMPClientUnauthorizedException
 *         The user name or password was not correct.
 * @throws SMPClientBadRequestException
 *         The request was not well formed.
 */
public void deleteServiceGroup(@Nonnull final IParticipantIdentifier aServiceGroupID, @Nonnull final BasicAuthClientCredentials aCredentials) throws SMPClientException {
    ValueEnforcer.notNull(aCredentials, "Credentials");
    final String sURI = getSMPHostURI() + aServiceGroupID.getURIPercentEncoded();
    if (LOGGER.isDebugEnabled())
        LOGGER.debug("BDXRClient deleteServiceGroup@" + sURI);
    final HttpDelete aRequest = new HttpDelete(sURI);
    aRequest.addHeader(CHttpHeader.AUTHORIZATION, aCredentials.getRequestValue());
    executeGenericRequest(aRequest, new SMPHttpResponseHandlerWriteOperations());
}
Also used : HttpDelete(org.apache.http.client.methods.HttpDelete) SMPHttpResponseHandlerWriteOperations(com.helger.smpclient.httpclient.SMPHttpResponseHandlerWriteOperations)

Example 2 with SMPHttpResponseHandlerWriteOperations

use of com.helger.smpclient.httpclient.SMPHttpResponseHandlerWriteOperations in project peppol-commons by phax.

the class SMPClient method _saveServiceInformation.

private void _saveServiceInformation(@Nonnull final IParticipantIdentifier aServiceGroupID, @Nonnull final IDocumentTypeIdentifier aDocumentTypeID, @Nonnull final ServiceMetadataType aServiceMetadata, @Nonnull final BasicAuthClientCredentials aCredentials) throws SMPClientException {
    final String sBody = new SMPMarshallerServiceMetadataType(isXMLSchemaValidation()).getAsString(aServiceMetadata);
    if (sBody == null)
        throw new IllegalArgumentException("Failed to serialize ServiceMetadata: " + aServiceMetadata);
    final String sURI = getSMPHostURI() + aServiceGroupID.getURIPercentEncoded() + "/" + URL_PART_SERVICES + "/" + aDocumentTypeID.getURIPercentEncoded();
    if (LOGGER.isDebugEnabled())
        LOGGER.debug("SMPClient saveServiceRegistration@" + 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());
}
Also used : StringEntity(org.apache.http.entity.StringEntity) SMPMarshallerServiceMetadataType(com.helger.smpclient.peppol.marshal.SMPMarshallerServiceMetadataType) SMPHttpResponseHandlerWriteOperations(com.helger.smpclient.httpclient.SMPHttpResponseHandlerWriteOperations) HttpPut(org.apache.http.client.methods.HttpPut)

Example 3 with SMPHttpResponseHandlerWriteOperations

use of com.helger.smpclient.httpclient.SMPHttpResponseHandlerWriteOperations 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 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 SMPMarshallerServiceGroupType(isXMLSchemaValidation()).getAsString(aServiceGroup);
    if (sBody == null)
        throw new IllegalArgumentException("Failed to serialize ServiceGroup: " + aServiceGroup);
    final String sURI = getSMPHostURI() + CIdentifier.getURIPercentEncoded(aServiceGroup.getParticipantIdentifier());
    if (LOGGER.isDebugEnabled())
        LOGGER.debug("SMPClient 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());
}
Also used : StringEntity(org.apache.http.entity.StringEntity) SMPMarshallerServiceGroupType(com.helger.smpclient.peppol.marshal.SMPMarshallerServiceGroupType) SMPHttpResponseHandlerWriteOperations(com.helger.smpclient.httpclient.SMPHttpResponseHandlerWriteOperations) HttpPut(org.apache.http.client.methods.HttpPut)

Example 4 with SMPHttpResponseHandlerWriteOperations

use of com.helger.smpclient.httpclient.SMPHttpResponseHandlerWriteOperations in project peppol-commons by phax.

the class BDXR2Client method _saveServiceInformation.

private void _saveServiceInformation(@Nonnull final ServiceMetadataType aServiceMetadata, @Nonnull final BasicAuthClientCredentials aCredentials) throws SMPClientException {
    final String sBody = new BDXR2ServiceMetadataMarshaller(isXMLSchemaValidation()).getAsString(aServiceMetadata);
    if (sBody == null)
        throw new IllegalArgumentException("Failed to serialize ServiceMetadata: " + aServiceMetadata);
    final String sURI = getSMPHostURI() + PATH_OASIS_BDXR_SMP_2 + CIdentifier.getURIPercentEncoded(aServiceMetadata.getParticipantID()) + '/' + URL_PART_SERVICES + '/' + CIdentifier.getURIPercentEncoded(aServiceMetadata.getID());
    if (LOGGER.isDebugEnabled())
        LOGGER.debug("BDXR2Client saveServiceRegistration@" + 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());
}
Also used : StringEntity(org.apache.http.entity.StringEntity) SMPHttpResponseHandlerWriteOperations(com.helger.smpclient.httpclient.SMPHttpResponseHandlerWriteOperations) HttpPut(org.apache.http.client.methods.HttpPut) BDXR2ServiceMetadataMarshaller(com.helger.smpclient.bdxr2.marshal.BDXR2ServiceMetadataMarshaller)

Example 5 with SMPHttpResponseHandlerWriteOperations

use of com.helger.smpclient.httpclient.SMPHttpResponseHandlerWriteOperations 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());
}
Also used : StringEntity(org.apache.http.entity.StringEntity) BDXR2ServiceGroupMarshaller(com.helger.smpclient.bdxr2.marshal.BDXR2ServiceGroupMarshaller) SMPHttpResponseHandlerWriteOperations(com.helger.smpclient.httpclient.SMPHttpResponseHandlerWriteOperations) HttpPut(org.apache.http.client.methods.HttpPut)

Aggregations

SMPHttpResponseHandlerWriteOperations (com.helger.smpclient.httpclient.SMPHttpResponseHandlerWriteOperations)12 HttpDelete (org.apache.http.client.methods.HttpDelete)6 HttpPut (org.apache.http.client.methods.HttpPut)6 StringEntity (org.apache.http.entity.StringEntity)6 BDXR1MarshallerServiceGroupType (com.helger.smpclient.bdxr1.marshal.BDXR1MarshallerServiceGroupType)1 BDXR1MarshallerServiceMetadataType (com.helger.smpclient.bdxr1.marshal.BDXR1MarshallerServiceMetadataType)1 BDXR2ServiceGroupMarshaller (com.helger.smpclient.bdxr2.marshal.BDXR2ServiceGroupMarshaller)1 BDXR2ServiceMetadataMarshaller (com.helger.smpclient.bdxr2.marshal.BDXR2ServiceMetadataMarshaller)1 SMPMarshallerServiceGroupType (com.helger.smpclient.peppol.marshal.SMPMarshallerServiceGroupType)1 SMPMarshallerServiceMetadataType (com.helger.smpclient.peppol.marshal.SMPMarshallerServiceMetadataType)1