diff --git a/dbcmnpsrc/FE/mnpapp/mockResponse/retrieveSdp18a.json b/dbcmnpsrc/FE/mnpapp/mockResponse/retrieveSdp18a.json new file mode 100644 index 0000000..7a24a0c --- /dev/null +++ b/dbcmnpsrc/FE/mnpapp/mockResponse/retrieveSdp18a.json @@ -0,0 +1,5 @@ +{ + "id": "123", + "rifCliente": "0000000859510539", + "statoCertificazioneCliente": "C" +} \ No newline at end of file diff --git a/dbcmnpsrc/FE/mnpapp/mockResponse/retrieveSdp20b.json b/dbcmnpsrc/FE/mnpapp/mockResponse/retrieveSdp20b.json new file mode 100644 index 0000000..86978fa --- /dev/null +++ b/dbcmnpsrc/FE/mnpapp/mockResponse/retrieveSdp20b.json @@ -0,0 +1,10 @@ +[ + { + "id": "0000000859510539:3920131398", + "numLinea": "3920131398", + "rifCliente": "0000000859510539", + "statoLinea": { + "descrizione": "ATTIVO" + } + } +] \ No newline at end of file diff --git a/dbcmnpsrc/FE/mnpapp/mockResponse/retrieveSdpBU.json b/dbcmnpsrc/FE/mnpapp/mockResponse/retrieveSdpBU.json new file mode 100644 index 0000000..dd9a5a7 --- /dev/null +++ b/dbcmnpsrc/FE/mnpapp/mockResponse/retrieveSdpBU.json @@ -0,0 +1,5 @@ +{ + "cf": "0000000859510539", + "customerCertification": "Y", + "piva": "00859510539" +} \ No newline at end of file diff --git a/dbcmnpsrc/FE/mnpapp/mockResponse/retrieveSdpESO.json b/dbcmnpsrc/FE/mnpapp/mockResponse/retrieveSdpESO.json new file mode 100644 index 0000000..933e4d7 --- /dev/null +++ b/dbcmnpsrc/FE/mnpapp/mockResponse/retrieveSdpESO.json @@ -0,0 +1,50 @@ +{ + "attributi": { + "blocco": { + "anagr": "S", + "fraud": "000", + "fs": "S" + }, + "dati_commerciali": { + "cliente": "DCNFBA80B06F89M", + "marcaggio_cliente": "X" + }, + "descrizione_profilo": "ABBONATO", + "dettaglio_stato": { + "cessazione_mnp": "S" + }, + "esp": "TIM", + "prepagato": "S", + "profilo": "00", + "stato": "PREATTIVO", + "tipologia": "BU", + "usage": { + "main_msisdn": "3245562345", + "value": "MAIN" + } + }, + "carta": { + "icc-id20": "00000000000001313901" + }, + "info": { + "code": "00", + "msg": "OK" + }, + "msisdn": "3631517588", + "risorse_rete": { + "Data_ultima_operazione": "20030502160251", + "stato": "LI", + "tipologia": "A" + }, + "servizi": { + "servizio": [ + { + "attributi_servizio": { + "additional": "3355173796", + "sottoservizio": "BEAR" + }, + "name": "BEAR" + } + ] + } +} \ No newline at end of file diff --git a/dbcmnpsrc/FE/mnpapp/properties/delta_MNP_SM_2460_resources.properties b/dbcmnpsrc/FE/mnpapp/properties/delta_MNP_SM_2460_resources.properties new file mode 100644 index 0000000..498aa29 --- /dev/null +++ b/dbcmnpsrc/FE/mnpapp/properties/delta_MNP_SM_2460_resources.properties @@ -0,0 +1,10 @@ +############### Middleware Modernization 2024: Servizi GISP lotto7 - Authorization HTTP - Basic - BEGIN - ############## + +#La stringa rappresenta la concatenazione della ':' fornite da ESO per l'autenticazione +ESO_RETRIEVE_REST_POST_AUTHBASIC_BASE64 = RVNPX00yTV9TRFA6RXNvW1N0ZzJdLQ== + +#Properties utili SOLO per SVILUPPO (VALORI: 0 = COMUNICAZIONE REST WS, 1 = MOCK RETRIEVE ESO RESPONSE) +ESO_RETRIEVE_REST_POST_MOCK_RESPONSE_ENABLED = 0 +ESO_RETRIEVE_REST_POST_MOCK_RESPONSE=/mnpapp/mockResponse/retrieveSdpESO.json + +############### Middleware Modernization 2024: Servizi GISP lotto7 - Authorization HTTP - Basic - END - ################ \ No newline at end of file diff --git a/dbcmnpsrc/FE/mnpdev/mnp/src/mnp/proxy/ws/WSRestHandler.java b/dbcmnpsrc/FE/mnpdev/mnp/src/mnp/proxy/ws/WSRestHandler.java index 8bef8f9..c95bb2b 100644 --- a/dbcmnpsrc/FE/mnpdev/mnp/src/mnp/proxy/ws/WSRestHandler.java +++ b/dbcmnpsrc/FE/mnpdev/mnp/src/mnp/proxy/ws/WSRestHandler.java @@ -11,6 +11,7 @@ import mnp.utility.DateUtils; import mnp.utility.Func; import mnp.utility.Resources; import org.apache.http.Header; +import org.apache.http.HttpStatus; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; @@ -63,15 +64,25 @@ public class WSRestHandler extends GenericHandler { post.setEntity(postingString); post.setHeaders(headers); response = client.execute(post); - BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); - String line; - while ((line = rd.readLine()) != null) { - jsonString.append(line).append('\n'); + + //check sulla risposta HTTP di ESO + if(response.getStatusLine().getStatusCode() == HttpStatus.SC_OK){ // se 200 + BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); + String line; + while ((line = rd.readLine()) != null) { + jsonString.append(line).append('\n'); + } } + else { //Altrimenti ci aspettiamo solo status code: 401 (Richiesta non autorizzata) o 503 (Non espletata) + log.write("9999","ERRORE REST POST response: " + response.getStatusLine().getStatusCode()); + throw new Exception("HTTP Status Code: " + response.getStatusLine().getStatusCode() +" Reason Phrase: " + response.getStatusLine().getReasonPhrase()); + } + client.close(); response.close(); + } catch (Exception ex) { - log.write("2512","ERRORE POST response"); + log.write("9999","ERRORE REST POST response: " + ex.getMessage()); throw ex; } finally { try { @@ -328,11 +339,26 @@ public class WSRestHandler extends GenericHandler { logWrite("9999", "retrieveESORestPost: INIZIO CHIAMATA SERVIZIO REST"); String risposta = ""; try { - Header[] headers = setHeaderRetrieveESO("retriveESO"); - String url = Resources.getESO_RETRIEVE_REST_POST_URL(); - risposta = restPost(url,headers,requestSdpJson,log); - logWrite("9999", "retrieveESORestPost: url chiamato: "+url); - logWrite("9999", "retrieveESORestPost: FINE CHIAMATA SERVIZIO REST"); + + if("1".equals(Resources.getESO_RETRIEVE_REST_POST_MOCK_RESPONSE_ENABLED())) { + logWrite("9999", "retrieveESO: RETRIEVE ESO MOCK RESPONSE"); + BufferedReader reader = new BufferedReader(new FileReader(Resources.getESO_RETRIEVE_REST_POST_MOCK_RESPONSE())); + try { + String line; + while ((line = reader.readLine()) != null) { + risposta = line; + } + } finally { + reader.close(); + } + } else { + Header[] headers = setHeaderRetrieveESO("retriveESO"); + String url = Resources.getESO_RETRIEVE_REST_POST_URL(); + risposta = restPost(url, headers, requestSdpJson, log); + logWrite("9999", "retrieveESORestPost: url chiamato: " + url); + logWrite("9999", "retrieveESORestPost: FINE CHIAMATA SERVIZIO REST"); + } + } catch (Exception ex) { logWrite("9999", "retrieveESORestPost: ECCEZIONE NELLA CHIAMATA REST:" + " Message: " +ex.getMessage() +" Cause: "+ex.getCause()); throw ex; diff --git a/dbcmnpsrc/FE/mnpdev/mnp/src/mnp/utility/Resources.java b/dbcmnpsrc/FE/mnpdev/mnp/src/mnp/utility/Resources.java index e2adb72..3ef6e96 100644 --- a/dbcmnpsrc/FE/mnpdev/mnp/src/mnp/utility/Resources.java +++ b/dbcmnpsrc/FE/mnpdev/mnp/src/mnp/utility/Resources.java @@ -2521,4 +2521,15 @@ public class Resources { return trim(props.getProperty("ESO_RETRIEVE_REST_POST_AUTHBASIC_BASE64")); } + + public static String getESO_RETRIEVE_REST_POST_MOCK_RESPONSE() { + init(); + return trim(props.getProperty("ESO_RETRIEVE_REST_POST_MOCK_RESPONSE")); + } + + public static String getESO_RETRIEVE_REST_POST_MOCK_RESPONSE_ENABLED() { + init(); + return trim(props.getProperty("ESO_RETRIEVE_REST_POST_MOCK_RESPONSE_ENABLED")); + } + }