Skip to content

Commit

Permalink
Merge pull request #86 from consiglionazionaledellericerche/84-introd…
Browse files Browse the repository at this point in the history
…urre-un-timeout-configurabile-per-le-chiamate-rest-ad-attestati

Semplificata impostazione timeout chiamate REST verso Attestati.
  • Loading branch information
criluc authored Nov 17, 2023
2 parents f5f8e1b + 6212736 commit 1aeb97c
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions app/manager/attestati/service/CertificationsComunication.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ public class CertificationsComunication {

private static final String OAUTH_TOKEN = "oauth.token.attestati";

private static final String POST_TIMEOUT = "5min";

@Inject
private CacheValues cacheValues;
@Inject
Expand Down Expand Up @@ -295,7 +293,7 @@ private WSRequest prepareOAuthRequest(String token, String url, String contentTy
.setHeader("Content-Type", contentType)
.setHeader("Authorization", "Bearer " + token);

wsRequest.timeout(POST_TIMEOUT);
wsRequest.timeout(getTimeout());
return wsRequest;
}

Expand All @@ -322,7 +320,7 @@ public Set<String> getPeopleList(Office office, int year, int month)
+ "/" + year + "/" + month;

WSRequest wsRequest = prepareOAuthRequest(token, url, JSON_CONTENT_TYPE);
HttpResponse httpResponse = wsRequest.timeout(getTimeout()).get();
HttpResponse httpResponse = wsRequest.get();

// Caso di token non valido
if (httpResponse.getStatus() == Http.StatusCode.UNAUTHORIZED) {
Expand Down Expand Up @@ -362,7 +360,7 @@ public Optional<SeatCertification> getPersonSeatCertification(Person person,
+ "/" + person.getNumber() + "/" + year + "/" + month;

WSRequest wsRequest = prepareOAuthRequest(token, url, JSON_CONTENT_TYPE);
HttpResponse httpResponse = wsRequest.timeout(getTimeout()).get();
HttpResponse httpResponse = wsRequest.get();

// Caso di token non valido
if (httpResponse.getStatus() == Http.StatusCode.UNAUTHORIZED) {
Expand Down Expand Up @@ -424,7 +422,7 @@ public HttpResponse sendRigaAssenza(Certification certification)
String json = new Gson().toJson(riga);
wsRequest.body(json);

return wsRequest.timeout(getTimeout()).post();
return wsRequest.post();
}

/**
Expand All @@ -446,9 +444,9 @@ public HttpResponse sendRigaBuoniPasto(Certification certification,
wsRequest.body(json);

if (update) {
return wsRequest.timeout(getTimeout()).put();
return wsRequest.put();
}
return wsRequest.timeout(getTimeout()).post();
return wsRequest.post();
}

/**
Expand All @@ -468,7 +466,7 @@ public HttpResponse sendRigaFormazione(Certification certification)
String json = new Gson().toJson(riga);
wsRequest.body(json);

return wsRequest.timeout(getTimeout()).post();
return wsRequest.post();
}

/**
Expand All @@ -488,7 +486,7 @@ public HttpResponse sendRigaCompetenza(Certification certification)
String json = new Gson().toJson(riga);
wsRequest.body(json);

return wsRequest.timeout(getTimeout()).post();
return wsRequest.post();
}

/**
Expand All @@ -508,7 +506,7 @@ public HttpResponse deleteRigaAssenza(Certification certification)
String json = new Gson().toJson(rigaAssenza);
wsRequest.body(json);

return wsRequest.timeout(getTimeout()).delete();
return wsRequest.delete();
}

/**
Expand All @@ -528,7 +526,7 @@ public HttpResponse deleteRigaFormazione(Certification certification)
String json = new Gson().toJson(riga);
wsRequest.body(json);

return wsRequest.timeout(getTimeout()).delete();
return wsRequest.delete();
}

/**
Expand All @@ -548,7 +546,7 @@ public HttpResponse deleteRigaCompetenza(Certification certification)
String json = new Gson().toJson(riga);
wsRequest.body(json);

return wsRequest.timeout(getTimeout()).delete();
return wsRequest.delete();
}

/**
Expand All @@ -567,7 +565,7 @@ public List<CodiceAssenza> getAbsencesList() throws ExecutionException {
String url = API_URL + API_URL_ASSENZE_PER_CONTRATTO + "/" + "CL0609";

WSRequest wsRequest = prepareOAuthRequest(token, url, JSON_CONTENT_TYPE);
HttpResponse httpResponse = wsRequest.timeout(getTimeout()).get();
HttpResponse httpResponse = wsRequest.get();

// Caso di token non valido
if (httpResponse.getStatus() == Http.StatusCode.UNAUTHORIZED) {
Expand Down Expand Up @@ -605,7 +603,7 @@ public List<StatoAttestatoMese> getStatoAttestatoMese(Office office, int year, i
+ "/" + year + "/" + month;

WSRequest wsRequest = prepareOAuthRequest(token, url, JSON_CONTENT_TYPE);
HttpResponse httpResponse = wsRequest.timeout(getTimeout()).get();
HttpResponse httpResponse = wsRequest.get();

// Caso di token non valido
if (httpResponse.getStatus() == Http.StatusCode.UNAUTHORIZED) {
Expand Down Expand Up @@ -638,7 +636,7 @@ public PeriodoDipendente getPeriodoDipendente(int periodoId)
final String url = API_URL_INT + API_INT_PERIODO_DIPENDENTE + "/" + periodoId;

WSRequest wsRequest = prepareOAuthRequest(token, url, JSON_CONTENT_TYPE);
HttpResponse httpResponse = wsRequest.timeout(getTimeout()).get();
HttpResponse httpResponse = wsRequest.get();

// Caso di token non valido
if (httpResponse.getStatus() == Http.StatusCode.UNAUTHORIZED) {
Expand Down Expand Up @@ -669,7 +667,7 @@ public CruscottoDipendente getCruscotto(int dipendenteId, int year)
final String url = API_URL_INT + API_INT_CRUSCOTTO + "/" + dipendenteId + "/" + year;

WSRequest wsRequest = prepareOAuthRequest(token, url, JSON_CONTENT_TYPE);
HttpResponse httpResponse = wsRequest.timeout(getTimeout()).get();
HttpResponse httpResponse = wsRequest.get();

// Caso di token non valido
if (httpResponse.getStatus() == Http.StatusCode.UNAUTHORIZED) {
Expand Down Expand Up @@ -703,7 +701,7 @@ public TipoBlocchettoSede getTipoBlocchetto(int year, int month, Office office)
+ "/" + year + "/" + month;

WSRequest wsRequest = prepareOAuthRequest(token, url, JSON_CONTENT_TYPE);
HttpResponse httpResponse = wsRequest.timeout(getTimeout()).get();
HttpResponse httpResponse = wsRequest.get();

// Caso di token non valido
if (httpResponse.getStatus() == Http.StatusCode.UNAUTHORIZED) {
Expand Down

0 comments on commit 1aeb97c

Please sign in to comment.