1515import java .util .List ;
1616import java .util .Map .Entry ;
1717
18+ import javax .net .ssl .SSLException ;
19+
1820import org .apache .commons .io .IOUtils ;
1921import org .apache .commons .lang .NotImplementedException ;
2022import org .apache .http .HttpHost ;
3537import org .piwigo .remotesync .api .IClient ;
3638import org .piwigo .remotesync .api .IClientConfiguration ;
3739import org .piwigo .remotesync .api .exception .ClientException ;
40+ import org .piwigo .remotesync .api .exception .ClientSSLException ;
3841import org .piwigo .remotesync .api .exception .ClientServerException ;
3942import org .piwigo .remotesync .api .exception .ServerException ;
4043import org .piwigo .remotesync .api .request .AbstractRequest ;
@@ -105,7 +108,7 @@ protected <T extends BasicResponse> T doSendRequest(AbstractRequest<T> request)
105108 }
106109 }
107110
108- protected <T extends BasicResponse > String getXmlResponse (AbstractRequest <T > request ) throws ClientException , ServerException {
111+ protected <T extends BasicResponse > String getXmlResponse (AbstractRequest <T > request ) throws ClientServerException {
109112 CloseableHttpResponse httpResponse = null ;
110113
111114 try {
@@ -115,6 +118,8 @@ protected <T extends BasicResponse> String getXmlResponse(AbstractRequest<T> req
115118 throw new ServerException (httpResponse .getStatusLine ().getReasonPhrase () + " (code " + httpResponse .getStatusLine ().getStatusCode () + ")" );
116119
117120 return IOUtils .toString (httpResponse .getEntity ().getContent (), "UTF-8" );
121+ } catch (ClientServerException e ) {
122+ throw e ;
118123 } catch (Exception e ) {
119124 throw new ClientException ("Unable to read response content" , e );
120125 } finally {
@@ -154,6 +159,8 @@ else if (value instanceof List) {
154159 method .setEntity (multipartEntityBuilder .build ());
155160
156161 return getHttpClient ().execute (method );
162+ } catch (SSLException e ) {
163+ throw new ClientSSLException ("SSL certificate exception (Please use option 'Trust SSL certificates')" , e );
157164 } catch (Exception e ) {
158165 throw new ClientException ("Unable to send request" , e );
159166 }
0 commit comments