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

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

[EDELIVERY-13939] review option is not persisted on create

parent 15a7eb8c
No related branches found
No related tags found
No related merge requests found
Pipeline #207117 failed
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
services: services:
domismp-service: domismp-service:
ports: ports:
# - "3908:3306" - "3908:3306"
- "8982:8080" - "8982:8080"
# - "6902:6901" # - "6902:6901"
# - "8953:53" # - "8953:53"
......
...@@ -103,6 +103,8 @@ init_mysql() { ...@@ -103,6 +103,8 @@ init_mysql() {
sleep 3s sleep 3s
mv /var/lib/mysql ${DATA_DIR} mv /var/lib/mysql ${DATA_DIR}
fi fi
# set mysql authentication plugin to mysql_native_password
printf "\n[mysqld]\nbind-address = 0.0.0.0\ndefault_authentication_plugin = mysql_native_password\n" | tee -a /etc/mysql/my.cnf
rm -rf /var/lib/mysql rm -rf /var/lib/mysql
ln -sf ${MYSQL_DATA_DIR} /var/lib/mysql ln -sf ${MYSQL_DATA_DIR} /var/lib/mysql
...@@ -119,7 +121,7 @@ init_mysql() { ...@@ -119,7 +121,7 @@ init_mysql() {
echo "[INFO] MySQL ${SMP_DB_SCHEMA} not found, creating initial DBs" echo "[INFO] MySQL ${SMP_DB_SCHEMA} not found, creating initial DBs"
echo 'Create smp database' echo 'Create smp database'
mysql -h localhost -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '$MYSQL_ROOT_PASSWORD';drop schema if exists $SMP_DB_SCHEMA;DROP USER IF EXISTS $SMP_DB_USER; create schema $SMP_DB_SCHEMA;alter database $SMP_DB_SCHEMA charset=utf8; create user $SMP_DB_USER identified by '$SMP_DB_USER_PASSWORD';grant all on $SMP_DB_SCHEMA.* to $SMP_DB_USER;" mysql -h localhost -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '$MYSQL_ROOT_PASSWORD';CREATE USER 'root'@'%' IDENTIFIED BY '$MYSQL_ROOT_PASSWORD';GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';drop schema if exists $SMP_DB_SCHEMA;DROP USER IF EXISTS $SMP_DB_USER; create schema $SMP_DB_SCHEMA;alter database $SMP_DB_SCHEMA charset=utf8; create user $SMP_DB_USER identified by '$SMP_DB_USER_PASSWORD';grant all on $SMP_DB_SCHEMA.* to $SMP_DB_USER;"
if [ -f "/tmp/custom-data/mysql5innodb.sql" ]; then if [ -f "/tmp/custom-data/mysql5innodb.sql" ]; then
echo "Use custom database script! " echo "Use custom database script! "
......
...@@ -93,6 +93,7 @@ export class ResourceDialogComponent { ...@@ -93,6 +93,7 @@ export class ResourceDialogComponent {
resource.identifierScheme = this.resourceForm.get('identifierScheme').value; resource.identifierScheme = this.resourceForm.get('identifierScheme').value;
resource.resourceTypeIdentifier = this.resourceForm.get('resourceTypeIdentifier').value; resource.resourceTypeIdentifier = this.resourceForm.get('resourceTypeIdentifier').value;
resource.visibility = this.resourceForm.get('visibility').value; resource.visibility = this.resourceForm.get('visibility').value;
resource.reviewEnabled = this.resourceForm.get('reviewEnabled').value;
return resource; return resource;
} }
...@@ -156,16 +157,17 @@ export class ResourceDialogComponent { ...@@ -156,16 +157,17 @@ export class ResourceDialogComponent {
public createResource(resource: ResourceRo) { public createResource(resource: ResourceRo) {
this.submitInProgress = true; this.submitInProgress = true;
this.editGroupService.createResourceForGroup(this.resource, this.group, this.domain).subscribe((result: ResourceRo) => { this.editGroupService.createResourceForGroup(this.resource, this.group, this.domain).subscribe({
if (!!result) { next: (result: ResourceRo) => {
this.closeDialog(); if (!!result) {
this.closeDialog();
}
this.submitInProgress = false;
}, error: (error) => {
this.alertService.error(error.error?.errorDescription)
this.submitInProgress = false;
} }
this.submitInProgress = false;
}, (error) => {
this.alertService.error(error.error?.errorDescription)
this.submitInProgress = false;
}); });
} }
public saveResource(resource: ResourceRo): void { public saveResource(resource: ResourceRo): void {
......
...@@ -3,11 +3,15 @@ import {GroupRo} from "../../common/model/group-ro.model"; ...@@ -3,11 +3,15 @@ import {GroupRo} from "../../common/model/group-ro.model";
import {ResourceRo} from "../../common/model/resource-ro.model"; import {ResourceRo} from "../../common/model/resource-ro.model";
import {TableResult} from "../../common/model/table-result.model"; import {TableResult} from "../../common/model/table-result.model";
import {DomainRo} from "../../common/model/domain-ro.model"; import {DomainRo} from "../../common/model/domain-ro.model";
import {ResourceDefinitionRo} from "../../system-settings/admin-extension/resource-definition-ro.model"; import {
ResourceDefinitionRo
} from "../../system-settings/admin-extension/resource-definition-ro.model";
import {EditResourceService} from "./edit-resource.service"; import {EditResourceService} from "./edit-resource.service";
import {EditDomainService} from "../edit-domain/edit-domain.service"; import {EditDomainService} from "../edit-domain/edit-domain.service";
import {EditGroupService} from "../edit-group/edit-group.service"; import {EditGroupService} from "../edit-group/edit-group.service";
import {AlertMessageService} from "../../common/alert-message/alert-message.service"; import {
AlertMessageService
} from "../../common/alert-message/alert-message.service";
import {MatTableDataSource} from "@angular/material/table"; import {MatTableDataSource} from "@angular/material/table";
/** /**
...@@ -18,7 +22,7 @@ import {MatTableDataSource} from "@angular/material/table"; ...@@ -18,7 +22,7 @@ import {MatTableDataSource} from "@angular/material/table";
* @since 5.1 * @since 5.1
*/ */
@Injectable() @Injectable()
export class EditResourceController extends MatTableDataSource<ResourceRo>{ export class EditResourceController extends MatTableDataSource<ResourceRo> {
domainList: DomainRo[] = []; domainList: DomainRo[] = [];
groupList: GroupRo[] = []; groupList: GroupRo[] = [];
...@@ -77,6 +81,20 @@ export class EditResourceController extends MatTableDataSource<ResourceRo>{ ...@@ -77,6 +81,20 @@ export class EditResourceController extends MatTableDataSource<ResourceRo>{
return this._selectedResource; return this._selectedResource;
}; };
selectedResourceUpdated(resource: ResourceRo) {
// find current resource from list by resource id
if (resource.resourceId == this._selectedResource.resourceId) {
this._selectedResource.resourceTypeIdentifier = resource.resourceTypeIdentifier;
this._selectedResource.identifierScheme = resource.identifierScheme;
this._selectedResource.identifierValue = resource.identifierValue;
this._selectedResource.visibility = resource.visibility;
this._selectedResource.reviewEnabled = resource.reviewEnabled
} else {
console.log('selected resource not found')
this.selectedResource = resource;
}
}
@Input() set selectedResource(resource: ResourceRo) { @Input() set selectedResource(resource: ResourceRo) {
this._selectedResource = resource; this._selectedResource = resource;
}; };
...@@ -88,12 +106,14 @@ export class EditResourceController extends MatTableDataSource<ResourceRo>{ ...@@ -88,12 +106,14 @@ export class EditResourceController extends MatTableDataSource<ResourceRo>{
refreshDomains() { refreshDomains() {
this.isLoadingResults = true; this.isLoadingResults = true;
this.domainService.getDomainsForResourceAdminUserObservable() this.domainService.getDomainsForResourceAdminUserObservable()
.subscribe({next: (result: DomainRo[]) => { .subscribe({
this.updateDomainList(result) next: (result: DomainRo[]) => {
}, error: (err: any) => { this.updateDomainList(result)
this.alertService.error(err.error?.errorDescription) }, error: (err: any) => {
this.isLoadingResults = false; this.alertService.error(err.error?.errorDescription)
}}); this.isLoadingResults = false;
}
});
} }
refreshGroups() { refreshGroups() {
...@@ -104,11 +124,13 @@ export class EditResourceController extends MatTableDataSource<ResourceRo>{ ...@@ -104,11 +124,13 @@ export class EditResourceController extends MatTableDataSource<ResourceRo>{
} }
this.isLoadingResults = true; this.isLoadingResults = true;
this.groupService.getDomainGroupsForResourceAdminObservable(this.selectedDomain) this.groupService.getDomainGroupsForResourceAdminObservable(this.selectedDomain)
.subscribe((result: GroupRo[]) => { .subscribe({
this.updateGroupList(result) next: (result: GroupRo[]) => {
}, (error: any) => { this.updateGroupList(result)
this.isLoadingResults = false; }, error: (error: any) => {
this.alertService.error(error.error?.errorDescription) this.isLoadingResults = false;
this.alertService.error(error.error?.errorDescription)
}
}); });
} }
...@@ -121,21 +143,25 @@ export class EditResourceController extends MatTableDataSource<ResourceRo>{ ...@@ -121,21 +143,25 @@ export class EditResourceController extends MatTableDataSource<ResourceRo>{
this.isLoadingResults = true; this.isLoadingResults = true;
this.resourceService.getGroupResourcesForResourceAdminObservable(this.selectedGroup, this.selectedDomain, this.resourceService.getGroupResourcesForResourceAdminObservable(this.selectedGroup, this.selectedDomain,
this.resourcesFilter, this.pageIndex, this.pageSize) this.resourcesFilter, this.pageIndex, this.pageSize)
.subscribe((result: TableResult<ResourceRo>) => { .subscribe({
this.updateResourceList(result.serviceEntities) next: (result: TableResult<ResourceRo>) => {
this.isLoadingResults = false; this.updateResourceList(result.serviceEntities)
}, (error: any) => { this.isLoadingResults = false;
this.isLoadingResults = false; }, error: (error: any) => {
this.alertService.error(error.error?.errorDescription) this.isLoadingResults = false;
this.alertService.error(error.error?.errorDescription)
}
}); });
} }
refreshDomainsResourceDefinitions() { refreshDomainsResourceDefinitions() {
this.domainService.getDomainResourceDefinitionsObservable(this.selectedDomain) this.domainService.getDomainResourceDefinitionsObservable(this.selectedDomain)
.subscribe((result: ResourceDefinitionRo[]) => { .subscribe({
this._selectedDomainResourceDefs = result next: (result: ResourceDefinitionRo[]) => {
}, (error: any) => { this._selectedDomainResourceDefs = result
this.alertService.error(error.error?.errorDescription) }, error: (error: any) => {
this.alertService.error(error.error?.errorDescription)
}
}); });
} }
...@@ -158,20 +184,14 @@ export class EditResourceController extends MatTableDataSource<ResourceRo>{ ...@@ -158,20 +184,14 @@ export class EditResourceController extends MatTableDataSource<ResourceRo>{
} }
updateResourceList(list: ResourceRo[]) { updateResourceList(list: ResourceRo[]) {
console.log('updateResourceList selected resource:' + this._selectedResource)
// find current resource from list by resource id
let currR: ResourceRo = this.selectedResource; let currR: ResourceRo = this.selectedResource;
this.selectedResource = null; this.selectedResource = null;
this.data = list; this.data = list;
if (!!currR) { if (!!currR) {
console.log('selected resource :' + currR)
this.selectedResource = list.find(r => this.selectedResource = list.find(r =>
r.identifierScheme == currR.identifierScheme && r.identifierScheme == currR.identifierScheme &&
r.identifierValue == currR.identifierValue); r.identifierValue == currR.identifierValue);
console.log('selected resource found :' + this._selectedResource)
} }
if (!this.selectedResource && !!list && list.length > 0) { if (!this.selectedResource && !!list && list.length > 0) {
......
...@@ -33,7 +33,6 @@ import {EditResourceController} from "../edit-resource.controller"; ...@@ -33,7 +33,6 @@ import {EditResourceController} from "../edit-resource.controller";
styleUrls: ['./resource-details-panel.component.scss'] styleUrls: ['./resource-details-panel.component.scss']
}) })
export class ResourceDetailsPanelComponent implements BeforeLeaveGuard { export class ResourceDetailsPanelComponent implements BeforeLeaveGuard {
readonly groupVisibilityOptions = Object.keys(VisibilityEnum) readonly groupVisibilityOptions = Object.keys(VisibilityEnum)
.map(el => { .map(el => {
return {key: el, value: VisibilityEnum[el]} return {key: el, value: VisibilityEnum[el]}
...@@ -157,8 +156,8 @@ export class ResourceDetailsPanelComponent implements BeforeLeaveGuard { ...@@ -157,8 +156,8 @@ export class ResourceDetailsPanelComponent implements BeforeLeaveGuard {
try { try {
if (!!result) { if (!!result) {
this.alertService.successForTranslation("resource.details.panel.alert.resource.saved"); this.alertService.successForTranslation("resource.details.panel.alert.resource.saved");
this.editResourceController.selectedResource = result; this.editResourceController.selectedResourceUpdated(result);
this._resource = result; this.resource = result;
this.resourceForm.markAsPristine(); this.resourceForm.markAsPristine();
} }
} finally { } finally {
......
...@@ -69,6 +69,8 @@ public class UIResourceService { ...@@ -69,6 +69,8 @@ public class UIResourceService {
private static final String ACTION_RESOURCE_UPDATE = "UpdateResource"; private static final String ACTION_RESOURCE_UPDATE = "UpdateResource";
private static final SMPLogger LOG = SMPLoggerFactory.getLogger(UIResourceService.class); private static final SMPLogger LOG = SMPLoggerFactory.getLogger(UIResourceService.class);
public static final String GROUP_DOES_NOT_EXIST = "Group does not exist!";
public static final String GROUP_DOES_NOT_BELONG_TO_THE_GIVEN_DOMAIN = "Group does not belong to the given domain!";
private final ResourceDao resourceDao; private final ResourceDao resourceDao;
...@@ -111,7 +113,7 @@ public class UIResourceService { ...@@ -111,7 +113,7 @@ public class UIResourceService {
DBGroup group = groupDao.find(groupId); DBGroup group = groupDao.find(groupId);
if (group == null) { if (group == null) {
throw new SMPRuntimeException(ErrorCode.INVALID_REQUEST, ACTION_RESOURCE_LIST, "Group does not exist!"); throw new SMPRuntimeException(ErrorCode.INVALID_REQUEST, ACTION_RESOURCE_LIST, GROUP_DOES_NOT_EXIST);
} }
DBResourceFilter filter = DBResourceFilter.createBuilder() DBResourceFilter filter = DBResourceFilter.createBuilder()
...@@ -142,7 +144,7 @@ public class UIResourceService { ...@@ -142,7 +144,7 @@ public class UIResourceService {
DBGroup group = groupDao.find(groupId); DBGroup group = groupDao.find(groupId);
if (group == null) { if (group == null) {
throw new SMPRuntimeException(ErrorCode.INVALID_REQUEST, ACTION_RESOURCE_LIST, "Group does not exist!"); throw new SMPRuntimeException(ErrorCode.INVALID_REQUEST, ACTION_RESOURCE_LIST, GROUP_DOES_NOT_EXIST);
} }
DBUser user = userDao.find(userId); DBUser user = userDao.find(userId);
if (user == null) { if (user == null) {
...@@ -183,7 +185,7 @@ public class UIResourceService { ...@@ -183,7 +185,7 @@ public class UIResourceService {
throw new SMPRuntimeException(ErrorCode.INVALID_REQUEST, ACTION_RESOURCE_DELETE, "Resource does not belong to the group!"); throw new SMPRuntimeException(ErrorCode.INVALID_REQUEST, ACTION_RESOURCE_DELETE, "Resource does not belong to the group!");
} }
if (!Objects.equals(resource.getGroup().getDomain().getId(), domainId)) { if (!Objects.equals(resource.getGroup().getDomain().getId(), domainId)) {
throw new SMPRuntimeException(ErrorCode.INVALID_REQUEST, ACTION_RESOURCE_DELETE, "Group does not belong to the given domain!"); throw new SMPRuntimeException(ErrorCode.INVALID_REQUEST, ACTION_RESOURCE_DELETE, GROUP_DOES_NOT_BELONG_TO_THE_GIVEN_DOMAIN);
} }
DBDomain resourceDomain = resource.getGroup().getDomain(); DBDomain resourceDomain = resource.getGroup().getDomain();
if (smlIntegrationService.isSMLIntegrationEnabled() && if (smlIntegrationService.isSMLIntegrationEnabled() &&
...@@ -200,12 +202,12 @@ public class UIResourceService { ...@@ -200,12 +202,12 @@ public class UIResourceService {
DBGroup group = groupDao.find(groupId); DBGroup group = groupDao.find(groupId);
if (group == null) { if (group == null) {
throw new SMPRuntimeException(ErrorCode.INVALID_REQUEST, ACTION_RESOURCE_CREATE, "Group does not exist!"); throw new SMPRuntimeException(ErrorCode.INVALID_REQUEST, ACTION_RESOURCE_CREATE, GROUP_DOES_NOT_EXIST);
} }
DBDomain domain = group.getDomain(); DBDomain domain = group.getDomain();
if (!Objects.equals(domain.getId(), domainId)) { if (!Objects.equals(domain.getId(), domainId)) {
throw new SMPRuntimeException(ErrorCode.INVALID_REQUEST, ACTION_RESOURCE_CREATE, "Group does not belong to the given domain!"); throw new SMPRuntimeException(ErrorCode.INVALID_REQUEST, ACTION_RESOURCE_CREATE, GROUP_DOES_NOT_BELONG_TO_THE_GIVEN_DOMAIN);
} }
Optional<DBResourceDef> optRedef = resourceDefDao.getResourceDefByIdentifier(resourceRO.getResourceTypeIdentifier()); Optional<DBResourceDef> optRedef = resourceDefDao.getResourceDefByIdentifier(resourceRO.getResourceTypeIdentifier());
...@@ -270,11 +272,11 @@ public class UIResourceService { ...@@ -270,11 +272,11 @@ public class UIResourceService {
DBGroup group = groupDao.find(groupId); DBGroup group = groupDao.find(groupId);
if (group == null) { if (group == null) {
throw new SMPRuntimeException(ErrorCode.INVALID_REQUEST, ACTION_RESOURCE_UPDATE, "Group does not exist!"); throw new SMPRuntimeException(ErrorCode.INVALID_REQUEST, ACTION_RESOURCE_UPDATE, GROUP_DOES_NOT_EXIST);
} }
if (!Objects.equals(group.getDomain().getId(), domainId)) { if (!Objects.equals(group.getDomain().getId(), domainId)) {
throw new SMPRuntimeException(ErrorCode.INVALID_REQUEST, ACTION_RESOURCE_UPDATE, "Group does not belong to the given domain!"); throw new SMPRuntimeException(ErrorCode.INVALID_REQUEST, ACTION_RESOURCE_UPDATE, GROUP_DOES_NOT_BELONG_TO_THE_GIVEN_DOMAIN);
} }
Optional<DBResourceDef> optRedef = resourceDefDao.getResourceDefByIdentifier(resourceRO.getResourceTypeIdentifier()); Optional<DBResourceDef> optRedef = resourceDefDao.getResourceDefByIdentifier(resourceRO.getResourceTypeIdentifier());
...@@ -294,7 +296,12 @@ public class UIResourceService { ...@@ -294,7 +296,12 @@ public class UIResourceService {
if (resourceRO.isReviewEnabled() != null) { if (resourceRO.isReviewEnabled() != null) {
resource.setReviewEnabled(isTrue(resourceRO.isReviewEnabled())); resource.setReviewEnabled(isTrue(resourceRO.isReviewEnabled()));
} }
return conversionService.convert(resource, ResourceRO.class); ResourceRO resourceROResult = conversionService.convert(resource, ResourceRO.class);
if (StringUtils.isNotBlank(resourceRO.getResourceId())){
// return the same encrypted id so the UI can use update old resource
resourceROResult.setResourceId(resourceRO.getResourceId());
}
return resourceROResult;
} }
@Transactional @Transactional
......
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