Merge branch 'master' into develop
This commit is contained in:
@@ -6,14 +6,16 @@ import java.util.HashMap;
|
||||
|
||||
public class AuthTokenDetails {
|
||||
private long deviceId;
|
||||
private String profileDb;
|
||||
private UserDTO userDTO;
|
||||
private HashMap<String, AuthTokenProfileDetails> profilesData;
|
||||
|
||||
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.profileDb = profileDb;
|
||||
this.userDTO = userDTO;
|
||||
this.profilesData = profilesData;
|
||||
}
|
||||
@@ -22,6 +24,10 @@ public class AuthTokenDetails {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public String getProfileDb() {
|
||||
return profileDb;
|
||||
}
|
||||
|
||||
public UserDTO getUserDTO() {
|
||||
return userDTO;
|
||||
}
|
||||
|
||||
@@ -75,14 +75,21 @@ public class AuthService {
|
||||
|
||||
UserDataDTO userData = new UserDataDTO();
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(profileDb)) { // SELEZIONE DB DIRETTO
|
||||
multiDBTransactionManager.closeAll();
|
||||
multiDBTransactionManager.setPrimaryDs(loginRequestDTO.getProfileDb());
|
||||
|
||||
userData.setUser(this.getUser(username, password, multiDBTransactionManager));
|
||||
} else {
|
||||
if (UtilityString.isNullOrEmpty(profileDb)) {
|
||||
List<String> profiles = userService.retrieveAvailableProfiles(username);
|
||||
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) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import io.jsonwebtoken.SignatureAlgorithm;
|
||||
import io.jsonwebtoken.io.Encoders;
|
||||
import io.jsonwebtoken.security.Keys;
|
||||
import it.integry.ems.exception.PrimaryDatabaseNotPresentException;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
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 =
|
||||
new UsernamePasswordAuthenticationToken(username, password,
|
||||
ImmutableList.of(new SimpleGrantedAuthority(keyGroup)));
|
||||
@@ -163,7 +164,9 @@ public class RefreshTokenService {
|
||||
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);
|
||||
|
||||
return authenticationToken;
|
||||
|
||||
@@ -8,6 +8,7 @@ import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.system.exchange.dto.CertificatiSinfoOneDTO;
|
||||
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.MtbColr;
|
||||
import it.integry.ems_model.entity.MtbColt;
|
||||
@@ -130,9 +131,25 @@ public class ExchangeColliImportService {
|
||||
try (MultiDBTransactionManager exchangeMultiDbThread = new MultiDBTransactionManager(exchangeMultiDb.getPrimaryDatasource().getProfile(), false);
|
||||
MultiDBTransactionManager internalMultiDbThread = new MultiDBTransactionManager(internalMultiDb.getPrimaryDatasource().getProfile(), false)) {
|
||||
|
||||
entityProcessor.processEntity(dataToSave, true, true, ROSSOGARGANO_EXCHANGE_USER, internalMultiDbThread, requestDataDTO);
|
||||
singleUpdateImported(exchangeMultiDbThread.getPrimaryConnection(), (MtbColt) dataToSave, testataTableName, useTempTable);
|
||||
singleUpdateImported(exchangeMultiDbThread.getPrimaryConnection(), (MtbColt) dataToSave, righeTableName, useTempTable);
|
||||
MtbColt mtbColtToSave = (MtbColt) dataToSave;
|
||||
if (mtbColtToSave.hasDocument() && mtbColtToSave.getOperation() == OperationType.DELETE) {
|
||||
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();
|
||||
exchangeMultiDbThread.commitAll();
|
||||
|
||||
Reference in New Issue
Block a user