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