Search in sources :

Example 1 with ContrattiService

use of it.cnr.contab.incarichi00.service.ContrattiService in project sigla-main by consiglionazionaledellericerche.

the class CRUDIncarichiProceduraBP method scaricaFile.

public void scaricaFile(ActionContext actioncontext, String cmsNodeRef) throws IOException, ServletException, ApplicationException {
    ContrattiService contrattiService = SpringUtil.getBean(ContrattiService.class);
    StorageObject storageObject = contrattiService.getStorageObjectBykey(cmsNodeRef);
    InputStream is = contrattiService.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);
    IOUtils.copyLarge(is, os);
}
Also used : StorageObject(it.cnr.si.spring.storage.StorageObject) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) BigInteger(java.math.BigInteger) ContrattiService(it.cnr.contab.incarichi00.service.ContrattiService)

Example 2 with ContrattiService

use of it.cnr.contab.incarichi00.service.ContrattiService in project sigla-main by consiglionazionaledellericerche.

the class CRUDIncarichiProceduraBP method scaricaAllegato.

private void scaricaAllegato(ActionContext actioncontext, Incarichi_archivioBulk incarichi_archivioBulk) throws IOException {
    ContrattiService storeService = SpringUtil.getBean(ContrattiService.class);
    StorageObject storageObject = storeService.getStorageObjectBykey(incarichi_archivioBulk.getCms_node_ref());
    InputStream is = storeService.getResource(incarichi_archivioBulk.getCms_node_ref());
    ((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) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) ContrattiService(it.cnr.contab.incarichi00.service.ContrattiService)

Example 3 with ContrattiService

use of it.cnr.contab.incarichi00.service.ContrattiService in project sigla-main by consiglionazionaledellericerche.

the class IncarichiRepertorioComponent method salvaDefinitivoCMIS.

public void salvaDefinitivoCMIS(UserContext userContext, Incarichi_repertorioBulk incarico_repertorio) throws ComponentException {
    List<StorageObject> nodeAddAspect = new ArrayList<StorageObject>();
    List<StorageObject> nodeAddConsumer = new ArrayList<StorageObject>();
    ContrattiService contrattiService = SpringUtil.getBean("contrattiService", ContrattiService.class);
    try {
        StorageObject nodeIncarico = contrattiService.getStorageObjectByPath(incarico_repertorio.getCMISFolder().getCMISPath());
        if (nodeIncarico != null && !contrattiService.hasAspect(nodeIncarico, StorageContrattiAspect.SIGLA_CONTRATTI_STATO_DEFINITIVO.value())) {
            contrattiService.addAspect(nodeIncarico, StorageContrattiAspect.SIGLA_CONTRATTI_STATO_DEFINITIVO.value());
            contrattiService.addConsumerToEveryone(nodeIncarico);
            nodeAddAspect.add(nodeIncarico);
            nodeAddConsumer.add(nodeIncarico);
            StorageObject nodeProcedura = contrattiService.getStorageObjectByPath(incarico_repertorio.getIncarichi_procedura().getCMISFolder().getCMISPath());
            if (nodeProcedura != null)
                contrattiService.addConsumerToEveryone(nodeProcedura);
        }
        BulkList listArchiviFile = new BulkList();
        listArchiviFile.addAll(incarico_repertorio.getArchivioAllegati());
        listArchiviFile.addAll(incarico_repertorio.getIncarichi_repertorio_varColl());
        listArchiviFile.addAll(incarico_repertorio.getIncarichi_repertorio_rappColl());
        for (Iterator i = listArchiviFile.iterator(); i.hasNext(); ) {
            Incarichi_archivioBulk allegato = (Incarichi_archivioBulk) i.next();
            if (allegato.getCms_node_ref() != null) {
                StorageObject nodeAllegato = contrattiService.getStorageObjectBykey(allegato.getCms_node_ref());
                if (nodeAllegato != null && !contrattiService.hasAspect(nodeAllegato, StorageContrattiAspect.SIGLA_CONTRATTI_STATO_ANNULLATO.value()) && !contrattiService.hasAspect(nodeAllegato, StorageContrattiAspect.SIGLA_CONTRATTI_STATO_DEFINITIVO.value())) {
                    contrattiService.addAspect(nodeAllegato, StorageContrattiAspect.SIGLA_CONTRATTI_STATO_DEFINITIVO.value());
                    nodeAddAspect.add(nodeAllegato);
                }
                if (nodeAllegato != null) {
                    if (incarico_repertorio.isIncaricoAnnullato() || incarico_repertorio.isIncaricoProvvisorio() || allegato.isAnnullato() || !(allegato.isBando() || allegato.isCurriculumVincitore() || allegato.isAggiornamentoCurriculumVincitore() || allegato.isConflittoInteressi()))
                        contrattiService.setInheritedPermission(nodeAllegato, false);
                    else if (allegato.isBando())
                        contrattiService.setInheritedPermission(nodeAllegato, true);
                    else if (incarico_repertorio.isIncaricoDefinitivo() && (allegato.isCurriculumVincitore() || allegato.isAggiornamentoCurriculumVincitore() || allegato.isConflittoInteressi()))
                        contrattiService.setInheritedPermission(nodeAllegato, true);
                    else
                        contrattiService.setInheritedPermission(nodeAllegato, false);
                }
            }
        }
    } catch (Exception e) {
        // Codice per riallineare il documentale allo stato precedente rispetto alle modifiche
        for (StorageObject node : nodeAddAspect) contrattiService.removeAspect(node, StorageContrattiAspect.SIGLA_CONTRATTI_STATO_DEFINITIVO.value());
        for (StorageObject node : nodeAddConsumer) contrattiService.removeConsumerToEveryone(node);
        throw new ApplicationException(e.getMessage());
    }
}
Also used : StorageObject(it.cnr.si.spring.storage.StorageObject) ApplicationException(it.cnr.jada.comp.ApplicationException) BulkList(it.cnr.jada.bulk.BulkList) ContrattiService(it.cnr.contab.incarichi00.service.ContrattiService) IntrospectionException(it.cnr.jada.persistency.IntrospectionException) SQLException(java.sql.SQLException) ApplicationException(it.cnr.jada.comp.ApplicationException) PersistencyException(it.cnr.jada.persistency.PersistencyException) ComponentException(it.cnr.jada.comp.ComponentException)

Example 4 with ContrattiService

use of it.cnr.contab.incarichi00.service.ContrattiService in project sigla-main by consiglionazionaledellericerche.

the class IncarichiProceduraComponent method addConsumerToEveryone.

public void addConsumerToEveryone(UserContext userContext, Incarichi_proceduraBulk incarico_procedura) throws ComponentException {
    ContrattiService contrattiService = SpringUtil.getBean(ContrattiService.class);
    Optional.ofNullable(contrattiService.getStorageObjectByPath(incarico_procedura.getCMISFolder().getCMISPath())).ifPresent(storageObject -> contrattiService.addConsumerToEveryone(storageObject));
}
Also used : ContrattiService(it.cnr.contab.incarichi00.service.ContrattiService)

Example 5 with ContrattiService

use of it.cnr.contab.incarichi00.service.ContrattiService in project sigla-main by consiglionazionaledellericerche.

the class IncarichiProceduraComponent method salvaDefinitivoCMIS.

public void salvaDefinitivoCMIS(UserContext userContext, Incarichi_proceduraBulk incarico_procedura) throws ComponentException {
    List<StorageObject> nodeAddAspect = new ArrayList<StorageObject>();
    ContrattiService contrattiService = SpringUtil.getBean(ContrattiService.class);
    try {
        Optional.ofNullable(contrattiService.getStorageObjectByPath(incarico_procedura.getCMISFolder().getCMISPath())).filter(storageObject -> storageObject.<List<String>>getPropertyValue(StoragePropertyNames.SECONDARY_OBJECT_TYPE_IDS.value()).contains(StorageContrattiAspect.SIGLA_CONTRATTI_STATO_DEFINITIVO.value())).ifPresent(storageObject -> {
            List<String> aspects = storageObject.<List<String>>getPropertyValue(StoragePropertyNames.SECONDARY_OBJECT_TYPE_IDS.value());
            aspects.add(StorageContrattiAspect.SIGLA_CONTRATTI_STATO_DEFINITIVO.value());
            contrattiService.updateProperties(Collections.singletonMap(StoragePropertyNames.SECONDARY_OBJECT_TYPE_IDS.value(), aspects), storageObject);
        });
        BulkList listArchiviFile = new BulkList();
        listArchiviFile.addAll(incarico_procedura.getArchivioAllegati());
        for (Iterator i = listArchiviFile.iterator(); i.hasNext(); ) {
            Incarichi_archivioBulk allegato = (Incarichi_archivioBulk) i.next();
            if (allegato.getCms_node_ref() != null) {
                Optional<StorageObject> optStorage = Optional.ofNullable(contrattiService.getStorageObjectBykey(allegato.getCms_node_ref()));
                if (optStorage.isPresent()) {
                    contrattiService.addConsumer(optStorage.get(), SIGLAGroups.GROUP_CONTRATTI.name());
                    contrattiService.addConsumer(optStorage.get(), SIGLAGroups.GROUP_INCARICHI.name());
                }
                optStorage.filter(storageObject -> !storageObject.<List<String>>getPropertyValue(StoragePropertyNames.SECONDARY_OBJECT_TYPE_IDS.value()).contains(StorageContrattiAspect.SIGLA_CONTRATTI_STATO_ANNULLATO.value()) && !storageObject.<List<String>>getPropertyValue(StoragePropertyNames.SECONDARY_OBJECT_TYPE_IDS.value()).contains(StorageContrattiAspect.SIGLA_CONTRATTI_STATO_DEFINITIVO.value())).ifPresent(storageObject -> {
                    contrattiService.addAspect(storageObject, StorageContrattiAspect.SIGLA_CONTRATTI_STATO_DEFINITIVO.value());
                });
                if (allegato != null && optStorage.isPresent()) {
                    if (incarico_procedura.isProceduraAnnullata() || incarico_procedura.isProceduraProvvisoria() || allegato.isAnnullato() || !(allegato.isBando() || allegato.isCurriculumVincitore() || allegato.isAggiornamentoCurriculumVincitore() || allegato.isConflittoInteressi()))
                        contrattiService.setInheritedPermission(optStorage.get(), false);
                    else if (allegato.isBando())
                        contrattiService.setInheritedPermission(optStorage.get(), true);
                    else if (incarico_procedura.isProceduraDefinitiva() && (allegato.isCurriculumVincitore() || allegato.isAggiornamentoCurriculumVincitore() || allegato.isConflittoInteressi()))
                        contrattiService.setInheritedPermission(optStorage.get(), true);
                    else
                        contrattiService.setInheritedPermission(optStorage.get(), false);
                }
            }
        }
    } catch (StorageException e) {
        // Codice per riallineare il documentale allo stato precedente rispetto alle modifiche
        for (StorageObject storageObject : nodeAddAspect) {
            contrattiService.removeAspect(storageObject, StorageContrattiAspect.SIGLA_CONTRATTI_STATO_DEFINITIVO.value());
        }
        throw new ApplicationException(e.getMessage());
    }
}
Also used : V_terzo_per_compensoHome(it.cnr.contab.compensi00.docs.bulk.V_terzo_per_compensoHome) LoggerFactory(org.slf4j.LoggerFactory) V_struttura_organizzativaHome(it.cnr.contab.config00.sto.bulk.V_struttura_organizzativaHome) BigDecimal(java.math.BigDecimal) StorageException(it.cnr.si.spring.storage.StorageException) NotImplementedException(org.apache.commons.lang.NotImplementedException) CRUDComponent(it.cnr.jada.comp.CRUDComponent) Procedure_amministrativeBulk(it.cnr.contab.config00.contratto.bulk.Procedure_amministrativeBulk) StorageObject(it.cnr.si.spring.storage.StorageObject) Gruppo_fileBulk(it.cnr.contab.config00.file.bulk.Gruppo_fileBulk) Timestamp(java.sql.Timestamp) SQLBuilder(it.cnr.jada.persistency.sql.SQLBuilder) ComuneBulk(it.cnr.contab.anagraf00.tabter.bulk.ComuneBulk) RemoteException(java.rmi.RemoteException) EJBException(javax.ejb.EJBException) Tipo_fileBulk(it.cnr.contab.config00.file.bulk.Tipo_fileBulk) StorageContrattiAspect(it.cnr.contab.incarichi00.storage.StorageContrattiAspect) it.cnr.contab.incarichi00.bulk.storage(it.cnr.contab.incarichi00.bulk.storage) Query(it.cnr.jada.persistency.sql.Query) StoragePropertyNames(it.cnr.si.spring.storage.config.StoragePropertyNames) CompensoBulk(it.cnr.contab.compensi00.docs.bulk.CompensoBulk) it.cnr.contab.incarichi00.tabrif.bulk(it.cnr.contab.incarichi00.tabrif.bulk) SpringUtil(it.cnr.contab.service.SpringUtil) TerzoBulk(it.cnr.contab.anagraf00.core.bulk.TerzoBulk) UserContext(it.cnr.jada.UserContext) OggettoBulk(it.cnr.jada.bulk.OggettoBulk) java.util(java.util) Unita_organizzativaBulk(it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk) RepertorioLimitiComponentSession(it.cnr.contab.incarichi00.ejb.RepertorioLimitiComponentSession) Utility(it.cnr.contab.util.Utility) CompensoHome(it.cnr.contab.compensi00.docs.bulk.CompensoHome) MimetypesFileTypeMap(javax.activation.MimetypesFileTypeMap) V_terzo_per_compensoBulk(it.cnr.contab.compensi00.docs.bulk.V_terzo_per_compensoBulk) it.cnr.contab.incarichi00.bulk(it.cnr.contab.incarichi00.bulk) IntrospectionException(it.cnr.jada.persistency.IntrospectionException) Configurazione_cnrBulk(it.cnr.contab.config00.bulk.Configurazione_cnrBulk) IncarichiRepertorioComponentSession(it.cnr.contab.incarichi00.ejb.IncarichiRepertorioComponentSession) SIGLAGroups(it.cnr.contab.util.SIGLAGroups) FindClause(it.cnr.jada.persistency.sql.FindClause) V_struttura_organizzativaBulk(it.cnr.contab.config00.sto.bulk.V_struttura_organizzativaBulk) CNRUserContext(it.cnr.contab.utenze00.bp.CNRUserContext) ApplicationException(it.cnr.jada.comp.ApplicationException) PersistencyException(it.cnr.jada.persistency.PersistencyException) Logger(org.slf4j.Logger) Tipo_atto_amministrativoBulk(it.cnr.contab.config00.contratto.bulk.Tipo_atto_amministrativoBulk) IOException(java.io.IOException) ContrattiService(it.cnr.contab.incarichi00.service.ContrattiService) BulkList(it.cnr.jada.bulk.BulkList) StorageFile(it.cnr.si.spring.storage.bulk.StorageFile) DateServices(it.cnr.contab.doccont00.comp.DateServices) CdsBulk(it.cnr.contab.config00.sto.bulk.CdsBulk) Gruppo_fileHome(it.cnr.contab.config00.file.bulk.Gruppo_fileHome) Tipo_rapportoBulk(it.cnr.contab.anagraf00.tabrif.bulk.Tipo_rapportoBulk) ComponentException(it.cnr.jada.comp.ComponentException) CompoundFindClause(it.cnr.jada.persistency.sql.CompoundFindClause) StorageObject(it.cnr.si.spring.storage.StorageObject) BulkList(it.cnr.jada.bulk.BulkList) ContrattiService(it.cnr.contab.incarichi00.service.ContrattiService) ApplicationException(it.cnr.jada.comp.ApplicationException) BulkList(it.cnr.jada.bulk.BulkList) StorageException(it.cnr.si.spring.storage.StorageException)

Aggregations

ContrattiService (it.cnr.contab.incarichi00.service.ContrattiService)12 StorageObject (it.cnr.si.spring.storage.StorageObject)8 BulkList (it.cnr.jada.bulk.BulkList)6 ApplicationException (it.cnr.jada.comp.ApplicationException)6 ComponentException (it.cnr.jada.comp.ComponentException)6 IntrospectionException (it.cnr.jada.persistency.IntrospectionException)6 PersistencyException (it.cnr.jada.persistency.PersistencyException)6 StorageFile (it.cnr.si.spring.storage.bulk.StorageFile)5 IncarichiRepertorioComponentSession (it.cnr.contab.incarichi00.ejb.IncarichiRepertorioComponentSession)4 EJBException (javax.ejb.EJBException)4 Tipo_rapportoBulk (it.cnr.contab.anagraf00.tabrif.bulk.Tipo_rapportoBulk)3 CompensoBulk (it.cnr.contab.compensi00.docs.bulk.CompensoBulk)3 CompensoHome (it.cnr.contab.compensi00.docs.bulk.CompensoHome)3 V_terzo_per_compensoBulk (it.cnr.contab.compensi00.docs.bulk.V_terzo_per_compensoBulk)3 V_terzo_per_compensoHome (it.cnr.contab.compensi00.docs.bulk.V_terzo_per_compensoHome)3 Unita_organizzativaBulk (it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk)3 it.cnr.contab.incarichi00.bulk (it.cnr.contab.incarichi00.bulk)3 SpringUtil (it.cnr.contab.service.SpringUtil)3 CNRUserContext (it.cnr.contab.utenze00.bp.CNRUserContext)3 Utility (it.cnr.contab.util.Utility)3