Search in sources :

Example 1 with AllegatoGenericoBulk

use of it.cnr.contab.util00.bulk.storage.AllegatoGenericoBulk in project sigla-main by consiglionazionaledellericerche.

the class CRUDMissioneBP method delete.

@Override
public void delete(ActionContext actioncontext) throws BusinessProcessException {
    if (Optional.ofNullable(getModel()).filter(MissioneBulk.class::isInstance).map(MissioneBulk.class::cast).map(el -> {
        try {
            return el.isMissioneFromGemis() && !el.isAbilitatoCancellazioneMissioneFromGemis(actioncontext.getUserContext());
        } catch (Exception e) {
            throw new DetailedRuntimeException(e);
        }
    }).orElse(Boolean.FALSE))
        throw handleException(new ApplicationException("Missione non eliminabile in quanto proveniente da un flusso approvato."));
    MissioneBulk missioneBulk = (MissioneBulk) getModel();
    if (missioneBulk.isMissioneFromGemis()) {
        for (AllegatoGenericoBulk allegato : missioneBulk.getArchivioAllegati()) {
            allegato.setDaNonEliminare(true);
        }
    }
    super.delete(actioncontext);
}
Also used : ServletException(javax.servlet.ServletException) EconomicaDareDetailCRUDController(it.cnr.contab.coepcoan00.bp.EconomicaDareDetailCRUDController) IDefferedUpdateSaldiBP(it.cnr.contab.doccont00.bp.IDefferedUpdateSaldiBP) MissioniCMISService(it.cnr.contab.missioni00.service.MissioniCMISService) Button(it.cnr.jada.util.jsp.Button) BigDecimal(java.math.BigDecimal) StorageException(it.cnr.si.spring.storage.StorageException) DocumentoGenericoComponentSession(it.cnr.contab.docamm00.ejb.DocumentoGenericoComponentSession) SimpleDetailCRUDController(it.cnr.jada.util.action.SimpleDetailCRUDController) IDocumentoAmministrativoSpesaBP(it.cnr.contab.docamm00.bp.IDocumentoAmministrativoSpesaBP) BigInteger(java.math.BigInteger) Accertamento_scadenzarioBulk(it.cnr.contab.doccont00.core.bulk.Accertamento_scadenzarioBulk) CollapsableDetailCRUDController(it.cnr.jada.util.action.CollapsableDetailCRUDController) ParseException(java.text.ParseException) ValidationException(it.cnr.jada.bulk.ValidationException) Print_spooler_paramBulk(it.cnr.contab.reports.bulk.Print_spooler_paramBulk) StorageObject(it.cnr.si.spring.storage.StorageObject) CRUDScritturaPDoppiaBP(it.cnr.contab.coepcoan00.bp.CRUDScritturaPDoppiaBP) StorePath(it.cnr.contab.spring.service.StorePath) EconomicaAvereDetailCRUDController(it.cnr.contab.coepcoan00.bp.EconomicaAvereDetailCRUDController) DetailedException(it.cnr.jada.DetailedException) Parametri_cnrBulk(it.cnr.contab.config00.bulk.Parametri_cnrBulk) Collectors(java.util.stream.Collectors) CambioBulk(it.cnr.contab.docamm00.tabrif.bulk.CambioBulk) InvocationTargetException(java.lang.reflect.InvocationTargetException) RemoteException(java.rmi.RemoteException) RicercaDocContComponentSession(it.cnr.contab.chiusura00.ejb.RicercaDocContComponentSession) StorageDriver(it.cnr.si.spring.storage.StorageDriver) IValidaDocContBP(it.cnr.contab.doccont00.bp.IValidaDocContBP) DetailedRuntimeException(it.cnr.jada.DetailedRuntimeException) it.cnr.jada.action(it.cnr.jada.action) NazioneBulk(it.cnr.contab.anagraf00.tabter.bulk.NazioneBulk) MissioneComponentSession(it.cnr.contab.missioni00.ejb.MissioneComponentSession) StoragePropertyNames(it.cnr.si.spring.storage.config.StoragePropertyNames) IDocAmmEconomicaBP(it.cnr.contab.docamm00.bp.IDocAmmEconomicaBP) SpringUtil(it.cnr.contab.service.SpringUtil) UserContext(it.cnr.jada.UserContext) UploadedFile(it.cnr.jada.util.upload.UploadedFile) OggettoBulk(it.cnr.jada.bulk.OggettoBulk) java.util(java.util) Utility(it.cnr.contab.util.Utility) IDocumentoAmministrativoBulk(it.cnr.contab.docamm00.docs.bulk.IDocumentoAmministrativoBulk) AllegatiCRUDBP(it.cnr.contab.util00.bp.AllegatiCRUDBP) Introspector(it.cnr.jada.util.Introspector) Configurazione_cnrComponentSession(it.cnr.contab.config00.ejb.Configurazione_cnrComponentSession) ApplicationException(it.cnr.jada.comp.ApplicationException) DivisaBulk(it.cnr.contab.docamm00.tabrif.bulk.DivisaBulk) AllegatoParentBulk(it.cnr.contab.util00.bulk.storage.AllegatoParentBulk) ObbligazioneResBulk(it.cnr.contab.doccont00.core.bulk.ObbligazioneResBulk) BulkList(it.cnr.jada.bulk.BulkList) RiportoDocAmmComponentSession(it.cnr.contab.docamm00.ejb.RiportoDocAmmComponentSession) AllegatoGenericoBulk(it.cnr.contab.util00.bulk.storage.AllegatoGenericoBulk) it.cnr.contab.missioni00.docs.bulk(it.cnr.contab.missioni00.docs.bulk) java.io(java.io) Obbligazione_scadenzarioBulk(it.cnr.contab.doccont00.core.bulk.Obbligazione_scadenzarioBulk) ComponentException(it.cnr.jada.comp.ComponentException) ApplicationException(it.cnr.jada.comp.ApplicationException) AllegatoGenericoBulk(it.cnr.contab.util00.bulk.storage.AllegatoGenericoBulk) ServletException(javax.servlet.ServletException) StorageException(it.cnr.si.spring.storage.StorageException) ParseException(java.text.ParseException) ValidationException(it.cnr.jada.bulk.ValidationException) DetailedException(it.cnr.jada.DetailedException) InvocationTargetException(java.lang.reflect.InvocationTargetException) RemoteException(java.rmi.RemoteException) DetailedRuntimeException(it.cnr.jada.DetailedRuntimeException) ApplicationException(it.cnr.jada.comp.ApplicationException) ComponentException(it.cnr.jada.comp.ComponentException) DetailedRuntimeException(it.cnr.jada.DetailedRuntimeException)

Example 2 with AllegatoGenericoBulk

use of it.cnr.contab.util00.bulk.storage.AllegatoGenericoBulk 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 3 with AllegatoGenericoBulk

use of it.cnr.contab.util00.bulk.storage.AllegatoGenericoBulk 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 4 with AllegatoGenericoBulk

use of it.cnr.contab.util00.bulk.storage.AllegatoGenericoBulk in project sigla-main by consiglionazionaledellericerche.

the class AllegatiCRUDBP method scaricaAllegatoGenerico.

public void scaricaAllegatoGenerico(ActionContext actioncontext) throws IOException, ServletException, ApplicationException {
    AllegatoGenericoBulk allegato = (T) crudArchivioAllegati.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(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 5 with AllegatoGenericoBulk

use of it.cnr.contab.util00.bulk.storage.AllegatoGenericoBulk in project sigla-main by consiglionazionaledellericerche.

the class AllegatiCRUDBP method archiviaAllegati.

@SuppressWarnings("unchecked")
protected void archiviaAllegati(ActionContext actioncontext) throws BusinessProcessException, ApplicationException {
    AllegatoParentBulk allegatoParentBulk = (AllegatoParentBulk) getModel();
    for (AllegatoGenericoBulk allegato : allegatoParentBulk.getArchivioAllegati()) {
        if (allegato.isToBeCreated()) {
            final File file = Optional.ofNullable(allegato.getFile()).orElseThrow(() -> new ApplicationException("File non presente"));
            try {
                allegato.complete(actioncontext.getUserContext());
                storeService.storeSimpleDocument(allegato, new FileInputStream(file), allegato.getContentType(), allegato.getNome(), getStorePath((K) allegatoParentBulk, true));
                allegato.setCrudStatus(OggettoBulk.NORMAL);
            } catch (FileNotFoundException e) {
                throw handleException(e);
            } catch (StorageException e) {
                if (e.getType().equals(StorageException.Type.CONSTRAINT_VIOLATED))
                    throw new ApplicationException("File [" + allegato.getNome() + "] gia' presente. Inserimento non possibile!");
                throw handleException(e);
            }
        } else if (allegato.isToBeUpdated()) {
            if (isPossibileModifica(allegato)) {
                try {
                    if (allegato.getFile() != null) {
                        storeService.updateStream(allegato.getStorageKey(), new FileInputStream(allegato.getFile()), allegato.getContentType());
                    }
                    allegato.complete(actioncontext.getUserContext());
                    storeService.updateProperties(allegato, storeService.getStorageObjectBykey(allegato.getStorageKey()));
                    allegato.setCrudStatus(OggettoBulk.NORMAL);
                } catch (FileNotFoundException e) {
                    throw handleException(e);
                } catch (StorageException e) {
                    if (e.getType().equals(StorageException.Type.CONSTRAINT_VIOLATED))
                        throw new ApplicationException("File [" + allegato.getNome() + "] gia' presente. Inserimento non possibile!");
                    throw handleException(e);
                }
            }
        }
    }
    gestioneCancellazioneAllegati(allegatoParentBulk);
}
Also used : ApplicationException(it.cnr.jada.comp.ApplicationException) AllegatoParentBulk(it.cnr.contab.util00.bulk.storage.AllegatoParentBulk) AllegatoGenericoBulk(it.cnr.contab.util00.bulk.storage.AllegatoGenericoBulk) StorageException(it.cnr.si.spring.storage.StorageException)

Aggregations

AllegatoGenericoBulk (it.cnr.contab.util00.bulk.storage.AllegatoGenericoBulk)12 AllegatoParentBulk (it.cnr.contab.util00.bulk.storage.AllegatoParentBulk)8 ApplicationException (it.cnr.jada.comp.ApplicationException)7 StorageException (it.cnr.si.spring.storage.StorageException)7 StorageObject (it.cnr.si.spring.storage.StorageObject)7 RemoteException (java.rmi.RemoteException)5 SpringUtil (it.cnr.contab.service.SpringUtil)4 BulkList (it.cnr.jada.bulk.BulkList)4 StoragePropertyNames (it.cnr.si.spring.storage.config.StoragePropertyNames)4 java.io (java.io)4 Utility (it.cnr.contab.util.Utility)3 BusinessProcessException (it.cnr.jada.action.BusinessProcessException)3 OggettoBulk (it.cnr.jada.bulk.OggettoBulk)3 ComponentException (it.cnr.jada.comp.ComponentException)3 AllegatiCRUDBP (it.cnr.contab.util00.bp.AllegatiCRUDBP)2 DetailedRuntimeException (it.cnr.jada.DetailedRuntimeException)2 ValidationException (it.cnr.jada.bulk.ValidationException)2 CompoundFindClause (it.cnr.jada.persistency.sql.CompoundFindClause)2 RemoteIterator (it.cnr.jada.util.RemoteIterator)2 SimpleDetailCRUDController (it.cnr.jada.util.action.SimpleDetailCRUDController)2