Search in sources :

Example 1 with BadFormatException

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));
}
Also used : BadFormatException(io.lumeer.core.exception.BadFormatException) LinkType(io.lumeer.api.model.LinkType)

Example 2 with BadFormatException

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;
}
Also used : BadFormatException(io.lumeer.core.exception.BadFormatException) CreateLinkInstance(io.lumeer.engine.api.event.CreateLinkInstance) LinkInstance(io.lumeer.api.model.LinkInstance) UpdateLinkInstance(io.lumeer.engine.api.event.UpdateLinkInstance) ImportLinkTypeContent(io.lumeer.engine.api.event.ImportLinkTypeContent)

Example 3 with BadFormatException

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));
}
Also used : BadFormatException(io.lumeer.core.exception.BadFormatException) LinkType(io.lumeer.api.model.LinkType)

Aggregations

BadFormatException (io.lumeer.core.exception.BadFormatException)3 LinkType (io.lumeer.api.model.LinkType)2 LinkInstance (io.lumeer.api.model.LinkInstance)1 CreateLinkInstance (io.lumeer.engine.api.event.CreateLinkInstance)1 ImportLinkTypeContent (io.lumeer.engine.api.event.ImportLinkTypeContent)1 UpdateLinkInstance (io.lumeer.engine.api.event.UpdateLinkInstance)1