Search in sources :

Example 21 with StorageObject

use of it.cnr.si.spring.storage.StorageObject in project sigla-main by consiglionazionaledellericerche.

the class AbstractFirmaDigitaleDocContBP method addToZip.

private void addToZip(DocumentiContabiliService documentiContabiliService, ZipOutputStream zos, String path, StatoTrasmissione statoTrasmissione) {
    documentiContabiliService.getChildren(documentiContabiliService.getStorageObjectByPath(path).getKey()).stream().forEach(storageObject -> {
        try {
            if (!Optional.ofNullable(storageObject.getPropertyValue(StoragePropertyNames.BASE_TYPE_ID.value())).map(String.class::cast).filter(s -> s.equals(StoragePropertyNames.CMIS_FOLDER.value())).isPresent()) {
                ZipEntry zipEntryChild = new ZipEntry(statoTrasmissione.getCMISFolderName().concat(Optional.ofNullable(storageObject.getPath()).map(s -> s.substring(statoTrasmissione.getStorePath().length())).orElse(StorageDriver.SUFFIX)));
                zos.putNextEntry(zipEntryChild);
                IOUtils.copyLarge(documentiContabiliService.getResource(storageObject), zos);
            } else {
                addToZip(documentiContabiliService, zos, storageObject.getPath(), statoTrasmissione);
            }
        } catch (IOException e) {
            throw new DetailedRuntimeException(e);
        }
    });
}
Also used : LoggerFactory(org.slf4j.LoggerFactory) DocumentiCollegatiDocAmmService(it.cnr.contab.docamm00.service.DocumentiCollegatiDocAmmService) HttpStatus(org.apache.http.HttpStatus) ActionContext(it.cnr.jada.action.ActionContext) Button(it.cnr.jada.util.jsp.Button) PDFMergerUtility(org.apache.pdfbox.multipdf.PDFMergerUtility) StatoTrasmissione(it.cnr.contab.doccont00.intcass.bulk.StatoTrasmissione) StorageException(it.cnr.si.spring.storage.StorageException) ZipEntry(java.util.zip.ZipEntry) Apparence(it.cnr.contab.util.Apparence) ColumnFieldProperty(it.cnr.jada.bulk.ColumnFieldProperty) CRUDNotNullConstraintException(it.cnr.jada.comp.CRUDNotNullConstraintException) StorageObject(it.cnr.si.spring.storage.StorageObject) ZipException(java.util.zip.ZipException) Mandato_rigaBulk(it.cnr.contab.doccont00.core.bulk.Mandato_rigaBulk) MandatoIBulk(it.cnr.contab.doccont00.core.bulk.MandatoIBulk) EJBCommonServices(it.cnr.jada.util.ejb.EJBCommonServices) Collectors(java.util.stream.Collectors) RemoteException(java.rmi.RemoteException) BusinessProcessException(it.cnr.jada.action.BusinessProcessException) FirmaOTPBulk(it.cnr.contab.firma.bulk.FirmaOTPBulk) StorageDriver(it.cnr.si.spring.storage.StorageDriver) IOUtils(org.apache.commons.io.IOUtils) DetailedRuntimeException(it.cnr.jada.DetailedRuntimeException) Numerazione_doc_ammBulk(it.cnr.contab.docamm00.docs.bulk.Numerazione_doc_ammBulk) ContabiliService(it.cnr.contab.doccont00.service.ContabiliService) StoragePropertyNames(it.cnr.si.spring.storage.config.StoragePropertyNames) SelezionatoreListaBP(it.cnr.jada.util.action.SelezionatoreListaBP) PdfSignApparence(it.cnr.contab.util.PdfSignApparence) SpringUtil(it.cnr.contab.service.SpringUtil) ZipOutputStream(java.util.zip.ZipOutputStream) HttpActionContext(it.cnr.jada.action.HttpActionContext) OggettoBulk(it.cnr.jada.bulk.OggettoBulk) java.util(java.util) Unita_organizzativaBulk(it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk) Utility(it.cnr.contab.util.Utility) Tipo_documento_ammBulk(it.cnr.contab.docamm00.docs.bulk.Tipo_documento_ammBulk) CRUDComponentSession(it.cnr.jada.ejb.CRUDComponentSession) DocumentiContabiliService(it.cnr.contab.doccont00.service.DocumentiContabiliService) OrderedHashtable(it.cnr.jada.util.OrderedHashtable) AbilitatoFirma(it.cnr.contab.utenze00.bulk.AbilitatoFirma) Configurazione_cnrComponentSession(it.cnr.contab.config00.ejb.Configurazione_cnrComponentSession) ApplicationException(it.cnr.jada.comp.ApplicationException) Logger(org.slf4j.Logger) HttpServletResponse(javax.servlet.http.HttpServletResponse) UtenteFirmaDettaglioBulk(it.cnr.contab.utenze00.bulk.UtenteFirmaDettaglioBulk) MandatoBulk(it.cnr.contab.doccont00.core.bulk.MandatoBulk) MemoryUsageSetting(org.apache.pdfbox.io.MemoryUsageSetting) CNRUserInfo(it.cnr.contab.utenze00.bulk.CNRUserInfo) SearchProvider(it.cnr.jada.util.action.SearchProvider) java.io(java.io) Numerazione_doc_contBulk(it.cnr.contab.doccont00.core.bulk.Numerazione_doc_contBulk) UtenteComponentSession(it.cnr.contab.utente00.ejb.UtenteComponentSession) Config(it.cnr.jada.action.Config) ComponentException(it.cnr.jada.comp.ComponentException) ZipEntry(java.util.zip.ZipEntry) DetailedRuntimeException(it.cnr.jada.DetailedRuntimeException)

Example 22 with StorageObject

use of it.cnr.si.spring.storage.StorageObject in project sigla-main by consiglionazionaledellericerche.

the class AllegatiDocContBP method scaricaAllegatoAmministrativo.

public void scaricaAllegatoAmministrativo(ActionContext actioncontext) throws IOException, ServletException, ApplicationException {
    AllegatoGenericoBulk allegato = (AllegatoGenericoBulk) getDettaglioAllegati().getModel();
    StorageObject storageObject = storeService.getStorageObjectBykey(allegato.getStorageKey());
    InputStream is = storeService.getResource(allegato.getStorageKey());
    ((HttpActionContext) actioncontext).getResponse().setContentLength((storageObject.<BigInteger>getPropertyValue(StoragePropertyNames.CONTENT_STREAM_LENGTH.value())).intValue());
    ((HttpActionContext) actioncontext).getResponse().setContentType((String) 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();
}
Also used : StorageObject(it.cnr.si.spring.storage.StorageObject) AllegatoGenericoBulk(it.cnr.contab.util00.bulk.storage.AllegatoGenericoBulk)

Example 23 with StorageObject

use of it.cnr.si.spring.storage.StorageObject in project sigla-main by consiglionazionaledellericerche.

the class AllegatiDocContBP method aggiungiAllegati.

public void aggiungiAllegati(ActionContext actioncontext, List<UploadedFile> uploadedFiles) throws BusinessProcessException {
    final V_mandato_reversaleBulk v_mandato_reversaleBulk = Optional.ofNullable(getModel()).filter(V_mandato_reversaleBulk.class::isInstance).map(V_mandato_reversaleBulk.class::cast).orElseThrow(() -> handleException(new ApplicationException("Modello non trovato!")));
    for (UploadedFile uploadedFile : uploadedFiles) {
        AllegatoGenericoBulk allegato = new AllegatoGenericoBulk();
        allegato.setContentType(Optional.ofNullable(uploadedFile).flatMap(uploadedFile1 -> Optional.ofNullable(uploadedFile1.getContentType())).orElseThrow(() -> handleException(new ApplicationException("Non è stato possibile determinare il tipo di file!"))));
        allegato.setNome(Optional.ofNullable(uploadedFile).flatMap(uploadedFile1 -> Optional.ofNullable(uploadedFile1.getName())).orElseThrow(() -> handleException(new ApplicationException("Non è stato possibile determinare il nome del file!"))));
        allegato.setFile(Optional.ofNullable(uploadedFile).flatMap(uploadedFile1 -> Optional.ofNullable(uploadedFile1.getFile())).orElseThrow(() -> handleException(new ApplicationException("File non presente!"))));
        try {
            final Optional<StorageObject> parentFolder = Optional.ofNullable(storeService.getStorageObjectByPath(v_mandato_reversaleBulk.getStorePath()));
            if (parentFolder.isPresent()) {
                try {
                    storeService.storeSimpleDocument(allegato, new FileInputStream(allegato.getFile()), allegato.getContentType(), allegato.getNome(), Optional.ofNullable(uploadedFile.getFilePath()).map(s -> s.substring(s.indexOf(File.separator), s.indexOf(uploadedFile.getName()))).map(s -> v_mandato_reversaleBulk.getStorePath().concat(s)).orElse(v_mandato_reversaleBulk.getStorePath()));
                } catch (StringIndexOutOfBoundsException _ex) {
                    logger.warn("File non caricato path locale {}", uploadedFile.getFilePath());
                    throw handleException(new ApplicationMessageFormatException("Il caricamento è stato interrotto verificare il file [{0}]", uploadedFile.getFilePath()));
                }
            } else {
                throw handleException(new ApplicationException("La Cartella di destinazione non esiste!"));
            }
        } catch (FileNotFoundException e) {
            throw handleException(e);
        } catch (StorageException e) {
            if (e.getType().equals(StorageException.Type.CONSTRAINT_VIOLATED))
                throw handleException(new ApplicationException("File [" + allegato.getNome() + "] gia' presente. Inserimento non possibile!"));
            throw handleException(e);
        }
    }
    edit(actioncontext, v_mandato_reversaleBulk);
    setMessage(FormBP.INFO_MESSAGE, "Allegati inseriti correttamente al documento.");
}
Also used : UploadedFile(it.cnr.jada.util.upload.UploadedFile) HttpActionContext(it.cnr.jada.action.HttpActionContext) OggettoBulk(it.cnr.jada.bulk.OggettoBulk) java.util(java.util) V_mandato_reversaleBulk(it.cnr.contab.doccont00.intcass.bulk.V_mandato_reversaleBulk) ServletException(javax.servlet.ServletException) LoggerFactory(org.slf4j.LoggerFactory) DocumentiCollegatiDocAmmService(it.cnr.contab.docamm00.service.DocumentiCollegatiDocAmmService) Utility(it.cnr.contab.util.Utility) it.cnr.contab.doccont00.core.bulk(it.cnr.contab.doccont00.core.bulk) ActionContext(it.cnr.jada.action.ActionContext) StatoTrasmissione(it.cnr.contab.doccont00.intcass.bulk.StatoTrasmissione) StorageException(it.cnr.si.spring.storage.StorageException) Tipo_documento_ammBulk(it.cnr.contab.docamm00.docs.bulk.Tipo_documento_ammBulk) AllegatiCRUDBP(it.cnr.contab.util00.bp.AllegatiCRUDBP) SimpleDetailCRUDController(it.cnr.jada.util.action.SimpleDetailCRUDController) BigInteger(java.math.BigInteger) StoreService(it.cnr.si.spring.storage.StoreService) ValidationException(it.cnr.jada.bulk.ValidationException) OrderedHashtable(it.cnr.jada.util.OrderedHashtable) ApplicationException(it.cnr.jada.comp.ApplicationException) FormBP(it.cnr.jada.util.action.FormBP) AllegatoParentBulk(it.cnr.contab.util00.bulk.storage.AllegatoParentBulk) Logger(org.slf4j.Logger) StorageObject(it.cnr.si.spring.storage.StorageObject) AllegatoStorePath(it.cnr.contab.util00.bulk.storage.AllegatoStorePath) BulkList(it.cnr.jada.bulk.BulkList) Collectors(java.util.stream.Collectors) RemoteException(java.rmi.RemoteException) AllegatoGenericoBulk(it.cnr.contab.util00.bulk.storage.AllegatoGenericoBulk) BusinessProcessException(it.cnr.jada.action.BusinessProcessException) DetailedRuntimeException(it.cnr.jada.DetailedRuntimeException) Numerazione_doc_ammBulk(it.cnr.contab.docamm00.docs.bulk.Numerazione_doc_ammBulk) Stream(java.util.stream.Stream) java.io(java.io) ApplicationMessageFormatException(it.cnr.contab.util.ApplicationMessageFormatException) ContabiliService(it.cnr.contab.doccont00.service.ContabiliService) StoragePropertyNames(it.cnr.si.spring.storage.config.StoragePropertyNames) ComponentException(it.cnr.jada.comp.ComponentException) SpringUtil(it.cnr.contab.service.SpringUtil) V_mandato_reversaleBulk(it.cnr.contab.doccont00.intcass.bulk.V_mandato_reversaleBulk) ApplicationException(it.cnr.jada.comp.ApplicationException) UploadedFile(it.cnr.jada.util.upload.UploadedFile) StorageObject(it.cnr.si.spring.storage.StorageObject) AllegatoGenericoBulk(it.cnr.contab.util00.bulk.storage.AllegatoGenericoBulk) ApplicationMessageFormatException(it.cnr.contab.util.ApplicationMessageFormatException) StorageException(it.cnr.si.spring.storage.StorageException)

Example 24 with StorageObject

use of it.cnr.si.spring.storage.StorageObject in project sigla-main by consiglionazionaledellericerche.

the class CRUDConfigAnagContrattoBP method initializeModelForEdit.

@Override
public OggettoBulk initializeModelForEdit(ActionContext actioncontext, OggettoBulk oggettobulk) throws BusinessProcessException {
    ContrattoBulk contratto = (ContrattoBulk) super.initializeModelForEdit(actioncontext, oggettobulk);
    try {
        Optional.ofNullable(contrattoService.getFolderContratto(contratto)).map(storageObject -> contrattoService.getChildren(storageObject.getKey())).map(storageObjects -> storageObjects.stream()).orElse(Stream.empty()).filter(storageObject -> Optional.ofNullable(storageObject.getKey()).isPresent()).forEach(child -> {
            contratto.setAllegatoFlusso(false);
            if (contratto.isFromFlussoAcquisti()) {
                AllegatoContrattoFlussoDocumentBulk allegato = AllegatoContrattoFlussoDocumentBulk.construct(child);
                Optional.ofNullable(child.<List<String>>getPropertyValue(StoragePropertyNames.SECONDARY_OBJECT_TYPE_IDS.value())).map(strings -> strings.stream()).ifPresent(stringStream -> {
                    stringStream.filter(s -> AllegatoContrattoFlussoDocumentBulk.ti_allegatoFlussoKeys.get(s) != null).findFirst().ifPresent(s -> allegato.setType(s));
                    if (allegato.getType() != null) {
                        allegato.setContentType(child.getPropertyValue(StoragePropertyNames.CONTENT_STREAM_MIME_TYPE.value()));
                        allegato.setDescrizione(child.getPropertyValue(StoragePropertyNames.DESCRIPTION.value()));
                        allegato.setTitolo(child.getPropertyValue(StoragePropertyNames.TITLE.value()));
                        allegato.setNome(allegato.getTitolo());
                        allegato.setCrudStatus(OggettoBulk.NORMAL);
                        contratto.addToArchivioAllegatiFlusso(allegato);
                        contratto.setAllegatoFlusso(true);
                        if (!allegato.isContentStreamPresent())
                            setMessage(ERROR_MESSAGE, "Attenzione l'allegato [" + allegato.getName() + "] risulta privo di contenuto!");
                    }
                });
            }
            if (contratto.getAllegatoFlusso() == false) {
                AllegatoContrattoDocumentBulk allegato = AllegatoContrattoDocumentBulk.construct(child);
                allegato.setContentType(child.getPropertyValue(StoragePropertyNames.CONTENT_STREAM_MIME_TYPE.value()));
                allegato.setDescrizione(child.getPropertyValue(StoragePropertyNames.DESCRIPTION.value()));
                allegato.setTitolo(child.getPropertyValue(StoragePropertyNames.TITLE.value()));
                allegato.setNome(child.getPropertyValue("sigla_contratti_attachment:original_name"));
                allegato.setType(child.getPropertyValue(StoragePropertyNames.OBJECT_TYPE_ID.value()));
                allegato.setLink(child.<String>getPropertyValue("sigla_contratti_aspect_link:url"));
                allegato.setCrudStatus(OggettoBulk.NORMAL);
                contratto.addToArchivioAllegati(allegato);
                if (!allegato.isContentStreamPresent())
                    setMessage(ERROR_MESSAGE, "Attenzione l'allegato [" + allegato.getName() + "] risulta privo di contenuto!");
            }
        });
    } catch (ApplicationException e) {
        throw handleException(e);
    }
    return contratto;
}
Also used : HttpActionContext(it.cnr.jada.action.HttpActionContext) UploadedFile(it.cnr.jada.util.upload.UploadedFile) OggettoBulk(it.cnr.jada.bulk.OggettoBulk) ContrattoService(it.cnr.contab.config00.service.ContrattoService) Unita_organizzativaBulk(it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk) ServletException(javax.servlet.ServletException) Date(java.util.Date) HSSFCell(org.apache.poi.hssf.usermodel.HSSFCell) Utility(it.cnr.contab.util.Utility) ActionContext(it.cnr.jada.action.ActionContext) HSSFRow(org.apache.poi.hssf.usermodel.HSSFRow) Ass_contratto_ditteBulk(it.cnr.contab.config00.contratto.bulk.Ass_contratto_ditteBulk) StorageException(it.cnr.si.spring.storage.StorageException) Ass_contratto_uoBulk(it.cnr.contab.config00.contratto.bulk.Ass_contratto_uoBulk) SimpleDetailCRUDController(it.cnr.jada.util.action.SimpleDetailCRUDController) HSSFSheet(org.apache.poi.hssf.usermodel.HSSFSheet) SimpleCRUDBP(it.cnr.jada.util.action.SimpleCRUDBP) BigInteger(java.math.BigInteger) SIGLAGroups(it.cnr.contab.util.SIGLAGroups) RemoteIterator(it.cnr.jada.util.RemoteIterator) ValidationException(it.cnr.jada.bulk.ValidationException) RecordFormatException(org.apache.poi.util.RecordFormatException) OutputStream(java.io.OutputStream) RemoveException(javax.ejb.RemoveException) CNRUserContext(it.cnr.contab.utenze00.bp.CNRUserContext) ApplicationException(it.cnr.jada.comp.ApplicationException) Iterator(java.util.Iterator) ContrattoComponentSession(it.cnr.contab.config00.ejb.ContrattoComponentSession) StorageObject(it.cnr.si.spring.storage.StorageObject) ContrattoBulk(it.cnr.contab.config00.contratto.bulk.ContrattoBulk) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) EJBCommonServices(it.cnr.jada.util.ejb.EJBCommonServices) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) RemoteException(java.rmi.RemoteException) EJBException(javax.ejb.EJBException) BusinessProcessException(it.cnr.jada.action.BusinessProcessException) AllegatoContrattoFlussoDocumentBulk(it.cnr.contab.config00.contratto.bulk.AllegatoContrattoFlussoDocumentBulk) List(java.util.List) Stream(java.util.stream.Stream) Optional(java.util.Optional) AllegatoContrattoDocumentBulk(it.cnr.contab.config00.contratto.bulk.AllegatoContrattoDocumentBulk) StoragePropertyNames(it.cnr.si.spring.storage.config.StoragePropertyNames) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook) ComponentException(it.cnr.jada.comp.ComponentException) InputStream(java.io.InputStream) SpringUtil(it.cnr.contab.service.SpringUtil) AllegatoContrattoDocumentBulk(it.cnr.contab.config00.contratto.bulk.AllegatoContrattoDocumentBulk) ApplicationException(it.cnr.jada.comp.ApplicationException) AllegatoContrattoFlussoDocumentBulk(it.cnr.contab.config00.contratto.bulk.AllegatoContrattoFlussoDocumentBulk) ContrattoBulk(it.cnr.contab.config00.contratto.bulk.ContrattoBulk)

Example 25 with StorageObject

use of it.cnr.si.spring.storage.StorageObject in project sigla-main by consiglionazionaledellericerche.

the class CRUDConfigAnagContrattoBP method pubblicaContratto.

@Deprecated
public void pubblicaContratto(ActionContext context) throws it.cnr.jada.action.BusinessProcessException {
    ContrattoBulk contratto = (ContrattoBulk) getModel();
    try {
        archiviaAllegati(context, contratto);
    } catch (ApplicationException e) {
        throw handleException(e);
    }
    try {
        StorageObject folder = contrattoService.getFolderContratto((ContrattoBulk) getModel());
        if (!contratto.isAllegatoContrattoPresent())
            throw handleException(new ApplicationException("Bisogna allegare il file del Contratto!"));
        contratto.setFl_pubblica_contratto(Boolean.TRUE);
        contratto.setToBeUpdated();
        ContrattoComponentSession comp = (ContrattoComponentSession) createComponentSession();
        comp.modificaConBulk(context.getUserContext(), contratto);
        if (folder != null) {
            contrattoService.updateProperties(contratto, folder);
            contrattoService.addAspect(folder, "P:sigla_contratti_aspect:stato_definitivo");
            contrattoService.addConsumer(folder, SIGLAGroups.GROUP_CONTRATTI.name());
            contrattoService.setInheritedPermission(contrattoService.getStorageObjectByPath(contrattoService.getCMISPathFolderContratto(contratto)), Boolean.FALSE);
        }
        edit(context, contratto);
    } catch (it.cnr.jada.comp.ComponentException ex) {
        throw handleException(ex);
    } catch (java.rmi.RemoteException ex) {
        throw handleException(ex);
    }
}
Also used : ApplicationException(it.cnr.jada.comp.ApplicationException) StorageObject(it.cnr.si.spring.storage.StorageObject) ContrattoComponentSession(it.cnr.contab.config00.ejb.ContrattoComponentSession) ContrattoBulk(it.cnr.contab.config00.contratto.bulk.ContrattoBulk) ComponentException(it.cnr.jada.comp.ComponentException) RemoteException(java.rmi.RemoteException)

Aggregations

StorageObject (it.cnr.si.spring.storage.StorageObject)86 ApplicationException (it.cnr.jada.comp.ApplicationException)48 ComponentException (it.cnr.jada.comp.ComponentException)36 BigInteger (java.math.BigInteger)34 StorageException (it.cnr.si.spring.storage.StorageException)31 RemoteException (java.rmi.RemoteException)27 StoragePropertyNames (it.cnr.si.spring.storage.config.StoragePropertyNames)25 SpringUtil (it.cnr.contab.service.SpringUtil)24 BusinessProcessException (it.cnr.jada.action.BusinessProcessException)24 HttpActionContext (it.cnr.jada.action.HttpActionContext)24 OggettoBulk (it.cnr.jada.bulk.OggettoBulk)23 StoreService (it.cnr.si.spring.storage.StoreService)21 java.util (java.util)20 ServletException (javax.servlet.ServletException)19 ActionContext (it.cnr.jada.action.ActionContext)18 Unita_organizzativaBulk (it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk)16 EJBCommonServices (it.cnr.jada.util.ejb.EJBCommonServices)16 Collectors (java.util.stream.Collectors)16 Print_spoolerBulk (it.cnr.contab.reports.bulk.Print_spoolerBulk)15 Report (it.cnr.contab.reports.bulk.Report)15