Fissato problema sulla creazione di utenti con mail già registrata.
This commit is contained in:
parent
3cafe90e55
commit
92b952c5fd
2
pom.xml
2
pom.xml
|
@ -6,7 +6,7 @@
|
|||
|
||||
<groupId>it.cnr.isti.epasmed</groupId>
|
||||
<artifactId>epasmed</artifactId>
|
||||
<version>1.0.2</version>
|
||||
<version>1.0.3</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>epasmed</name>
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package it.cnr.isti.epasmed.sync;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.text.Normalizer;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
@ -353,8 +354,13 @@ public class SyncService {
|
|||
String email = createCNREmail(sia);
|
||||
epasPersonsDTO.setEmail(email);
|
||||
epasPersonsDTO.setQualification(PERSON_DEFAULT_QUALIFICATION);
|
||||
epasPerson = epasPersonsService.create(epasPersonsDTO);
|
||||
logger.info("EPAS Created Person: {}", epasPerson);
|
||||
try {
|
||||
epasPerson = epasPersonsService.create(epasPersonsDTO);
|
||||
logger.info("EPAS Created Person: {}", epasPerson);
|
||||
} catch (Exception e) {
|
||||
logger.error("Error creating person: {}", epasPersonsDTO);
|
||||
logger.error(e.getLocalizedMessage(),e);
|
||||
}
|
||||
} else {
|
||||
EPASPersonsDTO epasPersonsDTO = epasPersonsMapper.epasPersonsToEPASPersonsDTO(epasPerson);
|
||||
epasPersonsDTO.setName(sia.getNome());
|
||||
|
@ -380,14 +386,26 @@ public class SyncService {
|
|||
private String createCNREmail(SIAnagrafico sia) {
|
||||
StringBuilder cnrEmail = new StringBuilder();
|
||||
if (sia.getNome() != null && !sia.getNome().isEmpty()) {
|
||||
cnrEmail.append(sia.getNome().toLowerCase());
|
||||
String nome=sia.getNome();
|
||||
if(!Normalizer.isNormalized(sia.getNome(), Normalizer.Form.NFKD)){
|
||||
nome=Normalizer.normalize(sia.getNome(), Normalizer.Form.NFKD).replaceAll("\\p{M}", "");
|
||||
}
|
||||
cnrEmail.append(nome.toLowerCase());
|
||||
if (sia.getCognome() != null && !sia.getCognome().isEmpty()) {
|
||||
String cognome=sia.getCognome();
|
||||
if(!Normalizer.isNormalized(sia.getCognome(), Normalizer.Form.NFKD)){
|
||||
cognome=Normalizer.normalize(sia.getCognome(), Normalizer.Form.NFKD).replaceAll("\\p{M}", "");
|
||||
}
|
||||
cnrEmail.append(".");
|
||||
cnrEmail.append(sia.getCognome().toLowerCase().trim());
|
||||
cnrEmail.append(cognome.toLowerCase().trim());
|
||||
}
|
||||
} else {
|
||||
if (sia.getCognome() != null && !sia.getCognome().isEmpty()) {
|
||||
cnrEmail.append(sia.getCognome().toLowerCase().trim());
|
||||
String cognome=sia.getCognome();
|
||||
if(!Normalizer.isNormalized(sia.getCognome(), Normalizer.Form.NFKD)){
|
||||
cognome=Normalizer.normalize(sia.getCognome(), Normalizer.Form.NFKD).replaceAll("\\p{M}", "");
|
||||
}
|
||||
cnrEmail.append(cognome.toLowerCase().trim());
|
||||
} else {
|
||||
cnrEmail.append("empty");
|
||||
}
|
||||
|
@ -401,7 +419,7 @@ public class SyncService {
|
|||
cnrEmail = new StringBuilder();
|
||||
cnrEmail.append("empty@cnr.it");
|
||||
}
|
||||
|
||||
logger.debug("Created CNR email: {}", cnrEmail.toString());
|
||||
return cnrEmail.toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ public class EPASPersonsResourceIT {
|
|||
private static final String OFFICE_DEFAULT_CODE = "074000";
|
||||
private static final String OFFICE_DEFAULT_CODEID = "225200";
|
||||
|
||||
private static final String PERSON_DEFAULT_ID = "xxx";
|
||||
private static final String PERSON_DEFAULT_ID = "113";
|
||||
private static final String PERSON_DEFAULT_NAME = "nometest1";
|
||||
private static final String PERSON_DEFAULT_SURNAME = "cognometest1";
|
||||
private static final String PERSON_DEFAULT_FISCAL_CODE = "codicefiscaletes";
|
||||
|
@ -116,7 +116,7 @@ public class EPASPersonsResourceIT {
|
|||
|
||||
@Test
|
||||
public void getPersonById() throws Exception {
|
||||
restEPASPersonsMockMvc.perform(get("/api/epas/persons/72")).andExpect(status().isOk());
|
||||
restEPASPersonsMockMvc.perform(get("/api/epas/persons/"+PERSON_DEFAULT_ID)).andExpect(status().isOk());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue