Search in sources :

Example 16 with StorageObject

use of it.cnr.si.spring.storage.StorageObject in project sigla-main by consiglionazionaledellericerche.

the class ContrattoService method findAllegatiContratto.

public List<AllegatoContrattoDocumentBulk> findAllegatiContratto(ContrattoBulk contratto) throws ApplicationException {
    List<AllegatoContrattoDocumentBulk> result = new ArrayList<AllegatoContrattoDocumentBulk>();
    List<StorageObject> children = findNodeAllegatiContratto(contratto);
    if (children != null) {
        for (StorageObject child : children) {
            if (!contratto.isFromFlussoAcquisti()) {
                AllegatoContrattoDocumentBulk allegato = AllegatoContrattoDocumentBulk.construct(child);
                allegato.setContentType(child.<String>getPropertyValue(StoragePropertyNames.CONTENT_STREAM_MIME_TYPE.value()));
                allegato.setNome(child.<String>getPropertyValue("sigla_contratti_attachment:original_name"));
                allegato.setDescrizione(child.<String>getPropertyValue(StoragePropertyNames.DESCRIPTION.value()));
                allegato.setTitolo(child.<String>getPropertyValue(StoragePropertyNames.TITLE.value()));
                allegato.setType(child.<String>getPropertyValue(StoragePropertyNames.OBJECT_TYPE_ID.value()));
                allegato.setLink(child.<String>getPropertyValue("sigla_contratti_aspect_link:url"));
                allegato.setCrudStatus(OggettoBulk.NORMAL);
                result.add(allegato);
            }
        }
    }
    return result;
}
Also used : AllegatoContrattoDocumentBulk(it.cnr.contab.config00.contratto.bulk.AllegatoContrattoDocumentBulk) StorageObject(it.cnr.si.spring.storage.StorageObject)

Example 17 with StorageObject

use of it.cnr.si.spring.storage.StorageObject in project sigla-main by consiglionazionaledellericerche.

the class ContrattoService method changeProgressivoNodeRef.

public void changeProgressivoNodeRef(StorageObject oldStorageObject, ContrattoBulk contratto) throws ApplicationException {
    List<StorageObject> children = getChildren(oldStorageObject.getKey());
    for (StorageObject child : children) {
        AllegatoContrattoDocumentBulk allegato = AllegatoContrattoDocumentBulk.construct(child);
        allegato.setNome(child.<String>getPropertyValue("sigla_contratti_attachment:original_name"));
        allegato.setType(child.<String>getPropertyValue(StoragePropertyNames.OBJECT_TYPE_ID.value()));
        allegato.setTitolo(child.<String>getPropertyValue(StoragePropertyNames.TITLE.value()));
        allegato.setDescrizione(child.<String>getPropertyValue(StoragePropertyNames.DESCRIPTION.value()));
        allegato.setContrattoBulk(contratto);
        updateProperties(allegato, child);
        if (contratto.isDefinitivo() && !allegato.getType().equals(AllegatoContrattoDocumentBulk.GENERICO))
            costruisciAlberaturaAlternativa(allegato, child);
    }
    updateProperties(contratto, oldStorageObject);
}
Also used : AllegatoContrattoDocumentBulk(it.cnr.contab.config00.contratto.bulk.AllegatoContrattoDocumentBulk) StorageObject(it.cnr.si.spring.storage.StorageObject)

Example 18 with StorageObject

use of it.cnr.si.spring.storage.StorageObject in project sigla-main by consiglionazionaledellericerche.

the class CRUDDistintaCassiereBP method invia.

public void invia(ActionContext context, FirmaOTPBulk firmaOTPBulk) throws Exception {
    Map<String, String> subjectDN = Optional.ofNullable(SpringUtil.getBean("documentiContabiliService", DocumentiContabiliService.class).getCertSubjectDN(firmaOTPBulk.getUserName(), firmaOTPBulk.getPassword())).orElseThrow(() -> new ApplicationException("Errore nella lettura dei certificati!\nVerificare Nome Utente e Password!"));
    if (Optional.ofNullable(controlloCodiceFiscale).filter(s -> s.equalsIgnoreCase("Y")).isPresent()) {
        SpringUtil.getBean("documentiContabiliService", DocumentiContabiliService.class).controllaCodiceFiscale(subjectDN, ((CNRUserInfo) context.getUserInfo()).getUtente());
    }
    if (!this.isFlusso() && !this.isAnnulli() && isAttivoSiopeplus()) {
        Distinta_cassiereBulk distintaProvvisoria = (Distinta_cassiereBulk) getModel();
        // spostato nel salva definitivo anche in questo caso
        StorageObject distintaStorageObject = Optional.ofNullable(distintaProvvisoria.getPg_distinta_def()).map(paDistintaDef -> documentiContabiliService.getStorageObjectByPath(distintaProvvisoria.getStorePath().concat(StorageDriver.SUFFIX).concat(distintaProvvisoria.getCMISName()))).orElse(inviaDistinta(context, distintaProvvisoria));
        Distinta_cassiereBulk distinta = (Distinta_cassiereBulk) getModel();
        List<String> nodes = new ArrayList<String>();
        nodes.add(distintaStorageObject.getPropertyValue(StoragePropertyNames.ALFCMIS_NODEREF.value()));
        List<V_mandato_reversaleBulk> dettagliRev = ((DistintaCassiereComponentSession) createComponentSession()).dettagliDistinta(context.getUserContext(), distinta, it.cnr.contab.doccont00.core.bulk.Numerazione_doc_contBulk.TIPO_REV);
        dettagliRev.stream().map(v_mandato_reversaleBulk -> documentiContabiliService.getDocumentKey(v_mandato_reversaleBulk, true)).filter(s -> s != null).forEach(s -> nodes.add(s));
        List<V_mandato_reversaleBulk> dettagliMan = ((DistintaCassiereComponentSession) createComponentSession()).dettagliDistinta(context.getUserContext(), distinta, it.cnr.contab.doccont00.core.bulk.Numerazione_doc_contBulk.TIPO_MAN);
        dettagliMan.stream().map(v_mandato_reversaleBulk -> documentiContabiliService.getDocumentKey(v_mandato_reversaleBulk, true)).filter(s -> s != null).forEach(s -> nodes.add(s));
        PdfSignApparence pdfSignApparence = new PdfSignApparence();
        pdfSignApparence.setNodes(nodes);
        pdfSignApparence.setUsername(firmaOTPBulk.getUserName());
        pdfSignApparence.setPassword(firmaOTPBulk.getPassword());
        pdfSignApparence.setOtp(firmaOTPBulk.getOtp());
        Apparence apparence = new Apparence(null, "Rome", "Firma ", "per invio all'Istituto cassiere\nFirmato dal " + getTitolo() + "\n" + subjectDN.get("GIVENNAME") + " " + subjectDN.get("SURNAME"), 400, 120, 1, 550, 80);
        // 300, 40,  1, 550, 80);
        pdfSignApparence.setApparence(apparence);
        try {
            documentiContabiliService.signDocuments(pdfSignApparence, "service/sigla/firma/doccont");
        } catch (StorageException _ex) {
            throw new ApplicationException(FirmaOTPBulk.errorMessage(_ex.getMessage()));
        }
        try {
            if (!this.isAnnulli()) {
                if (distinta.getEsercizio() != null && distinta.getPg_distinta_def() != null)
                    documentiContabiliService.inviaDistintaPEC(nodes, this.isSepa(), distinta.getEsercizio() + "/" + distinta.getPg_distinta_def());
                else
                    documentiContabiliService.inviaDistintaPEC(nodes, this.isSepa(), null);
            }
            distinta.setDt_invio_pec(DateServices.getDt_valida(context.getUserContext()));
            distinta.setUser(context.getUserContext().getUser());
            distinta.setToBeUpdated();
            setModel(context, createComponentSession().modificaConBulk(context.getUserContext(), distinta));
            commitUserTransaction();
            setMessage("Invio effettuato correttamente.");
        } catch (IOException e) {
            throw new BusinessProcessException(e);
        } catch (Exception e) {
            throw new BusinessProcessException(e);
        }
    } else {
        Distinta_cassiereBulk distinta = (Distinta_cassiereBulk) getModel();
        generaXML(context);
        File file = new File(System.getProperty("tmp.dir.SIGLAWeb") + getFile());
        StorageFile storageFile = new StorageFile(file, file.getName());
        if (storageFile != null) {
            // E' previsto solo l'inserimento ma non l'aggiornamento
            try {
                StorageObject storageObject = documentiContabiliService.restoreSimpleDocument(storageFile, storageFile.getInputStream(), storageFile.getContentType(), storageFile.getFileName(), distinta.getStorePath(), false);
                storageFile.setStorageObject(storageObject);
            } catch (StorageException e) {
                if (e.getType().equals(StorageException.Type.CONSTRAINT_VIOLATED))
                    throw new ApplicationException("File [" + storageFile.getFileName() + "] già presente o non completo di tutte le proprietà obbligatorie. Inserimento non possibile!");
                throw new ApplicationException("Errore nella registrazione del file XML sul Documentale (" + e.getMessage() + ")");
            }
            if (storageFile.getStorageObject().<BigInteger>getPropertyValue(StoragePropertyNames.CONTENT_STREAM_LENGTH.value()).intValue() > 0) {
                Optional.ofNullable(documentiContabiliService.getStorageObjectByPath(distinta.getStorePath().concat(StorageDriver.SUFFIX).concat(String.valueOf(distinta.getEsercizio())).concat("-").concat(distinta.getCd_unita_organizzativa()).concat("-").concat(String.valueOf(distinta.getPg_distinta_def())).concat("-I.").concat(formatoflusso).concat(".p7m"))).ifPresent(storageObject -> documentiContabiliService.delete(storageObject));
                String nomeFile = file.getName();
                String nomeFileP7m = nomeFile + ".p7m";
                SignP7M signP7M = new SignP7M(storageFile.getStorageObject().getPropertyValue(StoragePropertyNames.ALFCMIS_NODEREF.value()), firmaOTPBulk.getUserName(), firmaOTPBulk.getPassword(), firmaOTPBulk.getOtp(), nomeFileP7m);
                try {
                    final String signDocument = documentiContabiliService.signDocuments(signP7M, "service/sigla/firma/p7m", distinta.getStorePath());
                    documentiContabiliService.inviaDistintaPEC(Arrays.asList(signDocument), this.isSepa(), "<acquisizione_flusso_ordinativi_sepa>");
                    distinta.setDt_invio_pec(DateServices.getDt_valida(context.getUserContext()));
                    distinta.setUser(context.getUserContext().getUser());
                    distinta.setToBeUpdated();
                    final OggettoBulk oggettoBulk = createComponentSession().modificaConBulk(context.getUserContext(), distinta);
                    commitUserTransaction();
                    initializeModelForEdit(context, oggettoBulk);
                    setMessage("Invio effettuato correttamente.");
                } catch (StorageException _ex) {
                    throw new ApplicationException(FirmaOTPBulk.errorMessage(_ex.getMessage()));
                }
            } else {
                throw new ApplicationException("Errore durante il processo di firma elettronica. Ripetere l'operazione di firma!");
            }
        }
    }
}
Also used : ObjectFactory(it.cnr.contab.doccont00.intcass.xmlbnl.ObjectFactory) Format(java.text.Format) ServletException(javax.servlet.ServletException) LoggerFactory(org.slf4j.LoggerFactory) ActionContext(it.cnr.jada.action.ActionContext) DatatypeFactory(javax.xml.datatype.DatatypeFactory) Button(it.cnr.jada.util.jsp.Button) StatoTrasmissione(it.cnr.contab.doccont00.intcass.bulk.StatoTrasmissione) BigDecimal(java.math.BigDecimal) StorageException(it.cnr.si.spring.storage.StorageException) FlussoOrdinativi(it.cnr.contab.doccont00.intcass.xmlbnl.FlussoOrdinativi) DistintaCassiereComponent(it.cnr.contab.doccont00.comp.DistintaCassiereComponent) Reversale(it.cnr.contab.doccont00.intcass.xmlbnl.Reversale) DatatypeConstants(javax.xml.datatype.DatatypeConstants) XmlSignatureType(it.cnr.si.firmadigitale.firma.arss.stub.XmlSignatureType) BigInteger(java.math.BigInteger) PrintService(it.cnr.contab.reports.service.PrintService) Print_spooler_paramBulk(it.cnr.contab.reports.bulk.Print_spooler_paramBulk) StorageObject(it.cnr.si.spring.storage.StorageObject) it.cnr.contab.util(it.cnr.contab.util) EJBCommonServices(it.cnr.jada.util.ejb.EJBCommonServices) Risultato(it.cnr.si.siopeplus.model.Risultato) Parametri_cnrBulk(it.cnr.contab.config00.bulk.Parametri_cnrBulk) Collectors(java.util.stream.Collectors) OrdinativiSiopePlusService(it.cnr.si.siopeplus.service.OrdinativiSiopePlusService) RemoteException(java.rmi.RemoteException) BusinessProcessException(it.cnr.jada.action.BusinessProcessException) FirmaOTPBulk(it.cnr.contab.firma.bulk.FirmaOTPBulk) StorageDriver(it.cnr.si.spring.storage.StorageDriver) IOUtils(org.apache.commons.io.IOUtils) AbstractPrintBP(it.cnr.jada.util.action.AbstractPrintBP) SAXException(org.xml.sax.SAXException) StoragePropertyNames(it.cnr.si.spring.storage.config.StoragePropertyNames) AnagraficoBulk(it.cnr.contab.anagraf00.core.bulk.AnagraficoBulk) SpringUtil(it.cnr.contab.service.SpringUtil) ArubaSignServiceClient(it.cnr.si.firmadigitale.firma.arss.ArubaSignServiceClient) UserContext(it.cnr.jada.UserContext) HttpActionContext(it.cnr.jada.action.HttpActionContext) Classificazione(it.cnr.contab.doccont00.intcass.xmlbnl.Mandato.InformazioniBeneficiario.Classificazione) OggettoBulk(it.cnr.jada.bulk.OggettoBulk) java.util(java.util) Unita_organizzativaBulk(it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk) V_mandato_reversaleBulk(it.cnr.contab.doccont00.intcass.bulk.V_mandato_reversaleBulk) PageContext(javax.servlet.jsp.PageContext) Marshaller(javax.xml.bind.Marshaller) DistintaCassiereComponentSession(it.cnr.contab.doccont00.ejb.DistintaCassiereComponentSession) SimpleDateFormat(java.text.SimpleDateFormat) Configurazione_cnrBulk(it.cnr.contab.config00.bulk.Configurazione_cnrBulk) HttpServletRequest(javax.servlet.http.HttpServletRequest) AllegatiCRUDBP(it.cnr.contab.util00.bp.AllegatiCRUDBP) CRUDComponentSession(it.cnr.jada.ejb.CRUDComponentSession) DocumentiContabiliService(it.cnr.contab.doccont00.service.DocumentiContabiliService) BancaBulk(it.cnr.contab.anagraf00.core.bulk.BancaBulk) RemoteIterator(it.cnr.jada.util.RemoteIterator) SIOPEPlusServiceUnavailable(it.cnr.si.siopeplus.exception.SIOPEPlusServiceUnavailable) Distinta_cassiereBulk(it.cnr.contab.doccont00.intcass.bulk.Distinta_cassiereBulk) RemoteDetailCRUDController(it.cnr.jada.util.action.RemoteDetailCRUDController) JAXBContext(javax.xml.bind.JAXBContext) VDocumentiFlussoBulk(it.cnr.contab.doccont00.intcass.bulk.VDocumentiFlussoBulk) AbilitatoFirma(it.cnr.contab.utenze00.bulk.AbilitatoFirma) CNRUserContext(it.cnr.contab.utenze00.bp.CNRUserContext) Configurazione_cnrComponentSession(it.cnr.contab.config00.ejb.Configurazione_cnrComponentSession) ApplicationException(it.cnr.jada.comp.ApplicationException) Logger(org.slf4j.Logger) Rif_modalita_pagamentoBulk(it.cnr.contab.anagraf00.tabrif.bulk.Rif_modalita_pagamentoBulk) Print_spoolerBulk(it.cnr.contab.reports.bulk.Print_spoolerBulk) HttpServletResponse(javax.servlet.http.HttpServletResponse) UtenteFirmaDettaglioBulk(it.cnr.contab.utenze00.bulk.UtenteFirmaDettaglioBulk) MandatoBulk(it.cnr.contab.doccont00.core.bulk.MandatoBulk) StorageFile(it.cnr.si.spring.storage.bulk.StorageFile) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) AllegatoGenericoBulk(it.cnr.contab.util00.bulk.storage.AllegatoGenericoBulk) DateServices(it.cnr.contab.doccont00.comp.DateServices) Report(it.cnr.contab.reports.bulk.Report) ArubaSignServiceException(it.cnr.si.firmadigitale.firma.arss.ArubaSignServiceException) CNRUserInfo(it.cnr.contab.utenze00.bulk.CNRUserInfo) MimeTypes(it.cnr.si.spring.storage.MimeTypes) java.io(java.io) UtenteComponentSession(it.cnr.contab.utente00.ejb.UtenteComponentSession) JSPUtils(it.cnr.jada.util.jsp.JSPUtils) DateTimeFormatter(java.time.format.DateTimeFormatter) StatoVariazioneSostituzione(it.cnr.contab.util.enumeration.StatoVariazioneSostituzione) Liquid_coriComponentSession(it.cnr.contab.cori00.ejb.Liquid_coriComponentSession) ReversaleBulk(it.cnr.contab.doccont00.core.bulk.ReversaleBulk) Mandato(it.cnr.contab.doccont00.intcass.xmlbnl.Mandato) OfflineReportPrintBP(it.cnr.contab.reports.bp.OfflineReportPrintBP) ComponentException(it.cnr.jada.comp.ComponentException) CompoundFindClause(it.cnr.jada.persistency.sql.CompoundFindClause) DocumentiContabiliService(it.cnr.contab.doccont00.service.DocumentiContabiliService) StorageObject(it.cnr.si.spring.storage.StorageObject) OggettoBulk(it.cnr.jada.bulk.OggettoBulk) BusinessProcessException(it.cnr.jada.action.BusinessProcessException) ServletException(javax.servlet.ServletException) StorageException(it.cnr.si.spring.storage.StorageException) RemoteException(java.rmi.RemoteException) BusinessProcessException(it.cnr.jada.action.BusinessProcessException) SAXException(org.xml.sax.SAXException) ApplicationException(it.cnr.jada.comp.ApplicationException) ArubaSignServiceException(it.cnr.si.firmadigitale.firma.arss.ArubaSignServiceException) ComponentException(it.cnr.jada.comp.ComponentException) ApplicationException(it.cnr.jada.comp.ApplicationException) V_mandato_reversaleBulk(it.cnr.contab.doccont00.intcass.bulk.V_mandato_reversaleBulk) Distinta_cassiereBulk(it.cnr.contab.doccont00.intcass.bulk.Distinta_cassiereBulk) DistintaCassiereComponentSession(it.cnr.contab.doccont00.ejb.DistintaCassiereComponentSession) StorageFile(it.cnr.si.spring.storage.bulk.StorageFile) BigInteger(java.math.BigInteger) StorageException(it.cnr.si.spring.storage.StorageException) StorageFile(it.cnr.si.spring.storage.bulk.StorageFile)

Example 19 with StorageObject

use of it.cnr.si.spring.storage.StorageObject in project sigla-main by consiglionazionaledellericerche.

the class CRUDDistintaCassiereBP method scaricaDistinta.

public void scaricaDistinta(ActionContext actioncontext) throws Exception {
    Distinta_cassiereBulk distinta = (Distinta_cassiereBulk) getModel();
    final HttpActionContext httpActionContext = (HttpActionContext) actioncontext;
    Optional.ofNullable(this.getParametriCnr()).map(Parametri_cnrBulk::getFl_tesoreria_unica).filter(tesoreriaUnica -> tesoreriaUnica.equals(Boolean.TRUE)).ifPresent(tesoreriaUnica -> {
        Optional.ofNullable(documentiContabiliService.getStorageObjectByPath(distinta.getStorePath().concat(StorageDriver.SUFFIX).concat(String.valueOf(distinta.getEsercizio())).concat("-").concat(distinta.getCd_unita_organizzativa()).concat("-").concat(String.valueOf(distinta.getPg_distinta_def())).concat("-I.").concat(formatoflusso))).ifPresent(storageObject -> {
            httpActionContext.getResponse().setCharacterEncoding("UTF-8");
            httpActionContext.getResponse().setContentType(storageObject.getPropertyValue(StoragePropertyNames.CONTENT_STREAM_MIME_TYPE.value()));
            httpActionContext.getResponse().setDateHeader("Expires", 0);
            try {
                IOUtils.copyLarge(documentiContabiliService.getResource(storageObject), httpActionContext.getResponse().getOutputStream());
            } catch (IOException e) {
                throw new StorageException(StorageException.Type.GENERIC, e);
            }
        });
    });
}
Also used : ObjectFactory(it.cnr.contab.doccont00.intcass.xmlbnl.ObjectFactory) Format(java.text.Format) ServletException(javax.servlet.ServletException) LoggerFactory(org.slf4j.LoggerFactory) ActionContext(it.cnr.jada.action.ActionContext) DatatypeFactory(javax.xml.datatype.DatatypeFactory) Button(it.cnr.jada.util.jsp.Button) StatoTrasmissione(it.cnr.contab.doccont00.intcass.bulk.StatoTrasmissione) BigDecimal(java.math.BigDecimal) StorageException(it.cnr.si.spring.storage.StorageException) FlussoOrdinativi(it.cnr.contab.doccont00.intcass.xmlbnl.FlussoOrdinativi) DistintaCassiereComponent(it.cnr.contab.doccont00.comp.DistintaCassiereComponent) Reversale(it.cnr.contab.doccont00.intcass.xmlbnl.Reversale) DatatypeConstants(javax.xml.datatype.DatatypeConstants) XmlSignatureType(it.cnr.si.firmadigitale.firma.arss.stub.XmlSignatureType) BigInteger(java.math.BigInteger) PrintService(it.cnr.contab.reports.service.PrintService) Print_spooler_paramBulk(it.cnr.contab.reports.bulk.Print_spooler_paramBulk) StorageObject(it.cnr.si.spring.storage.StorageObject) it.cnr.contab.util(it.cnr.contab.util) EJBCommonServices(it.cnr.jada.util.ejb.EJBCommonServices) Risultato(it.cnr.si.siopeplus.model.Risultato) Parametri_cnrBulk(it.cnr.contab.config00.bulk.Parametri_cnrBulk) Collectors(java.util.stream.Collectors) OrdinativiSiopePlusService(it.cnr.si.siopeplus.service.OrdinativiSiopePlusService) RemoteException(java.rmi.RemoteException) BusinessProcessException(it.cnr.jada.action.BusinessProcessException) FirmaOTPBulk(it.cnr.contab.firma.bulk.FirmaOTPBulk) StorageDriver(it.cnr.si.spring.storage.StorageDriver) IOUtils(org.apache.commons.io.IOUtils) AbstractPrintBP(it.cnr.jada.util.action.AbstractPrintBP) SAXException(org.xml.sax.SAXException) StoragePropertyNames(it.cnr.si.spring.storage.config.StoragePropertyNames) AnagraficoBulk(it.cnr.contab.anagraf00.core.bulk.AnagraficoBulk) SpringUtil(it.cnr.contab.service.SpringUtil) ArubaSignServiceClient(it.cnr.si.firmadigitale.firma.arss.ArubaSignServiceClient) UserContext(it.cnr.jada.UserContext) HttpActionContext(it.cnr.jada.action.HttpActionContext) Classificazione(it.cnr.contab.doccont00.intcass.xmlbnl.Mandato.InformazioniBeneficiario.Classificazione) OggettoBulk(it.cnr.jada.bulk.OggettoBulk) java.util(java.util) Unita_organizzativaBulk(it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk) V_mandato_reversaleBulk(it.cnr.contab.doccont00.intcass.bulk.V_mandato_reversaleBulk) PageContext(javax.servlet.jsp.PageContext) Marshaller(javax.xml.bind.Marshaller) DistintaCassiereComponentSession(it.cnr.contab.doccont00.ejb.DistintaCassiereComponentSession) SimpleDateFormat(java.text.SimpleDateFormat) Configurazione_cnrBulk(it.cnr.contab.config00.bulk.Configurazione_cnrBulk) HttpServletRequest(javax.servlet.http.HttpServletRequest) AllegatiCRUDBP(it.cnr.contab.util00.bp.AllegatiCRUDBP) CRUDComponentSession(it.cnr.jada.ejb.CRUDComponentSession) DocumentiContabiliService(it.cnr.contab.doccont00.service.DocumentiContabiliService) BancaBulk(it.cnr.contab.anagraf00.core.bulk.BancaBulk) RemoteIterator(it.cnr.jada.util.RemoteIterator) SIOPEPlusServiceUnavailable(it.cnr.si.siopeplus.exception.SIOPEPlusServiceUnavailable) Distinta_cassiereBulk(it.cnr.contab.doccont00.intcass.bulk.Distinta_cassiereBulk) RemoteDetailCRUDController(it.cnr.jada.util.action.RemoteDetailCRUDController) JAXBContext(javax.xml.bind.JAXBContext) VDocumentiFlussoBulk(it.cnr.contab.doccont00.intcass.bulk.VDocumentiFlussoBulk) AbilitatoFirma(it.cnr.contab.utenze00.bulk.AbilitatoFirma) CNRUserContext(it.cnr.contab.utenze00.bp.CNRUserContext) Configurazione_cnrComponentSession(it.cnr.contab.config00.ejb.Configurazione_cnrComponentSession) ApplicationException(it.cnr.jada.comp.ApplicationException) Logger(org.slf4j.Logger) Rif_modalita_pagamentoBulk(it.cnr.contab.anagraf00.tabrif.bulk.Rif_modalita_pagamentoBulk) Print_spoolerBulk(it.cnr.contab.reports.bulk.Print_spoolerBulk) HttpServletResponse(javax.servlet.http.HttpServletResponse) UtenteFirmaDettaglioBulk(it.cnr.contab.utenze00.bulk.UtenteFirmaDettaglioBulk) MandatoBulk(it.cnr.contab.doccont00.core.bulk.MandatoBulk) StorageFile(it.cnr.si.spring.storage.bulk.StorageFile) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) AllegatoGenericoBulk(it.cnr.contab.util00.bulk.storage.AllegatoGenericoBulk) DateServices(it.cnr.contab.doccont00.comp.DateServices) Report(it.cnr.contab.reports.bulk.Report) ArubaSignServiceException(it.cnr.si.firmadigitale.firma.arss.ArubaSignServiceException) CNRUserInfo(it.cnr.contab.utenze00.bulk.CNRUserInfo) MimeTypes(it.cnr.si.spring.storage.MimeTypes) java.io(java.io) UtenteComponentSession(it.cnr.contab.utente00.ejb.UtenteComponentSession) JSPUtils(it.cnr.jada.util.jsp.JSPUtils) DateTimeFormatter(java.time.format.DateTimeFormatter) StatoVariazioneSostituzione(it.cnr.contab.util.enumeration.StatoVariazioneSostituzione) Liquid_coriComponentSession(it.cnr.contab.cori00.ejb.Liquid_coriComponentSession) ReversaleBulk(it.cnr.contab.doccont00.core.bulk.ReversaleBulk) Mandato(it.cnr.contab.doccont00.intcass.xmlbnl.Mandato) OfflineReportPrintBP(it.cnr.contab.reports.bp.OfflineReportPrintBP) ComponentException(it.cnr.jada.comp.ComponentException) CompoundFindClause(it.cnr.jada.persistency.sql.CompoundFindClause) Distinta_cassiereBulk(it.cnr.contab.doccont00.intcass.bulk.Distinta_cassiereBulk) HttpActionContext(it.cnr.jada.action.HttpActionContext) StorageException(it.cnr.si.spring.storage.StorageException) Parametri_cnrBulk(it.cnr.contab.config00.bulk.Parametri_cnrBulk)

Example 20 with StorageObject

use of it.cnr.si.spring.storage.StorageObject in project sigla-main by consiglionazionaledellericerche.

the class CRUDDistintaCassiereBP method inviaSiopeplus.

public void inviaSiopeplus(ActionContext context, FirmaOTPBulk firmaOTPBulk) throws Exception {
    Map<String, String> subjectDN = Optional.ofNullable(documentiContabiliService.getCertSubjectDN(firmaOTPBulk.getUserName(), firmaOTPBulk.getPassword())).orElseThrow(() -> new ApplicationException("Errore nella lettura dei certificati!\nVerificare Nome Utente e Password!"));
    if (Optional.ofNullable(controlloCodiceFiscale).filter(s -> s.equalsIgnoreCase("Y")).isPresent()) {
        documentiContabiliService.controllaCodiceFiscale(subjectDN, ((CNRUserInfo) context.getUserInfo()).getUtente());
    }
    Distinta_cassiereBulk distinta = (Distinta_cassiereBulk) getModel();
    final String storePath = distinta.getStorePath();
    final String baseIdentificativoFlusso = distinta.getBaseIdentificativoFlusso();
    Optional<StorageObject> optStorageObject = Optional.ofNullable(documentiContabiliService.getStorageObjectByPath(Arrays.asList(storePath, distinta.getFileNameXML()).stream().collect(Collectors.joining(StorageDriver.SUFFIX))));
    if (!optStorageObject.isPresent()) {
        optStorageObject = documentiContabiliService.getChildren(documentiContabiliService.getStorageObjectByPath(storePath).getKey()).stream().filter(storageObject1 -> storageObject1.<String>getPropertyValue(StoragePropertyNames.NAME.value()).startsWith(baseIdentificativoFlusso)).max(Comparator.comparing(storageObject1 -> storageObject1.getPropertyValue("cmis:lastModificationDate")));
    }
    StorageObject storageObject = optStorageObject.orElseThrow(() -> new ApplicationException("Flusso ordinativi siope+ non trovato!"));
    if (!documentiContabiliService.hasAspect(storageObject, SIGLAStoragePropertyNames.CNR_SIGNEDDOCUMENT.value())) {
        ArubaSignServiceClient client = documentiContabiliService.getArubaSignServiceClient();
        byte[] contentSigned;
        try {
            contentSigned = client.xmlSignature(firmaOTPBulk.getUserName(), firmaOTPBulk.getPassword(), firmaOTPBulk.getOtp(), IOUtils.toByteArray(documentiContabiliService.getResource(storageObject)), XmlSignatureType.XMLENVELOPED);
        } catch (ArubaSignServiceException _ex) {
            logger.error("SIOPE+ firma flusso ", _ex);
            throw new ApplicationException(FirmaOTPBulk.errorMessage(_ex.getMessage()));
        }
        storageObject = documentiContabiliService.updateStream(storageObject.getKey(), new ByteArrayInputStream(contentSigned), MimeTypes.XML.mimetype());
        documentiContabiliService.updateProperties(Collections.singletonMap(StoragePropertyNames.SECONDARY_OBJECT_TYPE_IDS.value(), Optional.ofNullable(storageObject.<List<String>>getPropertyValue(StoragePropertyNames.SECONDARY_OBJECT_TYPE_IDS.value())).map(strings -> {
            strings.add(SIGLAStoragePropertyNames.CNR_SIGNEDDOCUMENT.value());
            return strings;
        }).orElse(Arrays.asList(SIGLAStoragePropertyNames.CNR_SIGNEDDOCUMENT.value()))), storageObject);
    }
    try {
        ordinativiSiopePlusService.validateFlussoOrdinativi(documentiContabiliService.getResource(storageObject));
    } catch (SAXException _ex) {
        documentiContabiliService.updateProperties(Collections.singletonMap(StoragePropertyNames.SECONDARY_OBJECT_TYPE_IDS.value(), Optional.ofNullable(storageObject.<List<String>>getPropertyValue(StoragePropertyNames.SECONDARY_OBJECT_TYPE_IDS.value())).map(strings -> {
            strings.remove(SIGLAStoragePropertyNames.CNR_SIGNEDDOCUMENT.value());
            return strings;
        }).orElse(Collections.emptyList())), storageObject);
        distinta.setStato(Distinta_cassiereBulk.Stato.PROVVISORIA);
        distinta.setPg_distinta_def(null);
        distinta.setToBeUpdated();
        setModel(context, createComponentSession().modificaConBulk(context.getUserContext(), distinta));
        commitUserTransaction();
        setMessage("File formalmente errato, la distinta è stata riportata in stato PROVVISORIO!\n" + _ex.getMessage());
        return;
    }
    Risultato risultato = null;
    try {
        risultato = ordinativiSiopePlusService.postFlusso(documentiContabiliService.getResource(storageObject));
    } catch (SIOPEPlusServiceUnavailable _ex) {
        throw handleException(new ApplicationException("Invio flusso non possibile!\nIl sistema è aperto dalle ore 05.00 " + "alle ore 23.00 di tutti i giorni lavorativi del calendario\n" + "nazionale inclusi i sabati non festivi (con orario ridotto fino alle ore 13.00)."));
    }
    it.cnr.contab.doccont00.ejb.DistintaCassiereComponentSession distintaComp = (it.cnr.contab.doccont00.ejb.DistintaCassiereComponentSession) createComponentSession();
    distinta = distintaComp.inviaDistintaSiopePlus(context.getUserContext(), distinta, risultato.getProgFlusso());
    setModel(context, createComponentSession().modificaConBulk(context.getUserContext(), distinta));
    commitUserTransaction();
    archiviaStampa(context, distinta);
    setMessage("Invio effettuato correttamente.");
}
Also used : ObjectFactory(it.cnr.contab.doccont00.intcass.xmlbnl.ObjectFactory) Format(java.text.Format) ServletException(javax.servlet.ServletException) LoggerFactory(org.slf4j.LoggerFactory) ActionContext(it.cnr.jada.action.ActionContext) DatatypeFactory(javax.xml.datatype.DatatypeFactory) Button(it.cnr.jada.util.jsp.Button) StatoTrasmissione(it.cnr.contab.doccont00.intcass.bulk.StatoTrasmissione) BigDecimal(java.math.BigDecimal) StorageException(it.cnr.si.spring.storage.StorageException) FlussoOrdinativi(it.cnr.contab.doccont00.intcass.xmlbnl.FlussoOrdinativi) DistintaCassiereComponent(it.cnr.contab.doccont00.comp.DistintaCassiereComponent) Reversale(it.cnr.contab.doccont00.intcass.xmlbnl.Reversale) DatatypeConstants(javax.xml.datatype.DatatypeConstants) XmlSignatureType(it.cnr.si.firmadigitale.firma.arss.stub.XmlSignatureType) BigInteger(java.math.BigInteger) PrintService(it.cnr.contab.reports.service.PrintService) Print_spooler_paramBulk(it.cnr.contab.reports.bulk.Print_spooler_paramBulk) StorageObject(it.cnr.si.spring.storage.StorageObject) it.cnr.contab.util(it.cnr.contab.util) EJBCommonServices(it.cnr.jada.util.ejb.EJBCommonServices) Risultato(it.cnr.si.siopeplus.model.Risultato) Parametri_cnrBulk(it.cnr.contab.config00.bulk.Parametri_cnrBulk) Collectors(java.util.stream.Collectors) OrdinativiSiopePlusService(it.cnr.si.siopeplus.service.OrdinativiSiopePlusService) RemoteException(java.rmi.RemoteException) BusinessProcessException(it.cnr.jada.action.BusinessProcessException) FirmaOTPBulk(it.cnr.contab.firma.bulk.FirmaOTPBulk) StorageDriver(it.cnr.si.spring.storage.StorageDriver) IOUtils(org.apache.commons.io.IOUtils) AbstractPrintBP(it.cnr.jada.util.action.AbstractPrintBP) SAXException(org.xml.sax.SAXException) StoragePropertyNames(it.cnr.si.spring.storage.config.StoragePropertyNames) AnagraficoBulk(it.cnr.contab.anagraf00.core.bulk.AnagraficoBulk) SpringUtil(it.cnr.contab.service.SpringUtil) ArubaSignServiceClient(it.cnr.si.firmadigitale.firma.arss.ArubaSignServiceClient) UserContext(it.cnr.jada.UserContext) HttpActionContext(it.cnr.jada.action.HttpActionContext) Classificazione(it.cnr.contab.doccont00.intcass.xmlbnl.Mandato.InformazioniBeneficiario.Classificazione) OggettoBulk(it.cnr.jada.bulk.OggettoBulk) java.util(java.util) Unita_organizzativaBulk(it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk) V_mandato_reversaleBulk(it.cnr.contab.doccont00.intcass.bulk.V_mandato_reversaleBulk) PageContext(javax.servlet.jsp.PageContext) Marshaller(javax.xml.bind.Marshaller) DistintaCassiereComponentSession(it.cnr.contab.doccont00.ejb.DistintaCassiereComponentSession) SimpleDateFormat(java.text.SimpleDateFormat) Configurazione_cnrBulk(it.cnr.contab.config00.bulk.Configurazione_cnrBulk) HttpServletRequest(javax.servlet.http.HttpServletRequest) AllegatiCRUDBP(it.cnr.contab.util00.bp.AllegatiCRUDBP) CRUDComponentSession(it.cnr.jada.ejb.CRUDComponentSession) DocumentiContabiliService(it.cnr.contab.doccont00.service.DocumentiContabiliService) BancaBulk(it.cnr.contab.anagraf00.core.bulk.BancaBulk) RemoteIterator(it.cnr.jada.util.RemoteIterator) SIOPEPlusServiceUnavailable(it.cnr.si.siopeplus.exception.SIOPEPlusServiceUnavailable) Distinta_cassiereBulk(it.cnr.contab.doccont00.intcass.bulk.Distinta_cassiereBulk) RemoteDetailCRUDController(it.cnr.jada.util.action.RemoteDetailCRUDController) JAXBContext(javax.xml.bind.JAXBContext) VDocumentiFlussoBulk(it.cnr.contab.doccont00.intcass.bulk.VDocumentiFlussoBulk) AbilitatoFirma(it.cnr.contab.utenze00.bulk.AbilitatoFirma) CNRUserContext(it.cnr.contab.utenze00.bp.CNRUserContext) Configurazione_cnrComponentSession(it.cnr.contab.config00.ejb.Configurazione_cnrComponentSession) ApplicationException(it.cnr.jada.comp.ApplicationException) Logger(org.slf4j.Logger) Rif_modalita_pagamentoBulk(it.cnr.contab.anagraf00.tabrif.bulk.Rif_modalita_pagamentoBulk) Print_spoolerBulk(it.cnr.contab.reports.bulk.Print_spoolerBulk) HttpServletResponse(javax.servlet.http.HttpServletResponse) UtenteFirmaDettaglioBulk(it.cnr.contab.utenze00.bulk.UtenteFirmaDettaglioBulk) MandatoBulk(it.cnr.contab.doccont00.core.bulk.MandatoBulk) StorageFile(it.cnr.si.spring.storage.bulk.StorageFile) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) AllegatoGenericoBulk(it.cnr.contab.util00.bulk.storage.AllegatoGenericoBulk) DateServices(it.cnr.contab.doccont00.comp.DateServices) Report(it.cnr.contab.reports.bulk.Report) ArubaSignServiceException(it.cnr.si.firmadigitale.firma.arss.ArubaSignServiceException) CNRUserInfo(it.cnr.contab.utenze00.bulk.CNRUserInfo) MimeTypes(it.cnr.si.spring.storage.MimeTypes) java.io(java.io) UtenteComponentSession(it.cnr.contab.utente00.ejb.UtenteComponentSession) JSPUtils(it.cnr.jada.util.jsp.JSPUtils) DateTimeFormatter(java.time.format.DateTimeFormatter) StatoVariazioneSostituzione(it.cnr.contab.util.enumeration.StatoVariazioneSostituzione) Liquid_coriComponentSession(it.cnr.contab.cori00.ejb.Liquid_coriComponentSession) ReversaleBulk(it.cnr.contab.doccont00.core.bulk.ReversaleBulk) Mandato(it.cnr.contab.doccont00.intcass.xmlbnl.Mandato) OfflineReportPrintBP(it.cnr.contab.reports.bp.OfflineReportPrintBP) ComponentException(it.cnr.jada.comp.ComponentException) CompoundFindClause(it.cnr.jada.persistency.sql.CompoundFindClause) StorageObject(it.cnr.si.spring.storage.StorageObject) ArubaSignServiceException(it.cnr.si.firmadigitale.firma.arss.ArubaSignServiceException) DistintaCassiereComponentSession(it.cnr.contab.doccont00.ejb.DistintaCassiereComponentSession) SAXException(org.xml.sax.SAXException) ApplicationException(it.cnr.jada.comp.ApplicationException) Distinta_cassiereBulk(it.cnr.contab.doccont00.intcass.bulk.Distinta_cassiereBulk) DistintaCassiereComponentSession(it.cnr.contab.doccont00.ejb.DistintaCassiereComponentSession) Risultato(it.cnr.si.siopeplus.model.Risultato) ArubaSignServiceClient(it.cnr.si.firmadigitale.firma.arss.ArubaSignServiceClient) SIOPEPlusServiceUnavailable(it.cnr.si.siopeplus.exception.SIOPEPlusServiceUnavailable)

Aggregations

StorageObject (it.cnr.si.spring.storage.StorageObject)86 ApplicationException (it.cnr.jada.comp.ApplicationException)48 ComponentException (it.cnr.jada.comp.ComponentException)36 BigInteger (java.math.BigInteger)34 StorageException (it.cnr.si.spring.storage.StorageException)31 RemoteException (java.rmi.RemoteException)27 StoragePropertyNames (it.cnr.si.spring.storage.config.StoragePropertyNames)25 SpringUtil (it.cnr.contab.service.SpringUtil)24 BusinessProcessException (it.cnr.jada.action.BusinessProcessException)24 HttpActionContext (it.cnr.jada.action.HttpActionContext)24 OggettoBulk (it.cnr.jada.bulk.OggettoBulk)23 StoreService (it.cnr.si.spring.storage.StoreService)21 java.util (java.util)20 ServletException (javax.servlet.ServletException)19 ActionContext (it.cnr.jada.action.ActionContext)18 Unita_organizzativaBulk (it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk)16 EJBCommonServices (it.cnr.jada.util.ejb.EJBCommonServices)16 Collectors (java.util.stream.Collectors)16 Print_spoolerBulk (it.cnr.contab.reports.bulk.Print_spoolerBulk)15 Report (it.cnr.contab.reports.bulk.Report)15