use of io.lumeer.core.exception.BadFormatException in project engine by Lumeer.
the class LinkTypeFacade method updateLinkType.
public LinkType updateLinkType(String id, LinkType linkType, final boolean skipFceLimits) {
LinkType storedLinkType = checkLinkTypePermission(id, RoleType.Read);
if (!storedLinkType.getCollectionIds().containsAll(linkType.getCollectionIds())) {
throw new BadFormatException("Can not change LinkType collectionIds property");
}
if (!skipFceLimits) {
permissionsChecker.checkFunctionsLimit(linkType);
permissionsChecker.checkRulesLimit(linkType);
}
permissionsChecker.checkRulesPermissions(linkType.getRules());
permissionsChecker.checkAttributesFunctionAccess(linkType.getAttributes());
LinkType updatingLinkType = new LinkType(storedLinkType);
updatingLinkType.patch(linkType, permissionsChecker.getActualRoles(storedLinkType));
keepUnmodifiableFields(updatingLinkType, storedLinkType);
mapLinkTypeUpdateValues(linkType);
return mapLinkTypeData(linkTypeDao.updateLinkType(id, updatingLinkType, storedLinkType));
}
use of io.lumeer.core.exception.BadFormatException in project engine by Lumeer.
the class LinkInstanceFacade method createLinkInstances.
public List<LinkInstance> createLinkInstances(final List<LinkInstance> linkInstances, final boolean sendIndividualNotifications) {
if (linkInstances.size() > 0) {
final String linkTypeId = linkInstances.get(0).getLinkTypeId();
var linkType = checkCreateLinks(linkTypeId);
checkLinkDocumentsExists(linkInstances);
if (linkInstances.stream().anyMatch(linkInstance -> !linkInstance.getLinkTypeId().equals(linkTypeId))) {
throw new BadFormatException("Cannot create link instances of multiple link types at once.");
}
final List<LinkInstance> storedLinkInstances = createLinkInstances(linkType, linkInstances, sendIndividualNotifications);
if (importLinkTypeContentEvent != null) {
importLinkTypeContentEvent.fire(new ImportLinkTypeContent(linkType));
}
return storedLinkInstances;
}
return linkInstances;
}
use of io.lumeer.core.exception.BadFormatException in project engine by Lumeer.
the class LinkTypeFacade method updateLinkTypeRules.
public LinkType updateLinkTypeRules(String id, LinkType linkType, final boolean skipFceLimits) {
LinkType storedLinkType = checkLinkTypePermission(id, RoleType.TechConfig);
if (!storedLinkType.getCollectionIds().containsAll(linkType.getCollectionIds())) {
throw new BadFormatException("Can not change LinkType collectionIds property");
}
if (!skipFceLimits) {
permissionsChecker.checkFunctionsLimit(linkType);
permissionsChecker.checkRulesLimit(linkType);
}
permissionsChecker.checkRulesPermissions(linkType.getRules());
LinkType updatingLinkType = new LinkType(storedLinkType);
updatingLinkType.setRules(linkType.getRules());
keepUnmodifiableFields(updatingLinkType, storedLinkType);
return mapLinkTypeData(linkTypeDao.updateLinkType(id, updatingLinkType, storedLinkType));
}
Aggregations