Finish Hotfix-1
This commit is contained in:
@@ -6,14 +6,16 @@ import java.util.HashMap;
|
|||||||
|
|
||||||
public class AuthTokenDetails {
|
public class AuthTokenDetails {
|
||||||
private long deviceId;
|
private long deviceId;
|
||||||
|
private String profileDb;
|
||||||
private UserDTO userDTO;
|
private UserDTO userDTO;
|
||||||
private HashMap<String, AuthTokenProfileDetails> profilesData;
|
private HashMap<String, AuthTokenProfileDetails> profilesData;
|
||||||
|
|
||||||
public AuthTokenDetails() {
|
public AuthTokenDetails() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public AuthTokenDetails(long deviceId, UserDTO userDTO, HashMap<String, AuthTokenProfileDetails> profilesData) {
|
public AuthTokenDetails(long deviceId, String profileDb, UserDTO userDTO, HashMap<String, AuthTokenProfileDetails> profilesData) {
|
||||||
this.deviceId = deviceId;
|
this.deviceId = deviceId;
|
||||||
|
this.profileDb = profileDb;
|
||||||
this.userDTO = userDTO;
|
this.userDTO = userDTO;
|
||||||
this.profilesData = profilesData;
|
this.profilesData = profilesData;
|
||||||
}
|
}
|
||||||
@@ -22,6 +24,10 @@ public class AuthTokenDetails {
|
|||||||
return deviceId;
|
return deviceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getProfileDb() {
|
||||||
|
return profileDb;
|
||||||
|
}
|
||||||
|
|
||||||
public UserDTO getUserDTO() {
|
public UserDTO getUserDTO() {
|
||||||
return userDTO;
|
return userDTO;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,14 +75,21 @@ public class AuthService {
|
|||||||
|
|
||||||
UserDataDTO userData = new UserDataDTO();
|
UserDataDTO userData = new UserDataDTO();
|
||||||
|
|
||||||
if (!UtilityString.isNullOrEmpty(profileDb)) { // SELEZIONE DB DIRETTO
|
if (UtilityString.isNullOrEmpty(profileDb)) {
|
||||||
multiDBTransactionManager.closeAll();
|
|
||||||
multiDBTransactionManager.setPrimaryDs(loginRequestDTO.getProfileDb());
|
|
||||||
|
|
||||||
userData.setUser(this.getUser(username, password, multiDBTransactionManager));
|
|
||||||
} else {
|
|
||||||
List<String> profiles = userService.retrieveAvailableProfiles(username);
|
List<String> profiles = userService.retrieveAvailableProfiles(username);
|
||||||
userData.setAvailableProfiles(profiles);
|
userData.setAvailableProfiles(profiles);
|
||||||
|
|
||||||
|
|
||||||
|
if (profiles != null && profiles.size() == 1) {
|
||||||
|
profileDb = userData.getAvailableProfiles().get(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!UtilityString.isNullOrEmpty(profileDb)) { // SELEZIONE DB DIRETTO
|
||||||
|
multiDBTransactionManager.closeAll();
|
||||||
|
multiDBTransactionManager.setPrimaryDs(profileDb);
|
||||||
|
|
||||||
|
userData.setUser(this.getUser(username, password, multiDBTransactionManager));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userData.getUser() == null) {
|
if (userData.getUser() == null) {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableList;
|
|||||||
import io.jsonwebtoken.SignatureAlgorithm;
|
import io.jsonwebtoken.SignatureAlgorithm;
|
||||||
import io.jsonwebtoken.io.Encoders;
|
import io.jsonwebtoken.io.Encoders;
|
||||||
import io.jsonwebtoken.security.Keys;
|
import io.jsonwebtoken.security.Keys;
|
||||||
|
import it.integry.ems.exception.PrimaryDatabaseNotPresentException;
|
||||||
import it.integry.ems.service.EntityProcessor;
|
import it.integry.ems.service.EntityProcessor;
|
||||||
import it.integry.ems.settings.Model.SettingsModel;
|
import it.integry.ems.settings.Model.SettingsModel;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
@@ -143,7 +144,7 @@ public class RefreshTokenService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private UsernamePasswordAuthenticationToken createAuthenticationToken(String username, String password, String keyGroup, long deviceId) {
|
private UsernamePasswordAuthenticationToken createAuthenticationToken(String username, String password, String keyGroup, long deviceId) throws PrimaryDatabaseNotPresentException {
|
||||||
UsernamePasswordAuthenticationToken authenticationToken =
|
UsernamePasswordAuthenticationToken authenticationToken =
|
||||||
new UsernamePasswordAuthenticationToken(username, password,
|
new UsernamePasswordAuthenticationToken(username, password,
|
||||||
ImmutableList.of(new SimpleGrantedAuthority(keyGroup)));
|
ImmutableList.of(new SimpleGrantedAuthority(keyGroup)));
|
||||||
@@ -163,7 +164,9 @@ public class RefreshTokenService {
|
|||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
AuthTokenDetails authTokenDetails = new AuthTokenDetails(deviceId, user, profilesData);
|
AuthTokenDetails authTokenDetails = new AuthTokenDetails(deviceId,
|
||||||
|
multiDBTransactionManager.getPrimaryDatasource().getProfile(),
|
||||||
|
user, profilesData);
|
||||||
authenticationToken.setDetails(authTokenDetails);
|
authenticationToken.setDetails(authTokenDetails);
|
||||||
|
|
||||||
return authenticationToken;
|
return authenticationToken;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import it.integry.ems.service.EntityProcessor;
|
|||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
import it.integry.ems.system.exchange.dto.CertificatiSinfoOneDTO;
|
import it.integry.ems.system.exchange.dto.CertificatiSinfoOneDTO;
|
||||||
import it.integry.ems_model.base.EquatableEntityInterface;
|
import it.integry.ems_model.base.EquatableEntityInterface;
|
||||||
|
import it.integry.ems_model.config.EmsRestConstants;
|
||||||
import it.integry.ems_model.entity.DtbDoct;
|
import it.integry.ems_model.entity.DtbDoct;
|
||||||
import it.integry.ems_model.entity.MtbColr;
|
import it.integry.ems_model.entity.MtbColr;
|
||||||
import it.integry.ems_model.entity.MtbColt;
|
import it.integry.ems_model.entity.MtbColt;
|
||||||
@@ -115,7 +116,7 @@ public class ExchangeColliImportService {
|
|||||||
|
|
||||||
allMtbColts.forEach(x -> {
|
allMtbColts.forEach(x -> {
|
||||||
x.setOperation(x.getOperation() == OperationType.INSERT ? OperationType.INSERT_OR_UPDATE : x.getOperation());
|
x.setOperation(x.getOperation() == OperationType.INSERT ? OperationType.INSERT_OR_UPDATE : x.getOperation());
|
||||||
((MtbColt)x).getMtbColr().forEach(y -> y.setOperation(y.getOperation() == OperationType.INSERT ? OperationType.INSERT_OR_UPDATE : y.getOperation()));
|
((MtbColt) x).getMtbColr().forEach(y -> y.setOperation(y.getOperation() == OperationType.INSERT ? OperationType.INSERT_OR_UPDATE : y.getOperation()));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -130,9 +131,25 @@ public class ExchangeColliImportService {
|
|||||||
try (MultiDBTransactionManager exchangeMultiDbThread = new MultiDBTransactionManager(exchangeMultiDb.getPrimaryDatasource().getProfile(), false);
|
try (MultiDBTransactionManager exchangeMultiDbThread = new MultiDBTransactionManager(exchangeMultiDb.getPrimaryDatasource().getProfile(), false);
|
||||||
MultiDBTransactionManager internalMultiDbThread = new MultiDBTransactionManager(internalMultiDb.getPrimaryDatasource().getProfile(), false)) {
|
MultiDBTransactionManager internalMultiDbThread = new MultiDBTransactionManager(internalMultiDb.getPrimaryDatasource().getProfile(), false)) {
|
||||||
|
|
||||||
entityProcessor.processEntity(dataToSave, true, true, ROSSOGARGANO_EXCHANGE_USER, internalMultiDbThread, requestDataDTO);
|
MtbColt mtbColtToSave = (MtbColt) dataToSave;
|
||||||
singleUpdateImported(exchangeMultiDbThread.getPrimaryConnection(), (MtbColt) dataToSave, testataTableName, useTempTable);
|
if (mtbColtToSave.hasDocument() && mtbColtToSave.getOperation() == OperationType.DELETE) {
|
||||||
singleUpdateImported(exchangeMultiDbThread.getPrimaryConnection(), (MtbColt) dataToSave, righeTableName, useTempTable);
|
MtbColt mtbColtRemoveDocument = (MtbColt) mtbColtToSave.clone();
|
||||||
|
mtbColtRemoveDocument.setMtbColr(new ArrayList<>())
|
||||||
|
.setCodDtip(EmsRestConstants.NULL)
|
||||||
|
.setSerDoc(EmsRestConstants.NULL)
|
||||||
|
.setDataDoc(EmsRestConstants.DATE_NULL)
|
||||||
|
.setOperation(OperationType.UPDATE);
|
||||||
|
|
||||||
|
entityProcessor.processEntity(mtbColtRemoveDocument, true, true, ROSSOGARGANO_EXCHANGE_USER, internalMultiDbThread, requestDataDTO);
|
||||||
|
|
||||||
|
mtbColtToSave.setCodDtip(EmsRestConstants.NULL)
|
||||||
|
.setSerDoc(EmsRestConstants.NULL)
|
||||||
|
.setDataDoc(EmsRestConstants.DATE_NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
entityProcessor.processEntity(mtbColtToSave, true, true, ROSSOGARGANO_EXCHANGE_USER, internalMultiDbThread, requestDataDTO);
|
||||||
|
singleUpdateImported(exchangeMultiDbThread.getPrimaryConnection(), mtbColtToSave, testataTableName, useTempTable);
|
||||||
|
singleUpdateImported(exchangeMultiDbThread.getPrimaryConnection(), mtbColtToSave, righeTableName, useTempTable);
|
||||||
|
|
||||||
internalMultiDbThread.commitAll();
|
internalMultiDbThread.commitAll();
|
||||||
exchangeMultiDbThread.commitAll();
|
exchangeMultiDbThread.commitAll();
|
||||||
@@ -156,7 +173,7 @@ public class ExchangeColliImportService {
|
|||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
|
|
||||||
if (firstErrorObjectIfPresent != null) throw ((Result.Error)firstErrorObjectIfPresent).getError();
|
if (firstErrorObjectIfPresent != null) throw ((Result.Error) firstErrorObjectIfPresent).getError();
|
||||||
} finally {
|
} finally {
|
||||||
if (useTempTable)
|
if (useTempTable)
|
||||||
exchangeImportSchemaManagerService.deleteTempTables(exchangeMultiDb.getPrimaryConnection(), colliSchemaType);
|
exchangeImportSchemaManagerService.deleteTempTables(exchangeMultiDb.getPrimaryConnection(), colliSchemaType);
|
||||||
|
|||||||
Reference in New Issue
Block a user