Merge remote-tracking branch 'origin/master' into production
This commit is contained in:
commit
26c1b51adc
2
pom.xml
2
pom.xml
|
@ -29,7 +29,7 @@
|
||||||
<dependency> <!-- this dependency includes dependency to uoa-authorization-library -->
|
<dependency> <!-- this dependency includes dependency to uoa-authorization-library -->
|
||||||
<groupId>eu.dnetlib</groupId>
|
<groupId>eu.dnetlib</groupId>
|
||||||
<artifactId>uoa-admin-tools-library</artifactId>
|
<artifactId>uoa-admin-tools-library</artifactId>
|
||||||
<version>1.0.10</version>
|
<version>1.0.12</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>eu.dnetlib</groupId>
|
<groupId>eu.dnetlib</groupId>
|
||||||
|
|
|
@ -234,8 +234,6 @@ function uniqueIndexes() {
|
||||||
db.stakeholder.createIndex( { "alias": 1 }, { unique: true } );
|
db.stakeholder.createIndex( { "alias": 1 }, { unique: true } );
|
||||||
}
|
}
|
||||||
|
|
||||||
// use monitordb;
|
|
||||||
|
|
||||||
upperCaseEnumValues();
|
upperCaseEnumValues();
|
||||||
addHeightInIndicators();
|
addHeightInIndicators();
|
||||||
addVisibility();
|
addVisibility();
|
||||||
|
|
|
@ -52,8 +52,6 @@ function addFooterHelpTextForPortalType(portalType) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// use monitordb;
|
|
||||||
|
|
||||||
addHomePageInPortalType("funder");
|
addHomePageInPortalType("funder");
|
||||||
addFooterDivIdForPortalType("funder");
|
addFooterDivIdForPortalType("funder");
|
||||||
addFooterHelpTextForPortalType("funder");
|
addFooterHelpTextForPortalType("funder");
|
||||||
|
|
|
@ -176,7 +176,5 @@ function addFundingStreamInDefaultMSCA() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// use monitordb;
|
|
||||||
|
|
||||||
statsProfileOfIndicatorsAsVariable();
|
statsProfileOfIndicatorsAsVariable();
|
||||||
addFundingStreamInDefaultMSCA();
|
addFundingStreamInDefaultMSCA();
|
||||||
|
|
|
@ -12,5 +12,12 @@ function deleteIndexParameters() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// use irish-prod;
|
function addCopyWithDefaultValue() {
|
||||||
|
/* Set default profiles with copy: false */
|
||||||
|
db.stakeholder.updateMany({defaultId: null, copy: {$exists: false}}, {$set: {copy: false}});
|
||||||
|
/* Set not default profiles with copy: true */
|
||||||
|
db.stakeholder.updateMany({defaultId: {$ne: null}, copy: {$exists: false}}, {$set: {copy: true}});
|
||||||
|
}
|
||||||
|
|
||||||
deleteIndexParameters();
|
deleteIndexParameters();
|
||||||
|
addCopyWithDefaultValue();
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
package eu.dnetlib.uoamonitorservice.controllers;
|
package eu.dnetlib.uoamonitorservice.controllers;
|
||||||
|
|
||||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Portal;
|
import eu.dnetlib.uoaadmintoolslibrary.entities.Portal;
|
||||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ForbiddenException;
|
|
||||||
import eu.dnetlib.uoaadmintoolslibrary.services.PortalService;
|
import eu.dnetlib.uoaadmintoolslibrary.services.PortalService;
|
||||||
import eu.dnetlib.uoamonitorservice.dto.copy;
|
|
||||||
import eu.dnetlib.uoamonitorservice.dto.StakeholderFull;
|
import eu.dnetlib.uoamonitorservice.dto.StakeholderFull;
|
||||||
|
import eu.dnetlib.uoamonitorservice.dto.copy;
|
||||||
import eu.dnetlib.uoamonitorservice.entities.Stakeholder;
|
import eu.dnetlib.uoamonitorservice.entities.Stakeholder;
|
||||||
import eu.dnetlib.uoamonitorservice.generics.StakeholderGeneric;
|
|
||||||
import eu.dnetlib.uoamonitorservice.primitives.Visibility;
|
import eu.dnetlib.uoamonitorservice.primitives.Visibility;
|
||||||
|
import eu.dnetlib.uoamonitorservice.service.CommonService;
|
||||||
import eu.dnetlib.uoamonitorservice.service.StakeholderService;
|
import eu.dnetlib.uoamonitorservice.service.StakeholderService;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
@ -16,7 +15,6 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin(origins = "*")
|
@CrossOrigin(origins = "*")
|
||||||
|
@ -25,11 +23,13 @@ public class StakeholderController {
|
||||||
|
|
||||||
private final PortalService portalService;
|
private final PortalService portalService;
|
||||||
private final StakeholderService stakeholderService;
|
private final StakeholderService stakeholderService;
|
||||||
|
private final CommonService commonService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public StakeholderController(PortalService portalService, StakeholderService stakeholderService) {
|
public StakeholderController(PortalService portalService, StakeholderService stakeholderService, CommonService commonService) {
|
||||||
this.portalService = portalService;
|
this.portalService = portalService;
|
||||||
this.stakeholderService = stakeholderService;
|
this.stakeholderService = stakeholderService;
|
||||||
|
this.commonService = commonService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreAuthorize("isAuthenticated()")
|
@PreAuthorize("isAuthenticated()")
|
||||||
|
@ -89,7 +89,7 @@ public class StakeholderController {
|
||||||
public StakeholderFull getStakeholder(@PathVariable("alias") String alias) {
|
public StakeholderFull getStakeholder(@PathVariable("alias") String alias) {
|
||||||
StakeholderFull stakeholder = this.stakeholderService.getFullStakeholder(this.stakeholderService.findByAlias(alias));
|
StakeholderFull stakeholder = this.stakeholderService.getFullStakeholder(this.stakeholderService.findByAlias(alias));
|
||||||
if (stakeholder == null) {
|
if (stakeholder == null) {
|
||||||
throw new ForbiddenException("Get stakeholder: You are not authorized to access stakeholder with alias: " + alias);
|
this.commonService.unauthorized("Get stakeholder: You are not authorized to access stakeholder with alias: " + alias);
|
||||||
}
|
}
|
||||||
return stakeholder;
|
return stakeholder;
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,7 @@ public class CategoryService {
|
||||||
this.updateChildren(category);
|
this.updateChildren(category);
|
||||||
category = this.save(category);
|
category = this.save(category);
|
||||||
} else {
|
} else {
|
||||||
throw new ForbiddenException("You are not authorized to update stakeholder with id: " + stakeholder.getId());
|
this.commonService.unauthorized("You are not authorized to update stakeholder with id: " + stakeholder.getId());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.commonService.hasCreateAuthority(stakeholder.getType())) {
|
if (this.commonService.hasCreateAuthority(stakeholder.getType())) {
|
||||||
|
@ -113,7 +113,7 @@ public class CategoryService {
|
||||||
}
|
}
|
||||||
this.addCategory(topic, category.getId());
|
this.addCategory(topic, category.getId());
|
||||||
} else {
|
} else {
|
||||||
throw new ForbiddenException("You are not authorized to create a category in stakeholder with id: " + stakeholder.getId());
|
this.commonService.unauthorized("You are not authorized to create a category in stakeholder with id: " + stakeholder.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.getFullCategory(stakeholder.getType(), stakeholder.getAlias(), category);
|
return this.getFullCategory(stakeholder.getType(), stakeholder.getAlias(), category);
|
||||||
|
@ -145,8 +145,9 @@ public class CategoryService {
|
||||||
throw new EntityNotFoundException("Some subCategories dont exist in the category with id " + category.getId());
|
throw new EntityNotFoundException("Some subCategories dont exist in the category with id " + category.getId());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new ForbiddenException("You are not authorized to reorder subCategories in category with id: " + category.getId());
|
this.commonService.unauthorized("You are not authorized to reorder subCategories in category with id: " + category.getId());
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reorderChildren(Stakeholder defaultStakeholder, Category defaultCategory, List<String> defaultSubCategories) {
|
public void reorderChildren(Stakeholder defaultStakeholder, Category defaultCategory, List<String> defaultSubCategories) {
|
||||||
|
@ -171,7 +172,7 @@ public class CategoryService {
|
||||||
}
|
}
|
||||||
this.dao.delete(category);
|
this.dao.delete(category);
|
||||||
} else {
|
} else {
|
||||||
throw new ForbiddenException("Delete category: You are not authorized to delete category with id: " + category.getId());
|
this.commonService.unauthorized("Delete category: You are not authorized to delete category with id: " + category.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,8 +206,9 @@ public class CategoryService {
|
||||||
category.update(this.save(new Category(category)));
|
category.update(this.save(new Category(category)));
|
||||||
return category;
|
return category;
|
||||||
} else {
|
} else {
|
||||||
throw new ForbiddenException("Change category visibility: You are not authorized to update category with id: " + category.getId());
|
this.commonService.unauthorized("Change category visibility: You are not authorized to update category with id: " + category.getId());
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CategoryFull changeVisibility(String type, String alias, Category category, Visibility visibility, Boolean propagate) {
|
public CategoryFull changeVisibility(String type, String alias, Category category, Visibility visibility, Boolean propagate) {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package eu.dnetlib.uoamonitorservice.service;
|
package eu.dnetlib.uoamonitorservice.service;
|
||||||
|
|
||||||
|
import eu.dnetlib.uoaadmintoolslibrary.handlers.ForbiddenException;
|
||||||
|
import eu.dnetlib.uoaadmintoolslibrary.handlers.UnauthorizedException;
|
||||||
import eu.dnetlib.uoaauthorizationlibrary.security.AuthorizationService;
|
import eu.dnetlib.uoaauthorizationlibrary.security.AuthorizationService;
|
||||||
import eu.dnetlib.uoamonitorservice.dto.TopicFull;
|
import eu.dnetlib.uoamonitorservice.dto.TopicFull;
|
||||||
import eu.dnetlib.uoamonitorservice.generics.Common;
|
import eu.dnetlib.uoamonitorservice.generics.Common;
|
||||||
|
@ -69,4 +71,12 @@ public class CommonService {
|
||||||
});
|
});
|
||||||
return ids;
|
return ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void unauthorized(String message) {
|
||||||
|
if(authorizationService.getAaiId() != null) {
|
||||||
|
throw new ForbiddenException(message);
|
||||||
|
} else {
|
||||||
|
throw new UnauthorizedException(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package eu.dnetlib.uoamonitorservice.service;
|
package eu.dnetlib.uoamonitorservice.service;
|
||||||
|
|
||||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ForbiddenException;
|
|
||||||
import eu.dnetlib.uoamonitorservice.dao.*;
|
import eu.dnetlib.uoamonitorservice.dao.*;
|
||||||
import eu.dnetlib.uoamonitorservice.entities.Indicator;
|
import eu.dnetlib.uoamonitorservice.entities.Indicator;
|
||||||
import eu.dnetlib.uoamonitorservice.entities.Section;
|
import eu.dnetlib.uoamonitorservice.entities.Section;
|
||||||
|
@ -82,7 +81,7 @@ public class IndicatorService {
|
||||||
this.updateChildren(indicator);
|
this.updateChildren(indicator);
|
||||||
indicator = this.save(indicator);
|
indicator = this.save(indicator);
|
||||||
} else {
|
} else {
|
||||||
throw new ForbiddenException("You are not authorized to update stakeholder with id: " + stakeholder.getId());
|
this.commonService.unauthorized("You are not authorized to update stakeholder with id: " + stakeholder.getId());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.commonService.hasCreateAuthority(stakeholder.getType())) {
|
if (this.commonService.hasCreateAuthority(stakeholder.getType())) {
|
||||||
|
@ -90,7 +89,7 @@ public class IndicatorService {
|
||||||
this.createChildren(section, indicator);
|
this.createChildren(section, indicator);
|
||||||
this.addIndicator(section, indicator.getId());
|
this.addIndicator(section, indicator.getId());
|
||||||
} else {
|
} else {
|
||||||
throw new ForbiddenException("You are not authorized to create an indicator in stakeholder with id: " + stakeholder.getId());
|
this.commonService.unauthorized("You are not authorized to create an indicator in stakeholder with id: " + stakeholder.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return indicator;
|
return indicator;
|
||||||
|
@ -128,7 +127,7 @@ public class IndicatorService {
|
||||||
}
|
}
|
||||||
this.dao.delete(indicator);
|
this.dao.delete(indicator);
|
||||||
} else {
|
} else {
|
||||||
throw new ForbiddenException("Delete indicator: You are not authorized to delete indicator with id: " + indicator.getId());
|
this.commonService.unauthorized("Delete indicator: You are not authorized to delete indicator with id: " + indicator.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +156,8 @@ public class IndicatorService {
|
||||||
indicator.setVisibility(visibility);
|
indicator.setVisibility(visibility);
|
||||||
return this.save(indicator);
|
return this.save(indicator);
|
||||||
} else {
|
} else {
|
||||||
throw new ForbiddenException("Change section visibility: You are not authorized to update section with id: " + indicator.getId());
|
this.commonService.unauthorized("Change section visibility: You are not authorized to update section with id: " + indicator.getId());
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,7 @@ public class SectionService {
|
||||||
this.createChildren(subCategory, new Section(section), -1);
|
this.createChildren(subCategory, new Section(section), -1);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
throw new ForbiddenException("You are not authorized to create sections in stakeholder with id: " + stakeholder.getId());
|
this.commonService.unauthorized("You are not authorized to create sections in stakeholder with id: " + stakeholder.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ public class SectionService {
|
||||||
this.updateChildren(section);
|
this.updateChildren(section);
|
||||||
section = this.save(section);
|
section = this.save(section);
|
||||||
} else {
|
} else {
|
||||||
throw new ForbiddenException("You are not authorized to update stakeholder with id: " + stakeholder.getId());
|
this.commonService.unauthorized("You are not authorized to update stakeholder with id: " + stakeholder.getId());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.commonService.hasCreateAuthority(stakeholder.getType())) {
|
if (this.commonService.hasCreateAuthority(stakeholder.getType())) {
|
||||||
|
@ -123,7 +123,7 @@ public class SectionService {
|
||||||
this.createChildren(subCategory, section, index);
|
this.createChildren(subCategory, section, index);
|
||||||
this.addSection(subCategory, section.getId(), index);
|
this.addSection(subCategory, section.getId(), index);
|
||||||
} else {
|
} else {
|
||||||
throw new ForbiddenException("You are not authorized to create a section in stakeholder with id: " + stakeholder.getId());
|
this.commonService.unauthorized("You are not authorized to create a section in stakeholder with id: " + stakeholder.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.getFullSection(stakeholder.getType(), stakeholder.getAlias(), section);
|
return this.getFullSection(stakeholder.getType(), stakeholder.getAlias(), section);
|
||||||
|
@ -168,8 +168,9 @@ public class SectionService {
|
||||||
throw new EntityNotFoundException("Some indicators dont exist in the section with id " + section.getId());
|
throw new EntityNotFoundException("Some indicators dont exist in the section with id " + section.getId());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new ForbiddenException("You are not authorized to reorder indicators in section with id: " + section.getId());
|
this.commonService.unauthorized("You are not authorized to reorder indicators in section with id: " + section.getId());
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reorderChildren(Stakeholder defaultStakeholder, Section defaultSection, List<String> defaultIndicators) {
|
public void reorderChildren(Stakeholder defaultStakeholder, Section defaultSection, List<String> defaultIndicators) {
|
||||||
|
@ -194,7 +195,7 @@ public class SectionService {
|
||||||
}
|
}
|
||||||
this.dao.delete(section);
|
this.dao.delete(section);
|
||||||
} else {
|
} else {
|
||||||
throw new ForbiddenException("Delete section: You are not authorized to delete section with id: " + section.getId());
|
this.commonService.unauthorized("Delete section: You are not authorized to delete section with id: " + section.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,7 +239,8 @@ public class SectionService {
|
||||||
section.update(this.save(new Section(section)));
|
section.update(this.save(new Section(section)));
|
||||||
return section;
|
return section;
|
||||||
} else {
|
} else {
|
||||||
throw new ForbiddenException("Change section visibility: You are not authorized to update section with id: " + section.getId());
|
this.commonService.unauthorized("Change section visibility: You are not authorized to update section with id: " + section.getId());
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class StakeholderService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Stakeholder findByPath(String stakeholderId) {
|
public Stakeholder findByPath(String stakeholderId) {
|
||||||
if(stakeholderId.equals("-1")) {
|
if (stakeholderId.equals("-1")) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return dao.findById(stakeholderId).orElseThrow(() -> new EntityNotFoundException("Stakeholder with id: " + stakeholderId + " not found"));
|
return dao.findById(stakeholderId).orElseThrow(() -> new EntityNotFoundException("Stakeholder with id: " + stakeholderId + " not found"));
|
||||||
|
@ -81,29 +81,25 @@ public class StakeholderService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public StakeholderFull getFullStakeholder(Stakeholder stakeholder) {
|
public StakeholderFull getFullStakeholder(Stakeholder stakeholder) {
|
||||||
if (this.commonService.hasVisibilityAuthority(stakeholder.getType(), stakeholder.getAlias(), stakeholder)) {
|
if (!stakeholder.isCopy() && stakeholder.getDefaultId() != null) {
|
||||||
if(!stakeholder.isCopy() && stakeholder.getDefaultId() != null) {
|
Stakeholder defaultStakeholder = this.findByPath(stakeholder.getDefaultId());
|
||||||
Stakeholder defaultStakeholder = this.findByPath(stakeholder.getDefaultId());
|
if (defaultStakeholder != null) {
|
||||||
if(defaultStakeholder != null) {
|
return new StakeholderFull(stakeholder,
|
||||||
return new StakeholderFull(stakeholder,
|
defaultStakeholder.getTopics().stream()
|
||||||
defaultStakeholder.getTopics().stream()
|
.map(topicId -> topicService.getFullTopic(stakeholder.getType(), stakeholder.getAlias(), topicId))
|
||||||
.map(topicId -> topicService.getFullTopic(stakeholder.getType(), stakeholder.getAlias(), topicId))
|
.collect(Collectors.toList()));
|
||||||
.collect(Collectors.toList()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return new StakeholderFull(stakeholder,
|
|
||||||
stakeholder.getTopics().stream()
|
|
||||||
.map(topicId -> topicService.getFullTopic(stakeholder.getType(), stakeholder.getAlias(), topicId))
|
|
||||||
.collect(Collectors.toList()));
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
return new StakeholderFull(stakeholder,
|
||||||
|
stakeholder.getTopics().stream()
|
||||||
|
.map(topicId -> topicService.getFullTopic(stakeholder.getType(), stakeholder.getAlias(), topicId))
|
||||||
|
.collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Stakeholder buildStakeholder(Stakeholder stakeholder, String copyId) {
|
public Stakeholder buildStakeholder(Stakeholder stakeholder, String copyId) {
|
||||||
if(stakeholder.getDefaultId() == null) {
|
if (stakeholder.getDefaultId() == null) {
|
||||||
stakeholder.setCopy(false);
|
stakeholder.setCopy(false);
|
||||||
if(copyId == null) {
|
if (copyId == null) {
|
||||||
stakeholder.setTopics(new ArrayList<>());
|
stakeholder.setTopics(new ArrayList<>());
|
||||||
} else {
|
} else {
|
||||||
Stakeholder copyFrom = this.findByPath(copyId);
|
Stakeholder copyFrom = this.findByPath(copyId);
|
||||||
|
@ -111,9 +107,9 @@ public class StakeholderService {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
stakeholder.setTopics(new ArrayList<>());
|
stakeholder.setTopics(new ArrayList<>());
|
||||||
if(stakeholder.isCopy()) {
|
if (stakeholder.isCopy()) {
|
||||||
Stakeholder defaultStakeholder = this.findByPath(stakeholder.getDefaultId());
|
Stakeholder defaultStakeholder = this.findByPath(stakeholder.getDefaultId());
|
||||||
if(defaultStakeholder != null) {
|
if (defaultStakeholder != null) {
|
||||||
stakeholder.setTopics(defaultStakeholder.getTopics().stream().map(this.topicService::build).collect(Collectors.toList()));
|
stakeholder.setTopics(defaultStakeholder.getTopics().stream().map(this.topicService::build).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,9 +127,9 @@ public class StakeholderService {
|
||||||
});
|
});
|
||||||
stakeholder.setTopics(new ArrayList<>());
|
stakeholder.setTopics(new ArrayList<>());
|
||||||
} else {
|
} else {
|
||||||
if(old.getTopics().isEmpty() && old.getDefaultId() != null) {
|
if (old.getTopics().isEmpty() && old.getDefaultId() != null) {
|
||||||
Stakeholder defaultStakeholder = this.findByPath(stakeholder.getDefaultId());
|
Stakeholder defaultStakeholder = this.findByPath(stakeholder.getDefaultId());
|
||||||
if(defaultStakeholder != null) {
|
if (defaultStakeholder != null) {
|
||||||
stakeholder.setTopics(defaultStakeholder.getTopics().stream().map(this.topicService::build).collect(Collectors.toList()));
|
stakeholder.setTopics(defaultStakeholder.getTopics().stream().map(this.topicService::build).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,8 +154,9 @@ public class StakeholderService {
|
||||||
throw new EntityNotFoundException("Some topics dont exist in the stakeholder with id " + stakeholder.getId());
|
throw new EntityNotFoundException("Some topics dont exist in the stakeholder with id " + stakeholder.getId());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new ForbiddenException("You are not authorized to reorder topics in stakeholder with id: " + stakeholder.getId());
|
this.commonService.unauthorized("You are not authorized to reorder topics in stakeholder with id: " + stakeholder.getId());
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reorderChildren(Stakeholder defaultStakeholder, List<String> defaultTopics) {
|
public void reorderChildren(Stakeholder defaultStakeholder, List<String> defaultTopics) {
|
||||||
|
@ -181,8 +178,9 @@ public class StakeholderService {
|
||||||
this.dao.delete(id);
|
this.dao.delete(id);
|
||||||
return stakeholder.getAlias();
|
return stakeholder.getAlias();
|
||||||
} else {
|
} else {
|
||||||
throw new ForbiddenException("Delete stakeholder: You are not authorized to delete stakeholder with id: " + id);
|
this.commonService.unauthorized("Delete stakeholder: You are not authorized to delete stakeholder with id: " + id);
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StakeholderFull changeVisibility(StakeholderFull stakeholder, Visibility visibility, Boolean propagate) {
|
public StakeholderFull changeVisibility(StakeholderFull stakeholder, Visibility visibility, Boolean propagate) {
|
||||||
|
@ -196,8 +194,9 @@ public class StakeholderService {
|
||||||
stakeholder.update(this.save(new Stakeholder(stakeholder)));
|
stakeholder.update(this.save(new Stakeholder(stakeholder)));
|
||||||
return stakeholder;
|
return stakeholder;
|
||||||
} else {
|
} else {
|
||||||
throw new ForbiddenException("Change stakeholder visibility: You are not authorized to update stakeholder with id: " + stakeholder.getId());
|
this.commonService.unauthorized("Change stakeholder visibility: You are not authorized to update stakeholder with id: " + stakeholder.getId());
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StakeholderFull changeVisibility(Stakeholder stakeholder, Visibility visibility, Boolean propagate) {
|
public StakeholderFull changeVisibility(Stakeholder stakeholder, Visibility visibility, Boolean propagate) {
|
||||||
|
|
|
@ -112,7 +112,7 @@ public class SubCategoryService {
|
||||||
this.updateChildren(subCategory);
|
this.updateChildren(subCategory);
|
||||||
subCategory = this.save(subCategory);
|
subCategory = this.save(subCategory);
|
||||||
} else {
|
} else {
|
||||||
throw new ForbiddenException("You are not authorized to update stakeholder with id: " + stakeholder.getId());
|
this.commonService.unauthorized("You are not authorized to update stakeholder with id: " + stakeholder.getId());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.commonService.hasCreateAuthority(stakeholder.getType())) {
|
if (this.commonService.hasCreateAuthority(stakeholder.getType())) {
|
||||||
|
@ -120,7 +120,7 @@ public class SubCategoryService {
|
||||||
this.createChildren(category, subCategory);
|
this.createChildren(category, subCategory);
|
||||||
this.addSubCategory(category, subCategory.getId());
|
this.addSubCategory(category, subCategory.getId());
|
||||||
} else {
|
} else {
|
||||||
throw new ForbiddenException("You are not authorized to create a subCategory in stakeholder with id: " + stakeholder.getId());
|
this.commonService.unauthorized("You are not authorized to create a subCategory in stakeholder with id: " + stakeholder.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.getFullSubCategory(stakeholder.getType(), stakeholder.getAlias(), subCategory);
|
return this.getFullSubCategory(stakeholder.getType(), stakeholder.getAlias(), subCategory);
|
||||||
|
@ -153,8 +153,9 @@ public class SubCategoryService {
|
||||||
this.moveIndicatorChildren(stakeholder, subCategory, moveIndicator);
|
this.moveIndicatorChildren(stakeholder, subCategory, moveIndicator);
|
||||||
return this.getFullSubCategory(stakeholder.getType(), stakeholder.getAlias(), subCategory);
|
return this.getFullSubCategory(stakeholder.getType(), stakeholder.getAlias(), subCategory);
|
||||||
} else {
|
} else {
|
||||||
throw new ForbiddenException("You are not authorized to move indicators in subCategory with id: " + subCategory.getId());
|
this.commonService.unauthorized("You are not authorized to move indicators in subCategory with id: " + subCategory.getId());
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void moveIndicatorChildren(Stakeholder defaultStakeholder, SubCategory defaultSubCategory, MoveIndicator moveIndicator) {
|
public void moveIndicatorChildren(Stakeholder defaultStakeholder, SubCategory defaultSubCategory, MoveIndicator moveIndicator) {
|
||||||
|
@ -191,8 +192,9 @@ public class SubCategoryService {
|
||||||
throw new EntityNotFoundException("Some sections dont exist in the subCategory with id " + subCategory.getId());
|
throw new EntityNotFoundException("Some sections dont exist in the subCategory with id " + subCategory.getId());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new ForbiddenException("You are not authorized to reorder sections in subCategory with id: " + subCategory.getId());
|
this.commonService.unauthorized("You are not authorized to reorder sections in subCategory with id: " + subCategory.getId());
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SubCategoryFull reorderCharts(Stakeholder stakeholder, SubCategory subCategory, List<String> charts) {
|
public SubCategoryFull reorderCharts(Stakeholder stakeholder, SubCategory subCategory, List<String> charts) {
|
||||||
|
@ -206,8 +208,9 @@ public class SubCategoryService {
|
||||||
throw new EntityNotFoundException("Some sections dont exist in the subCategory with id " + subCategory.getId());
|
throw new EntityNotFoundException("Some sections dont exist in the subCategory with id " + subCategory.getId());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new ForbiddenException("You are not authorized to reorder sections in subCategory with id: " + subCategory.getId());
|
this.commonService.unauthorized("You are not authorized to reorder sections in subCategory with id: " + subCategory.getId());
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reorderChildrenNumbers(Stakeholder defaultStakeholder, SubCategory defaultSubCategory, List<String> defaultSections) {
|
public void reorderChildrenNumbers(Stakeholder defaultStakeholder, SubCategory defaultSubCategory, List<String> defaultSections) {
|
||||||
|
@ -245,7 +248,7 @@ public class SubCategoryService {
|
||||||
}
|
}
|
||||||
this.dao.delete(subCategory);
|
this.dao.delete(subCategory);
|
||||||
} else {
|
} else {
|
||||||
throw new ForbiddenException("Delete subCategory: You are not authorized to delete subCategory with id: " + subCategory.getId());
|
this.commonService.unauthorized("Delete subCategory: You are not authorized to delete subCategory with id: " + subCategory.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,8 +285,9 @@ public class SubCategoryService {
|
||||||
subCategory.update(this.save(new SubCategory(subCategory)));
|
subCategory.update(this.save(new SubCategory(subCategory)));
|
||||||
return subCategory;
|
return subCategory;
|
||||||
} else {
|
} else {
|
||||||
throw new ForbiddenException("Change subCategory visibility: You are not authorized to update subCategory with id: " + subCategory.getId());
|
this.commonService.unauthorized("Change subCategory visibility: You are not authorized to update subCategory with id: " + subCategory.getId());
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SubCategoryFull changeVisibility(String type, String alias, SubCategory subCategory, Visibility visibility, Boolean propagate) {
|
public SubCategoryFull changeVisibility(String type, String alias, SubCategory subCategory, Visibility visibility, Boolean propagate) {
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class TopicService {
|
||||||
this.updateChildren(topic);
|
this.updateChildren(topic);
|
||||||
topic = this.save(topic);
|
topic = this.save(topic);
|
||||||
} else {
|
} else {
|
||||||
throw new ForbiddenException("You are not authorized to update stakeholder with id: " + stakeholder.getId());
|
this.commonService.unauthorized("You are not authorized to update stakeholder with id: " + stakeholder.getId());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(this.commonService.hasCreateAuthority(stakeholder.getType())) {
|
if(this.commonService.hasCreateAuthority(stakeholder.getType())) {
|
||||||
|
@ -102,7 +102,7 @@ public class TopicService {
|
||||||
this.createChildren(stakeholder, topic);
|
this.createChildren(stakeholder, topic);
|
||||||
this.addTopic(stakeholder, topic.getId());
|
this.addTopic(stakeholder, topic.getId());
|
||||||
} else {
|
} else {
|
||||||
throw new ForbiddenException("You are not authorized to create a topic in stakeholder with id: " + stakeholder.getId());
|
this.commonService.unauthorized("You are not authorized to create a topic in stakeholder with id: " + stakeholder.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.getFullTopic(stakeholder.getType(), stakeholder.getAlias(), topic);
|
return this.getFullTopic(stakeholder.getType(), stakeholder.getAlias(), topic);
|
||||||
|
@ -132,8 +132,9 @@ public class TopicService {
|
||||||
throw new EntityNotFoundException("Some categories dont exist in the topic with id " + topic.getId());
|
throw new EntityNotFoundException("Some categories dont exist in the topic with id " + topic.getId());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new ForbiddenException("You are not authorized to reorder categories in topic with id: " + topic.getId());
|
this.commonService.unauthorized("You are not authorized to reorder categories in topic with id: " + topic.getId());
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reorderChildren(Stakeholder defaultStakeholder, Topic defaultTopic, List<String> defaultCategories) {
|
public void reorderChildren(Stakeholder defaultStakeholder, Topic defaultTopic, List<String> defaultCategories) {
|
||||||
|
@ -158,7 +159,7 @@ public class TopicService {
|
||||||
}
|
}
|
||||||
this.dao.delete(topic);
|
this.dao.delete(topic);
|
||||||
} else {
|
} else {
|
||||||
throw new ForbiddenException("Delete topic: You are not authorized to delete topic with id: " + topic.getId());
|
this.commonService.unauthorized("Delete topic: You are not authorized to delete topic with id: " + topic.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,8 +193,9 @@ public class TopicService {
|
||||||
topic.update(this.save(new Topic(topic)));
|
topic.update(this.save(new Topic(topic)));
|
||||||
return topic;
|
return topic;
|
||||||
} else {
|
} else {
|
||||||
throw new ForbiddenException("Change topic visibility: You are not authorized to update topic with id: " + topic.getId());
|
this.commonService.unauthorized("Change topic visibility: You are not authorized to update topic with id: " + topic.getId());
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TopicFull changeVisibility(String type, String alias, Topic topic, Visibility visibility, Boolean propagate) {
|
public TopicFull changeVisibility(String type, String alias, Topic topic, Visibility visibility, Boolean propagate) {
|
||||||
|
|
Loading…
Reference in New Issue