diff --git a/ems-engine/src/main/java/it/integry/ems/activity/service/SteUPService.java b/ems-engine/src/main/java/it/integry/ems/activity/service/SteUPService.java index da64a4eaca..25078fe2c1 100644 --- a/ems-engine/src/main/java/it/integry/ems/activity/service/SteUPService.java +++ b/ems-engine/src/main/java/it/integry/ems/activity/service/SteUPService.java @@ -85,8 +85,8 @@ public class SteUPService { - private HashMap authUser() throws Exception { - HashMap loggedUser = authUserFromRequest(); + private HashMap authUser(String md5User) throws Exception { + HashMap loggedUser = authUserFromRequest(md5User); if (loggedUser != null) { int keyGroup = Integer.parseInt(loggedUser.get("key_group").toString()); if (!(this.isGroupRilevatore(keyGroup) || this.isGroupTecnico(keyGroup))) { @@ -96,11 +96,11 @@ public class SteUPService { return loggedUser; } - private HashMap authUserFromRequest() throws Exception { + private HashMap authUserFromRequest(String md5User) throws Exception { String userName = requestDataDTO.getUsername(); String password = requestDataDTO.getPassword(); String profileDB = multiDBTransactionManager.getPrimaryDatasource().getProfile(); - return systemService.login(userName, password, "", profileDB); + return systemService.login(userName, password, md5User, profileDB); } private String getUserNamePv(String codMdep) throws Exception { @@ -127,7 +127,7 @@ public class SteUPService { public HashMap login(String profileDb, String md5User) throws Exception { HashMap toReturn = new HashMap<>(); - HashMap loggedUser = this.authUser(); + HashMap loggedUser = this.authUser(md5User); String userName = loggedUser.get("user_name").toString(); Integer keyGroup = Integer.valueOf(loggedUser.get("key_group").toString()); @@ -284,7 +284,7 @@ public class SteUPService { public void setIndiceGradimento(String activityId, String codJfas, Integer indiceGradimento) throws Exception { Integer maxValue = 10; - HashMap loggedUser = this.authUserFromRequest(); + HashMap loggedUser = this.authUserFromRequest(null); String userName = loggedUser.get("user_name").toString(); int keyGroup = Integer.parseInt(loggedUser.get("key_group").toString()); @@ -334,10 +334,10 @@ public class SteUPService { HashMap loggedUser; if (UtilityString.nullIfBlank(md5User) != null) { // RICHIESTA DA APP - loggedUser = this.authUser(); + loggedUser = this.authUser(md5User); } else { // RICHIESTA DA PORTALE (non manda md5user) - loggedUser = this.authUserFromRequest(); + loggedUser = this.authUserFromRequest(null); } String userName = loggedUser.get("user_name").toString(); @@ -459,12 +459,13 @@ public class SteUPService { String activityTypeId = entry.getActivityTypeId(); String codJfas = entry.getCodJfas(); String codCmac = entry.getCodCmac(); + String md5User = entry.getMd5User(); Date dataCreation = UtilityDate.StringToDate(entry.getDataCreation(), CommonConstants.DATETIME_FORMAT_YMD); if (UtilityString.isNullOrEmpty(activityTypeId)) throw new Exception("Motivazione attività non presente"); - HashMap loggedUser = this.authUser(); + HashMap loggedUser = this.authUser(md5User); String userNameCreator = loggedUser.get("user_name").toString(); String userNamePv = this.getUserNamePv(codMdep); boolean flag_isNewIspezione = false; @@ -710,10 +711,9 @@ public class SteUPService { boolean containBarcode = hashMapList.stream().anyMatch(x -> finalBarcodes.contains(((String) x.get("barcode")))); if (!containBarcode) { - List> barcode = hashMapList.stream().filter(x -> x.get("barcode") != null).collect(Collectors.toList()); if (!barcode.isEmpty()) - barcodes.add(barcode.stream().findFirst().map(x -> x.get("barcode").toString()).get()); + barcodes.add(barcode.get(0).get("barcode").toString()); } } } else { @@ -914,7 +914,7 @@ public class SteUPService { } public StbActivity uploadAttachment(MultipartFile f, String activityId, String md5User) throws Exception { - authUserFromRequest(); + authUserFromRequest(md5User); logger.info("Uploading attachment activity ID: " + activityId); String fileName = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".zip"; String pathFile = UtilityDirs.getEmsApiTempDirectoryPath() + File.separator + activityId + File.separator;