Skip to content

Commit

Permalink
Added new SMP client exception SMPClientParticipantNotFoundException
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed Jul 10, 2024
1 parent f13d11b commit cf86ba3
Show file tree
Hide file tree
Showing 9 changed files with 142 additions and 39 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@ They depend on several other libraries so I suggest you are going for the Maven

# News and noteworthy

* v9.4.1 - work in progress
* Added new submodule `dbnalliance-xhe`. See [#53](https://github.com/phax/peppol-commons/pull/53) - thx @robinsongarciax
* Added new SMP client exception `SMPClientParticipantNotFoundException` to indicate non-existing Service Groups
* v9.4.0 - 2024-05-24
* Renamed `IParticipantIdentifierScheme` to `IPeppolParticipantIdentifierScheme`
* Tried to make the usage of `IIdentifierFactory` more customizable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import com.helger.smpclient.exception.SMPClientBadRequestException;
import com.helger.smpclient.exception.SMPClientException;
import com.helger.smpclient.exception.SMPClientNotFoundException;
import com.helger.smpclient.exception.SMPClientParticipantNotFoundException;
import com.helger.smpclient.exception.SMPClientUnauthorizedException;
import com.helger.smpclient.httpclient.SMPHttpResponseHandlerWriteOperations;
import com.helger.smpclient.url.ISMPURLProvider;
Expand Down Expand Up @@ -212,8 +213,10 @@ public ServiceGroupType saveServiceGroup (@Nonnull final IParticipantIdentifier
* <code>null</code>.
* @throws SMPClientException
* in case something goes wrong
* @throws SMPClientParticipantNotFoundException
* The service group id does not exist in the network.
* @throws SMPClientNotFoundException
* The service group id did not exist.
* The service group id or document types did not exist.
* @throws SMPClientUnauthorizedException
* The user name or password was not correct.
* @throws SMPClientBadRequestException
Expand Down Expand Up @@ -271,9 +274,10 @@ private void _saveServiceInformation (@Nonnull final ParticipantIdentifierType a
* in case something goes wrong
* @throws SMPClientUnauthorizedException
* The user name or password was not correct.
* @throws SMPClientParticipantNotFoundException
* The service group id does not exist in the network.
* @throws SMPClientNotFoundException
* A HTTP Not Found was received. This can happen if the service was
* not found.
* The service group id or document types did not exist.
* @throws SMPClientBadRequestException
* The request was not well formed.
* @see #saveServiceRedirect(ParticipantIdentifierType,
Expand Down Expand Up @@ -313,9 +317,10 @@ public void saveServiceInformation (@Nonnull final ServiceInformationType aServi
* in case something goes wrong
* @throws SMPClientUnauthorizedException
* The user name or password was not correct.
* @throws SMPClientParticipantNotFoundException
* The service group id does not exist in the network.
* @throws SMPClientNotFoundException
* A HTTP Not Found was received. This can happen if the service was
* not found.
* The service group id or document types did not exist.
* @throws SMPClientBadRequestException
* The request was not well formed.
* @see #saveServiceInformation(ServiceInformationType,
Expand Down Expand Up @@ -353,8 +358,10 @@ public void saveServiceRedirect (@Nonnull final ParticipantIdentifierType aServi
* in case something goes wrong
* @throws SMPClientUnauthorizedException
* The user name or password was not correct.
* @throws SMPClientParticipantNotFoundException
* The service group id does not exist in the network.
* @throws SMPClientNotFoundException
* The service meta data object did not exist.
* The service group id or document types did not exist.
* @throws SMPClientBadRequestException
* The request was not well formed.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import com.helger.smpclient.exception.SMPClientBadRequestException;
import com.helger.smpclient.exception.SMPClientException;
import com.helger.smpclient.exception.SMPClientNotFoundException;
import com.helger.smpclient.exception.SMPClientParticipantNotFoundException;
import com.helger.smpclient.exception.SMPClientUnauthorizedException;
import com.helger.smpclient.httpclient.SMPHttpResponseHandlerWriteOperations;
import com.helger.smpclient.url.ISMPURLProvider;
Expand Down Expand Up @@ -213,8 +214,10 @@ public ServiceGroupType saveServiceGroup (@Nonnull final IParticipantIdentifier
* <code>null</code>.
* @throws SMPClientException
* in case something goes wrong
* @throws SMPClientParticipantNotFoundException
* The service group id does not exist in the network.
* @throws SMPClientNotFoundException
* The service group id did not exist.
* The service group id or document types did not exist.
* @throws SMPClientUnauthorizedException
* The user name or password was not correct.
* @throws SMPClientBadRequestException
Expand Down Expand Up @@ -275,9 +278,10 @@ private void _saveServiceInformation (@Nonnull final ServiceMetadataType aServic
* in case something goes wrong
* @throws SMPClientUnauthorizedException
* The user name or password was not correct.
* @throws SMPClientParticipantNotFoundException
* The service group id does not exist in the network.
* @throws SMPClientNotFoundException
* A HTTP Not Found was received. This can happen if the service was
* not found.
* The service group id or document types did not exist.
* @throws SMPClientBadRequestException
* The request was not well formed.
* @see #saveServiceRedirect(ParticipantIDType, IDType, RedirectType,
Expand Down Expand Up @@ -321,9 +325,10 @@ public void saveServiceEndpoints (@Nonnull final ParticipantIDType aServiceGroup
* in case something goes wrong
* @throws SMPClientUnauthorizedException
* The user name or password was not correct.
* @throws SMPClientParticipantNotFoundException
* The service group id does not exist in the network.
* @throws SMPClientNotFoundException
* A HTTP Not Found was received. This can happen if the service was
* not found.
* The service group id or document types did not exist.
* @throws SMPClientBadRequestException
* The request was not well formed.
* @see #saveServiceEndpoints(ParticipantIDType, IDType, List,
Expand Down Expand Up @@ -368,8 +373,10 @@ public void saveServiceRedirect (@Nonnull final ParticipantIDType aServiceGroupI
* in case something goes wrong
* @throws SMPClientUnauthorizedException
* The user name or password was not correct.
* @throws SMPClientParticipantNotFoundException
* The service group id does not exist in the network.
* @throws SMPClientNotFoundException
* The service meta data object did not exist.
* The service group id or document types did not exist.
* @throws SMPClientBadRequestException
* The request was not well formed.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import com.helger.smpclient.exception.SMPClientBadRequestException;
import com.helger.smpclient.exception.SMPClientException;
import com.helger.smpclient.exception.SMPClientNotFoundException;
import com.helger.smpclient.exception.SMPClientParticipantNotFoundException;
import com.helger.smpclient.exception.SMPClientUnauthorizedException;
import com.helger.smpclient.httpclient.AbstractGenericSMPClient;
import com.helger.smpclient.httpclient.SMPHttpResponseHandlerSigned;
Expand Down Expand Up @@ -157,8 +158,10 @@ public BDXR2ClientReadOnly (@Nonnull final URI aSMPHost)
* in case something goes wrong
* @throws SMPClientUnauthorizedException
* A HTTP Forbidden was received, should not happen.
* @throws SMPClientParticipantNotFoundException
* The service group id does not exist in the network.
* @throws SMPClientNotFoundException
* The service group id did not exist.
* The service group id or document types did not exist.
* @throws SMPClientBadRequestException
* The request was not well formed.
* @see #getServiceGroupOrNull(IParticipantIdentifier)
Expand Down Expand Up @@ -191,7 +194,7 @@ public ServiceGroupType getServiceGroupOrNull (@Nonnull final IParticipantIdenti
{
return getServiceGroup (aServiceGroupID);
}
catch (final SMPClientNotFoundException ex)
catch (final SMPClientNotFoundException | SMPClientParticipantNotFoundException ex)
{
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Found no ServiceGroup");
Expand Down Expand Up @@ -251,8 +254,10 @@ public static ICommonsList <IDocumentTypeIdentifier> getAllDocumentTypes (@Nulla
* in case something goes wrong
* @throws SMPClientUnauthorizedException
* A HTTP Forbidden was received, should not happen.
* @throws SMPClientParticipantNotFoundException
* The service group id does not exist in the network.
* @throws SMPClientNotFoundException
* The service group id or document type did not exist.
* The service group id or document types did not exist.
* @throws SMPClientBadRequestException
* The request was not well formed.
* @see #getServiceMetadataOrNull(IParticipantIdentifier,
Expand Down Expand Up @@ -420,7 +425,7 @@ public ServiceMetadataType getServiceMetadataOrNull (@Nonnull final IParticipant
{
return getServiceMetadata (aServiceGroupID, aDocumentTypeID);
}
catch (final SMPClientNotFoundException ex)
catch (final SMPClientNotFoundException | SMPClientParticipantNotFoundException ex)
{
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Found no ServiceMetadata");
Expand Down Expand Up @@ -567,8 +572,10 @@ public static X509Certificate getEndpointCertificate (@Nullable final EndpointTy
* in case something goes wrong
* @throws SMPClientUnauthorizedException
* A HTTP Forbidden was received, should not happen.
* @throws SMPClientParticipantNotFoundException
* The service group id does not exist in the network.
* @throws SMPClientNotFoundException
* The service group id did not exist.
* The service group id or document types did not exist.
* @throws SMPClientBadRequestException
* The request was not well formed.
* @throws SMPDNSResolutionException
Expand Down Expand Up @@ -600,8 +607,10 @@ public static ServiceGroupType getServiceGroupByDNS (@Nonnull final ISMPURLProvi
* in case something goes wrong
* @throws SMPClientUnauthorizedException
* A HTTP Forbidden was received, should not happen.
* @throws SMPClientParticipantNotFoundException
* The service group id does not exist in the network.
* @throws SMPClientNotFoundException
* The service group id or document type did not exist.
* The service group id or document types did not exist.
* @throws SMPClientBadRequestException
* The request was not well formed.
* @throws SMPDNSResolutionException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@

import org.apache.hc.client5.http.HttpResponseException;

import com.helger.commons.annotation.DevelopersNote;

/**
* This exception is thrown, if the HTTP response was 404.
* This exception is thrown, if the HTTP response was 404. See also
* {@link SMPClientParticipantNotFoundException}.
*
* @author Philip Helger
*/
Expand All @@ -35,11 +38,15 @@ public SMPClientNotFoundException (@Nonnull final HttpResponseException ex)
super (ex);
}

@Deprecated (forRemoval = true, since = "9.4.1")
@DevelopersNote ("Use SMPClientParticipantNotFoundException instead")
public SMPClientNotFoundException (@Nonnull final UnknownHostException ex)
{
super (ex);
}

@Deprecated (forRemoval = true, since = "9.4.1")
@DevelopersNote ("Use SMPClientParticipantNotFoundException instead")
public SMPClientNotFoundException (@Nonnull final ConnectException ex)
{
super (ex);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (C) 2015-2024 Philip Helger
* philip[at]helger[dot]com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.helger.smpclient.exception;

import java.net.ConnectException;
import java.net.UnknownHostException;

import javax.annotation.Nonnull;

/**
* This exception is thrown if a participant was not found on the network
*
* @author Philip Helger
* @since 9.4.1
*/
public class SMPClientParticipantNotFoundException extends SMPClientException
{
public SMPClientParticipantNotFoundException (@Nonnull final UnknownHostException ex)
{
super (ex);
}

public SMPClientParticipantNotFoundException (@Nonnull final ConnectException ex)
{
super (ex);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import com.helger.smpclient.exception.SMPClientBadRequestException;
import com.helger.smpclient.exception.SMPClientException;
import com.helger.smpclient.exception.SMPClientNotFoundException;
import com.helger.smpclient.exception.SMPClientParticipantNotFoundException;
import com.helger.smpclient.exception.SMPClientUnauthorizedException;
import com.helger.xsds.xmldsig.X509DataType;

Expand Down Expand Up @@ -444,9 +445,9 @@ public static SMPClientException getConvertedException (@Nonnull final Exception

// Special case
if (ex instanceof UnknownHostException)
return new SMPClientNotFoundException ((UnknownHostException) ex);
return new SMPClientParticipantNotFoundException ((UnknownHostException) ex);
if (ex instanceof ConnectException)
return new SMPClientNotFoundException ((ConnectException) ex);
return new SMPClientParticipantNotFoundException ((ConnectException) ex);

// For new SMPClientBadResponseException
if (ex instanceof ClientProtocolException && ex.getCause () instanceof SMPClientException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.helger.smpclient.exception.SMPClientBadRequestException;
import com.helger.smpclient.exception.SMPClientException;
import com.helger.smpclient.exception.SMPClientNotFoundException;
import com.helger.smpclient.exception.SMPClientParticipantNotFoundException;
import com.helger.smpclient.exception.SMPClientUnauthorizedException;
import com.helger.smpclient.httpclient.SMPHttpResponseHandlerWriteOperations;
import com.helger.smpclient.peppol.marshal.SMPMarshallerServiceGroupType;
Expand Down Expand Up @@ -208,8 +209,10 @@ public ServiceGroupType saveServiceGroup (@Nonnull final IParticipantIdentifier
* <code>null</code>.
* @throws SMPClientException
* in case something goes wrong
* @throws SMPClientParticipantNotFoundException
* The service group id does not exist in the network.
* @throws SMPClientNotFoundException
* The service group id did not exist.
* The service group id or document types did not exist.
* @throws SMPClientUnauthorizedException
* The user name or password was not correct.
* @throws SMPClientBadRequestException
Expand Down Expand Up @@ -267,9 +270,10 @@ private void _saveServiceInformation (@Nonnull final IParticipantIdentifier aSer
* in case something goes wrong
* @throws SMPClientUnauthorizedException
* The user name or password was not correct.
* @throws SMPClientParticipantNotFoundException
* The service group id does not exist in the network.
* @throws SMPClientNotFoundException
* A HTTP Not Found was received. This can happen if the service was
* not found.
* The service group id or document types did not exist.
* @throws SMPClientBadRequestException
* The request was not well formed.
* @see #saveServiceRedirect(IParticipantIdentifier, IDocumentTypeIdentifier,
Expand Down Expand Up @@ -309,9 +313,10 @@ public void saveServiceInformation (@Nonnull final ServiceInformationType aServi
* in case something goes wrong
* @throws SMPClientUnauthorizedException
* The user name or password was not correct.
* @throws SMPClientParticipantNotFoundException
* The service group id does not exist in the network.
* @throws SMPClientNotFoundException
* A HTTP Not Found was received. This can happen if the service was
* not found.
* The service group id or document types did not exist.
* @throws SMPClientBadRequestException
* The request was not well formed.
* @see #saveServiceInformation(ServiceInformationType,
Expand Down Expand Up @@ -349,8 +354,10 @@ public void saveServiceRedirect (@Nonnull final IParticipantIdentifier aServiceG
* in case something goes wrong
* @throws SMPClientUnauthorizedException
* The user name or password was not correct.
* @throws SMPClientParticipantNotFoundException
* The service group id does not exist in the network.
* @throws SMPClientNotFoundException
* The service meta data object did not exist.
* The service group id or document types did not exist.
* @throws SMPClientBadRequestException
* The request was not well formed.
*/
Expand Down
Loading

0 comments on commit cf86ba3

Please sign in to comment.