Search in sources :

Example 11 with ACLType

use of it.cnr.cool.cmis.model.ACLType in project cool-jconon by consiglionazionaledellericerche.

the class CallService method internalEsclusioni.

protected Long internalEsclusioni(Session session, MultipartHttpServletRequest mRequest, BindingSession bindingSession, String contextURL, Locale locale, String userId) throws IOException {
    String callId = mRequest.getParameter("callId");
    String note = mRequest.getParameter("note");
    String firma = mRequest.getParameter("firma");
    List<String> applicationsId = Arrays.asList(Optional.ofNullable(mRequest.getParameterValues("application")).orElse(new String[0]));
    String query = mRequest.getParameter("query");
    boolean stampaPunteggi = Boolean.valueOf(mRequest.getParameter("stampaPunteggi"));
    Folder call = (Folder) session.getObject(String.valueOf(callId));
    if (!call.getAllowableActions().getAllowableActions().contains(Action.CAN_UPDATE_PROPERTIES))
        throw new ClientMessageException("message.error.call.cannnot.modify");
    List<String> nodeRefAllegato = addAttachmentToCall(session, bindingSession, call, mRequest.getFiles("file"));
    Criteria criteriaApplications = CriteriaFactory.createCriteria(JCONONFolderType.JCONON_APPLICATION.queryName());
    criteriaApplications.add(Restrictions.inFolder(call.getPropertyValue(PropertyIds.OBJECT_ID)));
    criteriaApplications.add(Restrictions.eq(JCONONPropertyIds.APPLICATION_STATO_DOMANDA.value(), ApplicationService.StatoDomanda.CONFERMATA.getValue()));
    criteriaApplications.add(Restrictions.isNull(JCONONPropertyIds.APPLICATION_ESCLUSIONE_RINUNCIA.value()));
    applicationsId.stream().filter(string -> !string.isEmpty()).findAny().map(map -> criteriaApplications.add(Restrictions.in(PropertyIds.OBJECT_ID, applicationsId.toArray())));
    long result = 0;
    ItemIterable<QueryResult> applications;
    if (applicationsId.stream().filter(string -> !string.isEmpty()).findAny().filter(s -> s.length() > 0).isPresent()) {
        applications = criteriaApplications.executeQuery(session, false, session.getDefaultContext());
    } else {
        applications = session.query(query, false, session.getDefaultContext());
    }
    for (QueryResult application : applications.getPage(Integer.MAX_VALUE)) {
        Folder applicationObject = (Folder) session.getObject((String) application.getPropertyById(PropertyIds.OBJECT_ID).getFirstValue());
        List<String> proveConseguite = new ArrayList<String>();
        boolean flPunteggioTitoli = Optional.ofNullable(applicationObject.<Boolean>getPropertyValue("jconon_application:fl_punteggio_titoli")).orElse(false), flPunteggioScritto = Optional.ofNullable(applicationObject.<Boolean>getPropertyValue("jconon_application:fl_punteggio_scritto")).orElse(false), flPunteggioSecondoScritto = Optional.ofNullable(applicationObject.<Boolean>getPropertyValue("jconon_application:fl_punteggio_secondo_scritto")).orElse(false), flPunteggioColloquio = Optional.ofNullable(applicationObject.<Boolean>getPropertyValue("jconon_application:fl_punteggio_colloquio")).orElse(false), flPunteggioProvaPratica = Optional.ofNullable(applicationObject.<Boolean>getPropertyValue("jconon_application:fl_punteggio_prova_pratica")).orElse(false), flPunteggio6 = Optional.ofNullable(applicationObject.<Boolean>getPropertyValue("jconon_application:fl_punteggio_6")).orElse(false);
        result++;
        if (flPunteggioTitoli)
            proveConseguite.add(call.getPropertyValue(PrintService.JCONON_CALL_PUNTEGGIO_1));
        if (flPunteggioScritto)
            proveConseguite.add(call.getPropertyValue(PrintService.JCONON_CALL_PUNTEGGIO_2));
        if (flPunteggioSecondoScritto)
            proveConseguite.add(call.getPropertyValue(PrintService.JCONON_CALL_PUNTEGGIO_3));
        if (flPunteggioColloquio)
            proveConseguite.add(call.getPropertyValue(PrintService.JCONON_CALL_PUNTEGGIO_4));
        if (flPunteggioProvaPratica)
            proveConseguite.add(call.getPropertyValue(PrintService.JCONON_CALL_PUNTEGGIO_5));
        if (flPunteggio6)
            proveConseguite.add(call.getPropertyValue(PrintService.JCONON_CALL_PUNTEGGIO_6));
        final Optional<String> attachmentId = Optional.ofNullable(competitionService.findAttachmentId(session, applicationObject.getId(), JCONONDocumentType.JCONON_ATTACHMENT_ESCLUSIONE));
        if (attachmentId.isPresent()) {
            if (Optional.ofNullable(session.getObject(attachmentId.get()).<String>getPropertyValue(JCONON_ESCLUSIONE_STATO)).filter(s -> s.equalsIgnoreCase(StatoComunicazione.GENERATO.name())).isPresent()) {
                continue;
            }
        }
        StrSubstitutor sub = formatPlaceHolder(applicationObject, applicationObject.getFolderParent());
        byte[] bytes = printService.printEsclusione(session, applicationObject, contextURL, locale, stampaPunteggi, sub.replace(note), firma, proveConseguite.stream().collect(Collectors.joining(", ")));
        String name = "ESCLUSIONE_" + applicationObject.getPropertyValue(JCONONPropertyIds.APPLICATION_COGNOME.value()) + " " + applicationObject.getPropertyValue(JCONONPropertyIds.APPLICATION_NOME.value()) + "_" + applicationObject.getPropertyValue(JCONONPropertyIds.APPLICATION_USER.value()) + "_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd_HH-mm-ss")) + ".pdf";
        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put(PropertyIds.OBJECT_TYPE_ID, JCONONDocumentType.JCONON_ATTACHMENT_ESCLUSIONE.value());
        properties.put(PropertyIds.NAME, name);
        properties.put(JCONONPropertyIds.ATTACHMENT_USER.value(), applicationObject.getPropertyValue(JCONONPropertyIds.APPLICATION_USER.value()));
        properties.put(JCONON_ESCLUSIONE_STATO, StatoComunicazione.GENERATO.name());
        properties.put("jconon_esclusione:email", applicationObject.getPropertyValue(JCONONPropertyIds.APPLICATION_EMAIL_COMUNICAZIONI.value()));
        properties.put("jconon_esclusione:email_pec", applicationObject.getPropertyValue(JCONONPropertyIds.APPLICATION_EMAIL_PEC_COMUNICAZIONI.value()));
        List<String> aspects = Stream.of(JCONONPolicyType.JCONON_ATTACHMENT_GENERIC_DOCUMENT.value(), JCONONPolicyType.JCONON_ATTACHMENT_FROM_RDP.value()).collect(Collectors.toList());
        if (!nodeRefAllegato.isEmpty()) {
            properties.put(JCONONPropertyIds.ATTACHMENT_RELATED.value(), nodeRefAllegato.stream().collect(Collectors.joining(",")));
            aspects.add(JCONONPolicyType.JCONON_ATTACHMENT_ATTACHED.value());
        }
        properties.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, aspects);
        ContentStreamImpl contentStream = new ContentStreamImpl();
        contentStream.setStream(new ByteArrayInputStream(bytes));
        contentStream.setMimeType("application/pdf");
        String documentPresentId = findAttachmentName(session, applicationObject.getId(), name);
        if (documentPresentId == null) {
            Document doc = applicationObject.createDocument(properties, contentStream, VersioningState.MAJOR);
            aclService.setInheritedPermission(bindingSession, doc.getPropertyValue(CoolPropertyIds.ALFCMIS_NODEREF.value()), false);
            Map<String, ACLType> acesGroup = new HashMap<String, ACLType>();
            acesGroup.put(JcononGroups.CONCORSI.group(), ACLType.Coordinator);
            acesGroup.put("GROUP_" + getCallGroupRdPName(call), ACLType.Coordinator);
            aclService.addAcl(bindingSession, doc.getPropertyValue(CoolPropertyIds.ALFCMIS_NODEREF.value()), acesGroup);
        } else {
            Document doc = (Document) session.getObject(documentPresentId);
            doc.updateProperties(properties);
            doc.setContentStream(contentStream, true);
        }
    }
    return result;
}
Also used : Order(it.cnr.si.opencmis.criteria.Order) ByteArrayDataSource(javax.mail.util.ByteArrayDataSource) InlineResponse201(it.cnr.si.cool.jconon.io.model.InlineResponse201) ApplicationService(it.cnr.si.cool.jconon.service.application.ApplicationService) Autowired(org.springframework.beans.factory.annotation.Autowired) CallRepository(it.cnr.si.cool.jconon.repository.CallRepository) StringUtils(org.apache.commons.lang3.StringUtils) BigDecimal(java.math.BigDecimal) CriteriaFactory(it.cnr.si.opencmis.criteria.CriteriaFactory) OperationContextUtils(org.apache.chemistry.opencmis.client.util.OperationContextUtils) HSSFSheet(org.apache.poi.hssf.usermodel.HSSFSheet) CoolPropertyIds(it.cnr.cool.cmis.model.CoolPropertyIds) ObjectIdImpl(org.apache.chemistry.opencmis.client.runtime.ObjectIdImpl) BigInteger(java.math.BigInteger) HttpStatus(org.apache.commons.httpclient.HttpStatus) PrintParameterModel(it.cnr.si.cool.jconon.model.PrintParameterModel) PropertyDefinition(org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition) CompetitionFolderService(it.cnr.si.cool.jconon.service.cache.CompetitionFolderService) JCONONPolicyType(it.cnr.si.cool.jconon.cmis.model.JCONONPolicyType) org.apache.chemistry.opencmis.commons.enums(org.apache.chemistry.opencmis.commons.enums) ZoneId(java.time.ZoneId) CMISUser(it.cnr.cool.security.service.impl.alfresco.CMISUser) MailService(it.cnr.cool.mail.MailService) Stream(java.util.stream.Stream) MessageContent2(it.cnr.si.cool.jconon.io.model.MessageContent2) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook) VerificaPECTask(it.cnr.si.cool.jconon.dto.VerificaPECTask) it.cnr.si.cool.jconon.util(it.cnr.si.cool.jconon.util) java.util(java.util) MimeTypes(it.cnr.cool.util.MimeTypes) CmisRuntimeException(org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException) LocalDateTime(java.time.LocalDateTime) SimpleDateFormat(java.text.SimpleDateFormat) JsonParser(com.google.gson.JsonParser) NumberFormat(java.text.NumberFormat) InternetAddress(javax.mail.internet.InternetAddress) HttpServletRequest(javax.servlet.http.HttpServletRequest) GroupsEnum(it.cnr.cool.security.GroupsEnum) Service(org.springframework.stereotype.Service) StreamSupport(java.util.stream.StreamSupport) Restrictions(it.cnr.si.opencmis.criteria.restrictions.Restrictions) UrlBuilder(org.apache.chemistry.opencmis.commons.impl.UrlBuilder) org.apache.chemistry.opencmis.client.api(org.apache.chemistry.opencmis.client.api) JSONTokener(org.json.JSONTokener) PropertyData(org.apache.chemistry.opencmis.commons.data.PropertyData) JCONONFolderType(it.cnr.si.cool.jconon.cmis.model.JCONONFolderType) StrServ(it.cnr.cool.util.StrServ) HelpdeskService(it.cnr.si.cool.jconon.service.helpdesk.HelpdeskService) ProtocolRepository(it.cnr.si.cool.jconon.repository.ProtocolRepository) UserService(it.cnr.cool.security.service.UserService) Message(javax.mail.Message) JsonObject(com.google.gson.JsonObject) PermissionServiceImpl(it.cnr.cool.web.PermissionServiceImpl) URLName(javax.mail.URLName) LoggerFactory(org.slf4j.LoggerFactory) MultipartHttpServletRequest(org.springframework.web.multipart.MultipartHttpServletRequest) CmisObjectNotFoundException(org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException) MessagingException(javax.mail.MessagingException) JSONObject(org.json.JSONObject) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Cell(org.apache.poi.ss.usermodel.Cell) ParseException(java.text.ParseException) Store(javax.mail.Store) CmisBindingsHelper(org.apache.chemistry.opencmis.client.bindings.impl.CmisBindingsHelper) Response(org.apache.chemistry.opencmis.client.bindings.spi.http.Response) AddressException(javax.mail.internet.AddressException) NewMessage(it.cnr.si.cool.jconon.io.model.NewMessage) QueueService(it.cnr.si.cool.jconon.service.QueueService) StringUtil(it.cnr.cool.util.StringUtil) SubjectTerm(javax.mail.search.SubjectTerm) ACLType(it.cnr.cool.cmis.model.ACLType) Collectors(java.util.stream.Collectors) Environment(org.springframework.core.env.Environment) PropertyIds(org.apache.chemistry.opencmis.commons.PropertyIds) LocalDate(java.time.LocalDate) EmailException(org.apache.commons.mail.EmailException) CoolUserFactoryException(it.cnr.cool.exception.CoolUserFactoryException) JCONONPropertyIds(it.cnr.si.cool.jconon.cmis.model.JCONONPropertyIds) Async(org.springframework.scheduling.annotation.Async) PECConfiguration(it.cnr.si.cool.jconon.configuration.PECConfiguration) ContentStreamImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl) CommonsMultipartResolver(org.springframework.web.multipart.commons.CommonsMultipartResolver) IO(it.cnr.si.cool.jconon.io.repository.IO) PrintService(it.cnr.si.cool.jconon.service.PrintService) Inject(javax.inject.Inject) SearchTerm(javax.mail.search.SearchTerm) it.cnr.cool.cmis.service(it.cnr.cool.cmis.service) EmailAttachment(org.apache.commons.mail.EmailAttachment) Criteria(it.cnr.si.opencmis.criteria.Criteria) Util(it.cnr.cool.rest.util.Util) JCONONDocumentType(it.cnr.si.cool.jconon.cmis.model.JCONONDocumentType) TypeService(it.cnr.si.cool.jconon.service.TypeService) CacheRepository(it.cnr.si.cool.jconon.repository.CacheRepository) Logger(org.slf4j.Logger) BindingSession(org.apache.chemistry.opencmis.client.bindings.spi.BindingSession) ClientMessageException(it.cnr.cool.web.scripts.exception.ClientMessageException) Output(org.apache.chemistry.opencmis.client.bindings.spi.http.Output) StrSubstitutor(org.apache.commons.text.StrSubstitutor) ApplicationContext(org.springframework.context.ApplicationContext) EmailMessage(it.cnr.cool.mail.model.EmailMessage) java.io(java.io) DateTimeFormatter(java.time.format.DateTimeFormatter) Row(org.apache.poi.ss.usermodel.Row) MultipartFile(org.springframework.web.multipart.MultipartFile) CMISGroup(it.cnr.cool.security.service.impl.alfresco.CMISGroup) CMISUtil(it.cnr.cool.util.CMISUtil) I18nService(it.cnr.cool.service.I18nService) ContentStreamImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl) ACLType(it.cnr.cool.cmis.model.ACLType) Criteria(it.cnr.si.opencmis.criteria.Criteria) StrSubstitutor(org.apache.commons.text.StrSubstitutor) ClientMessageException(it.cnr.cool.web.scripts.exception.ClientMessageException) JsonObject(com.google.gson.JsonObject) JSONObject(org.json.JSONObject)

Example 12 with ACLType

use of it.cnr.cool.cmis.model.ACLType in project cool-jconon by consiglionazionaledellericerche.

the class CallService method publish.

public Folder publish(Session cmisSession, BindingSession currentBindingSession, String userId, String objectId, boolean publish, String contextURL, Locale locale) {
    final Folder call = (Folder) cmisSession.getObject(objectId);
    CMISUser user = userService.loadUserForConfirm(userId);
    if (!(user.isAdmin() || isMemberOfConcorsiGroup(user) || call.getPropertyValue(PropertyIds.CREATED_BY).equals(userId)))
        throw new ClientMessageException("message.error.call.cannot.publish");
    Map<String, ACLType> aces = new HashMap<String, ACLType>();
    aces.put(JcononGroups.EVERYONE.group(), ACLType.Consumer);
    GregorianCalendar dataInizioInvioDomande = call.getPropertyValue(JCONONPropertyIds.CALL_DATA_INIZIO_INVIO_DOMANDE.value());
    if (!publish && !(user.isAdmin() || isMemberOfConcorsiGroup(user))) {
        if (!dataInizioInvioDomande.after(Calendar.getInstance()))
            throw new ClientMessageException("message.error.call.cannot.publish");
    }
    if (JCONONPolicyType.isIncomplete(call))
        throw new ClientMessageException("message.error.call.incomplete");
    if (call.getType().getId().equalsIgnoreCase(JCONONFolderType.JCONON_CALL_MOBILITY.value()) || call.getType().getId().equalsIgnoreCase(JCONONFolderType.JCONON_CALL_MOBILITY_OPEN.value())) {
        if (!isCallAttachmentPresent(cmisSession, call, JCONONDocumentType.JCONON_ATTACHMENT_CALL_MOBILITY)) {
            throw new ClientMessageException("message.error.call.mobility.incomplete.attachment");
        }
    } else if (call.getType().getId().equalsIgnoreCase(JCONONFolderType.JCONON_CALL_MAN_INTESESSE.value())) {
        if (!isCallAttachmentPresent(cmisSession, call, JCONONDocumentType.JCONON_ATTACHMENT_CALL_MANIFESTAZIONE_INTERESSE)) {
            throw new ClientMessageException("message.error.call.man.intesse.incomplete.attachment");
        }
    } else {
        if (!isCallAttachmentPresent(cmisSession, call, JCONONDocumentType.JCONON_ATTACHMENT_CALL_IT))
            throw new ClientMessageException("message.error.call.incomplete.attachment");
    }
    if (dataInizioInvioDomande != null && call.getParentId().equals(competitionService.getCompetitionFolder().get("id"))) {
        moveCall(cmisSession, dataInizioInvioDomande, call);
    }
    if (publish && call.<List<String>>getPropertyValue(JCONONPropertyIds.CALL_ELENCO_SEZIONI_DOMANDA.value()).stream().filter(s -> s.equalsIgnoreCase("affix_tabDichiarazioni")).findAny().isPresent() && Optional.ofNullable(call.<List<String>>getPropertyValue(JCONONPropertyIds.CALL_ELENCO_ASPECTS.value())).map(List::isEmpty).orElse(Boolean.TRUE)) {
        throw new ClientMessageException("message.error.call.incomplete.section.affix_tabDichiarazioni");
    }
    if (publish && call.<List<String>>getPropertyValue(JCONONPropertyIds.CALL_ELENCO_SEZIONI_DOMANDA.value()).stream().filter(s -> s.equalsIgnoreCase("affix_tabUlterioriDati")).findAny().isPresent() && Optional.ofNullable(call.<List<String>>getPropertyValue(JCONONPropertyIds.CALL_ELENCO_ASPECTS_ULTERIORI_DATI.value())).map(List::isEmpty).orElse(Boolean.TRUE)) {
        throw new ClientMessageException("message.error.call.incomplete.section.affix_tabUlterioriDati");
    }
    if (publish && call.<List<String>>getPropertyValue(JCONONPropertyIds.CALL_ELENCO_SEZIONI_DOMANDA.value()).stream().filter(s -> s.equalsIgnoreCase("affix_tabDatiCNR")).findAny().isPresent() && Optional.ofNullable(call.<List<String>>getPropertyValue(JCONONPropertyIds.CALL_ELENCO_ASPECTS_SEZIONE_CNR.value())).map(List::isEmpty).orElse(Boolean.TRUE)) {
        throw new ClientMessageException("message.error.call.incomplete.section.affix_tabDatiCNR");
    }
    if (publish && call.<List<String>>getPropertyValue(JCONONPropertyIds.CALL_ELENCO_SEZIONI_DOMANDA.value()).stream().filter(s -> s.equalsIgnoreCase("affix_tabTitoli")).findAny().isPresent() && Optional.ofNullable(call.<List<String>>getPropertyValue(JCONONPropertyIds.CALL_ELENCO_ASSOCIATIONS.value())).map(List::isEmpty).orElse(Boolean.TRUE)) {
        throw new ClientMessageException("message.error.call.incomplete.section.affix_tabTitoli");
    }
    if (publish && call.<List<String>>getPropertyValue(JCONONPropertyIds.CALL_ELENCO_SEZIONI_DOMANDA.value()).stream().filter(s -> s.equalsIgnoreCase("affix_tabCurriculum")).findAny().isPresent() && Optional.ofNullable(call.<List<String>>getPropertyValue(JCONONPropertyIds.CALL_ELENCO_SEZIONE_CURRICULUM.value())).map(List::isEmpty).orElse(Boolean.TRUE)) {
        throw new ClientMessageException("message.error.call.incomplete.section.affix_tabCurriculum");
    }
    if (publish && call.<List<String>>getPropertyValue(JCONONPropertyIds.CALL_ELENCO_SEZIONI_DOMANDA.value()).stream().filter(s -> s.equalsIgnoreCase("affix_tabElencoProdotti")).findAny().isPresent() && Optional.ofNullable(call.<List<String>>getPropertyValue(JCONONPropertyIds.CALL_ELENCO_SEZIONE_PRODOTTI.value())).map(List::isEmpty).orElse(Boolean.TRUE)) {
        throw new ClientMessageException("message.error.call.incomplete.section.affix_tabElencoProdotti");
    }
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put(JCONONPropertyIds.CALL_PUBBLICATO.value(), publish);
    if (publish) {
        creaGruppoCommissione(call, userId);
        if (call.getPropertyValue(JCONONPropertyIds.CALL_ID_CATEGORIA_TECNICO_HELPDESK.value()) == null) {
            Integer idCategoriaCallType = helpdeskService.getCategoriaMaster(call.getType().getId());
            Integer idCategoriaHelpDESK = helpdeskService.createCategoria(idCategoriaCallType, "BANDO " + getCodiceBandoTruncated(call), "BANDO " + call.getPropertyValue(JCONONPropertyIds.CALL_CODICE.value()));
            Integer idCategoriaTecnicoHelpDESK = helpdeskService.createCategoria(idCategoriaHelpDESK, "Problema Tecnico", "Problema Tecnico");
            Integer idCategoriaNormativaHelpDESK = helpdeskService.createCategoria(idCategoriaHelpDESK, "Problema Normativo", "Problema Normativo");
            properties.put(JCONONPropertyIds.CALL_ID_CATEGORIA_TECNICO_HELPDESK.value(), idCategoriaTecnicoHelpDESK);
            properties.put(JCONONPropertyIds.CALL_ID_CATEGORIA_NORMATIVA_HELPDESK.value(), idCategoriaNormativaHelpDESK);
        }
        aces.put(JcononGroups.CONCORSI.group(), ACLType.Coordinator);
        aclService.addAcl(currentBindingSession, call.getProperty(CoolPropertyIds.ALFCMIS_NODEREF.value()).getValueAsString(), aces);
    } else {
        aclService.removeAcl(currentBindingSession, call.getProperty(CoolPropertyIds.ALFCMIS_NODEREF.value()).getValueAsString(), aces);
    }
    call.updateProperties(properties, true);
    return call;
}
Also used : BigInteger(java.math.BigInteger) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ACLType(it.cnr.cool.cmis.model.ACLType) CMISUser(it.cnr.cool.security.service.impl.alfresco.CMISUser) ClientMessageException(it.cnr.cool.web.scripts.exception.ClientMessageException) JsonObject(com.google.gson.JsonObject) JSONObject(org.json.JSONObject)

Example 13 with ACLType

use of it.cnr.cool.cmis.model.ACLType in project cool-jconon by consiglionazionaledellericerche.

the class CallService method creaGruppoCommissione.

private void creaGruppoCommissione(final Folder call, String userId) {
    if (call.getPropertyValue(JCONONPropertyIds.CALL_COMMISSIONE.value()) != null)
        return;
    // Creazione del gruppo per la commissione di Concorso
    final String groupRdPName = getCallGroupRdPName(call);
    final String groupCommissioneName = createGroupCommissioneName(call);
    try {
        String link = cmisService.getBaseURL().concat("service/cnr/groups/group");
        UrlBuilder url = new UrlBuilder(link);
        Response response = CmisBindingsHelper.getHttpInvoker(cmisService.getAdminSession()).invokePOST(url, MimeTypes.JSON.mimetype(), new Output() {

            @Override
            public void write(OutputStream out) throws Exception {
                String groupJson = "{";
                groupJson = groupJson.concat("\"parent_group_name\":\"" + JcononGroups.COMMISSIONI_CONCORSO.group() + "\",");
                groupJson = groupJson.concat("\"group_name\":\"" + groupCommissioneName + "\",");
                groupJson = groupJson.concat("\"display_name\":\"" + "COMMISSIONE BANDO [".concat(call.getPropertyValue(JCONONPropertyIds.CALL_CODICE.value())) + "]\",");
                groupJson = groupJson.concat("\"zones\":[\"AUTH.ALF\",\"APP.DEFAULT\"]");
                groupJson = groupJson.concat("}");
                out.write(groupJson.getBytes());
            }
        }, cmisService.getAdminSession());
        JSONObject jsonObject = new JSONObject(StringUtil.convertStreamToString(response.getStream()));
        String nodeRef = jsonObject.optString("nodeRef");
        if (nodeRef == "")
            return;
        /**
         * Aggiorno il bando con il NodeRef del gruppo commissione
         */
        Map<String, Object> propertiesCommissione = new HashMap<String, Object>();
        propertiesCommissione.put(JCONONPropertyIds.CALL_COMMISSIONE.value(), groupCommissioneName);
        call.updateProperties(propertiesCommissione, true);
        /**
         * Il Gruppo della Commissione deve avere il ruolo di contributor sul bando
         */
        addContibutorCommission(groupCommissioneName, call.getProperty(CoolPropertyIds.ALFCMIS_NODEREF.value()).getValueAsString());
        Map<String, ACLType> acesGroup = new HashMap<String, ACLType>();
        acesGroup.put(JcononGroups.CONCORSI.group(), ACLType.FullControl);
        acesGroup.put("GROUP_" + groupRdPName, ACLType.FullControl);
        aclService.addAcl(cmisService.getAdminSession(), nodeRef, acesGroup);
    } catch (Exception e) {
        LOGGER.error("ACL error", e);
    }
}
Also used : ACLType(it.cnr.cool.cmis.model.ACLType) CmisRuntimeException(org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException) CmisObjectNotFoundException(org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException) MessagingException(javax.mail.MessagingException) ParseException(java.text.ParseException) AddressException(javax.mail.internet.AddressException) EmailException(org.apache.commons.mail.EmailException) CoolUserFactoryException(it.cnr.cool.exception.CoolUserFactoryException) ClientMessageException(it.cnr.cool.web.scripts.exception.ClientMessageException) Response(org.apache.chemistry.opencmis.client.bindings.spi.http.Response) JSONObject(org.json.JSONObject) Output(org.apache.chemistry.opencmis.client.bindings.spi.http.Output) JsonObject(com.google.gson.JsonObject) JSONObject(org.json.JSONObject) UrlBuilder(org.apache.chemistry.opencmis.commons.impl.UrlBuilder)

Aggregations

ACLType (it.cnr.cool.cmis.model.ACLType)13 JSONObject (org.json.JSONObject)12 JsonObject (com.google.gson.JsonObject)10 ClientMessageException (it.cnr.cool.web.scripts.exception.ClientMessageException)10 CoolUserFactoryException (it.cnr.cool.exception.CoolUserFactoryException)7 CMISUser (it.cnr.cool.security.service.impl.alfresco.CMISUser)7 Output (org.apache.chemistry.opencmis.client.bindings.spi.http.Output)7 Response (org.apache.chemistry.opencmis.client.bindings.spi.http.Response)7 CmisObjectNotFoundException (org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException)7 UrlBuilder (org.apache.chemistry.opencmis.commons.impl.UrlBuilder)7 ContentStreamImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl)7 Criteria (it.cnr.si.opencmis.criteria.Criteria)6 ParseException (java.text.ParseException)6 MessagingException (javax.mail.MessagingException)6 AddressException (javax.mail.internet.AddressException)6 CmisRuntimeException (org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException)6 EmailException (org.apache.commons.mail.EmailException)6 CoolPropertyIds (it.cnr.cool.cmis.model.CoolPropertyIds)5 GroupsEnum (it.cnr.cool.security.GroupsEnum)5 UserService (it.cnr.cool.security.service.UserService)5