Search in sources :

Example 1 with BindingSession

use of org.apache.chemistry.opencmis.client.bindings.spi.BindingSession in project cool-jconon by consiglionazionaledellericerche.

the class CallService method inviaEsclusioni.

public Long inviaEsclusioni(Session session, BindingSession bindingSession, String query, String contexURL, String userId, String callId, String userName, String password, AddressType addressFromApplication) throws IOException {
    Folder call = (Folder) session.getObject(callId);
    ItemIterable<QueryResult> esclusioni = session.query(query, false);
    String subject = i18NService.getLabel("subject-info", Locale.ITALIAN) + i18NService.getLabel("subject-confirm-esclusione", Locale.ITALIAN, call.getProperty(JCONONPropertyIds.CALL_CODICE.value()).getValueAsString());
    long index = 0;
    for (QueryResult esclusione : esclusioni.getPage(Integer.MAX_VALUE)) {
        Document esclusioneObject = (Document) session.getObject((String) esclusione.getPropertyById(PropertyIds.OBJECT_ID).getFirstValue());
        final Optional<Folder> application = esclusioneObject.getParents().stream().findFirst();
        if (application.isPresent() && !Optional.ofNullable(application.get().getPropertyValue(JCONONPropertyIds.APPLICATION_ESCLUSIONE_RINUNCIA.value())).isPresent()) {
            Map<String, Serializable> properties = new HashMap<String, Serializable>();
            properties.put(JCONONPropertyIds.APPLICATION_ESCLUSIONE_RINUNCIA.value(), ApplicationService.StatoDomanda.ESCLUSA.getValue());
            cmisService.createAdminSession().getObject(application.get()).updateProperties(properties);
            Map<String, ACLType> acesToRemove = new HashMap<String, ACLType>();
            List<String> groups = getGroupsCallToApplication(call);
            for (String group : groups) {
                acesToRemove.put(group, ACLType.Contributor);
            }
            aclService.removeAcl(cmisService.getAdminSession(), application.get().getProperty(CoolPropertyIds.ALFCMIS_NODEREF.value()).getValueAsString(), acesToRemove);
        }
        aclService.setInheritedPermission(bindingSession, esclusioneObject.getProperty(CoolPropertyIds.ALFCMIS_NODEREF.value()).getValueAsString(), true);
        String contentURL = contexURL + "/rest/application/esclusione?nodeRef=" + esclusioneObject.getId();
        String user = esclusioneObject.<String>getPropertyValue(JCONONPropertyIds.ATTACHMENT_USER.value());
        List<Document> attachmentRelated = Optional.ofNullable(esclusioneObject.<String>getPropertyValue(JCONONPropertyIds.ATTACHMENT_RELATED.value())).map(s -> Arrays.asList(s.split(","))).orElse(Collections.emptyList()).stream().map(s -> session.getObject(s)).filter(Document.class::isInstance).map(Document.class::cast).collect(Collectors.toList());
        String address = obtainAddress(esclusioneObject, "jconon_esclusione:email_pec", "jconon_esclusione:email", addressFromApplication);
        SimplePECMail simplePECMail = new SimplePECMail(userName, password);
        simplePECMail.setHostName(pecConfiguration.getHostSmtp());
        simplePECMail.setSubject(subject + " $$ " + esclusioneObject.getId());
        String content = "Con riferimento alla Sua domanda di partecipazione al concorso indicato in oggetto, si invia in allegato la relativa esclusione.<br>";
        content += "Distinti saluti.<br/><br/><br/><hr/>";
        content += "<b>Questo messaggio e' stato generato da un sistema automatico. Si prega di non rispondere.</b><br/><br/>";
        try {
            simplePECMail.setFrom(userName);
            simplePECMail.setReplyTo(Collections.singleton(new InternetAddress("undisclosed-recipients")));
            simplePECMail.setTo(Collections.singleton(new InternetAddress(address)));
            simplePECMail.attach(new ByteArrayDataSource(new ByteArrayInputStream(content.getBytes()), "text/html"), "", "", EmailAttachment.INLINE);
            simplePECMail.attach(new ByteArrayDataSource(esclusioneObject.getContentStream().getStream(), esclusioneObject.getContentStreamMimeType()), esclusioneObject.getName(), esclusioneObject.getName());
            if (!attachmentRelated.isEmpty()) {
                for (Document doc : attachmentRelated) {
                    simplePECMail.attach(new ByteArrayDataSource(doc.getContentStream().getStream(), doc.getContentStreamMimeType()), doc.getName(), doc.getName());
                    aclService.addAcl(bindingSession, doc.getPropertyValue(CoolPropertyIds.ALFCMIS_NODEREF.value()), Stream.of(new AbstractMap.SimpleEntry<>(user, ACLType.Consumer)).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)));
                }
            }
            simplePECMail.send();
            Map<String, Object> properties = new HashMap<String, Object>();
            properties.put(JCONON_ESCLUSIONE_STATO, StatoComunicazione.SPEDITO.name());
            esclusioneObject.updateProperties(properties);
            index++;
        } catch (EmailException | AddressException e) {
            LOGGER.error("Cannot send email to {}", address, e);
        }
        if (Optional.ofNullable(ioClient).isPresent()) {
            Optional<String> fiscalCode = esclusioneObject.getParents().stream().findAny().flatMap(folder -> Optional.ofNullable(folder.<String>getPropertyValue(JCONONPropertyIds.APPLICATION_CODICE_FISCALE.value())));
            if (fiscalCode.isPresent()) {
                try {
                    NewMessage newMessage = new NewMessage();
                    newMessage.setTimeToLive(7200);
                    newMessage.setFiscalCode(fiscalCode.get());
                    MessageContent2 messageContent2 = new MessageContent2();
                    messageContent2.setSubject(StringUtils.rightPad("Bando ".concat(call.getProperty(JCONONPropertyIds.CALL_CODICE.value()).getValueAsString()), 10));
                    messageContent2.setMarkdown("# Esclusione\n" + "In riferimento alla Sua domanda di partecipazione al concorso indicato in oggetto, Le inviamo la seguente *Esclusione*, che può essere scaricata attraverso il seguente link:\n" + "\n" + "[Scarica l'Esclusione](" + contentURL + ")\n" + "\n" + "Distinti saluti.");
                    newMessage.setContent(messageContent2);
                    if (Optional.ofNullable(ioClient.getProfile(fiscalCode.get())).map(limitedProfile -> Optional.ofNullable(limitedProfile.getSenderAllowed()).orElse(Boolean.TRUE)).orElse(Boolean.FALSE)) {
                        final InlineResponse201 inlineResponse201 = ioClient.submitMessageforUser(fiscalCode.get(), newMessage);
                        LOGGER.info("The IO message was successfully sent to {} with Id: {}", fiscalCode.get(), inlineResponse201.getId());
                    }
                } catch (Exception e) {
                    LOGGER.error("Cannot send IO message to {}", fiscalCode.get(), e);
                }
            }
        }
    }
    callRepository.removeVerificaPECTask(subject);
    callRepository.verificaPECTask(userName, password, subject, JCONON_ESCLUSIONE_STATO);
    return index;
}
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) InternetAddress(javax.mail.internet.InternetAddress) MessageContent2(it.cnr.si.cool.jconon.io.model.MessageContent2) NewMessage(it.cnr.si.cool.jconon.io.model.NewMessage) InlineResponse201(it.cnr.si.cool.jconon.io.model.InlineResponse201) AddressException(javax.mail.internet.AddressException) EmailException(org.apache.commons.mail.EmailException) ByteArrayDataSource(javax.mail.util.ByteArrayDataSource) 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) JsonObject(com.google.gson.JsonObject) JSONObject(org.json.JSONObject)

Example 2 with BindingSession

use of org.apache.chemistry.opencmis.client.bindings.spi.BindingSession in project cool-jconon by consiglionazionaledellericerche.

the class CallService method inviaConvocazioni.

public Long inviaConvocazioni(Session session, BindingSession bindingSession, String query, String contexURL, String userId, String callId, String userName, String password, AddressType addressFromApplication) throws IOException {
    Folder call = (Folder) session.getObject(callId);
    ItemIterable<QueryResult> convocazioni = session.query(query, false);
    long index = 0;
    String subject = i18NService.getLabel("subject-info", Locale.ITALIAN) + i18NService.getLabel("subject-confirm-convocazione", Locale.ITALIAN, call.getProperty(JCONONPropertyIds.CALL_CODICE.value()).getValueAsString());
    for (QueryResult convocazione : convocazioni.getPage(Integer.MAX_VALUE)) {
        Document convocazioneObject = (Document) session.getObject((String) convocazione.getPropertyById(PropertyIds.OBJECT_ID).getFirstValue());
        aclService.setInheritedPermission(bindingSession, convocazioneObject.getProperty(CoolPropertyIds.ALFCMIS_NODEREF.value()).getValueAsString(), true);
        String contentURL = contexURL + "/rest/application/convocazione?nodeRef=" + convocazioneObject.getId();
        String address = obtainAddress(convocazioneObject, "jconon_convocazione:email_pec", "jconon_convocazione:email", addressFromApplication);
        String user = convocazioneObject.<String>getPropertyValue(JCONONPropertyIds.ATTACHMENT_USER.value());
        List<Document> attachmentRelated = Optional.ofNullable(convocazioneObject.<String>getPropertyValue(JCONONPropertyIds.ATTACHMENT_RELATED.value())).map(s -> Arrays.asList(s.split(","))).orElse(Collections.emptyList()).stream().map(s -> session.getObject(s)).filter(Document.class::isInstance).map(Document.class::cast).collect(Collectors.toList());
        SimplePECMail simplePECMail = new SimplePECMail(userName, password);
        simplePECMail.setHostName(pecConfiguration.getHostSmtp());
        simplePECMail.setSubject(subject + " $$ " + convocazioneObject.getId());
        String content = "Con riferimento alla Sua domanda di partecipazione al concorso indicato in oggetto, si invia in allegato la relativa convocazione.<br>" + "Per i candidati che non hanno indicato in domanda un indirizzo PEC o che non lo hanno comunicato in seguito, e' richiesta conferma di ricezione della presente cliccando sul seguente <a href=\"" + contentURL + "\">link</a> , <br/>qualora non dovesse funzionare copi questo [" + contentURL + "] nella barra degli indirizzi del browser.<br/>";
        content += "Distinti saluti.<br/><br/><br/><hr/>";
        content += "<b>Questo messaggio e' stato generato da un sistema automatico. Si prega di non rispondere.</b><br/><br/>";
        try {
            simplePECMail.setFrom(userName);
            simplePECMail.setReplyTo(Collections.singleton(new InternetAddress("undisclosed-recipients")));
            simplePECMail.setTo(Collections.singleton(new InternetAddress(address)));
            simplePECMail.attach(new ByteArrayDataSource(new ByteArrayInputStream(content.getBytes()), "text/html"), "", "", EmailAttachment.INLINE);
            simplePECMail.attach(new ByteArrayDataSource(convocazioneObject.getContentStream().getStream(), convocazioneObject.getContentStreamMimeType()), convocazioneObject.getName(), convocazioneObject.getName());
            if (!attachmentRelated.isEmpty()) {
                for (Document doc : attachmentRelated) {
                    simplePECMail.attach(new ByteArrayDataSource(doc.getContentStream().getStream(), doc.getContentStreamMimeType()), doc.getName(), doc.getName());
                    aclService.addAcl(bindingSession, doc.getPropertyValue(CoolPropertyIds.ALFCMIS_NODEREF.value()), Stream.of(new AbstractMap.SimpleEntry<>(user, ACLType.Consumer)).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)));
                }
            }
            simplePECMail.send();
            Map<String, Object> properties = new HashMap<String, Object>();
            properties.put(JCONON_CONVOCAZIONE_STATO, StatoComunicazione.SPEDITO.name());
            convocazioneObject.updateProperties(properties);
            index++;
        } catch (EmailException | AddressException e) {
            LOGGER.error("Cannot send email to {}", address, e);
        }
        if (Optional.ofNullable(ioClient).isPresent()) {
            Optional<String> fiscalCode = convocazioneObject.getParents().stream().findAny().flatMap(folder -> Optional.ofNullable(folder.<String>getPropertyValue(JCONONPropertyIds.APPLICATION_CODICE_FISCALE.value())));
            if (fiscalCode.isPresent()) {
                try {
                    NewMessage newMessage = new NewMessage();
                    newMessage.setTimeToLive(7200);
                    newMessage.setFiscalCode(fiscalCode.get());
                    MessageContent2 messageContent2 = new MessageContent2();
                    messageContent2.setSubject(StringUtils.rightPad("Bando ".concat(call.getProperty(JCONONPropertyIds.CALL_CODICE.value()).getValueAsString()), 10));
                    messageContent2.setMarkdown("# Convocazione\n" + "In riferimento alla Sua domanda di partecipazione al concorso indicato in oggetto, Le inviamo la seguente *Convocazione*, che può essere scaricata attraverso il seguente link:\n" + "\n" + "[Scarica la Convocazione](" + contentURL + ")\n" + "\n" + "Distinti saluti.");
                    newMessage.setContent(messageContent2);
                    if (Optional.ofNullable(ioClient.getProfile(fiscalCode.get())).map(limitedProfile -> Optional.ofNullable(limitedProfile.getSenderAllowed()).orElse(Boolean.TRUE)).orElse(Boolean.FALSE)) {
                        final InlineResponse201 inlineResponse201 = ioClient.submitMessageforUser(fiscalCode.get(), newMessage);
                        LOGGER.info("The IO message was successfully sent to {} with Id: {}", fiscalCode.get(), inlineResponse201.getId());
                    }
                } catch (Exception e) {
                    LOGGER.error("Cannot send IO message to {}", fiscalCode.get(), e);
                }
            }
        }
    }
    callRepository.removeVerificaPECTask(subject);
    callRepository.verificaPECTask(userName, password, subject, JCONON_CONVOCAZIONE_STATO);
    return index;
}
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) InternetAddress(javax.mail.internet.InternetAddress) MessageContent2(it.cnr.si.cool.jconon.io.model.MessageContent2) NewMessage(it.cnr.si.cool.jconon.io.model.NewMessage) InlineResponse201(it.cnr.si.cool.jconon.io.model.InlineResponse201) AddressException(javax.mail.internet.AddressException) EmailException(org.apache.commons.mail.EmailException) ByteArrayDataSource(javax.mail.util.ByteArrayDataSource) 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) JsonObject(com.google.gson.JsonObject) JSONObject(org.json.JSONObject)

Example 3 with BindingSession

use of org.apache.chemistry.opencmis.client.bindings.spi.BindingSession in project cool-jconon by consiglionazionaledellericerche.

the class CallService method comunicazioni.

protected Long comunicazioni(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 filtersProvvisorieInviate = mRequest.getParameter("filters-provvisorie_inviate");
    Integer totalepunteggioda = null, totalepunteggioa = null;
    try {
        totalepunteggioda = Optional.ofNullable(mRequest.getParameter("totalepunteggioda")).filter(s -> s.length() > 0).map(Integer::valueOf).orElse(null);
        totalepunteggioa = Optional.ofNullable(mRequest.getParameter("totalepunteggioa")).filter(s -> s.length() > 0).map(Integer::valueOf).orElse(null);
    } catch (NumberFormatException _ex) {
    }
    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.inTree(call.getPropertyValue(PropertyIds.OBJECT_ID)));
    if (Optional.ofNullable(filtersProvvisorieInviate).isPresent() && !filtersProvvisorieInviate.equalsIgnoreCase("tutte") && !filtersProvvisorieInviate.equalsIgnoreCase("attive") && !filtersProvvisorieInviate.equalsIgnoreCase("escluse")) {
        criteriaApplications.add(Restrictions.eq(JCONONPropertyIds.APPLICATION_STATO_DOMANDA.value(), filtersProvvisorieInviate));
    }
    if (Optional.ofNullable(filtersProvvisorieInviate).isPresent() && filtersProvvisorieInviate.equalsIgnoreCase("attive")) {
        criteriaApplications.add(Restrictions.eq(JCONONPropertyIds.APPLICATION_STATO_DOMANDA.value(), ApplicationService.StatoDomanda.CONFERMATA.getValue()));
        criteriaApplications.add(Restrictions.isNull(JCONONPropertyIds.APPLICATION_ESCLUSIONE_RINUNCIA.value()));
    }
    if (Optional.ofNullable(filtersProvvisorieInviate).isPresent() && filtersProvvisorieInviate.equalsIgnoreCase("escluse")) {
        criteriaApplications.add(Restrictions.eq(JCONONPropertyIds.APPLICATION_STATO_DOMANDA.value(), ApplicationService.StatoDomanda.CONFERMATA.getValue()));
        criteriaApplications.add(Restrictions.isNotNull(JCONONPropertyIds.APPLICATION_ESCLUSIONE_RINUNCIA.value()));
    }
    if (Optional.ofNullable(totalepunteggioda).isPresent()) {
        criteriaApplications.add(Restrictions.ge(JCONONPropertyIds.APPLICATION_TOTALE_PUNTEGGIO.value(), totalepunteggioda));
    }
    if (Optional.ofNullable(totalepunteggioa).isPresent()) {
        criteriaApplications.add(Restrictions.le(JCONONPropertyIds.APPLICATION_TOTALE_PUNTEGGIO.value(), totalepunteggioa));
    }
    applicationsId.stream().filter(string -> !string.isEmpty()).findAny().map(map -> criteriaApplications.add(Restrictions.in(PropertyIds.OBJECT_ID, applicationsId.toArray())));
    long result = 0;
    ItemIterable<QueryResult> applications = criteriaApplications.executeQuery(session, false, session.getDefaultContext());
    for (QueryResult application : applications.getPage(Integer.MAX_VALUE)) {
        Folder applicationObject = (Folder) session.getObject((String) application.getPropertyById(PropertyIds.OBJECT_ID).getFirstValue());
        final String attachmentId = competitionService.findAttachmentId(session, applicationObject.getId(), JCONONDocumentType.JCONON_ATTACHMENT_COMUNICAZIONE);
        if (attachmentId != null) {
            final CmisObject document = session.getObject(attachmentId);
            if (document.getPropertyValue(JCONON_COMUNICAZIONE_STATO) != null && document.getPropertyValue(JCONON_COMUNICAZIONE_STATO).equals(StatoComunicazione.GENERATO.name())) {
                continue;
            }
        }
        StrSubstitutor sub = formatPlaceHolder(applicationObject, applicationObject.getFolderParent());
        byte[] bytes = printService.printComunicazione(session, applicationObject, contextURL, locale, sub.replace(note), firma);
        String name = "COMUNICAZIONE_" + 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";
        result++;
        LOGGER.info("Generate comunication n. {} width name {}", result, name);
        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put(PropertyIds.OBJECT_TYPE_ID, JCONONDocumentType.JCONON_ATTACHMENT_COMUNICAZIONE.value());
        properties.put(PropertyIds.NAME, name);
        properties.put(JCONONPropertyIds.ATTACHMENT_USER.value(), applicationObject.getPropertyValue(JCONONPropertyIds.APPLICATION_USER.value()));
        properties.put(JCONON_COMUNICAZIONE_STATO, StatoComunicazione.GENERATO.name());
        properties.put("jconon_comunicazione:email", applicationObject.getPropertyValue(JCONONPropertyIds.APPLICATION_EMAIL_COMUNICAZIONI.value()));
        properties.put("jconon_comunicazione: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) BigInteger(java.math.BigInteger) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) StrSubstitutor(org.apache.commons.text.StrSubstitutor) ClientMessageException(it.cnr.cool.web.scripts.exception.ClientMessageException) JsonObject(com.google.gson.JsonObject) JSONObject(org.json.JSONObject)

Example 4 with BindingSession

use of org.apache.chemistry.opencmis.client.bindings.spi.BindingSession in project cool-jconon by consiglionazionaledellericerche.

the class ExportApplicationsService method exportApplications.

public Map<String, String> exportApplications(Session currentSession, BindingSession bindingSession, String nodeRefBando, CMISUser user, boolean all, boolean active, JSONArray types) {
    Folder bando = (Folder) currentSession.getObject(nodeRefBando);
    String finalApplicationName = Call.refactoringFileName(Arrays.asList("BANDO", bando.<String>getPropertyValue(JCONONPropertyIds.CALL_CODICE.value()), Optional.ofNullable(bando.<String>getPropertyValue(JCONONPropertyIds.CALL_SEDE.value())).map(s -> s.replaceAll("[^a-zA-Z0-9]+", " ")).orElse("")).stream().collect(Collectors.joining("_")), "_");
    Map<String, String> result;
    if (all) {
        List<String> documents = new ArrayList<String>();
        Criteria criteriaDomande = CriteriaFactory.createCriteria(JCONONFolderType.JCONON_APPLICATION.queryName());
        criteriaDomande.addColumn(PropertyIds.OBJECT_ID);
        criteriaDomande.add(Restrictions.inTree(nodeRefBando));
        criteriaDomande.add(Restrictions.eq(JCONONPropertyIds.APPLICATION_STATO_DOMANDA.value(), ApplicationService.StatoDomanda.CONFERMATA.getValue()));
        if (active) {
            criteriaDomande.add(Restrictions.isNull(JCONONPropertyIds.APPLICATION_ESCLUSIONE_RINUNCIA.value()));
        }
        ItemIterable<QueryResult> domande = criteriaDomande.executeQuery(currentSession, false, currentSession.getDefaultContext());
        for (QueryResult queryResultDomande : domande.getPage(Integer.MAX_VALUE)) {
            String applicationAttach = competitionService.findAttachmentId(currentSession, (String) queryResultDomande.getPropertyById(PropertyIds.OBJECT_ID).getFirstValue(), JCONONDocumentType.JCONON_ATTACHMENT_APPLICATION, true);
            if (applicationAttach != null) {
                documents.add(applicationAttach);
            }
        }
        if (documents.isEmpty()) {
            // Se non ci sono domande definitive finalCall non viene creata
            throw new ClientMessageException("Il bando " + finalApplicationName + " non presenta domande definitive");
        }
        result = invokePost(documents, finalApplicationName, bindingSession, user, true, types);
    } else {
        List<String> documents = callService.findDocumentFinal(currentSession, bindingSession, nodeRefBando, JCONONDocumentType.JCONON_ATTACHMENT_APPLICATION);
        if (documents.isEmpty()) {
            // Se non ci sono domande definitive finalCall non viene creata
            throw new ClientMessageException("Il bando " + finalApplicationName + " non presenta domande definitive");
        }
        result = invokePost(documents, finalApplicationName, bindingSession, user, false, null);
    }
    LOGGER.info("ExportApplicationsService - File " + finalApplicationName + ".zip creata");
    return result;
}
Also used : CMISService(it.cnr.cool.cmis.service.CMISService) java.util(java.util) MimeTypes(it.cnr.cool.util.MimeTypes) QueryResult(org.apache.chemistry.opencmis.client.api.QueryResult) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) Session(org.apache.chemistry.opencmis.client.api.Session) SessionParameter(org.apache.chemistry.opencmis.commons.SessionParameter) Call(it.cnr.si.cool.jconon.rest.Call) CriteriaFactory(it.cnr.si.opencmis.criteria.CriteriaFactory) Criteria(it.cnr.si.opencmis.criteria.Criteria) Service(org.springframework.stereotype.Service) Restrictions(it.cnr.si.opencmis.criteria.restrictions.Restrictions) UrlBuilder(org.apache.chemistry.opencmis.commons.impl.UrlBuilder) HttpStatus(org.apache.commons.httpclient.HttpStatus) Folder(org.apache.chemistry.opencmis.client.api.Folder) JCONONDocumentType(it.cnr.si.cool.jconon.cmis.model.JCONONDocumentType) CmisBindingsHelper(org.apache.chemistry.opencmis.client.bindings.impl.CmisBindingsHelper) OutputStream(java.io.OutputStream) CompetitionFolderService(it.cnr.si.cool.jconon.service.cache.CompetitionFolderService) Response(org.apache.chemistry.opencmis.client.bindings.spi.http.Response) Logger(org.slf4j.Logger) BindingSession(org.apache.chemistry.opencmis.client.bindings.spi.BindingSession) ACLService(it.cnr.cool.cmis.service.ACLService) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IOException(java.io.IOException) ClientMessageException(it.cnr.cool.web.scripts.exception.ClientMessageException) Output(org.apache.chemistry.opencmis.client.bindings.spi.http.Output) InputStreamReader(java.io.InputStreamReader) Collectors(java.util.stream.Collectors) JCONONFolderType(it.cnr.si.cool.jconon.cmis.model.JCONONFolderType) CallService(it.cnr.si.cool.jconon.service.call.CallService) CMISUser(it.cnr.cool.security.service.impl.alfresco.CMISUser) ItemIterable(org.apache.chemistry.opencmis.client.api.ItemIterable) PropertyIds(org.apache.chemistry.opencmis.commons.PropertyIds) JCONONPropertyIds(it.cnr.si.cool.jconon.cmis.model.JCONONPropertyIds) JSONArray(org.json.JSONArray) QueryResult(org.apache.chemistry.opencmis.client.api.QueryResult) ClientMessageException(it.cnr.cool.web.scripts.exception.ClientMessageException) Criteria(it.cnr.si.opencmis.criteria.Criteria) Folder(org.apache.chemistry.opencmis.client.api.Folder)

Example 5 with BindingSession

use of org.apache.chemistry.opencmis.client.bindings.spi.BindingSession in project cool-jconon by consiglionazionaledellericerche.

the class ExportApplicationServiceTest method exportApplicationsServiceTestUnautorized.

@Test
public void exportApplicationsServiceTestUnautorized() {
    BindingSession bindingSession = cmisService.createBindingSession(guestUserName, guestPassword);
    assertThrows(CmisUnauthorizedException.class, () -> {
        exportApplicationsService.exportApplications(cmisService.getRepositorySession(guestUserName, guestPassword), bindingSession, call.getPropertyValue(PropertyIds.OBJECT_ID), userService.loadUser(guestUserName, bindingSession), false, false, null);
    });
}
Also used : BindingSession(org.apache.chemistry.opencmis.client.bindings.spi.BindingSession) CommonServiceTest(it.cnr.si.cool.jconon.util.CommonServiceTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

BindingSession (org.apache.chemistry.opencmis.client.bindings.spi.BindingSession)15 CMISUser (it.cnr.cool.security.service.impl.alfresco.CMISUser)10 Criteria (it.cnr.si.opencmis.criteria.Criteria)10 java.util (java.util)10 UrlBuilder (org.apache.chemistry.opencmis.commons.impl.UrlBuilder)10 Logger (org.slf4j.Logger)10 LoggerFactory (org.slf4j.LoggerFactory)10 Autowired (org.springframework.beans.factory.annotation.Autowired)10 MimeTypes (it.cnr.cool.util.MimeTypes)9 ClientMessageException (it.cnr.cool.web.scripts.exception.ClientMessageException)9 JCONONDocumentType (it.cnr.si.cool.jconon.cmis.model.JCONONDocumentType)9 JCONONFolderType (it.cnr.si.cool.jconon.cmis.model.JCONONFolderType)9 JCONONPropertyIds (it.cnr.si.cool.jconon.cmis.model.JCONONPropertyIds)9 CompetitionFolderService (it.cnr.si.cool.jconon.service.cache.CompetitionFolderService)9 CriteriaFactory (it.cnr.si.opencmis.criteria.CriteriaFactory)9 Restrictions (it.cnr.si.opencmis.criteria.restrictions.Restrictions)9 Collectors (java.util.stream.Collectors)9 CmisBindingsHelper (org.apache.chemistry.opencmis.client.bindings.impl.CmisBindingsHelper)9 Output (org.apache.chemistry.opencmis.client.bindings.spi.http.Output)9 Response (org.apache.chemistry.opencmis.client.bindings.spi.http.Response)9