Search in sources :

Example 6 with SMPHttpResponseHandlerWriteOperations

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

the class SMPClient 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("SMPClient 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 7 with SMPHttpResponseHandlerWriteOperations

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

the class SMPClient method deleteServiceRegistration.

/**
 * Deletes a service meta data object given by its service group id and its
 * document type.
 *
 * @param aServiceGroupID
 *        The service group id of the service meta data to delete. May not be
 *        <code>null</code>.
 * @param aDocumentTypeID
 *        The document type of the service meta data 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 SMPClientUnauthorizedException
 *         The user name or password was not correct.
 * @throws SMPClientNotFoundException
 *         The service meta data object did not exist.
 * @throws SMPClientBadRequestException
 *         The request was not well formed.
 */
public void deleteServiceRegistration(@Nonnull final IParticipantIdentifier aServiceGroupID, @Nonnull final IDocumentTypeIdentifier aDocumentTypeID, @Nonnull final BasicAuthClientCredentials aCredentials) throws SMPClientException {
    ValueEnforcer.notNull(aServiceGroupID, "ServiceGroupID");
    ValueEnforcer.notNull(aDocumentTypeID, "DocumentTypeID");
    ValueEnforcer.notNull(aCredentials, "Credentials");
    final String sURI = getSMPHostURI() + aServiceGroupID.getURIPercentEncoded() + "/" + URL_PART_SERVICES + "/" + aDocumentTypeID.getURIPercentEncoded();
    if (LOGGER.isDebugEnabled())
        LOGGER.debug("SMPClient deleteServiceRegistration@" + 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 8 with SMPHttpResponseHandlerWriteOperations

use of com.helger.smpclient.httpclient.SMPHttpResponseHandlerWriteOperations 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 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 BDXR1MarshallerServiceGroupType(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("BDXRClient 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) BDXR1MarshallerServiceGroupType(com.helger.smpclient.bdxr1.marshal.BDXR1MarshallerServiceGroupType) SMPHttpResponseHandlerWriteOperations(com.helger.smpclient.httpclient.SMPHttpResponseHandlerWriteOperations) HttpPut(org.apache.http.client.methods.HttpPut)

Example 9 with SMPHttpResponseHandlerWriteOperations

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

the class BDXRClient method deleteServiceRegistration.

/**
 * Deletes a service meta data object given by its service group id and its
 * document type.
 *
 * @param aServiceGroupID
 *        The service group id of the service meta data to delete. May not be
 *        <code>null</code>.
 * @param aDocumentTypeID
 *        The document type of the service meta data 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 SMPClientUnauthorizedException
 *         The user name or password was not correct.
 * @throws SMPClientNotFoundException
 *         The service meta data object did not exist.
 * @throws SMPClientBadRequestException
 *         The request was not well formed.
 */
public void deleteServiceRegistration(@Nonnull final IParticipantIdentifier aServiceGroupID, @Nonnull final IDocumentTypeIdentifier aDocumentTypeID, @Nonnull final BasicAuthClientCredentials aCredentials) throws SMPClientException {
    ValueEnforcer.notNull(aServiceGroupID, "ServiceGroupID");
    ValueEnforcer.notNull(aDocumentTypeID, "DocumentTypeID");
    ValueEnforcer.notNull(aCredentials, "Credentials");
    final String sURI = getSMPHostURI() + aServiceGroupID.getURIPercentEncoded() + "/" + URL_PART_SERVICES + "/" + aDocumentTypeID.getURIPercentEncoded();
    if (LOGGER.isDebugEnabled())
        LOGGER.debug("BDXRClient deleteServiceRegistration@" + 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 10 with SMPHttpResponseHandlerWriteOperations

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

the class BDXRClient method _saveServiceInformation.

private void _saveServiceInformation(@Nonnull final ParticipantIdentifierType aServiceGroupID, @Nonnull final DocumentIdentifierType aDocumentTypeID, @Nonnull final ServiceMetadataType aServiceMetadata, @Nonnull final BasicAuthClientCredentials aCredentials) throws SMPClientException {
    final String sBody = new BDXR1MarshallerServiceMetadataType(isXMLSchemaValidation()).getAsString(aServiceMetadata);
    if (sBody == null)
        throw new IllegalArgumentException("Failed to serialize ServiceMetadata: " + aServiceMetadata);
    final String sURI = getSMPHostURI() + CIdentifier.getURIPercentEncoded(aServiceGroupID) + "/" + URL_PART_SERVICES + "/" + CIdentifier.getURIPercentEncoded(aDocumentTypeID);
    if (LOGGER.isDebugEnabled())
        LOGGER.debug("BDXRClient 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) BDXR1MarshallerServiceMetadataType(com.helger.smpclient.bdxr1.marshal.BDXR1MarshallerServiceMetadataType) 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