Search in sources :

Example 1 with HttpActionContext

use of it.cnr.jada.action.HttpActionContext in project sigla-main by consiglionazionaledellericerche.

the class CRUDFatturaPassivaElettronicaBP method scaricaFatturaFirmata.

public void scaricaFatturaFirmata(ActionContext actioncontext) throws IOException, ServletException, TransformerException, ApplicationException {
    DocumentoEleTestataBulk documentoEleTestata = (DocumentoEleTestataBulk) getModel();
    final StoreService storeService = SpringUtil.getBean("storeService", StoreService.class);
    final StorageObject fattura = Optional.ofNullable(getModel()).filter(DocumentoEleTestataBulk.class::isInstance).map(DocumentoEleTestataBulk.class::cast).map(DocumentoEleTestataBulk::getDocumentoEleTrasmissione).map(DocumentoEleTrasmissioneBulk::getCmisNodeRef).map(cmisNodeRef -> storeService.getStorageObjectBykey(cmisNodeRef)).filter(storageObject -> Optional.ofNullable(storageObject).isPresent()).map(fatturaFolder -> storeService.getChildren(fatturaFolder.getKey()).stream().filter(storageObject -> storageObject.<List<String>>getPropertyValue(StoragePropertyNames.SECONDARY_OBJECT_TYPE_IDS.value()).contains(StorageDocAmmAspect.SIGLA_FATTURE_ATTACHMENT_FATTURA_ELETTRONICA_XML_POST_FIRMA.value()) || storageObject.<List<String>>getPropertyValue(StoragePropertyNames.SECONDARY_OBJECT_TYPE_IDS.value()).contains(StorageDocAmmAspect.SIGLA_FATTURE_ATTACHMENT_TRASMISSIONE_FATTURA.value())).reduce((x, y) -> {
        return Optional.ofNullable(x).filter(storageObject -> storageObject.<List<String>>getPropertyValue(StoragePropertyNames.SECONDARY_OBJECT_TYPE_IDS.value()).contains(StorageDocAmmAspect.SIGLA_FATTURE_ATTACHMENT_FATTURA_ELETTRONICA_XML_POST_FIRMA.value())).orElse(y);
    }).get()).orElseThrow(() -> new RuntimeException("Fattura non trovata!"));
    final HttpServletResponse response = ((HttpActionContext) actioncontext).getResponse();
    InputStream is = storeService.getResource(fattura);
    response.setContentLength(fattura.<BigInteger>getPropertyValue(StoragePropertyNames.CONTENT_STREAM_LENGTH.value()).intValue());
    response.setContentType(fattura.getPropertyValue(StoragePropertyNames.CONTENT_STREAM_MIME_TYPE.value()));
    response.setDateHeader("Expires", 0);
    IOUtils.copyLarge(is, response.getOutputStream());
    response.getOutputStream().flush();
}
Also used : Transformer(javax.xml.transform.Transformer) ByteArrayDataSource(javax.mail.util.ByteArrayDataSource) Format(java.text.Format) CRUDFatturaPassivaAction(it.cnr.contab.docamm00.actions.CRUDFatturaPassivaAction) ServletException(javax.servlet.ServletException) StreamResult(javax.xml.transform.stream.StreamResult) ActionContext(it.cnr.jada.action.ActionContext) Button(it.cnr.jada.util.jsp.Button) FatturaPassivaComponentSession(it.cnr.contab.docamm00.ejb.FatturaPassivaComponentSession) BigDecimal(java.math.BigDecimal) ByteArrayInputStream(java.io.ByteArrayInputStream) SimpleDetailCRUDController(it.cnr.jada.util.action.SimpleDetailCRUDController) it.cnr.contab.docamm00.fatturapa.bulk(it.cnr.contab.docamm00.fatturapa.bulk) BigInteger(java.math.BigInteger) ZoneOffset(java.time.ZoneOffset) PrintService(it.cnr.contab.reports.service.PrintService) ValidationException(it.cnr.jada.bulk.ValidationException) StorageObject(it.cnr.si.spring.storage.StorageObject) Timestamp(java.sql.Timestamp) TemporalField(java.time.temporal.TemporalField) FatturaPassivaElettronicaService(it.cnr.contab.docamm00.service.FatturaPassivaElettronicaService) EJBCommonServices(it.cnr.jada.util.ejb.EJBCommonServices) RemoteException(java.rmi.RemoteException) BusinessProcessException(it.cnr.jada.action.BusinessProcessException) EJBException(javax.ejb.EJBException) IOUtils(org.apache.commons.io.IOUtils) Stream(java.util.stream.Stream) TipoDocumentoType(it.gov.agenziaentrate.ivaservizi.docs.xsd.fatture.v1.TipoDocumentoType) Fattura_passivaBulk(it.cnr.contab.docamm00.docs.bulk.Fattura_passivaBulk) EmailException(org.apache.commons.mail.EmailException) StoragePropertyNames(it.cnr.si.spring.storage.config.StoragePropertyNames) AnagraficoBulk(it.cnr.contab.anagraf00.core.bulk.AnagraficoBulk) SpringUtil(it.cnr.contab.service.SpringUtil) ContattoBulk(it.cnr.contab.anagraf00.core.bulk.ContattoBulk) TerzoBulk(it.cnr.contab.anagraf00.core.bulk.TerzoBulk) UserContext(it.cnr.jada.UserContext) HttpActionContext(it.cnr.jada.action.HttpActionContext) ChronoField(java.time.temporal.ChronoField) EsercizioComponentSession(it.cnr.contab.config00.ejb.EsercizioComponentSession) OggettoBulk(it.cnr.jada.bulk.OggettoBulk) java.util(java.util) Unita_organizzativaBulk(it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk) Fattura_passiva_rigaBulk(it.cnr.contab.docamm00.docs.bulk.Fattura_passiva_rigaBulk) TransformerException(javax.xml.transform.TransformerException) Tipo_sezionaleBulk(it.cnr.contab.docamm00.tabrif.bulk.Tipo_sezionaleBulk) StreamSource(javax.xml.transform.stream.StreamSource) RegimeFiscaleType(it.gov.agenziaentrate.ivaservizi.docs.xsd.fatture.v1.RegimeFiscaleType) LocalDateTime(java.time.LocalDateTime) JspWriter(javax.servlet.jsp.JspWriter) Utility(it.cnr.contab.util.Utility) SimpleDateFormat(java.text.SimpleDateFormat) Source(javax.xml.transform.Source) Configurazione_cnrBulk(it.cnr.contab.config00.bulk.Configurazione_cnrBulk) Tipo_documento_ammBulk(it.cnr.contab.docamm00.docs.bulk.Tipo_documento_ammBulk) AllegatiCRUDBP(it.cnr.contab.util00.bp.AllegatiCRUDBP) CRUDComponentSession(it.cnr.jada.ejb.CRUDComponentSession) Numerazione_baseComponentSession(it.cnr.contab.config00.tabnum.ejb.Numerazione_baseComponentSession) RemoteIterator(it.cnr.jada.util.RemoteIterator) StoreService(it.cnr.si.spring.storage.StoreService) DateUtils(it.cnr.jada.util.DateUtils) OutputStream(java.io.OutputStream) CNRUserContext(it.cnr.contab.utenze00.bp.CNRUserContext) ApplicationException(it.cnr.jada.comp.ApplicationException) FormBP(it.cnr.jada.util.action.FormBP) Voce_ivaBulk(it.cnr.contab.docamm00.tabrif.bulk.Voce_ivaBulk) BusyResourceException(it.cnr.jada.bulk.BusyResourceException) TelefonoBulk(it.cnr.contab.anagraf00.core.bulk.TelefonoBulk) StorageDocAmmAspect(it.cnr.contab.docamm00.storage.StorageDocAmmAspect) Print_spoolerBulk(it.cnr.contab.reports.bulk.Print_spoolerBulk) HttpServletResponse(javax.servlet.http.HttpServletResponse) IOException(java.io.IOException) AllegatoGenericoBulk(it.cnr.contab.util00.bulk.storage.AllegatoGenericoBulk) Report(it.cnr.contab.reports.bulk.Report) MimeTypes(it.cnr.si.spring.storage.MimeTypes) FatturaElettronicaPassivaComponentSession(it.cnr.contab.docamm00.ejb.FatturaElettronicaPassivaComponentSession) DateTimeFormatter(java.time.format.DateTimeFormatter) TransformerFactory(javax.xml.transform.TransformerFactory) ComponentException(it.cnr.jada.comp.ComponentException) CompoundFindClause(it.cnr.jada.persistency.sql.CompoundFindClause) InputStream(java.io.InputStream) StorageObject(it.cnr.si.spring.storage.StorageObject) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) HttpServletResponse(javax.servlet.http.HttpServletResponse) HttpActionContext(it.cnr.jada.action.HttpActionContext) BigInteger(java.math.BigInteger) StoreService(it.cnr.si.spring.storage.StoreService)

Example 2 with HttpActionContext

use of it.cnr.jada.action.HttpActionContext in project sigla-main by consiglionazionaledellericerche.

the class CRUDFatturaPassivaElettronicaBP method scaricaFatturaHtml.

public void scaricaFatturaHtml(ActionContext actioncontext) throws IOException, ServletException, TransformerException, ApplicationException {
    DocumentoEleTestataBulk documentoEleTestata = (DocumentoEleTestataBulk) getModel();
    StorageObject fatturaFolder = SpringUtil.getBean("storeService", StoreService.class).getStorageObjectBykey(documentoEleTestata.getDocumentoEleTrasmissione().getCmisNodeRef());
    List<StorageObject> files = SpringUtil.getBean("storeService", StoreService.class).getChildren(fatturaFolder.getKey());
    for (StorageObject storageObject : files) {
        if (storageObject.<List<String>>getPropertyValue(StoragePropertyNames.SECONDARY_OBJECT_TYPE_IDS.value()).contains("P:sigla_fatture_attachment:trasmissione_fattura")) {
            TransformerFactory tFactory = TransformerFactory.newInstance();
            Source xslDoc = null;
            if (documentoEleTestata.getDocumentoEleTrasmissione().getFormatoTrasmissione().equals("FPA12")) {
                xslDoc = new StreamSource(this.getClass().getResourceAsStream("/it/cnr/contab/docamm00/bp/fatturapa_v1.2.1.xsl"));
            } else if (documentoEleTestata.getDocumentoEleTrasmissione().getFormatoTrasmissione().equals("SDI11")) {
                xslDoc = new StreamSource(this.getClass().getResourceAsStream("/it/cnr/contab/docamm00/bp/fatturapa_v1.1.xsl"));
            } else {
                throw new ApplicationException("Il formato trasmissione indicato da SDI non rientra tra i formati attesi");
            }
            Source xmlDoc = new StreamSource(SpringUtil.getBean("storeService", StoreService.class).getResource(storageObject.getKey()));
            HttpServletResponse response = ((HttpActionContext) actioncontext).getResponse();
            OutputStream os = response.getOutputStream();
            response.setContentType("text/html");
            Transformer trasform = tFactory.newTransformer(xslDoc);
            trasform.transform(xmlDoc, new StreamResult(os));
            os.flush();
        }
    }
}
Also used : StorageObject(it.cnr.si.spring.storage.StorageObject) TransformerFactory(javax.xml.transform.TransformerFactory) Transformer(javax.xml.transform.Transformer) StreamResult(javax.xml.transform.stream.StreamResult) StreamSource(javax.xml.transform.stream.StreamSource) OutputStream(java.io.OutputStream) HttpServletResponse(javax.servlet.http.HttpServletResponse) StoreService(it.cnr.si.spring.storage.StoreService) ByteArrayDataSource(javax.mail.util.ByteArrayDataSource) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source) ApplicationException(it.cnr.jada.comp.ApplicationException) HttpActionContext(it.cnr.jada.action.HttpActionContext)

Example 3 with HttpActionContext

use of it.cnr.jada.action.HttpActionContext in project sigla-main by consiglionazionaledellericerche.

the class CRUDFatturaPassivaElettronicaBP method scaricaEsito.

public void scaricaEsito(ActionContext actioncontext) throws IOException, ServletException, TransformerException, ApplicationException {
    DocumentoEleTestataBulk documentoEleTestata = (DocumentoEleTestataBulk) getModel();
    StorageObject fatturaFolder = SpringUtil.getBean("storeService", StoreService.class).getStorageObjectBykey(documentoEleTestata.getDocumentoEleTrasmissione().getCmisNodeRef());
    List<StorageObject> files = SpringUtil.getBean("storeService", StoreService.class).getChildren(fatturaFolder.getKey());
    for (StorageObject storageObject : files) {
        if (storageObject.<List<String>>getPropertyValue(StoragePropertyNames.SECONDARY_OBJECT_TYPE_IDS.value()).contains(documentoEleTestata.getStatoDocumentoEle().equals(StatoDocumentoEleEnum.RIFIUTATO) ? StorageDocAmmAspect.SIGLA_FATTURE_ATTACHMENT_ESITO_RIFIUTATO.value() : StorageDocAmmAspect.SIGLA_FATTURE_ATTACHMENT_ESITO_ACCETTATO.value())) {
            HttpServletResponse response = ((HttpActionContext) actioncontext).getResponse();
            OutputStream os = response.getOutputStream();
            response.setContentType("application/octetstream");
            response.setContentLength(storageObject.<BigInteger>getPropertyValue(StoragePropertyNames.CONTENT_STREAM_LENGTH.value()).intValue());
            IOUtils.copy(SpringUtil.getBean("storeService", StoreService.class).getResource(storageObject.getKey()), os);
            os.flush();
        }
    }
}
Also used : StorageObject(it.cnr.si.spring.storage.StorageObject) OutputStream(java.io.OutputStream) HttpServletResponse(javax.servlet.http.HttpServletResponse) HttpActionContext(it.cnr.jada.action.HttpActionContext) BigInteger(java.math.BigInteger) StoreService(it.cnr.si.spring.storage.StoreService)

Example 4 with HttpActionContext

use of it.cnr.jada.action.HttpActionContext in project sigla-main by consiglionazionaledellericerche.

the class CRUDFatturaAttivaBP method scaricaFatturaAttivaHtml.

public void scaricaFatturaAttivaHtml(ActionContext actioncontext) throws IOException, ServletException, TransformerException, ApplicationException {
    Fattura_attivaBulk fattura = (Fattura_attivaBulk) getModel();
    Source xmlDoc = new StreamSource(docCollService.getStreamXmlFatturaAttiva(fattura));
    TransformerFactory tFactory = TransformerFactory.newInstance();
    Source xslDoc = new StreamSource(this.getClass().getResourceAsStream("/it/cnr/contab/docamm00/bp/fatturapa_v1.2.1.xsl"));
    HttpServletResponse response = ((HttpActionContext) actioncontext).getResponse();
    OutputStream os = response.getOutputStream();
    response.setContentType("text/html");
    Transformer trasform = tFactory.newTransformer(xslDoc);
    trasform.transform(xmlDoc, new StreamResult(os));
    os.flush();
}
Also used : TransformerFactory(javax.xml.transform.TransformerFactory) Transformer(javax.xml.transform.Transformer) StreamResult(javax.xml.transform.stream.StreamResult) StreamSource(javax.xml.transform.stream.StreamSource) HttpServletResponse(javax.servlet.http.HttpServletResponse) HttpActionContext(it.cnr.jada.action.HttpActionContext) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source)

Example 5 with HttpActionContext

use of it.cnr.jada.action.HttpActionContext in project sigla-main by consiglionazionaledellericerche.

the class CRUDFatturaPassivaBP method scaricaFatturaHtml.

public void scaricaFatturaHtml(ActionContext actioncontext) throws IOException, ServletException, TransformerException, ApplicationException {
    Fattura_passivaBulk fattura_passivaBulk = (Fattura_passivaBulk) getModel();
    DocumentoEleTestataBulk documentoEleTestata = fattura_passivaBulk.getDocumentoEleTestata();
    StorageObject fatturaFolder = SpringUtil.getBean("storeService", StoreService.class).getStorageObjectBykey(documentoEleTestata.getDocumentoEleTrasmissione().getCmisNodeRef());
    List<StorageObject> files = SpringUtil.getBean("storeService", StoreService.class).getChildren(fatturaFolder.getKey());
    for (StorageObject storageObject : files) {
        if (storageObject.<List<String>>getPropertyValue(StoragePropertyNames.SECONDARY_OBJECT_TYPE_IDS.value()).contains("P:sigla_fatture_attachment:trasmissione_fattura")) {
            TransformerFactory tFactory = TransformerFactory.newInstance();
            Source xslDoc = null;
            if (documentoEleTestata.getDocumentoEleTrasmissione().getFormatoTrasmissione().equals("FPA12")) {
                xslDoc = new StreamSource(this.getClass().getResourceAsStream("/it/cnr/contab/docamm00/bp/fatturapa_v1.2.1.xsl"));
            } else if (documentoEleTestata.getDocumentoEleTrasmissione().getFormatoTrasmissione().equals("SDI11")) {
                xslDoc = new StreamSource(this.getClass().getResourceAsStream("/it/cnr/contab/docamm00/bp/fatturapa_v1.1.xsl"));
            } else {
                throw new ApplicationException("Il formato trasmissione indicato da SDI non rientra tra i formati attesi");
            }
            Source xmlDoc = new StreamSource(SpringUtil.getBean("storeService", StoreService.class).getResource(storageObject.getKey()));
            HttpServletResponse response = ((HttpActionContext) actioncontext).getResponse();
            OutputStream os = response.getOutputStream();
            response.setContentType("text/html");
            Transformer trasform = tFactory.newTransformer(xslDoc);
            trasform.transform(xmlDoc, new StreamResult(os));
            os.flush();
        }
    }
}
Also used : StorageObject(it.cnr.si.spring.storage.StorageObject) TransformerFactory(javax.xml.transform.TransformerFactory) Transformer(javax.xml.transform.Transformer) StreamResult(javax.xml.transform.stream.StreamResult) StreamSource(javax.xml.transform.stream.StreamSource) OutputStream(java.io.OutputStream) HttpServletResponse(javax.servlet.http.HttpServletResponse) StoreService(it.cnr.si.spring.storage.StoreService) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source) ApplicationException(it.cnr.jada.comp.ApplicationException) HttpActionContext(it.cnr.jada.action.HttpActionContext)

Aggregations

HttpActionContext (it.cnr.jada.action.HttpActionContext)31 HttpServletResponse (javax.servlet.http.HttpServletResponse)12 BusinessProcessException (it.cnr.jada.action.BusinessProcessException)11 BigInteger (java.math.BigInteger)11 StorageObject (it.cnr.si.spring.storage.StorageObject)10 RemoteException (java.rmi.RemoteException)10 ComponentException (it.cnr.jada.comp.ComponentException)9 OutputStream (java.io.OutputStream)9 ApplicationException (it.cnr.jada.comp.ApplicationException)7 UserContext (it.cnr.jada.UserContext)6 InputStream (java.io.InputStream)6 Unita_organizzativaBulk (it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk)5 DocumentiContabiliService (it.cnr.contab.doccont00.service.DocumentiContabiliService)5 Print_spoolerBulk (it.cnr.contab.reports.bulk.Print_spoolerBulk)5 CNRUserContext (it.cnr.contab.utenze00.bp.CNRUserContext)5 ActionContext (it.cnr.jada.action.ActionContext)5 ServletException (javax.servlet.ServletException)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 StreamSource (javax.xml.transform.stream.StreamSource)5 V_mandato_reversaleBulk (it.cnr.contab.doccont00.intcass.bulk.V_mandato_reversaleBulk)4