Search in sources :

Example 31 with HttpActionContext

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

the class CRUDSelezionatoreDocumentiAmministrativiFatturazioneElettronicaBP method scaricaDocumentiCollegati.

public void scaricaDocumentiCollegati(ActionContext actioncontext) throws Exception {
    Integer esercizio = Integer.valueOf(((HttpActionContext) actioncontext).getParameter("esercizio"));
    String cds = ((HttpActionContext) actioncontext).getParameter("cds");
    String cdUo = ((HttpActionContext) actioncontext).getParameter("cdUo");
    Long pgFattura = Long.valueOf(((HttpActionContext) actioncontext).getParameter("pgFattura"));
    StorageObject storageObject = documentiCollegatiDocAmmService.recuperoFolderFattura(esercizio, cds, cdUo, pgFattura);
    InputStream is = null;
    if (storageObject == null) {
        is = getStreamNewDocument(actioncontext, esercizio, cds, cdUo, pgFattura);
    } else {
        is = documentiCollegatiDocAmmService.getStreamDocumentoAttivo(esercizio, cds, cdUo, pgFattura);
        if (is == null) {
            is = getStreamNewDocument(actioncontext, esercizio, cds, cdUo, pgFattura);
        }
    }
    if (is != null) {
        ((HttpActionContext) actioncontext).getResponse().setContentType("application/pdf");
        OutputStream os = ((HttpActionContext) actioncontext).getResponse().getOutputStream();
        ((HttpActionContext) actioncontext).getResponse().setDateHeader("Expires", 0);
        byte[] buffer = new byte[((HttpActionContext) actioncontext).getResponse().getBufferSize()];
        int buflength;
        while ((buflength = is.read(buffer)) > 0) {
            os.write(buffer, 0, buflength);
        }
        is.close();
        os.flush();
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BigInteger(java.math.BigInteger) StorageObject(it.cnr.si.spring.storage.StorageObject) 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