Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit 6406acf5 authored by Joze RIHTARSIC's avatar Joze RIHTARSIC
Browse files

Pull request #194: EDELIVERY-9216 Fix user error in...

Pull request #194: EDELIVERY-9216 Fix user error in service-group-details-dialog component for service group

Merge in EDELIVERY/smp from bugfix/EDELIVERY-9216-service-row-pop-up-is-not-opening-when-double-click-on-first-row-in-edit-page to EDELIVERY-8805-user-account-lock

* commit '18b734995254e50f240bbed87d5ae782e2f0eb31':
  Fix user error in service-group-details-dialog component for service group
parents a8be57d5 95019f7b
No related branches found
No related tags found
No related merge requests found
......@@ -64,7 +64,7 @@
</mat-expansion-panel-header>
<mat-selection-list #usersSelected
[disabled]="!securityService.isCurrentUserSMPAdmin()"
[compareWith]="compareTableItemById"
[compareWith]="compareUserByUserId"
[formControl]="dialogForm.controls['users']"
style="height: 200px; overflow-y: scroll; overflow-x: auto;">
<!-- // if username is null then there must be an cerificate id! -->
......
......@@ -228,12 +228,12 @@ export class ServiceGroupDetailsDialogComponent implements OnInit {
}
compareTableItemById(item1, item2): boolean {
return item1.id === item2.id;
compareUserByUserId(item1, item2): boolean {
return item1.userId === item2.userId;
}
compareDomain(domain: DomainRo, serviceGroupDomain: ServiceGroupDomainEditRo): boolean {
return domain.id === serviceGroupDomain.domainId;
return domain.domainCode === serviceGroupDomain.domainCode;
}
......
......@@ -16,6 +16,7 @@ import eu.europa.ec.edelivery.smp.logging.SMPLogger;
import eu.europa.ec.edelivery.smp.logging.SMPLoggerFactory;
import eu.europa.ec.edelivery.smp.services.SMLIntegrationService;
import eu.europa.ec.edelivery.smp.services.ui.filters.ServiceGroupFilter;
import eu.europa.ec.edelivery.smp.utils.SessionSecurityUtils;
import eu.europa.ec.smp.api.exceptions.XmlInvalidAgainstSchemaException;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
......@@ -38,9 +39,7 @@ import java.util.List;
import java.util.Objects;
import java.util.Optional;
import static eu.europa.ec.edelivery.smp.data.ui.ServiceGroupValidationRO.ERROR_CODE_INVALID_EXTENSION;
import static eu.europa.ec.edelivery.smp.data.ui.ServiceGroupValidationRO.ERROR_CODE_OK;
import static eu.europa.ec.edelivery.smp.data.ui.ServiceGroupValidationRO.ERROR_CODE_SERVICE_GROUP_EXISTS;
import static eu.europa.ec.edelivery.smp.data.ui.ServiceGroupValidationRO.*;
import static eu.europa.ec.edelivery.smp.exceptions.ErrorCode.*;
@Service
......@@ -466,28 +465,6 @@ public class UIServiceGroupService extends UIServiceBase<DBServiceGroup, Service
return participantSMLRecordList;
}
/**
* Method validates if domain list in consistent - code and sml subdomain are used only oncet
*
* @param serviceGroupRO
* @return
*
protected List<ServiceGroupDomainRO> validateDomainList(ServiceGroupRO serviceGroupRO) {
List<ServiceGroupDomainRO> serviceGroupDomainROList = serviceGroupRO.getServiceGroupDomains();
// validate (if domains are added only once) and create domain list for service group.
serviceGroupDomainROList.forEach(dro -> {
List<ServiceGroupDomainRO> result = serviceGroupDomainROList.stream()
.filter(domainToAdd -> Objects.equals(domainToAdd.getDomainCode(), dro.getDomainCode())
|| Objects.equals(domainToAdd.getSmlSubdomain(), dro.getSmlSubdomain()))
.collect(Collectors.toList());
if (result.size() != 1) {
throw new SMPRuntimeException(DUPLICATE_DOMAIN_FOR_SG, serviceGroupRO.getParticipantIdentifier(),
serviceGroupRO.getParticipantScheme(), dro.getDomainCode(), dro.getSmlSubdomain());
}
});
return serviceGroupDomainROList;
}*/
/**
* Update users on service group. Method is OK for update and add new domain
*
......@@ -499,7 +476,8 @@ public class UIServiceGroupService extends UIServiceBase<DBServiceGroup, Service
dbServiceGroup.getUsers().clear();
List<UserRO> lstUsers = serviceGroupRO.getUsers();
for (UserRO userRO : lstUsers) {
Optional<DBUser> optUser = userDao.findUserByUsername(userRO.getUsername());
Long userid = SessionSecurityUtils.decryptEntityId(userRO.getUserId());
Optional<DBUser> optUser = userDao.findUser(userid);
if (!optUser.isPresent()) {
throw new SMPRuntimeException(INTERNAL_ERROR,
"Database changed", "User "+userRO.getUsername()+ " not exists! (Refresh data)");
......@@ -586,14 +564,10 @@ public class UIServiceGroupService extends UIServiceBase<DBServiceGroup, Service
//also add domain to service group
serviceGroupRo.getServiceGroupDomains().add(servGrpDomain);
});
// add users
// add users add just encrypted ID
dbServiceGroup.getUsers().forEach(usr -> {
UserRO userRO = new UserRO();
userRO.setUserId(usr.getId()+"");
userRO.setUsername(usr.getUsername());
userRO.setActive(usr.isActive());
userRO.setEmailAddress(usr.getEmailAddress());
userRO.setRole(usr.getRole());
userRO.setUserId(SessionSecurityUtils.encryptedEntityId(usr.getId()));
serviceGroupRo.getUsers().add(userRO);
});
// do not add service extension to gain performance.
......
......@@ -134,7 +134,7 @@ public class ServiceGroupResourceTest {
assertNotNull(sgro.getParticipantScheme());
assertNotNull(sgro.getParticipantIdentifier());
assertEquals(1, sgro.getUsers().size());
assertEquals("sg_admin", sgro.getUsers().get(0).getUsername());
assertNotNull(sgro.getUsers().get(0).getUserId());
});
}
......@@ -155,7 +155,7 @@ public class ServiceGroupResourceTest {
assertEquals(PARTICIPANT_IDENTIFIER, res.getParticipantIdentifier());
assertEquals(PARTICIPANT_SCHEME, res.getParticipantScheme());
assertEquals(1, res.getUsers().size());
assertEquals("test_user_hashed_pass", res.getUsers().get(0).getUsername());
assertNotNull(res.getUsers().get(0).getUserId());
assertEquals(1, res.getServiceGroupDomains().size());
assertEquals(1, res.getServiceMetadata().size());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment