forked from Hakky54/mutual-tls-ssl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OldJerseyClientService.java
35 lines (25 loc) 路 1.03 KB
/
OldJerseyClientService.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package nl.altindag.client.service;
import static nl.altindag.client.ClientType.OLD_JERSEY_CLIENT;
import static nl.altindag.client.Constants.HEADER_KEY_CLIENT_TYPE;
import org.springframework.stereotype.Service;
import com.sun.jersey.api.client.Client;
import nl.altindag.client.ClientType;
import nl.altindag.client.model.ClientResponse;
@Service
public class OldJerseyClientService implements RequestService {
private final Client client;
public OldJerseyClientService(Client client) {
this.client = client;
}
@Override
public ClientResponse executeRequest(String url) {
com.sun.jersey.api.client.ClientResponse clientResponse = client.resource(url)
.header(HEADER_KEY_CLIENT_TYPE, getClientType().getValue())
.get(com.sun.jersey.api.client.ClientResponse.class);
return new ClientResponse(clientResponse.getEntity(String.class), clientResponse.getStatus());
}
@Override
public ClientType getClientType() {
return OLD_JERSEY_CLIENT;
}
}