Code development platform for open source projects from the European Union institutions

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

fix add Metadata without participant scheme

parent dcdd80e7
No related branches found
No related tags found
No related merge requests found
...@@ -34,12 +34,15 @@ import java.util.Objects; ...@@ -34,12 +34,15 @@ import java.util.Objects;
}) })
@NamedNativeQueries({ @NamedNativeQueries({
@NamedNativeQuery(name = "DBServiceMetadata.getBySGIdentifierAndSMDdentifier", query = "SELECT md.* FROM SMP_SERVICE_METADATA md INNER JOIN SMP_SERVICE_GROUP_DOMAIN sgd ON sgd.ID = md.FK_SG_DOM_ID " + @NamedNativeQuery(name = "DBServiceMetadata.getBySGIdentifierAndSMDdentifier", query = "SELECT md.* FROM SMP_SERVICE_METADATA md INNER JOIN SMP_SERVICE_GROUP_DOMAIN sgd ON sgd.ID = md.FK_SG_DOM_ID " +
" INNER JOIN SMP_SERVICE_GROUP sg ON sg.ID = sgd.FK_SG_ID\n" + " INNER JOIN SMP_SERVICE_GROUP sg ON sg.ID = sgd.FK_SG_ID" +
" where sg.PARTICIPANT_IDENTIFIER = :partcId AND sg.PARTICIPANT_SCHEME=:partcSch " + " where sg.PARTICIPANT_IDENTIFIER = :partcId " +
" AND md.DOCUMENT_IDENTIFIER=:docId AND (:docSch IS NULL OR md.DOCUMENT_SCHEME=:docSch)", resultClass = DBServiceMetadata.class), " AND (:partcSch IS NULL OR sg.PARTICIPANT_SCHEME= :partcSch) " +
" AND md.DOCUMENT_IDENTIFIER=:docId " +
" AND (:docSch IS NULL OR md.DOCUMENT_SCHEME=:docSch)", resultClass = DBServiceMetadata.class),
@NamedNativeQuery(name = "DBServiceMetadata.getBySGIdentifier", query = "SELECT md.* FROM SMP_SERVICE_METADATA md INNER JOIN SMP_SERVICE_GROUP_DOMAIN sgd ON sgd.ID = md.FK_SG_DOM_ID " + @NamedNativeQuery(name = "DBServiceMetadata.getBySGIdentifier", query = "SELECT md.* FROM SMP_SERVICE_METADATA md INNER JOIN SMP_SERVICE_GROUP_DOMAIN sgd ON sgd.ID = md.FK_SG_DOM_ID " +
" INNER JOIN SMP_SERVICE_GROUP sg ON sg.ID = sgd.FK_SG_ID " + " INNER JOIN SMP_SERVICE_GROUP sg ON sg.ID = sgd.FK_SG_ID " +
" where sg.PARTICIPANT_IDENTIFIER = :partcId AND sg.PARTICIPANT_SCHEME=:partcSch", resultClass = DBServiceMetadata.class) " where sg.PARTICIPANT_IDENTIFIER = :partcId " +
" AND (:partcSch IS NULL OR sg.PARTICIPANT_SCHEME= :partcSch) ", resultClass = DBServiceMetadata.class)
}) })
public class DBServiceMetadata extends BaseEntity { public class DBServiceMetadata extends BaseEntity {
......
...@@ -14,6 +14,7 @@ import eu.europa.ec.edelivery.smp.data.ui.enums.SMLStatusEnum; ...@@ -14,6 +14,7 @@ import eu.europa.ec.edelivery.smp.data.ui.enums.SMLStatusEnum;
import eu.europa.ec.edelivery.smp.exceptions.SMPRuntimeException; import eu.europa.ec.edelivery.smp.exceptions.SMPRuntimeException;
import eu.europa.ec.edelivery.smp.logging.SMPLogger; import eu.europa.ec.edelivery.smp.logging.SMPLogger;
import eu.europa.ec.edelivery.smp.logging.SMPLoggerFactory; import eu.europa.ec.edelivery.smp.logging.SMPLoggerFactory;
import eu.europa.ec.edelivery.smp.services.ConfigurationService;
import eu.europa.ec.edelivery.smp.services.SMLIntegrationService; import eu.europa.ec.edelivery.smp.services.SMLIntegrationService;
import eu.europa.ec.edelivery.smp.services.ui.filters.ServiceGroupFilter; import eu.europa.ec.edelivery.smp.services.ui.filters.ServiceGroupFilter;
import eu.europa.ec.edelivery.smp.utils.SessionSecurityUtils; import eu.europa.ec.edelivery.smp.utils.SessionSecurityUtils;
...@@ -52,13 +53,20 @@ public class UIServiceGroupService extends UIServiceBase<DBServiceGroup, Service ...@@ -52,13 +53,20 @@ public class UIServiceGroupService extends UIServiceBase<DBServiceGroup, Service
protected final UserDao userDao; protected final UserDao userDao;
protected final CaseSensitivityNormalizer caseSensitivityNormalizer; protected final CaseSensitivityNormalizer caseSensitivityNormalizer;
protected final SMLIntegrationService smlIntegrationService; protected final SMLIntegrationService smlIntegrationService;
protected final ConfigurationService configurationService;
public UIServiceGroupService(DomainDao domainDao, ServiceGroupDao serviceGroupDao, UserDao userDao, CaseSensitivityNormalizer caseSensitivityNormalizer, SMLIntegrationService smlIntegrationService) {
public UIServiceGroupService(DomainDao domainDao,
ServiceGroupDao serviceGroupDao,
UserDao userDao,
CaseSensitivityNormalizer caseSensitivityNormalizer,
SMLIntegrationService smlIntegrationService,
ConfigurationService configurationService) {
this.domainDao = domainDao; this.domainDao = domainDao;
this.serviceGroupDao = serviceGroupDao; this.serviceGroupDao = serviceGroupDao;
this.userDao = userDao; this.userDao = userDao;
this.caseSensitivityNormalizer = caseSensitivityNormalizer; this.caseSensitivityNormalizer = caseSensitivityNormalizer;
this.smlIntegrationService = smlIntegrationService; this.smlIntegrationService = smlIntegrationService;
this.configurationService = configurationService;
} }
@Override @Override
...@@ -286,7 +294,7 @@ public class UIServiceGroupService extends UIServiceBase<DBServiceGroup, Service ...@@ -286,7 +294,7 @@ public class UIServiceGroupService extends UIServiceBase<DBServiceGroup, Service
List<ServiceGroupDomainRO> serviceGroupDomainROList = serviceGroupRO.getServiceGroupDomains(); List<ServiceGroupDomainRO> serviceGroupDomainROList = serviceGroupRO.getServiceGroupDomains();
// validate (if domains are added only once) and create domain list for service group. // validate (if domains are added only once) and create domain list for service group.
serviceGroupDomainROList.forEach(dro -> { serviceGroupDomainROList.forEach(dro -> {
// everting ok find domain and add it to service group // everything ok find domain and add it to service group
Optional<DBDomain> dmn = domainDao.getDomainByCode(dro.getDomainCode()); Optional<DBDomain> dmn = domainDao.getDomainByCode(dro.getDomainCode());
if (dmn.isPresent()) { if (dmn.isPresent()) {
DBServiceGroupDomain domain = dbServiceGroup.addDomain(dmn.get()); DBServiceGroupDomain domain = dbServiceGroup.addDomain(dmn.get());
...@@ -420,7 +428,6 @@ public class UIServiceGroupService extends UIServiceBase<DBServiceGroup, Service ...@@ -420,7 +428,6 @@ public class UIServiceGroupService extends UIServiceBase<DBServiceGroup, Service
List<ParticipantSMLRecord> participantSMLRecordList = new ArrayList<>(); List<ParticipantSMLRecord> participantSMLRecordList = new ArrayList<>();
// / validate (if domains are added only once) and create domain list for service group. // / validate (if domains are added only once) and create domain list for service group.
// List<ServiceGroupDomainRO> serviceGroupDomainROList = validateDomainList(serviceGroupRO);
List<ServiceGroupDomainRO> serviceGroupDomainROList = serviceGroupRO.getServiceGroupDomains(); List<ServiceGroupDomainRO> serviceGroupDomainROList = serviceGroupRO.getServiceGroupDomains();
// copy array list of old domains and then put them back. Domain not added back will be deleted by hibernate // copy array list of old domains and then put them back. Domain not added back will be deleted by hibernate
// ... // ...
...@@ -497,9 +504,14 @@ public class UIServiceGroupService extends UIServiceBase<DBServiceGroup, Service ...@@ -497,9 +504,14 @@ public class UIServiceGroupService extends UIServiceBase<DBServiceGroup, Service
throw new SMPRuntimeException(MISSING_SG_ID, serviceGroupRO.getParticipantIdentifier(), serviceGroupRO.getParticipantScheme()); throw new SMPRuntimeException(MISSING_SG_ID, serviceGroupRO.getParticipantIdentifier(), serviceGroupRO.getParticipantScheme());
} }
// validate service group id // validate service group id
boolean schemeMandatory = configurationService.getParticipantSchemeMandatory();
LOG.debug("Validate service group [{}] with [{}] scheme", serviceGroupRO.getParticipantIdentifier(), (schemeMandatory?"mandatory":"optional"));
DBServiceGroup dbServiceGroup = getDatabaseDao().find(serviceGroupRO.getId()); DBServiceGroup dbServiceGroup = getDatabaseDao().find(serviceGroupRO.getId());
if (!Objects.equals(serviceGroupRO.getParticipantIdentifier(), dbServiceGroup.getParticipantIdentifier()) if (!Objects.equals(serviceGroupRO.getParticipantIdentifier(), dbServiceGroup.getParticipantIdentifier())
|| !Objects.equals(serviceGroupRO.getParticipantScheme(), dbServiceGroup.getParticipantScheme())) { || schemeMandatory &&
!Objects.equals(serviceGroupRO.getParticipantScheme(), dbServiceGroup.getParticipantScheme())) {
throw new SMPRuntimeException(INVALID_SG_ID, serviceGroupRO.getParticipantIdentifier(), throw new SMPRuntimeException(INVALID_SG_ID, serviceGroupRO.getParticipantIdentifier(),
serviceGroupRO.getParticipantScheme(), serviceGroupRO.getId()); serviceGroupRO.getParticipantScheme(), serviceGroupRO.getId());
} }
......
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