Creato repository per StbEmail
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
This commit is contained in:
6
.idea/sqldialects.xml
generated
Normal file
6
.idea/sqldialects.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="SqlDialectMappings">
|
||||
<file url="file://$PROJECT_DIR$/.idea/queries/Query_2.sql" dialect="TSQL" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -357,8 +357,8 @@ public abstract class BaseEntityExporter implements IEntityExporter {
|
||||
case EMAIL:
|
||||
|
||||
if (UtilityString.isNullOrEmpty(wtbUserInfo.getEmail()) &&
|
||||
UtilityString.isNullOrEmpty(wtbUserInfo.getEmailCc()) &&
|
||||
UtilityString.isNullOrEmpty(wtbUserInfo.getEmailCcn())) {
|
||||
UtilityString.isNullOrEmpty(wtbUserInfo.getEmailCc()) &&
|
||||
UtilityString.isNullOrEmpty(wtbUserInfo.getEmailCcn())) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -369,7 +369,8 @@ public abstract class BaseEntityExporter implements IEntityExporter {
|
||||
entityExportResponse.setMessageContent("Messaggio creato automaticamente: " + "INVIO " + type + " formato " + format);
|
||||
}
|
||||
|
||||
fileSharerSettings = MailService.readParameter(multiDBTransactionManager.getPrimaryConnection(), null);
|
||||
fileSharerSettings = ApplicationContextProvider.getApplicationContext().getBean(MailService.class)
|
||||
.readParameter(multiDBTransactionManager.getPrimaryConnection(), null);
|
||||
((EmailFileSharerSettings) fileSharerSettings)
|
||||
.withSubject(entityExportResponse.getMessageSubject())
|
||||
.withTextMessage(entityExportResponse.getMessageContent())
|
||||
@@ -403,7 +404,7 @@ public abstract class BaseEntityExporter implements IEntityExporter {
|
||||
}
|
||||
}
|
||||
|
||||
if (counterTotalSend > 0 && counterFailedSend == counterTotalSend && retException != null) {
|
||||
if (counterTotalSend > 0 && counterFailedSend == counterTotalSend && retException != null) {
|
||||
//Se gli invii precedenti sono andati bene usciamo
|
||||
throw retException;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package it.integry.ems.jpa.repository;
|
||||
|
||||
import it.integry.ems_model.entity.StbEmail;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface StbEmailRepository extends BaseRepository<StbEmail, Integer> {
|
||||
|
||||
@Query("SELECT e FROM StbEmail e WHERE e.flagDefault = 'S'")
|
||||
Optional<StbEmail> findByFlagDefaultTrue();
|
||||
|
||||
@Query("SELECT e FROM StbEmail e WHERE UPPER(e.eMail) = UPPER(?1)")
|
||||
Optional<StbEmail> findByEmailIgnoreCase(String email);
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import it.integry.ems.file_sharer.IFileSharerAttachment;
|
||||
import it.integry.ems.file_sharer.sharers.email.EmailFileAttachment;
|
||||
import it.integry.ems.file_sharer.sharers.email.EmailFileSharer;
|
||||
import it.integry.ems.file_sharer.sharers.email.EmailFileSharerSettings;
|
||||
import it.integry.ems.jpa.repository.StbEmailRepository;
|
||||
import it.integry.ems.json.ResponseJSONObjectMapper;
|
||||
import it.integry.ems.media.MimeTypesHandler;
|
||||
import it.integry.ems.response.FileItem;
|
||||
@@ -24,7 +25,6 @@ import it.integry.ems.utility.UtilityDebug;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.entity.StbEmail;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityList;
|
||||
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
@@ -78,6 +78,9 @@ public class MailService {
|
||||
@Autowired
|
||||
private EmsDBConst emsDBConst;
|
||||
|
||||
@Autowired
|
||||
private StbEmailRepository stbEmailRepository;
|
||||
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
public enum Level {
|
||||
@@ -87,7 +90,7 @@ public class MailService {
|
||||
ERROR
|
||||
}
|
||||
|
||||
public static EmailFileSharerSettings readParameter(@NotNull Connection connection, String fromEmail) throws Exception {
|
||||
public EmailFileSharerSettings readParameter(@NotNull Connection connection, String fromEmail) throws Exception {
|
||||
if (UtilityDebug.isIntegryServerDev()) {
|
||||
return useSystemParams();
|
||||
}
|
||||
@@ -95,15 +98,16 @@ public class MailService {
|
||||
EmailFileSharerSettings emailSettings = new EmailFileSharerSettings();
|
||||
|
||||
String sql;
|
||||
StbEmail stbEmail = null;
|
||||
if (!UtilityString.isNullOrEmpty(fromEmail)) {
|
||||
sql = "SELECT * from stb_email WHERE e_mail = " + UtilityDB.valueToString(fromEmail);
|
||||
|
||||
stbEmail = stbEmailRepository.findByEmailIgnoreCase(fromEmail)
|
||||
.orElse(null);
|
||||
} else {
|
||||
sql = "SELECT * from stb_email WHERE flag_default = 'S'";
|
||||
stbEmail = stbEmailRepository.findByFlagDefaultTrue()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
List<StbEmail> listEmail = UtilityDB.executeSimpleQueryDTO(connection, sql, StbEmail.class);
|
||||
|
||||
StbEmail stbEmail = listEmail != null && !listEmail.isEmpty() ? listEmail.get(0) : null;
|
||||
|
||||
if (stbEmail != null && stbEmail.getIdRiga() != null) {
|
||||
EmailFileSharerSettings.ENCRYPTION encryption = EmailFileSharerSettings.ENCRYPTION.NONE;
|
||||
@@ -300,7 +304,7 @@ public class MailService {
|
||||
}
|
||||
|
||||
public EmailFileSharerSettings internalReadParameter(Connection connection, String fromEmail) throws Exception {
|
||||
return MailService.readParameter(connection, fromEmail);
|
||||
return readParameter(connection, fromEmail);
|
||||
}
|
||||
|
||||
public Message sendMail(String from, String fromName, String to, String cc, String subject, String msg) throws Exception {
|
||||
|
||||
@@ -3,10 +3,12 @@ package it.integry.ems_model.entity;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import it.integry.ems_model.annotation.*;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import org.kie.api.definition.type.PropertyReactive;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.kie.api.definition.type.PropertyReactive;
|
||||
|
||||
@javax.persistence.Entity
|
||||
@javax.persistence.Table(name = StbEmail.ENTITY)
|
||||
@Master
|
||||
@PropertyReactive
|
||||
@Table(StbEmail.ENTITY)
|
||||
@@ -19,44 +21,58 @@ public class StbEmail extends EntityBase {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@javax.persistence.Id
|
||||
@javax.persistence.Column(name = "id_riga")
|
||||
@PK
|
||||
@SqlDetailId
|
||||
@SqlField(value = "id_riga", nullable = false)
|
||||
private Integer idRiga;
|
||||
|
||||
@javax.persistence.Column(name = "e_mail")
|
||||
@SqlField(value = "e_mail", maxLength = 255, nullable = false)
|
||||
private String eMail;
|
||||
|
||||
@javax.persistence.Column(name = "smtp")
|
||||
@SqlField(value = "smtp", maxLength = 255)
|
||||
private String smtp;
|
||||
|
||||
@javax.persistence.Column(name = "authentication")
|
||||
@SqlField(value = "authentication", maxLength = 1, nullable = false, defaultObjectValue = "S")
|
||||
private String authentication;
|
||||
|
||||
@javax.persistence.Column(name = "user_name")
|
||||
@SqlField(value = "user_name", maxLength = 255)
|
||||
private String userName;
|
||||
|
||||
@javax.persistence.Column(name = "password")
|
||||
@SqlField(value = "password", maxLength = 255)
|
||||
private String password;
|
||||
|
||||
@javax.persistence.Column(name = "port")
|
||||
@SqlField(value = "port", maxLength = 255)
|
||||
private String port;
|
||||
|
||||
@javax.persistence.Column(name = "SSL")
|
||||
@SqlField(value = "SSL", maxLength = 1, nullable = false, defaultObjectValue = "N")
|
||||
private String ssl;
|
||||
|
||||
@javax.persistence.Column(name = "crypt_password")
|
||||
@SqlField(value = "crypt_password", maxLength = 1, nullable = false, defaultObjectValue = "S")
|
||||
private String cryptPassword;
|
||||
|
||||
@javax.persistence.Column(name = "flag_default")
|
||||
@SqlField(value = "flag_default", maxLength = 1, nullable = false, defaultObjectValue = "N")
|
||||
private String flagDefault;
|
||||
|
||||
@javax.persistence.Column(name = "flag_default_contabilita")
|
||||
@SqlField(value = "flag_default_contabilita", maxLength = 1, nullable = false, defaultObjectValue = "N")
|
||||
private String flagDefaultContabilita;
|
||||
|
||||
@javax.persistence.Column(name = "imap")
|
||||
@SqlField(value = "imap", maxLength = 255)
|
||||
private String imap;
|
||||
|
||||
@javax.persistence.Column(name = "imap_port")
|
||||
@SqlField(value = "imap_port", maxLength = 255)
|
||||
private String imapPort;
|
||||
|
||||
|
||||
@@ -1469,8 +1469,6 @@ public class SystemController {
|
||||
public ServiceRestResponse test(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration) throws Exception {
|
||||
|
||||
mailService.sendSystemErrorLog("Test", "Questo è un messaggio di test", "pippo", new NotValidLicenseException(), new Date());
|
||||
|
||||
return ServiceRestResponse.createNegativeResponse("Errore super graveeeee");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user