use of it.cnr.si.spring.storage.StorageObject in project sigla-main by consiglionazionaledellericerche.
the class CRUDRichiestaUopBP method scaricaAllegato.
public void scaricaAllegato(ActionContext actioncontext) throws IOException, ServletException, ApplicationException {
AllegatoRichiestaBulk allegato = (AllegatoRichiestaBulk) getCrudArchivioAllegati().getModel();
StorageObject storageObject = richiesteCMISService.getStorageObjectBykey(allegato.getStorageKey());
InputStream is = richiesteCMISService.getResource(storageObject.getKey());
((HttpActionContext) actioncontext).getResponse().setContentLength(storageObject.<BigInteger>getPropertyValue(StoragePropertyNames.CONTENT_STREAM_LENGTH.value()).intValue());
((HttpActionContext) actioncontext).getResponse().setContentType(storageObject.getPropertyValue(StoragePropertyNames.CONTENT_STREAM_MIME_TYPE.value()));
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();
}
use of it.cnr.si.spring.storage.StorageObject in project sigla-main by consiglionazionaledellericerche.
the class CRUDRichiestaUopBP method scaricaDocumentoDettaglioCollegato.
public void scaricaDocumentoDettaglioCollegato(ActionContext actioncontext) throws Exception {
AllegatoRichiestaDettaglioBulk dettaglio = (AllegatoRichiestaDettaglioBulk) getDettaglioAllegatiController().getModel();
if (dettaglio != null) {
StorageObject storageObject = richiesteCMISService.getStorageObjectBykey(dettaglio.getStorageKey());
InputStream is = richiesteCMISService.getResource(storageObject.getKey());
((HttpActionContext) actioncontext).getResponse().setContentLength(storageObject.<BigInteger>getPropertyValue(StoragePropertyNames.CONTENT_STREAM_LENGTH.value()).intValue());
((HttpActionContext) actioncontext).getResponse().setContentType(storageObject.getPropertyValue(StoragePropertyNames.CONTENT_STREAM_MIME_TYPE.value()));
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();
} else {
throw new it.cnr.jada.action.MessageToUser("Documenti non presenti sul documentale per la riga selezionata");
}
}
use of it.cnr.si.spring.storage.StorageObject in project sigla-main by consiglionazionaledellericerche.
the class DistintaCassiereComponent method generaFlussoSiopeplus.
public StorageObject generaFlussoSiopeplus(UserContext userContext, Distinta_cassiereBulk distinta) throws ComponentException, RemoteException {
try {
final DocumentiContabiliService documentiContabiliService = SpringUtil.getBean("documentiContabiliService", DocumentiContabiliService.class);
DateTimeFormatter formatterTime = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss");
JAXBContext jc = JAXBContext.newInstance("it.siopeplus");
// creo i file del flusso
// Testata
final ObjectFactory objectFactory = new ObjectFactory();
it.siopeplus.FlussoOrdinativi currentFlusso = objectFactory.createFlussoOrdinativi();
Configurazione_cnrComponentSession sess = (Configurazione_cnrComponentSession) it.cnr.jada.util.ejb.EJBCommonServices.createEJB("CNRCONFIG00_EJB_Configurazione_cnrComponentSession");
String codiceAbi = Optional.ofNullable(sess.getVal01(userContext, CNRUserContext.getEsercizio(userContext), null, Configurazione_cnrBulk.PK_FLUSSO_ORDINATIVI, Configurazione_cnrBulk.SK_CODICE_ABI_BT)).orElseThrow(() -> new ApplicationException("Configurazione mancante per flusso Ordinativo [CODICE_ABI_BT]"));
String codiceA2A = Optional.ofNullable(sess.getVal01(userContext, CNRUserContext.getEsercizio(userContext), null, Configurazione_cnrBulk.PK_FLUSSO_ORDINATIVI, Configurazione_cnrBulk.SK_CODICE_A2A)).orElseThrow(() -> new ApplicationException("Configurazione mancante per flusso Ordinativo [CODICE_A2A]"));
String codiceEnte = Optional.ofNullable(sess.getVal01(userContext, CNRUserContext.getEsercizio(userContext), null, Configurazione_cnrBulk.PK_FLUSSO_ORDINATIVI, Configurazione_cnrBulk.SK_CODICE_ENTE)).orElseThrow(() -> new ApplicationException("Configurazione mancante per flusso Ordinativo [CODICE_ENTE]"));
String codiceEnteBT = Optional.ofNullable(sess.getVal01(userContext, CNRUserContext.getEsercizio(userContext), null, Configurazione_cnrBulk.PK_FLUSSO_ORDINATIVI, Configurazione_cnrBulk.SK_CODICE_ENTE_BT)).orElseThrow(() -> new ApplicationException("Configurazione mancante per flusso Ordinativo [CODICE_ENTE_BT]"));
String codiceTramiteBT = Optional.ofNullable(sess.getVal01(userContext, CNRUserContext.getEsercizio(userContext), null, Configurazione_cnrBulk.PK_FLUSSO_ORDINATIVI, Configurazione_cnrBulk.SK_CODICE_TRAMITE_BT)).orElseThrow(() -> new ApplicationException("Configurazione mancante per flusso Ordinativo [CODICE_TRAMITE_BT]"));
String codiceIstatEnte = Optional.ofNullable(sess.getVal01(userContext, CNRUserContext.getEsercizio(userContext), null, Configurazione_cnrBulk.PK_FLUSSO_ORDINATIVI, Configurazione_cnrBulk.SK_CODICE_ISTAT_ENTE)).orElseThrow(() -> new ApplicationException("Configurazione mancante per flusso Ordinativo [CODICE_ISTAT_ENTE]"));
final CtTestataFlusso testataFlusso = objectFactory.createCtTestataFlusso();
testataFlusso.setCodiceABIBT(codiceAbi);
testataFlusso.setRiferimentoEnte(codiceA2A);
testataFlusso.setIdentificativoFlusso(distinta.getIdentificativoFlusso());
testataFlusso.setDataOraCreazioneFlusso(DatatypeFactory.newInstance().newXMLGregorianCalendar(formatterTime.format(it.cnr.jada.util.ejb.EJBCommonServices.getServerTimestamp().toLocalDateTime())));
testataFlusso.setCodiceEnte(codiceEnte);
testataFlusso.setCodiceEnteBT(codiceEnteBT);
testataFlusso.setCodiceTramiteEnte(codiceA2A);
testataFlusso.setCodiceTramiteBT(codiceTramiteBT);
AnagraficoComponentSession component = (AnagraficoComponentSession) it.cnr.jada.util.ejb.EJBCommonServices.createEJB("CNRANAGRAF00_EJB_AnagraficoComponentSession");
AnagraficoBulk uoEnte = component.getAnagraficoEnte(userContext);
testataFlusso.setDescrizioneEnte(uoEnte.getRagione_sociale());
testataFlusso.setCodiceIstatEnte(codiceIstatEnte);
testataFlusso.setCodiceFiscaleEnte(uoEnte.getCodice_fiscale());
currentFlusso.getContent().add(objectFactory.createTestataFlusso(testataFlusso));
currentFlusso.getContent().add(objectFactory.createEsercizio(CNRUserContext.getEsercizio(userContext)));
List dettagliRev = dettagliDistinta(userContext, distinta, it.cnr.contab.doccont00.core.bulk.Numerazione_doc_contBulk.TIPO_REV);
// Elaboriamo prima le reversali
Reversale currentReversale = null;
for (Iterator i = dettagliRev.iterator(); i.hasNext(); ) {
V_mandato_reversaleBulk bulk = (V_mandato_reversaleBulk) i.next();
currentFlusso.getContent().add(objectFactory.createReversale(creaReversaleFlussoSiopeplus(userContext, bulk)));
}
List dettagliMan = dettagliDistinta(userContext, distinta, it.cnr.contab.doccont00.core.bulk.Numerazione_doc_contBulk.TIPO_MAN);
// Mandati
Mandato currentMandato = null;
for (Iterator i = dettagliMan.iterator(); i.hasNext(); ) {
V_mandato_reversaleBulk bulk = (V_mandato_reversaleBulk) i.next();
currentFlusso.getContent().add(objectFactory.createMandato(creaMandatoFlussoSiopeplus(userContext, bulk)));
}
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
Marshaller jaxbMarshaller = jc.createMarshaller();
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.FALSE);
jaxbMarshaller.marshal(currentFlusso, byteArrayOutputStream);
// FIX per firma xml
String out = new String(byteArrayOutputStream.toByteArray(), StandardCharsets.UTF_8);
out = out.replace("</flusso_ordinativi>", "\n</flusso_ordinativi>");
StorageFile storageFile = new StorageFile(out.getBytes(StandardCharsets.UTF_8), MimeTypes.XML.mimetype(), distinta.getFileNameXML());
final StorageObject storageObject = documentiContabiliService.getStorageObjectBykey(documentiContabiliService.restoreSimpleDocument(storageFile, new ByteArrayInputStream(storageFile.getBytes()), storageFile.getContentType(), storageFile.getFileName(), distinta.getStorePath(), true).getKey());
final BigInteger dimension = storageObject.<BigInteger>getPropertyValue(StoragePropertyNames.CONTENT_STREAM_LENGTH.value()).divide(BigInteger.valueOf(1024));
if (dimension.add(BigInteger.valueOf(7)).compareTo(DistintaCassiereComponentSession.MAX_OPI_DIMENSION) > 0) {
throw new ApplicationMessageFormatException("La dimensione del flusso {0}kbytes supera la dimensione massima consentita {1}kbytes!", dimension.add(BigInteger.valueOf(7)), DistintaCassiereComponentSession.MAX_OPI_DIMENSION);
}
return storageObject;
} catch (Exception e) {
throw handleException(e);
}
}
use of it.cnr.si.spring.storage.StorageObject in project sigla-main by consiglionazionaledellericerche.
the class CRUDMissioneBP method initializeModelForEditAllegati.
@Override
public OggettoBulk initializeModelForEditAllegati(ActionContext actioncontext, OggettoBulk oggettobulk) throws BusinessProcessException {
MissioneBulk allegatoParentBulk = (MissioneBulk) oggettobulk;
try {
if (allegatoParentBulk.getIdRimborsoMissione() != null) {
List<StorageObject> files = missioniCMISService.getFilesOrdineMissione(allegatoParentBulk);
if (files != null) {
for (StorageObject storageObject : files) {
if (missioniCMISService.hasAspect(storageObject, StoragePropertyNames.SYS_ARCHIVED.value()))
continue;
if (excludeChild(storageObject))
continue;
if (storageObject.getPropertyValue(StoragePropertyNames.BASE_TYPE_ID.value()).equals(StoragePropertyNames.CMIS_DOCUMENT.value())) {
AllegatoMissioneBulk allegato = (AllegatoMissioneBulk) Introspector.newInstance(getAllegatoClass(), storageObject);
allegato.setContentType(storageObject.<String>getPropertyValue(StoragePropertyNames.CONTENT_STREAM_MIME_TYPE.value()));
allegato.setNome(storageObject.getPropertyValue(StoragePropertyNames.NAME.value()));
allegato.setDescrizione(storageObject.getPropertyValue(StoragePropertyNames.DESCRIPTION.value()));
allegato.setTitolo(storageObject.getPropertyValue(StoragePropertyNames.TITLE.value()));
completeAllegato(allegato, storageObject);
allegato.setCrudStatus(OggettoBulk.NORMAL);
allegatoParentBulk.addToArchivioAllegati(allegato);
}
}
}
List<StorageObject> filesRimborso = missioniCMISService.getFilesRimborsoMissione(allegatoParentBulk);
if (filesRimborso != null) {
for (StorageObject storageObject : filesRimborso) {
if (missioniCMISService.hasAspect(storageObject, StoragePropertyNames.SYS_ARCHIVED.value()))
continue;
if (excludeChild(storageObject))
continue;
recuperoAllegatiDettaglioMissioneSigla(allegatoParentBulk, storageObject);
if (storageObject.getPropertyValue(StoragePropertyNames.BASE_TYPE_ID.value()).equals(StoragePropertyNames.CMIS_DOCUMENT.value())) {
AllegatoMissioneBulk allegato = (AllegatoMissioneBulk) Introspector.newInstance(getAllegatoClass(), storageObject);
allegato.setContentType(storageObject.<String>getPropertyValue(StoragePropertyNames.CONTENT_STREAM_MIME_TYPE.value()));
allegato.setNome(storageObject.getPropertyValue(StoragePropertyNames.NAME.value()));
allegato.setDescrizione(storageObject.getPropertyValue(StoragePropertyNames.DESCRIPTION.value()));
allegato.setTitolo(storageObject.getPropertyValue(StoragePropertyNames.TITLE.value()));
completeAllegato(allegato, storageObject);
allegato.setCrudStatus(OggettoBulk.NORMAL);
allegatoParentBulk.addToArchivioAllegati(allegato);
}
}
}
if (allegatoParentBulk.getIdFlusso() != null) {
StorageObject storageObject = missioniCMISService.recuperoFlows(allegatoParentBulk.getIdFlusso());
if (storageObject != null) {
AllegatoMissioneBulk allegato = (AllegatoMissioneBulk) Introspector.newInstance(getAllegatoClass(), storageObject);
allegato.setContentType(storageObject.<String>getPropertyValue(StoragePropertyNames.CONTENT_STREAM_MIME_TYPE.value()));
allegato.setNome(storageObject.getPropertyValue(StoragePropertyNames.NAME.value()));
allegato.setDescrizione(storageObject.getPropertyValue(StoragePropertyNames.DESCRIPTION.value()));
allegato.setTitolo(storageObject.getPropertyValue(StoragePropertyNames.TITLE.value()));
allegato.setAspectName(AllegatoMissioneBulk.FLUSSO_RIMBORSO);
allegato.setCrudStatus(OggettoBulk.NORMAL);
allegatoParentBulk.addToArchivioAllegati(allegato);
}
}
if (allegatoParentBulk.getIdFlussoOrdineMissione() != null) {
StorageObject storageObject = missioniCMISService.recuperoFlows(allegatoParentBulk.getIdFlussoOrdineMissione());
if (storageObject != null) {
AllegatoMissioneBulk allegato = (AllegatoMissioneBulk) Introspector.newInstance(getAllegatoClass(), storageObject);
allegato.setContentType(storageObject.<String>getPropertyValue(StoragePropertyNames.CONTENT_STREAM_MIME_TYPE.value()));
allegato.setNome(storageObject.getPropertyValue(StoragePropertyNames.NAME.value()));
allegato.setDescrizione(storageObject.getPropertyValue(StoragePropertyNames.DESCRIPTION.value()));
allegato.setTitolo(storageObject.getPropertyValue(StoragePropertyNames.TITLE.value()));
allegato.setAspectName(AllegatoMissioneBulk.FLUSSO_ORDINE);
allegato.setCrudStatus(OggettoBulk.NORMAL);
allegatoParentBulk.addToArchivioAllegati(allegato);
}
}
} else {
List<StorageObject> files = missioniCMISService.getFilesMissioneSigla(allegatoParentBulk);
if (files != null) {
for (StorageObject storageObject : files) {
if (missioniCMISService.hasAspect(storageObject, StoragePropertyNames.SYS_ARCHIVED.value()))
continue;
if (excludeChild(storageObject))
continue;
recuperoAllegatiDettaglioMissioneSigla(allegatoParentBulk, storageObject);
if (storageObject.getPropertyValue(StoragePropertyNames.BASE_TYPE_ID.value()).equals(StoragePropertyNames.CMIS_DOCUMENT.value())) {
AllegatoMissioneBulk allegato = (AllegatoMissioneBulk) Introspector.newInstance(getAllegatoClass(), storageObject);
allegato.setContentType(storageObject.<String>getPropertyValue(StoragePropertyNames.CONTENT_STREAM_MIME_TYPE.value()));
allegato.setNome(storageObject.getPropertyValue(StoragePropertyNames.NAME.value()));
allegato.setDescrizione(storageObject.getPropertyValue(StoragePropertyNames.DESCRIPTION.value()));
allegato.setTitolo(storageObject.getPropertyValue(StoragePropertyNames.TITLE.value()));
completeAllegato(allegato, storageObject);
allegato.setCrudStatus(OggettoBulk.NORMAL);
allegatoParentBulk.addToArchivioAllegati(allegato);
}
}
}
}
} catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException | DetailedException e) {
throw handleException(e);
}
return oggettobulk;
}
use of it.cnr.si.spring.storage.StorageObject in project sigla-main by consiglionazionaledellericerche.
the class CRUDMissioneBP method scaricaGiustificativiCollegati.
public void scaricaGiustificativiCollegati(ActionContext actioncontext) throws Exception {
AllegatoMissioneDettaglioSpesaBulk dettaglio = (AllegatoMissioneDettaglioSpesaBulk) getDettaglioSpesaAllegatiController().getModel();
if (dettaglio != null) {
StorageObject storageObject = missioniCMISService.getStorageObjectBykey(dettaglio.getStorageKey());
if (storageObject != null) {
InputStream is = missioniCMISService.getResource(storageObject);
((HttpActionContext) actioncontext).getResponse().setContentLength(storageObject.<BigInteger>getPropertyValue(StoragePropertyNames.CONTENT_STREAM_LENGTH.value()).intValue());
((HttpActionContext) actioncontext).getResponse().setContentType(storageObject.getPropertyValue(StoragePropertyNames.CONTENT_STREAM_MIME_TYPE.value()));
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();
} else {
throw new it.cnr.jada.action.MessageToUser("Giustificativi non presenti sul documentale per la riga selezionata");
}
} else {
throw new it.cnr.jada.action.MessageToUser("Giustificativi non presenti sul documentale per la riga selezionata");
}
}
Aggregations