View Javadoc
1   package fr.ifremer.quadrige3.core.service.http;
2   
3   /*-
4    * #%L
5    * Quadrige3 Core :: Client API
6    * %%
7    * Copyright (C) 2017 - 2019 Ifremer
8    * %%
9    * This program is free software: you can redistribute it and/or modify
10   * it under the terms of the GNU Affero General Public License as published by
11   * the Free Software Foundation, either version 3 of the License, or
12   * (at your option) any later version.
13   * 
14   * This program is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   * GNU General Public License for more details.
18   * 
19   * You should have received a copy of the GNU Affero General Public License
20   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21   * #L%
22   */
23  import com.google.gson.Gson;
24  import fr.ifremer.quadrige3.core.ProgressionCoreModel;
25  import fr.ifremer.quadrige3.core.security.AuthenticationInfo;
26  import org.apache.http.client.methods.HttpPost;
27  import org.apache.http.client.methods.HttpUriRequest;
28  import org.apache.http.entity.mime.content.ContentBody;
29  import org.apache.http.impl.client.CloseableHttpClient;
30  
31  import java.io.File;
32  import java.io.IOException;
33  import java.lang.reflect.Type;
34  import java.net.URI;
35  import java.util.Map;
36  
37  /**
38   * @author peck7 on 02/04/2019.
39   */
40  public interface HttpService {
41  
42      CloseableHttpClient getHttpClient(AuthenticationInfo authenticationInfo);
43  
44      Gson getGson();
45  
46      URI getPathUri(String... paths);
47  
48      void executeRequest(AuthenticationInfo authenticationInfo,
49                          HttpUriRequest request);
50  
51      <T> T executeRequest(AuthenticationInfo authenticationInfo,
52                           HttpUriRequest request,
53                           Class<? extends T> resultClass);
54  
55      <T> T executeRequest(AuthenticationInfo authenticationInfo,
56                           HttpUriRequest request,
57                           Class<? extends T> resultClass,
58                           boolean allowNullResult);
59  
60      <T> T executeRequest(AuthenticationInfo authenticationInfo,
61                           HttpUriRequest request,
62                           Type type);
63  
64      void executeDownloadFileRequest(AuthenticationInfo authenticationInfo,
65                                      HttpUriRequest request,
66                                      ProgressionCoreModel progressionModel,
67                                      File outputFile) throws IOException;
68  
69      void executeUploadFileRequest(AuthenticationInfo authenticationInfo,
70                                    HttpPost request,
71                                    ProgressionCoreModel progressionModel,
72                                    File inputFile,
73                                    Map<String, ContentBody> additionalParts);
74  
75  }