4141
4242import ihe .iti .xds_b ._2007 .DocumentRegistryPortType ;
4343import ihe .iti .xds_b ._2007 .DocumentRegistryService ;
44+ import ihe .iti .xds_b ._2007 .UpdateDocumentRegistryPortType ;
45+ import ihe .iti .xds_b ._2007 .UpdateDocumentRegistryService ;
4446import ihe .iti .xds_b ._2010 .XDSDeletetWS ;
4547import ihe .iti .xds_b ._2010 .XDSDeletetWSService ;
4648import it .finanze .sanita .fse2 .ms .iniclient .client .IIniClient ;
5254import it .finanze .sanita .fse2 .ms .iniclient .dto .SubmissionSetEntryDTO ;
5355import it .finanze .sanita .fse2 .ms .iniclient .enums .ActionEnumType ;
5456import it .finanze .sanita .fse2 .ms .iniclient .enums .SearchTypeEnum ;
57+ import it .finanze .sanita .fse2 .ms .iniclient .exceptions .IdDocumentNotFoundException ;
5558import it .finanze .sanita .fse2 .ms .iniclient .exceptions .base .BusinessException ;
5659import it .finanze .sanita .fse2 .ms .iniclient .service .IConfigSRV ;
5760import it .finanze .sanita .fse2 .ms .iniclient .service .ISecuritySRV ;
6770import oasis .names .tc .ebxml_regrep .xsd .lcm ._3 .SubmitObjectsRequest ;
6871import oasis .names .tc .ebxml_regrep .xsd .query ._3 .AdhocQueryRequest ;
6972import oasis .names .tc .ebxml_regrep .xsd .query ._3 .AdhocQueryResponse ;
73+ import oasis .names .tc .ebxml_regrep .xsd .rs ._3 .RegistryError ;
7074import oasis .names .tc .ebxml_regrep .xsd .rs ._3 .RegistryResponseType ;
71- import static it .finanze .sanita .fse2 .ms .iniclient .config .Constants .IniAudit .EVENT_DATE ;
72- import static it .finanze .sanita .fse2 .ms .iniclient .config .Constants .IniAudit .EVENT_TYPE ;
73- import static it .finanze .sanita .fse2 .ms .iniclient .config .Constants .IniAudit .WII ;
74- import static it .finanze .sanita .fse2 .ms .iniclient .enums .EventType .INI_CREATE_SOAP ;
75- import static it .finanze .sanita .fse2 .ms .iniclient .enums .EventType .INI_DELETE_SOAP ;
76- import static it .finanze .sanita .fse2 .ms .iniclient .enums .EventType .INI_REPLACE_SOAP ;
77- import static it .finanze .sanita .fse2 .ms .iniclient .enums .EventType .INI_UPDATE_SOAP ;
78- import static it .finanze .sanita .fse2 .ms .iniclient .enums .EventType .INI_RIFERIMENTO_SOAP ;
79- import static it .finanze .sanita .fse2 .ms .iniclient .enums .EventType .INI_GET_METADATI_SOAP ;
8075
8176/**
8277 * Production implemention of Ini Client.
@@ -108,7 +103,8 @@ public class IniClient implements IIniClient {
108103
109104 private DocumentRegistryPortType recuperoRiferimentoPort ;
110105
111-
106+ private UpdateDocumentRegistryPortType updateDocumentRegistryPort ;
107+
112108 @ PostConstruct
113109 void initialize () {
114110 try {
@@ -124,6 +120,13 @@ void initialize() {
124120 BindingProvider bindingProvider = (BindingProvider ) documentRegistryPort ;
125121 bindingProvider .getRequestContext ().put (BindingProvider .ENDPOINT_ADDRESS_PROPERTY , iniCFG .getUrlWsdlDocumentRegistryService ());
126122 }
123+
124+ UpdateDocumentRegistryService updateDocumentRegistryService = new UpdateDocumentRegistryService ();
125+ updateDocumentRegistryPort = updateDocumentRegistryService .getDocumentRegistryUpdateDocumentSetPortSoap12 ();
126+ if (!StringUtility .isNullOrEmpty (iniCFG .getUrlWsdlUpdateDocumentRegistryService ())) {
127+ BindingProvider bindingProvider = (BindingProvider ) updateDocumentRegistryPort ;
128+ bindingProvider .getRequestContext ().put (BindingProvider .ENDPOINT_ADDRESS_PROPERTY , iniCFG .getUrlWsdlUpdateDocumentRegistryService ());
129+ }
127130
128131 XDSDeletetWSService deletetWSService = new XDSDeletetWSService ();
129132 deletePort = deletetWSService .getXDSDeletetWSSPort ();
@@ -143,6 +146,7 @@ void initialize() {
143146 ((BindingProvider ) documentRegistryPort ).getRequestContext ().put (JAXWSProperties .SSL_SOCKET_FACTORY , sslContext .getSocketFactory ());
144147 ((BindingProvider ) deletePort ).getRequestContext ().put (JAXWSProperties .SSL_SOCKET_FACTORY , sslContext .getSocketFactory ());
145148 ((BindingProvider ) recuperoRiferimentoPort ).getRequestContext ().put (JAXWSProperties .SSL_SOCKET_FACTORY , sslContext .getSocketFactory ());
149+ ((BindingProvider ) updateDocumentRegistryPort ).getRequestContext ().put (JAXWSProperties .SSL_SOCKET_FACTORY , sslContext .getSocketFactory ());
146150 }
147151
148152 SOAPLoggingHandler loggingHandler = new SOAPLoggingHandler (auditIniSrv , configSRV );
@@ -153,6 +157,10 @@ void initialize() {
153157 List <Handler > handlerChainDelete = ((BindingProvider ) deletePort ).getBinding ().getHandlerChain ();
154158 handlerChainDelete .add (loggingHandler );
155159 ((BindingProvider ) deletePort ).getBinding ().setHandlerChain (handlerChainDelete );
160+
161+ List <Handler > handlerChainUpdate = ((BindingProvider ) updateDocumentRegistryPort ).getBinding ().getHandlerChain ();
162+ handlerChainUpdate .add (loggingHandler );
163+ ((BindingProvider ) updateDocumentRegistryPort ).getBinding ().setHandlerChain (handlerChainUpdate );
156164
157165 List <Handler > handlerChainRecuperoRiferimento = ((BindingProvider ) recuperoRiferimentoPort ).getBinding ().getHandlerChain ();
158166 handlerChainRecuperoRiferimento .add (loggingHandler );
@@ -203,27 +211,33 @@ public RegistryResponseType sendDeleteData(DeleteRequestDTO deleteRequestDto, JW
203211
204212 @ Override
205213 public RegistryResponseType sendUpdateV2Data (SubmitObjectsRequest submitObjectsRequest , JWTTokenDTO jwtTokenDTO ,String workflowInstanceId ,Date startingDate ) {
206- return sendUpdateData (submitObjectsRequest ,jwtTokenDTO ,workflowInstanceId ,startingDate ,ActionEnumType .UPDATE_V2 );
214+ log .debug ("Call to INI update " );
215+ List <Header > headers = samlHeaderBuilderUtility .buildHeader (jwtTokenDTO , ActionEnumType .UPDATE_V2 );
216+ WSBindingProvider bp = (WSBindingProvider )updateDocumentRegistryPort ;
217+ bp .setOutboundHeaders (headers );
218+
219+ bp .getRequestContext ().put (WII , workflowInstanceId );
220+ bp .getRequestContext ().put (EVENT_TYPE , INI_UPDATE_SOAP );
221+ bp .getRequestContext ().put (EVENT_DATE , startingDate );
222+ return updateDocumentRegistryPort .documentRegistryUpdateDocumentSet (submitObjectsRequest );
223+ // return sendUpdateData(submitObjectsRequest,jwtTokenDTO,workflowInstanceId,startingDate,ActionEnumType.UPDATE_V2);
207224 }
208225
209226
210227 @ Override
211228 public RegistryResponseType sendUpdateData (SubmitObjectsRequest submitObjectsRequest , JWTTokenDTO jwtTokenDTO ,String workflowInstanceId ,Date startingDate ) {
212- return sendUpdateData (submitObjectsRequest ,jwtTokenDTO ,workflowInstanceId ,startingDate ,ActionEnumType .UPDATE );
213- }
214-
215- private RegistryResponseType sendUpdateData (SubmitObjectsRequest submitObjectsRequest , JWTTokenDTO jwtTokenDTO ,String workflowInstanceId ,Date startingDate ,ActionEnumType actionEnum ) {
216- log .debug ("Call to INI update" );
217- List <Header > headers = samlHeaderBuilderUtility .buildHeader (jwtTokenDTO , actionEnum );
229+ log .debug ("Call to INI update " );
230+ List <Header > headers = samlHeaderBuilderUtility .buildHeader (jwtTokenDTO , ActionEnumType .UPDATE );
218231 WSBindingProvider bp = (WSBindingProvider )documentRegistryPort ;
219232 bp .setOutboundHeaders (headers );
220233
221234 bp .getRequestContext ().put (WII , workflowInstanceId );
222235 bp .getRequestContext ().put (EVENT_TYPE , INI_UPDATE_SOAP );
223236 bp .getRequestContext ().put (EVENT_DATE , startingDate );
224237 return documentRegistryPort .documentRegistryRegisterDocumentSetB (submitObjectsRequest );
238+ // return sendUpdateData(submitObjectsRequest,jwtTokenDTO,workflowInstanceId,startingDate,ActionEnumType.UPDATE);
225239 }
226-
240+
227241 @ Override
228242 public RegistryResponseType sendReplaceData (final DocumentEntryDTO documentEntryDTO , final SubmissionSetEntryDTO submissionSetEntryDTO ,
229243 final JWTTokenDTO jwtTokenDTO , final String uuid ,String workflowInstanceId ,Date startingDate ) {
@@ -291,13 +305,9 @@ public AdhocQueryResponse getReferenceMetadata(String uuid, String tipoRicerca,
291305
292306 StringBuilder sb = new StringBuilder ();
293307 if (response .getRegistryErrorList () != null && !CollectionUtils .isEmpty (response .getRegistryErrorList ().getRegistryError ())) {
294- // for(RegistryError error : response.getRegistryErrorList().getRegistryError()) {
295- // if (error.getCodeContext().equals("No results from the query")) {
296- // throw new IdDocumentNotFoundException("Non è stato possibile recuperare i riferimenti con i dati forniti in input");
297- // } else {
298- // sb.append(error.getCodeContext());
299- // }
300- // }
308+ for (RegistryError error : response .getRegistryErrorList ().getRegistryError ()) {
309+ sb .append ("ERROR_CODE: " +error .getErrorCode () + " ERROR_CONTEXT: " + error .getCodeContext ());
310+ }
301311 throw new BusinessException (sb .toString ());
302312 }
303313 return response ;
0 commit comments