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