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();
}
}
Aggregations