Skip to content

Commit

Permalink
Aggiunta prima versione del servizio per la gestione del tracciato pe…
Browse files Browse the repository at this point in the history
…ndenze in formato csv;

Corretti identificativi operazioni verso le API_ENTE.
  • Loading branch information
pintorig committed Aug 1, 2019
1 parent 8728fac commit 8094db2
Show file tree
Hide file tree
Showing 9 changed files with 194 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ addDominio=Configura dominio
addEntrata=Configura entrata
addIntermediario=Configura intermediario
addOperatore=Configura operatore
addPagamento=Notifica pagamento
addPagamento=Richiedi pagamento
addPendenza=Inserisci pendenza
addRiconciliazione=Inserisci riconciliazione
Expand Down Expand Up @@ -88,6 +87,7 @@ nodoInviaAvvisoDigitale=Invia avviso digitale
nodoInviaCarrelloRPT=Invia richiesta di pagamento
nodoInviaRichiestaStorno=Invia richiesta di storno
nodoInviaRPT=Invia pagamento attivato
notifyPagamento=Notifica pagamento
paaAttivaRPT=Attiva pagamento
paaInviaEsitoStorno=Invia esito storno
paaInviaRT=Invia ricevuta di pagamento
Expand All @@ -98,5 +98,7 @@ updatePagamento=Configura pagamento
updatePendenza=Configura pendenza
updateRpp=Configura transazione
updateRuolo=Configura ruolo
verifyPendenza=Verifica pendenza
verifyPendenzaMod4=Verifica pendenza modello 4


Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ Then assert responseStatus == 200 || responseStatus == 201
* def backofficeBaseurl = getGovPayApiBaseUrl({api: 'backoffice', versione: 'v1', autenticazione: 'spid'})
* def spidHeaders = {'X-SPID-FISCALNUMBER': 'RSSMRA30A01H501I','X-SPID-NAME': 'Mario','X-SPID-FAMILYNAME': 'Rossi','X-SPID-EMAIL': 'mrossi@mailserver.host.it'}

Given url backofficeBaseurl
And path '/logout'
And headers spidHeaders
When method get
Then status 200

Given url backofficeBaseurl
And path '/pagamenti', <idPagamento>
And headers spidHeaders
Expand Down
6 changes: 3 additions & 3 deletions jars/client-api-ente/src/main/resources/govpay-api-ec-v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ paths:
$ref: '#/components/responses/500'
'/pendenze/{idA2A}/{idPendenza}':
get:
operationId: getPendenza
operationId: verifyPendenza
summary: Verifica di una pendenza da avviso
tags:
- Verifica
Expand Down Expand Up @@ -91,7 +91,7 @@ paths:
$ref: '#/components/responses/500'
'/pendenze/{idDomino}/{idTipoPendenza}':
post:
operationId: verificaPendenza
operationId: verifyPendenzaMod4
summary: Verifica di una pendenza definita con dati custom
tags:
- Verifica
Expand Down Expand Up @@ -131,7 +131,7 @@ paths:
$ref: '#/components/responses/500'
'/pagamenti/{idDominio}/{iuv}':
post:
operationId: addPagamento
operationId: notifyPagamento
summary: Notifica di un pagamento
tags:
- Notifica
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public PostTracciatoDTO(Authentication user) {
}

private String idDominio;
private String idTipoPendenza;
private String nomeFile;
private byte [] contenuto;
private List<Versamento> inserimenti;
Expand Down Expand Up @@ -72,4 +73,10 @@ public Operatore getOperatore() {
public void setOperatore(Operatore operatore) {
this.operatore = operatore;
}
public String getIdTipoPendenza() {
return idTipoPendenza;
}
public void setIdTipoPendenza(String idTipoPendenza) {
this.idTipoPendenza = idTipoPendenza;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public String getSwaggerOperationId(Notifica notifica, Rpt rpt, BasicBD bd) {
break;
case ATTIVAZIONE:
case RICEVUTA:
swaggerOperationID = "addPagamento";
swaggerOperationID = "notifyPagamento";
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public Versamento invoke(String codVersamentoEnte, String bundlekey, String codU

if(iuv == null) {
path = "/pendenze/" + this.codApplicazione + "/" + codVersamentoEnte;
swaggerOperationID = "getPendenza";
swaggerOperationID = "verifyPendenza";
} else {
path = "/avvisi/" + codDominio + "/" + iuv;
}
Expand Down Expand Up @@ -229,7 +229,7 @@ public Versamento invokeInoltro(String codDominio, String codTipoVersamento, Str
List<Property> headerProperties = new ArrayList<>();
headerProperties.add(new Property("Accept", "application/json"));
String jsonResponse = "";
String swaggerOperationID = "verificaPendenza";
String swaggerOperationID = "verifyPendenzaMod4";
String path = "/pendenze/" + codDominio + "/" + codTipoVersamento;

PendenzaVerificata pendenzaVerificata = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ public Response updatePendenza(@Context UriInfo uriInfo, @Context HttpHeaders ht
return this.controller.pendenzeIdA2AIdPendenzaPATCH(this.getUser(), uriInfo, httpHeaders, idA2A, idPendenza, is,true);
}


@POST
@Path("/tracciati/{idDominio}/{idTipoPendenza}")
@Consumes({ "text/csv", "multipart/form-data" })
@Produces({ "application/json" })
public Response addTracciatoPendenze(@Context UriInfo uriInfo, @Context HttpHeaders httpHeaders, java.io.InputStream is, @PathParam("idDominio") String idDominio, @PathParam("idTipoPendenza") String idTipoPendenza, @QueryParam("avvisaturaDigitale") Boolean avvisaturaDigitale, @QueryParam("modalitaAvvisaturaDigitale") ModalitaAvvisaturaDigitale modalitaAvvisaturaDigitale){
this.controller.setContext(this.getContext());
return this.controller.pendenzeTracciatiIdDominioIdTipoPendenzaPOST(this.getUser(), uriInfo, httpHeaders, is, idDominio, idTipoPendenza, avvisaturaDigitale, modalitaAvvisaturaDigitale);
}

@PUT
@Path("/{idA2A}/{idPendenza}")
@Consumes({ "application/json" })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,8 @@ public Response pendenzePOST(Authentication user, UriInfo uriInfo, HttpHeaders h
}
}



public Response pendenzeIdDominioIdTipoPendenzaPOST(Authentication user, UriInfo uriInfo, HttpHeaders httpHeaders , String idDominio, String idTipoPendenza, java.io.InputStream is, Boolean stampaAvviso, Boolean avvisaturaDigitale, ModalitaAvvisaturaDigitale modalitaAvvisaturaDigitale) {
String methodName = "pendenzeIdDominioIdTipoPendenzaPOST";
String transactionId = this.context.getTransactionId();
Expand Down Expand Up @@ -565,7 +567,105 @@ public Response pendenzeTracciatiPOST(Authentication user, UriInfo uriInfo, Http
}
}

public Response pendenzeTracciatiIdDominioIdTipoPendenzaPOST(Authentication user, UriInfo uriInfo, HttpHeaders httpHeaders , java.io.InputStream is, String idDominio, String idTipoPendenza, Boolean avvisaturaDigitale, ModalitaAvvisaturaDigitale modalitaAvvisaturaDigitale) {
String methodName = "pendenzeTracciatiIdDominioIdTipoPendenzaPOST";
String transactionId = this.context.getTransactionId();

this.log.debug(MessageFormat.format(BaseController.LOG_MSG_ESECUZIONE_METODO_IN_CORSO, methodName));

try(ByteArrayOutputStream baos= new ByteArrayOutputStream();){

String contentTypeBody = null;
if(httpHeaders.getRequestHeaders().containsKey("Content-Type")) {
contentTypeBody = httpHeaders.getRequestHeaders().get("Content-Type").get(0);
}

this.log.debug(MessageFormat.format("Content-Type della richiesta: {0}.", contentTypeBody));


String fileName = null;
InputStream fileInputStream = null;
try{
// controllo se sono in una richiesta multipart
if(contentTypeBody != null && contentTypeBody.startsWith("multipart")) {
javax.mail.internet.ContentType cType = new javax.mail.internet.ContentType(contentTypeBody);
this.log.debug(MessageFormat.format("Content-Type Boundary: [{0}]", cType.getParameter("boundary")));

MimeMultipart mimeMultipart = new MimeMultipart(is,contentTypeBody);

for(int i = 0 ; i < mimeMultipart.countBodyParts() ; i ++) {
BodyPart bodyPart = mimeMultipart.getBodyPart(i);
fileName = getBodyPartFileName(bodyPart);

if(fileName != null) {
fileInputStream = bodyPart.getInputStream();
break;
}
}

if(fileInputStream != null) {
IOUtils.copy(fileInputStream, baos);
}
}
}catch(Exception e) {
this.log.error(e.getMessage(),e);
}

if(fileInputStream == null) {
// salvo il json ricevuto
IOUtils.copy(is, baos);
}

// autorizzazione sulla API
this.isAuthorized(user, Arrays.asList(TIPO_UTENZA.OPERATORE, TIPO_UTENZA.APPLICAZIONE), Arrays.asList(Servizio.PENDENZE), Arrays.asList(Diritti.SCRITTURA));

ValidatoreIdentificativi validatoreId = ValidatoreIdentificativi.newInstance();
validatoreId.validaIdDominio("idDominio", idDominio);
validatoreId.validaIdTipoVersamento("idTipoPendenza", idTipoPendenza);

// controllo che il dominio e tipo versamento siano autorizzati
if(!AuthorizationManager.isTipoVersamentoDominioAuthorized(user, idDominio, idTipoPendenza)) {
throw AuthorizationManager.toNotAuthorizedException(user, idDominio, idTipoPendenza);
}

// String jsonRequest = baos.toString();
// TracciatoPendenzePost tracciatoPendenzeRequest = JSONSerializable.parse(jsonRequest, TracciatoPendenzePost.class);
//
// tracciatoPendenzeRequest.validate();

TracciatiDAO tracciatiDAO = new TracciatiDAO();

PostTracciatoDTO postTracciatoDTO = new PostTracciatoDTO(user);

postTracciatoDTO.setIdDominio(idDominio);
postTracciatoDTO.setIdTipoPendenza(idTipoPendenza);
postTracciatoDTO.setNomeFile(idDominio + "_" + idTipoPendenza);
postTracciatoDTO.setAvvisaturaDigitale(avvisaturaDigitale);
if(modalitaAvvisaturaDigitale != null) {
ModoAvvisatura modoAvvisatura = modalitaAvvisaturaDigitale.equals(ModalitaAvvisaturaDigitale.ASINCRONA) ? ModoAvvisatura.ASICNRONA : ModoAvvisatura.SINCRONA;
postTracciatoDTO.setAvvisaturaModalita(modoAvvisatura );
}
postTracciatoDTO.setContenuto(baos.toByteArray());

GovpayLdapUserDetails userDetails = AutorizzazioneUtils.getAuthenticationDetails(user);
Operatore operatore = userDetails.getOperatore();
postTracciatoDTO.setOperatore(operatore);

PostTracciatoDTOResponse postTracciatoDTOResponse = tracciatiDAO.create(postTracciatoDTO);

TracciatoPendenzeIndex rsModel = TracciatiConverter.toTracciatoPendenzeRsModelIndex(postTracciatoDTOResponse.getTracciato());

Status responseStatus = Status.CREATED;
this.log.debug(MessageFormat.format(BaseController.LOG_MSG_ESECUZIONE_METODO_COMPLETATA, methodName));
return this.handleResponseOk(Response.status(responseStatus),transactionId).entity(rsModel.toJSON(null,this.serializationConfig)).build();
}catch (Exception e) {
return this.handleException(uriInfo, httpHeaders, methodName, e, transactionId);
} finally {
this.log(this.context);
}
}



public Response pendenzeTracciatiGET(Authentication user, UriInfo uriInfo, HttpHeaders httpHeaders , Integer pagina, Integer risultatiPerPagina, String idDominio, StatoTracciatoPendenza stato) {
String methodName = "pendenzeTracciatiGET";
Expand Down Expand Up @@ -803,7 +903,6 @@ public Response pendenzeTracciatiIdRichiestaGET(Authentication user, UriInfo uri
}



public Response pendenzeTracciatiIdStampeGET(Authentication user, UriInfo uriInfo, HttpHeaders httpHeaders , Integer id) {
String methodName = "pendenzeTracciatiIdStampeGET";
String transactionId = this.context.getTransactionId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,68 @@ paths:
$ref: '#/components/responses/403'
'500':
$ref: '#/components/responses/500'
'/pendenze/tracciati/{idDominio}/{idTipoPendenza}':
post:
tags:
- Pendenze
summary: Aggiunge un nuovo Tracciato di Pendenze in formato csv
parameters:
- in: path
name: idDominio
description: Identificativo dente creditore
required: true
schema:
type: string
- in: path
name: idTipoPendenza
description: Identificativo della tipologia pendenza
required: true
schema:
type: string
- in: query
name: avvisaturaDigitale
description: Indica se la pendenza deve essere avvisata digitalmente
required: false
schema:
type: boolean
default: false
- in: query
name: modalitaAvvisaturaDigitale
description: Modalita' di avvisatura scelta per le pendenza
required: false
schema:
$ref: '#/components/schemas/modalitaAvvisaturaDigitale'
requestBody:
content:
text/csv:
schema:
type: object
multipart/form-data:
schema:
type: object
properties:
fileName:
type: string
format: binary
description: Tracciato Pendenze in formato CSV
required: true
responses:
'201':
description: Tracciato aggiunto con successo
content:
application/json:
schema:
$ref: '#/components/schemas/tracciatoPendenzeIndex'
'400':
$ref: '#/components/responses/400'
'401':
$ref: '#/components/responses/401'
'403':
$ref: '#/components/responses/403'
'415':
$ref: '#/components/responses/415'
'500':
$ref: '#/components/responses/500'
'/tracciati':
get:
tags:
Expand Down

0 comments on commit 8094db2

Please sign in to comment.