diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdclasses/CF.java b/src/main/java/com/github/_1c_syntax/bsl/mdclasses/CF.java index dd494960c..af8fc0116 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdclasses/CF.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdclasses/CF.java @@ -38,7 +38,7 @@ import java.util.Map; import java.util.Optional; -public interface CF extends MDClass, ConfigurationTree { +public interface CF extends MDClass, ConfigurationTree, CFAccess { /** * Язык приложения по умолчанию diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdclasses/CFAccess.java b/src/main/java/com/github/_1c_syntax/bsl/mdclasses/CFAccess.java new file mode 100644 index 000000000..c71fe9b51 --- /dev/null +++ b/src/main/java/com/github/_1c_syntax/bsl/mdclasses/CFAccess.java @@ -0,0 +1,102 @@ +/* + * This file is a part of MDClasses. + * + * Copyright (c) 2019 - 2024 + * Tymko Oleg , Maximov Valery and contributors + * + * SPDX-License-Identifier: LGPL-3.0-or-later + * + * MDClasses is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * MDClasses is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with MDClasses. + */ +package com.github._1c_syntax.bsl.mdclasses; + + +import com.github._1c_syntax.bsl.mdclasses.helpers.Rights; +import com.github._1c_syntax.bsl.mdo.AccessRightsOwner; +import com.github._1c_syntax.bsl.mdo.MD; +import com.github._1c_syntax.bsl.mdo.Role; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; +import com.github._1c_syntax.bsl.types.MdoReference; + +import java.util.List; + +/** + * Расширение - права доступа + */ +public interface CFAccess extends AccessRightsOwner { + + /** + * Проверяет наличие указанного разрешения хотя бы у одной роли для конфигурации/расширения + * + * @param roleRight Право доступа + * @return Наличие права доступа + */ + default boolean rightAccess(RoleRight roleRight) { + return Rights.rightAccess((CF) this, roleRight); + } + + /** + * Проверяет наличие указанного разрешения хотя бы у одной роли для MD + * + * @param roleRight Право доступа + * @param md Любой объект md + * @return Наличие права доступа + */ + default boolean rightAccess(RoleRight roleRight, MD md) { + return Rights.rightAccess((CF) this, roleRight, md); + } + + /** + * Проверяет наличие указанного разрешения хотя бы у одной роли для ссылки + * + * @param roleRight Право доступа + * @param mdoReference Ссылка mdo reference + * @return Наличие права доступа + */ + default boolean rightAccess(RoleRight roleRight, MdoReference mdoReference) { + return Rights.rightAccess((CF) this, roleRight, mdoReference); + } + + /** + * Возвращает список ролей, имеющих указанное разрешения для конфигурации/расширения + * + * @param roleRight Право доступа + * @return Список ролей с правом + */ + default List rolesAccess(RoleRight roleRight) { + return Rights.rolesAccess((CF) this, roleRight); + } + + /** + * Возвращает список ролей, имеющих указанное разрешения для md + * + * @param roleRight Право доступа + * @param md Любой объект md + * @return Список ролей с правом + */ + default List rolesAccess(RoleRight roleRight, MD md) { + return Rights.rolesAccess((CF) this, roleRight, md); + } + + /** + * Возвращает список ролей, имеющих указанное разрешения для ссылки + * + * @param roleRight Право доступа + * @param mdoReference Ссылка mdo reference + * @return Список ролей с правом + */ + default List rolesAccess(RoleRight roleRight, MdoReference mdoReference) { + return Rights.rolesAccess((CF) this, roleRight, mdoReference); + } +} diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdclasses/Configuration.java b/src/main/java/com/github/_1c_syntax/bsl/mdclasses/Configuration.java index ffe7f10fe..6868fcac8 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdclasses/Configuration.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdclasses/Configuration.java @@ -74,6 +74,7 @@ import com.github._1c_syntax.bsl.mdo.support.DataLockControlMode; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.mdo.support.ScriptVariant; import com.github._1c_syntax.bsl.mdo.support.UseMode; import com.github._1c_syntax.bsl.mdo.support.UsePurposes; @@ -112,6 +113,8 @@ public class Configuration implements CF { */ public static final Configuration EMPTY = createEmptyConfiguration(); + private static final List POSSIBLE_RIGHTS = computePossibleRighs(); + /* * CF */ @@ -342,6 +345,13 @@ public Map getModulesByURI() { return modulesByURI.getOrCompute(); } + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return POSSIBLE_RIGHTS; + } + private List computePlainChildren() { return LazyLoader.computePlainChildren(this); } @@ -371,4 +381,35 @@ private static Configuration createEmptyConfiguration() { .uuid(emptyString) .build(); } + + private static List computePossibleRighs() { + return List.of( + RoleRight.ADMINISTRATION, + RoleRight.DATA_ADMINISTRATION, + RoleRight.UPDATE_DATA_BASE_CONFIGURATION, + RoleRight.EXCLUSIVE_MODE, + RoleRight.ACTIVE_USERS, + RoleRight.EVENT_LOG, + RoleRight.THIN_CLIENT, + RoleRight.WEB_CLIENT, + RoleRight.MOBILE_CLIENT, + RoleRight.THICK_CLIENT, + RoleRight.EXTERNAL_CONNECTION, + RoleRight.AUTOMATION, + RoleRight.TECHNICAL_SPECIALIST_MODE, + RoleRight.COLLABORATION_SYSTEM_INFO_BASE_REGISTRATION, + RoleRight.MAIN_WINDOW_MODE_EMBEDDED_WORKPLACE, + RoleRight.MAIN_WINDOW_MODE_KIOSK, + RoleRight.MAIN_WINDOW_MODE_NORMAL, + RoleRight.MAIN_WINDOW_MODE_FULLSCREEN_WORKPLACE, + RoleRight.MAIN_WINDOW_MODE_WORKPLACE, + RoleRight.ANALYTICS_SYSTEM_CLIENT, + RoleRight.EXCLUSIVE_MODE_TERMINATION_AT_SESSION_START, + RoleRight.SAVE_USER_DATA, + RoleRight.CONFIGURATION_EXTENSIONS_ADMINISTRATION, + RoleRight.INTERACTIVE_OPEN_EXT_DATA_PROCESSORS, + RoleRight.INTERACTIVE_OPEN_EXT_REPORTS, + RoleRight.OUTPUT + ); + } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdclasses/ConfigurationExtension.java b/src/main/java/com/github/_1c_syntax/bsl/mdclasses/ConfigurationExtension.java index 77faffb5f..05aca5bd7 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdclasses/ConfigurationExtension.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdclasses/ConfigurationExtension.java @@ -74,6 +74,7 @@ import com.github._1c_syntax.bsl.mdo.support.ConfigurationExtensionPurpose; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.mdo.support.ScriptVariant; import com.github._1c_syntax.bsl.mdo.support.UsePurposes; import com.github._1c_syntax.bsl.mdo.utils.LazyLoader; @@ -289,6 +290,13 @@ public Map getModulesByURI() { return modulesByURI.getOrCompute(); } + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return Configuration.possibleRights(); + } + private List computePlainChildren() { return LazyLoader.computePlainChildren(this); } @@ -301,7 +309,6 @@ private Map computeModulesByObject() { return LazyLoader.computeModulesByObject(this); } - private List computeAllModules() { return LazyLoader.computeAllModules(this); } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdclasses/helpers/Rights.java b/src/main/java/com/github/_1c_syntax/bsl/mdclasses/helpers/Rights.java new file mode 100644 index 000000000..fb6b35540 --- /dev/null +++ b/src/main/java/com/github/_1c_syntax/bsl/mdclasses/helpers/Rights.java @@ -0,0 +1,221 @@ +/* + * This file is a part of MDClasses. + * + * Copyright (c) 2019 - 2024 + * Tymko Oleg , Maximov Valery and contributors + * + * SPDX-License-Identifier: LGPL-3.0-or-later + * + * MDClasses is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * MDClasses is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with MDClasses. + */ +package com.github._1c_syntax.bsl.mdclasses.helpers; + +import com.github._1c_syntax.bsl.mdclasses.CF; +import com.github._1c_syntax.bsl.mdclasses.Configuration; +import com.github._1c_syntax.bsl.mdo.AccessRightsOwner; +import com.github._1c_syntax.bsl.mdo.MD; +import com.github._1c_syntax.bsl.mdo.Role; +import com.github._1c_syntax.bsl.mdo.storage.RoleData; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; +import com.github._1c_syntax.bsl.types.MdoReference; +import io.github.classgraph.ClassGraph; +import io.github.classgraph.ClassInfo; +import lombok.experimental.UtilityClass; + +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Помощник для работы с ролями и правами + */ +@UtilityClass +public class Rights { + + private static final Map> POSSIBLE_RIGHTS = computePossibleRights(); + + /** + * Проверяет наличие указанного разрешения хотя бы у одной роли для конфигурации/расширения + * + * @param cf Конфигурация/расширение + * @param roleRight Право доступа + * @return Наличие права доступа + */ + public boolean rightAccess(CF cf, RoleRight roleRight) { + return rightAccess(cf, cf.getMdoReference(), roleRight); + } + + /** + * Проверяет наличие указанного разрешения хотя бы у одной роли для MD + * + * @param cf Конфигурация/расширение + * @param roleRight Право доступа + * @param md Любой объект md + * @return Наличие права доступа + */ + public boolean rightAccess(CF cf, RoleRight roleRight, MD md) { + return rightAccess(cf, md.getMdoReference(), roleRight); + } + + /** + * Проверяет наличие указанного разрешения хотя бы у одной роли для ссылки + * + * @param cf Конфигурация/расширение + * @param roleRight Право доступа + * @param mdoReference Ссылка mdo reference + * @return Наличие права доступа + */ + public boolean rightAccess(CF cf, RoleRight roleRight, MdoReference mdoReference) { + return rightAccess(cf, mdoReference, roleRight); + } + + /** + * Возвращает список ролей, имеющих указанное разрешения для конфигурации/расширения + * + * @param cf Конфигурация/расширение + * @param roleRight Право доступа + * @return Список ролей с правом + */ + public List rolesAccess(CF cf, RoleRight roleRight) { + return rolesAccess(cf, cf.getMdoReference(), roleRight); + } + + /** + * Возвращает список ролей, имеющих указанное разрешения для md + * + * @param cf Конфигурация/расширение + * @param roleRight Право доступа + * @param md Любой объект md + * @return Список ролей с правом + */ + public List rolesAccess(CF cf, RoleRight roleRight, MD md) { + return rolesAccess(cf, md.getMdoReference(), roleRight); + } + + /** + * Возвращает список ролей, имеющих указанное разрешения для ссылки + * + * @param cf Конфигурация/расширение + * @param roleRight Право доступа + * @param mdoReference Ссылка mdo reference + * @return Список ролей с правом + */ + public List rolesAccess(CF cf, RoleRight roleRight, MdoReference mdoReference) { + return rolesAccess(cf, mdoReference, roleRight); + } + + /** + * Возможные ограничения доступа (права). + * Лучше использовать статик метод possibleRights класса. + */ + public List getPossibleRights(Class clazz) { + return POSSIBLE_RIGHTS.getOrDefault(clazz.getName(), Collections.emptyList()); + } + + /** + * Проверяет переданное право на допустимость для применения к объекту + */ + public boolean isValidRight(Class clazz, RoleRight roleRight) { + return getPossibleRights(clazz).contains(roleRight); + } + + private static boolean rightAccess(CF cf, MdoReference mdoReference, RoleRight roleRight) { + if (cf.equals(Configuration.EMPTY)) { + return false; + } + return cf.getRoles().stream() + .map(Role::getData) + .filter(roleData -> !roleData.equals(RoleData.EMPTY)) + .map(RoleData::getObjectRights) + .flatMap(Collection::stream) + .filter(objectRight -> objectRight.getName().equals(mdoReference.getMdoRef())) + .map(RoleData.ObjectRight::getRights) + .flatMap(Collection::stream) + .anyMatch(right -> roleRight == right.getName() && right.isValue()); + } + + private static List rolesAccess(CF cf, MdoReference mdoReference, RoleRight roleRight) { + if (cf.equals(Configuration.EMPTY)) { + return Collections.emptyList(); + } + + var mdoRef = mdoReference.getMdoRef(); + List roles = new ArrayList<>(); + cf.getRoles().forEach((Role role) -> { + var hasAcccess = role.getData().getObjectRights().stream() + .filter(objectRight -> objectRight.getName().equals(mdoRef)) + .map(RoleData.ObjectRight::getRights) + .flatMap(Collection::stream) + .anyMatch(right -> roleRight == right.getName() && right.isValue()); + + if (hasAcccess) { + roles.add(role); + } + }); + + return Collections.unmodifiableList(roles); + } + + private static Map> computePossibleRights() { + try (var scanResult = new ClassGraph() + .enableClassInfo() + .acceptPackages("com.github._1c_syntax.bsl") + .scan()) { + + var classes = scanResult.getClassesImplementing(AccessRightsOwner.class); + Map> rights = new HashMap<>(); + + classes.stream() + .filter(ci -> !ci.isInterface()) + .map(ClassInfo::getName) + .forEach(name -> rights.put(name, getPossibleRights(name))); + return Collections.unmodifiableMap(rights); + } + } + + @SuppressWarnings("unchecked") + private List getPossibleRights(String className) { + Class clazz; + try { + clazz = (Class) Class.forName(className); + } catch (ClassNotFoundException e) { + return Collections.emptyList(); + } + + var value = Arrays.stream(clazz.getDeclaredMethods()) + .filter(method -> "possibleRights".equals(method.getName())) + .findFirst(); + + if (value.isPresent()) { + try { + var result = value.get().invoke(clazz); + if (result instanceof List rights) { + return rights.stream() + .filter(RoleRight.class::isInstance) + .map(RoleRight.class::cast) + .toList(); + } + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + // no-op + } + } + + return Collections.emptyList(); + } +} diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdclasses/helpers/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/mdclasses/helpers/package-info.java new file mode 100644 index 000000000..d5ba76978 --- /dev/null +++ b/src/main/java/com/github/_1c_syntax/bsl/mdclasses/helpers/package-info.java @@ -0,0 +1,31 @@ +/* + * This file is a part of MDClasses. + * + * Copyright (c) 2019 - 2024 + * Tymko Oleg , Maximov Valery and contributors + * + * SPDX-License-Identifier: LGPL-3.0-or-later + * + * MDClasses is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * MDClasses is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with MDClasses. + */ +/** + * Набор различных помощников + */ +@ParametersAreNonnullByDefault +@ReturnValuesAreNonnullByDefault +package com.github._1c_syntax.bsl.mdclasses.helpers; + +import edu.umd.cs.findbugs.annotations.ReturnValuesAreNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/AccessRightsOwner.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/AccessRightsOwner.java new file mode 100644 index 000000000..37aaa51ff --- /dev/null +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/AccessRightsOwner.java @@ -0,0 +1,48 @@ +/* + * This file is a part of MDClasses. + * + * Copyright (c) 2019 - 2024 + * Tymko Oleg , Maximov Valery and contributors + * + * SPDX-License-Identifier: LGPL-3.0-or-later + * + * MDClasses is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * MDClasses is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with MDClasses. + */ +package com.github._1c_syntax.bsl.mdo; + +import com.github._1c_syntax.bsl.mdclasses.helpers.Rights; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; + +import java.util.List; + +/** + * Расширение - объект имеет ограничения доступа пользователе + */ +public interface AccessRightsOwner { + + /** + * Возможные ограничения доступа (права). + * Лучше использовать статик метод possibleRights класса. + */ + default List getPossibleRights() { + return Rights.getPossibleRights(getClass()); + } + + /** + * Проверяет переданное право на допустимость для применения к объекту + */ + default boolean isValidRight(RoleRight roleRight) { + return Rights.isValidRight(getClass(), roleRight); + } +} diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/AccountingRegister.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/AccountingRegister.java index 6a7038578..717481903 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/AccountingRegister.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/AccountingRegister.java @@ -28,6 +28,7 @@ import com.github._1c_syntax.bsl.mdo.children.Resource; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.mdo.utils.LazyLoader; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; @@ -46,7 +47,7 @@ @Builder @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) -public class AccountingRegister implements Register { +public class AccountingRegister implements Register, AccessRightsOwner { /* * Register @@ -115,6 +116,13 @@ public List getAllModules() { return allModules.getOrCompute(); } + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return AccumulationRegister.possibleRights(); + } + private List computeChildren() { return LazyLoader.computeChildren(this); } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/AccumulationRegister.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/AccumulationRegister.java index a2595c7d4..fbaaba2e3 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/AccumulationRegister.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/AccumulationRegister.java @@ -28,6 +28,7 @@ import com.github._1c_syntax.bsl.mdo.children.Resource; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.mdo.utils.LazyLoader; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; @@ -46,7 +47,9 @@ @Builder @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) -public class AccumulationRegister implements Register { +public class AccumulationRegister implements Register, AccessRightsOwner { + + private static final List POSSIBLE_RIGHTS = computePossibleRighs(); /* * Register @@ -115,6 +118,13 @@ public List getAllModules() { return allModules.getOrCompute(); } + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return POSSIBLE_RIGHTS; + } + private List computeChildren() { return LazyLoader.computeChildren(this); } @@ -126,6 +136,16 @@ private List computeAllAttributes() { private List computeAllModules() { return LazyLoader.computeAllModules(this); } + + private static List computePossibleRighs() { + return List.of( + RoleRight.READ, + RoleRight.UPDATE, + RoleRight.VIEW, + RoleRight.EDIT, + RoleRight.TOTALS_CONTROL + ); + } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/BusinessProcess.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/BusinessProcess.java index 51ed25d31..ecdc2726f 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/BusinessProcess.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/BusinessProcess.java @@ -26,6 +26,7 @@ import com.github._1c_syntax.bsl.mdo.children.ObjectTemplate; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.mdo.utils.LazyLoader; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; @@ -44,7 +45,10 @@ @Builder @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) -public class BusinessProcess implements ReferenceObject { +public class BusinessProcess implements ReferenceObject, AccessRightsOwner { + + private static final List POSSIBLE_RIGHTS = computePossibleRighs(); + /* * ReferenceObject */ @@ -130,6 +134,13 @@ public List getAllModules() { return allModules.getOrCompute(); } + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return POSSIBLE_RIGHTS; + } + private List computeChildren() { return LazyLoader.computeChildren(this); } @@ -149,4 +160,33 @@ private List computePlainStorageFields() { private List computeAllModules() { return LazyLoader.computeAllModules(this); } + + private static List computePossibleRighs() { + return List.of( + RoleRight.INSERT, + RoleRight.READ, + RoleRight.UPDATE, + RoleRight.DELETE, + RoleRight.VIEW, + RoleRight.EDIT, + RoleRight.INPUT_BY_STRING, + RoleRight.INTERACTIVE_DELETE, + RoleRight.INTERACTIVE_INSERT, + RoleRight.INTERACTIVE_SET_DELETION_MARK, + RoleRight.INTERACTIVE_CLEAR_DELETION_MARK, + RoleRight.INTERACTIVE_DELETE_MARKED, + RoleRight.START, + RoleRight.INTERACTIVE_START, + RoleRight.INTERACTIVE_ACTIVATE, + RoleRight.READ_DATA_HISTORY, + RoleRight.VIEW_DATA_HISTORY, + RoleRight.READ_DATA_HISTORY_OF_MISSING_DATA, + RoleRight.UPDATE_DATA_HISTORY, + RoleRight.UPDATE_DATA_HISTORY_OF_MISSING_DATA, + RoleRight.UPDATE_DATA_HISTORY_SETTINGS, + RoleRight.UPDATE_DATA_HISTORY_VERSION_COMMENT, + RoleRight.EDIT_DATA_HISTORY_VERSION_COMMENT, + RoleRight.SWITCH_TO_DATA_HISTORY_VERSION + ); + } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/CalculationRegister.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/CalculationRegister.java index 6fe84e2ca..af47edd60 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/CalculationRegister.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/CalculationRegister.java @@ -29,6 +29,7 @@ import com.github._1c_syntax.bsl.mdo.children.Resource; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.mdo.utils.LazyLoader; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; @@ -47,7 +48,9 @@ @Builder @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) -public class CalculationRegister implements Register { +public class CalculationRegister implements Register, AccessRightsOwner { + + private static final List POSSIBLE_RIGHTS = computePossibleRighs(); /* * Register @@ -119,6 +122,13 @@ public List getAllModules() { return allModules.getOrCompute(); } + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return POSSIBLE_RIGHTS; + } + private List computeChildren() { return LazyLoader.computeChildren(this); } @@ -131,4 +141,12 @@ private List computeAllModules() { return LazyLoader.computeAllModules(this); } + private static List computePossibleRighs() { + return List.of( + RoleRight.READ, + RoleRight.UPDATE, + RoleRight.VIEW, + RoleRight.EDIT + ); + } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/Catalog.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/Catalog.java index 382df3336..8cfe462af 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/Catalog.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/Catalog.java @@ -26,6 +26,7 @@ import com.github._1c_syntax.bsl.mdo.children.ObjectTemplate; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.mdo.utils.LazyLoader; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; @@ -44,7 +45,9 @@ @Builder @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) -public class Catalog implements ReferenceObject { +public class Catalog implements ReferenceObject, AccessRightsOwner { + + private static final List POSSIBLE_RIGHTS = computePossibleRighs(); /* * ReferenceObject @@ -126,6 +129,13 @@ public List getAllModules() { return allModules.getOrCompute(); } + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return POSSIBLE_RIGHTS; + } + private List computeChildren() { return LazyLoader.computeChildren(this); } @@ -146,4 +156,33 @@ private List computeAllModules() { return LazyLoader.computeAllModules(this); } + private static List computePossibleRighs() { + return List.of( + RoleRight.INSERT, + RoleRight.READ, + RoleRight.UPDATE, + RoleRight.DELETE, + RoleRight.VIEW, + RoleRight.EDIT, + RoleRight.INPUT_BY_STRING, + RoleRight.INTERACTIVE_DELETE, + RoleRight.INTERACTIVE_INSERT, + RoleRight.INTERACTIVE_SET_DELETION_MARK, + RoleRight.INTERACTIVE_CLEAR_DELETION_MARK, + RoleRight.INTERACTIVE_DELETE_MARKED, + RoleRight.INTERACTIVE_DELETE_PREDEFINED_DATA, + RoleRight.INTERACTIVE_SET_DELETION_MARK_PREDEFINED_DATA, + RoleRight.INTERACTIVE_CLEAR_DELETION_MARK_PREDEFINED_DATA, + RoleRight.INTERACTIVE_DELETE_MARKED_PREDEFINED_DATA, + RoleRight.READ_DATA_HISTORY, + RoleRight.VIEW_DATA_HISTORY, + RoleRight.READ_DATA_HISTORY_OF_MISSING_DATA, + RoleRight.UPDATE_DATA_HISTORY, + RoleRight.UPDATE_DATA_HISTORY_OF_MISSING_DATA, + RoleRight.UPDATE_DATA_HISTORY_SETTINGS, + RoleRight.UPDATE_DATA_HISTORY_VERSION_COMMENT, + RoleRight.EDIT_DATA_HISTORY_VERSION_COMMENT, + RoleRight.SWITCH_TO_DATA_HISTORY_VERSION + ); + } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/ChartOfAccounts.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/ChartOfAccounts.java index eb979e24d..08b3ce92f 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/ChartOfAccounts.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/ChartOfAccounts.java @@ -28,6 +28,7 @@ import com.github._1c_syntax.bsl.mdo.children.ObjectTemplate; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.mdo.utils.LazyLoader; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; @@ -46,7 +47,7 @@ @Builder @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) -public class ChartOfAccounts implements ReferenceObject { +public class ChartOfAccounts implements ReferenceObject, AccessRightsOwner { /* * ReferenceObject @@ -145,6 +146,13 @@ public List getAllModules() { return allModules.getOrCompute(); } + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return Catalog.possibleRights(); + } + private List computeChildren() { return LazyLoader.computeChildren(this); } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/ChartOfCalculationTypes.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/ChartOfCalculationTypes.java index fee2b4fd9..eead14f5d 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/ChartOfCalculationTypes.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/ChartOfCalculationTypes.java @@ -26,6 +26,7 @@ import com.github._1c_syntax.bsl.mdo.children.ObjectTemplate; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.mdo.utils.LazyLoader; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; @@ -44,7 +45,7 @@ @Builder @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) -public class ChartOfCalculationTypes implements ReferenceObject { +public class ChartOfCalculationTypes implements ReferenceObject, AccessRightsOwner { /* * ReferenceObject @@ -125,6 +126,13 @@ public List getAllModules() { return allModules.getOrCompute(); } + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return Catalog.possibleRights(); + } + private List computeChildren() { return LazyLoader.computeChildren(this); } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/ChartOfCharacteristicTypes.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/ChartOfCharacteristicTypes.java index 1b99878e3..b1991b953 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/ChartOfCharacteristicTypes.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/ChartOfCharacteristicTypes.java @@ -26,6 +26,7 @@ import com.github._1c_syntax.bsl.mdo.children.ObjectTemplate; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.mdo.utils.LazyLoader; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; @@ -44,7 +45,7 @@ @Builder @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) -public class ChartOfCharacteristicTypes implements ReferenceObject { +public class ChartOfCharacteristicTypes implements ReferenceObject, AccessRightsOwner { /* * ReferenceObject @@ -126,6 +127,13 @@ public List getAllModules() { return allModules.getOrCompute(); } + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return Catalog.possibleRights(); + } + private List computeChildren() { return LazyLoader.computeChildren(this); } @@ -145,5 +153,4 @@ private List computePlainStorageFields() { private List computeAllModules() { return LazyLoader.computeAllModules(this); } - } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/Command.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/Command.java index ae232eac8..4d5432488 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/Command.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/Command.java @@ -20,10 +20,10 @@ * License along with MDClasses. */ package com.github._1c_syntax.bsl.mdo; - -/** - * Интерфейс объектов команд объектов и общих команд - */ -public interface Command extends ModuleOwner { - -} + +/** + * Интерфейс объектов команд объектов и общих команд + */ +public interface Command extends ModuleOwner, AccessRightsOwner { + +} diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/CommonAttribute.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/CommonAttribute.java index faf1e1303..e70882823 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/CommonAttribute.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/CommonAttribute.java @@ -21,10 +21,12 @@ */ package com.github._1c_syntax.bsl.mdo; +import com.github._1c_syntax.bsl.mdo.children.ObjectAttribute; import com.github._1c_syntax.bsl.mdo.support.DataSeparation; import com.github._1c_syntax.bsl.mdo.support.IndexingType; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.mdo.support.UseMode; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; @@ -41,7 +43,7 @@ @Builder @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) -public class CommonAttribute implements MDObject { +public class CommonAttribute implements MDObject, AccessRightsOwner { /* * ReferenceObject @@ -159,6 +161,13 @@ public UseMode useMode(MdoReference mdoReference) { } } + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return ObjectAttribute.possibleRights(); + } + @Value @Builder public static class UseContent { diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/CommonCommand.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/CommonCommand.java index bbd6d2aae..c51a89047 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/CommonCommand.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/CommonCommand.java @@ -21,8 +21,10 @@ */ package com.github._1c_syntax.bsl.mdo; +import com.github._1c_syntax.bsl.mdo.children.ObjectCommand; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; import lombok.Builder; @@ -61,4 +63,10 @@ public class CommonCommand implements MDObject, Command { @Default List modules = Collections.emptyList(); + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return ObjectCommand.possibleRights(); + } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/CommonForm.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/CommonForm.java index bad85e275..29368eac4 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/CommonForm.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/CommonForm.java @@ -26,6 +26,7 @@ import com.github._1c_syntax.bsl.mdo.support.FormType; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; import lombok.Builder; @@ -41,7 +42,9 @@ @Builder @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) -public class CommonForm implements MDObject, Form { +public class CommonForm implements MDObject, Form, AccessRightsOwner { + + private static final List POSSIBLE_RIGHTS = List.of(RoleRight.VIEW); /* * MDObject @@ -79,4 +82,10 @@ public class CommonForm implements MDObject, Form { * Свое */ + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return POSSIBLE_RIGHTS; + } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/Constant.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/Constant.java index 80c85ab94..7f751f375 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/Constant.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/Constant.java @@ -23,6 +23,7 @@ import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; import lombok.Builder; @@ -38,7 +39,9 @@ @Builder @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) -public class Constant implements MDObject, ModuleOwner { +public class Constant implements MDObject, ModuleOwner, AccessRightsOwner { + + private static final List POSSIBLE_RIGHTS = computePossibleRighs(); /* * MDObject @@ -82,4 +85,26 @@ public class Constant implements MDObject, ModuleOwner { @Default MultiLanguageString explanation = MultiLanguageString.EMPTY; + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return POSSIBLE_RIGHTS; + } + + private static List computePossibleRighs() { + return List.of( + RoleRight.READ, + RoleRight.UPDATE, + RoleRight.VIEW, + RoleRight.EDIT, + RoleRight.READ_DATA_HISTORY, + RoleRight.VIEW_DATA_HISTORY, + RoleRight.UPDATE_DATA_HISTORY, + RoleRight.UPDATE_DATA_HISTORY_SETTINGS, + RoleRight.UPDATE_DATA_HISTORY_VERSION_COMMENT, + RoleRight.EDIT_DATA_HISTORY_VERSION_COMMENT, + RoleRight.SWITCH_TO_DATA_HISTORY_VERSION + ); + } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/DataProcessor.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/DataProcessor.java index e8c71ed96..348e711b7 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/DataProcessor.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/DataProcessor.java @@ -26,6 +26,7 @@ import com.github._1c_syntax.bsl.mdo.children.ObjectTemplate; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.mdo.utils.LazyLoader; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; @@ -45,7 +46,9 @@ @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) public class DataProcessor implements MDObject, ModuleOwner, CommandOwner, AttributeOwner, TabularSectionOwner, - FormOwner, TemplateOwner { + FormOwner, TemplateOwner, AccessRightsOwner { + + private static final List POSSIBLE_RIGHTS = List.of(RoleRight.READ, RoleRight.USE); /* * MDObject @@ -155,6 +158,13 @@ public List getAllModules() { return allModules.getOrCompute(); } + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return POSSIBLE_RIGHTS; + } + private List computeChildren() { return LazyLoader.computeChildren(this); } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/Document.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/Document.java index a0e42d7b4..77afec985 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/Document.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/Document.java @@ -26,6 +26,7 @@ import com.github._1c_syntax.bsl.mdo.children.ObjectTemplate; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.mdo.utils.LazyLoader; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; @@ -44,7 +45,9 @@ @Builder @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) -public class Document implements ReferenceObject { +public class Document implements ReferenceObject, AccessRightsOwner { + + private static final List POSSIBLE_RIGHTS = computePossibleRighs(); /* * ReferenceObject @@ -131,6 +134,13 @@ public List getAllModules() { return allModules.getOrCompute(); } + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return POSSIBLE_RIGHTS; + } + private List computeChildren() { return LazyLoader.computeChildren(this); } @@ -151,4 +161,35 @@ private List computeAllModules() { return LazyLoader.computeAllModules(this); } + private static List computePossibleRighs() { + return List.of( + RoleRight.INSERT, + RoleRight.READ, + RoleRight.UPDATE, + RoleRight.DELETE, + RoleRight.VIEW, + RoleRight.EDIT, + RoleRight.INPUT_BY_STRING, + RoleRight.POSTING, + RoleRight.UNDO_POSTING, + RoleRight.INTERACTIVE_DELETE, + RoleRight.INTERACTIVE_INSERT, + RoleRight.INTERACTIVE_SET_DELETION_MARK, + RoleRight.INTERACTIVE_CLEAR_DELETION_MARK, + RoleRight.INTERACTIVE_DELETE_MARKED, + RoleRight.INTERACTIVE_POSTING, + RoleRight.INTERACTIVE_POSTING_REGULAR, + RoleRight.INTERACTIVE_UNDO_POSTING, + RoleRight.INTERACTIVE_CHANGE_OF_POSTED, + RoleRight.READ_DATA_HISTORY, + RoleRight.VIEW_DATA_HISTORY, + RoleRight.READ_DATA_HISTORY_OF_MISSING_DATA, + RoleRight.UPDATE_DATA_HISTORY, + RoleRight.UPDATE_DATA_HISTORY_OF_MISSING_DATA, + RoleRight.UPDATE_DATA_HISTORY_SETTINGS, + RoleRight.UPDATE_DATA_HISTORY_VERSION_COMMENT, + RoleRight.EDIT_DATA_HISTORY_VERSION_COMMENT, + RoleRight.SWITCH_TO_DATA_HISTORY_VERSION + ); + } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/DocumentJournal.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/DocumentJournal.java index d25146a34..a3dd2a09a 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/DocumentJournal.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/DocumentJournal.java @@ -27,6 +27,7 @@ import com.github._1c_syntax.bsl.mdo.children.ObjectTemplate; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.mdo.utils.LazyLoader; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; @@ -45,7 +46,10 @@ @Builder @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) -public class DocumentJournal implements MDObject, ModuleOwner, CommandOwner, AttributeOwner, FormOwner, TemplateOwner { +public class DocumentJournal implements MDObject, ModuleOwner, CommandOwner, AttributeOwner, FormOwner, TemplateOwner, + AccessRightsOwner { + + private static final List POSSIBLE_RIGHTS = List.of(RoleRight.READ, RoleRight.VIEW); /* * MDObject @@ -135,6 +139,13 @@ public List getAllModules() { return allModules.getOrCompute(); } + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return POSSIBLE_RIGHTS; + } + private List computeChildren() { return LazyLoader.computeChildren(this); } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/ExchangePlan.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/ExchangePlan.java index ca91fa011..8c8f065f3 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/ExchangePlan.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/ExchangePlan.java @@ -27,6 +27,7 @@ import com.github._1c_syntax.bsl.mdo.support.AutoRecordType; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.mdo.utils.LazyLoader; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; @@ -45,7 +46,9 @@ @Builder @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) -public class ExchangePlan implements ReferenceObject { +public class ExchangePlan implements ReferenceObject, AccessRightsOwner { + + private static final List POSSIBLE_RIGHTS = computePossibleRighs(); /* * ReferenceObject @@ -170,6 +173,13 @@ public List getAllModules() { return allModules.getOrCompute(); } + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return POSSIBLE_RIGHTS; + } + private List computeChildren() { return LazyLoader.computeChildren(this); } @@ -190,6 +200,32 @@ private List computeAllModules() { return LazyLoader.computeAllModules(this); } + private static List computePossibleRighs() { + return List.of( + RoleRight.INSERT, + RoleRight.READ, + RoleRight.UPDATE, + RoleRight.DELETE, + RoleRight.VIEW, + RoleRight.EDIT, + RoleRight.INPUT_BY_STRING, + RoleRight.INTERACTIVE_DELETE, + RoleRight.INTERACTIVE_INSERT, + RoleRight.INTERACTIVE_SET_DELETION_MARK, + RoleRight.INTERACTIVE_CLEAR_DELETION_MARK, + RoleRight.INTERACTIVE_DELETE_MARKED, + RoleRight.READ_DATA_HISTORY, + RoleRight.VIEW_DATA_HISTORY, + RoleRight.READ_DATA_HISTORY_OF_MISSING_DATA, + RoleRight.UPDATE_DATA_HISTORY, + RoleRight.UPDATE_DATA_HISTORY_OF_MISSING_DATA, + RoleRight.UPDATE_DATA_HISTORY_SETTINGS, + RoleRight.UPDATE_DATA_HISTORY_VERSION_COMMENT, + RoleRight.EDIT_DATA_HISTORY_VERSION_COMMENT, + RoleRight.SWITCH_TO_DATA_HISTORY_VERSION + ); + } + @Value @Builder public static class RecordContent { diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/ExternalDataSource.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/ExternalDataSource.java index c6a66d8f5..0a5eec614 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/ExternalDataSource.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/ExternalDataSource.java @@ -24,6 +24,7 @@ import com.github._1c_syntax.bsl.mdo.children.ExternalDataSourceTable; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.mdo.utils.LazyLoader; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; @@ -42,7 +43,9 @@ @Builder @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) -public class ExternalDataSource implements MDObject, ChildrenOwner { +public class ExternalDataSource implements MDObject, ChildrenOwner, AccessRightsOwner { + + private static final List POSSIBLE_RIGHTS = computePossibleRighs(); /* * MDObject @@ -93,8 +96,24 @@ public List getPlainChildren() { return plainChildren.getOrCompute(); } + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return POSSIBLE_RIGHTS; + } + private List computePlainChildren() { return LazyLoader.computePlainChildren(this); } + private static List computePossibleRighs() { + return List.of( + RoleRight.USE, + RoleRight.STANDARD_AUTHENTICATION_CHANGE, + RoleRight.SESSION_STANDARD_AUTHENTICATION_CHANGE, + RoleRight.SESSION_OS_AUTHENTICATION_CHANGE, + RoleRight.ADMINISTRATION + ); + } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/FilterCriterion.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/FilterCriterion.java index 8d046f917..f4a84a681 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/FilterCriterion.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/FilterCriterion.java @@ -25,6 +25,7 @@ import com.github._1c_syntax.bsl.mdo.children.ObjectForm; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.mdo.utils.LazyLoader; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; @@ -43,7 +44,9 @@ @Builder @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) -public class FilterCriterion implements MDObject, ModuleOwner, CommandOwner, FormOwner { +public class FilterCriterion implements MDObject, ModuleOwner, CommandOwner, FormOwner, AccessRightsOwner { + + private static final List POSSIBLE_RIGHTS = List.of(RoleRight.VIEW); /* * MDObject @@ -114,6 +117,13 @@ public List getAllModules() { return allModules.getOrCompute(); } + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return POSSIBLE_RIGHTS; + } + private List computeChildren() { return LazyLoader.computeChildren(this); } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/InformationRegister.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/InformationRegister.java index 901a69f5e..e4126cecf 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/InformationRegister.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/InformationRegister.java @@ -28,6 +28,7 @@ import com.github._1c_syntax.bsl.mdo.children.Resource; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.mdo.utils.LazyLoader; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; @@ -46,7 +47,9 @@ @Builder @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) -public class InformationRegister implements Register { +public class InformationRegister implements Register, AccessRightsOwner { + + private static final List POSSIBLE_RIGHTS = computePossibleRighs(); /* * Register @@ -116,6 +119,13 @@ public List getAllModules() { return allModules.getOrCompute(); } + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return POSSIBLE_RIGHTS; + } + private List computeChildren() { return LazyLoader.computeChildren(this); } @@ -127,4 +137,23 @@ private List computeAllAttributes() { private List computeAllModules() { return LazyLoader.computeAllModules(this); } + + private static List computePossibleRighs() { + return List.of( + RoleRight.READ, + RoleRight.UPDATE, + RoleRight.VIEW, + RoleRight.EDIT, + RoleRight.TOTALS_CONTROL, + RoleRight.READ_DATA_HISTORY, + RoleRight.VIEW_DATA_HISTORY, + RoleRight.READ_DATA_HISTORY_OF_MISSING_DATA, + RoleRight.UPDATE_DATA_HISTORY, + RoleRight.UPDATE_DATA_HISTORY_OF_MISSING_DATA, + RoleRight.UPDATE_DATA_HISTORY_SETTINGS, + RoleRight.UPDATE_DATA_HISTORY_VERSION_COMMENT, + RoleRight.EDIT_DATA_HISTORY_VERSION_COMMENT, + RoleRight.SWITCH_TO_DATA_HISTORY_VERSION + ); + } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/Report.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/Report.java index 58a549f57..c10bcd751 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/Report.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/Report.java @@ -26,6 +26,7 @@ import com.github._1c_syntax.bsl.mdo.children.ObjectTemplate; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.mdo.utils.LazyLoader; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; @@ -46,7 +47,9 @@ @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) public class Report implements MDObject, ModuleOwner, CommandOwner, AttributeOwner, TabularSectionOwner, - FormOwner, TemplateOwner { + FormOwner, TemplateOwner, AccessRightsOwner { + + private static final List POSSIBLE_RIGHTS = List.of(RoleRight.READ, RoleRight.USE); /* * MDObject @@ -157,6 +160,13 @@ public List getAllModules() { return allModules.getOrCompute(); } + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return POSSIBLE_RIGHTS; + } + private List computeChildren() { return LazyLoader.computeChildren(this); } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/Sequence.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/Sequence.java index 7f9b5ced9..4292db5c6 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/Sequence.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/Sequence.java @@ -24,6 +24,7 @@ import com.github._1c_syntax.bsl.mdo.children.Dimension; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; import lombok.Builder; @@ -40,7 +41,9 @@ @Builder @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) -public class Sequence implements MDObject, AttributeOwner, ModuleOwner { +public class Sequence implements MDObject, AttributeOwner, ModuleOwner, AccessRightsOwner { + + private static final List POSSIBLE_RIGHTS = List.of(RoleRight.READ, RoleRight.EDIT); /* * MDObject @@ -98,4 +101,10 @@ public List getChildren() { return Collections.unmodifiableList(dimensions); } + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return POSSIBLE_RIGHTS; + } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/SessionParameter.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/SessionParameter.java index e61a9968c..71b7148dd 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/SessionParameter.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/SessionParameter.java @@ -23,6 +23,7 @@ import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; import lombok.Builder; @@ -31,11 +32,15 @@ import lombok.ToString; import lombok.Value; +import java.util.List; + @Value @Builder @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) -public class SessionParameter implements MDObject { +public class SessionParameter implements MDObject, AccessRightsOwner { + + private static final List POSSIBLE_RIGHTS = List.of(RoleRight.GET, RoleRight.SET); /* * MDObject @@ -60,4 +65,11 @@ public class SessionParameter implements MDObject { * Свое */ + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return POSSIBLE_RIGHTS; + } + } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/Subsystem.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/Subsystem.java index d72c16fcf..63d84e759 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/Subsystem.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/Subsystem.java @@ -23,6 +23,7 @@ import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.mdo.utils.LazyLoader; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; @@ -42,7 +43,9 @@ @Builder @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) -public class Subsystem implements MDObject, ChildrenOwner { +public class Subsystem implements MDObject, ChildrenOwner, AccessRightsOwner { + + private static final List POSSIBLE_RIGHTS = List.of(RoleRight.VIEW); /* * MDObject @@ -140,6 +143,13 @@ public List getPlainChildren() { return plainChildren.getOrCompute(); } + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return POSSIBLE_RIGHTS; + } + private List computePlainChildren() { return LazyLoader.computePlainChildren(this); } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/Task.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/Task.java index 1dd8a4402..ff8ee1cfa 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/Task.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/Task.java @@ -27,6 +27,7 @@ import com.github._1c_syntax.bsl.mdo.children.TaskAddressingAttribute; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.mdo.utils.LazyLoader; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; @@ -45,7 +46,9 @@ @Builder @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) -public class Task implements ReferenceObject { +public class Task implements ReferenceObject, AccessRightsOwner { + + private static final List POSSIBLE_RIGHTS = computePossibleRighs(); /* * ReferenceObject @@ -132,6 +135,13 @@ public List getAllModules() { return allModules.getOrCompute(); } + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return POSSIBLE_RIGHTS; + } + private List computeChildren() { return LazyLoader.computeChildren(this); } @@ -151,4 +161,33 @@ private List computePlainStorageFields() { private List computeAllModules() { return LazyLoader.computeAllModules(this); } + + private static List computePossibleRighs() { + return List.of( + RoleRight.INSERT, + RoleRight.READ, + RoleRight.UPDATE, + RoleRight.DELETE, + RoleRight.VIEW, + RoleRight.EDIT, + RoleRight.INPUT_BY_STRING, + RoleRight.INTERACTIVE_DELETE, + RoleRight.INTERACTIVE_INSERT, + RoleRight.INTERACTIVE_SET_DELETION_MARK, + RoleRight.INTERACTIVE_CLEAR_DELETION_MARK, + RoleRight.INTERACTIVE_DELETE_MARKED, + RoleRight.INTERACTIVE_ACTIVATE, + RoleRight.EXECUTE, + RoleRight.INTERACTIVE_EXECUTE, + RoleRight.READ_DATA_HISTORY, + RoleRight.VIEW_DATA_HISTORY, + RoleRight.READ_DATA_HISTORY_OF_MISSING_DATA, + RoleRight.UPDATE_DATA_HISTORY, + RoleRight.UPDATE_DATA_HISTORY_OF_MISSING_DATA, + RoleRight.UPDATE_DATA_HISTORY_SETTINGS, + RoleRight.UPDATE_DATA_HISTORY_VERSION_COMMENT, + RoleRight.EDIT_DATA_HISTORY_VERSION_COMMENT, + RoleRight.SWITCH_TO_DATA_HISTORY_VERSION + ); + } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/children/AccountingFlag.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/children/AccountingFlag.java index c46a3f197..869498a30 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/children/AccountingFlag.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/children/AccountingFlag.java @@ -21,11 +21,13 @@ */ package com.github._1c_syntax.bsl.mdo.children; +import com.github._1c_syntax.bsl.mdo.AccessRightsOwner; import com.github._1c_syntax.bsl.mdo.Attribute; import com.github._1c_syntax.bsl.mdo.support.AttributeKind; import com.github._1c_syntax.bsl.mdo.support.IndexingType; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; import lombok.Builder; @@ -34,11 +36,13 @@ import lombok.ToString; import lombok.Value; +import java.util.List; + @Value @Builder @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) -public class AccountingFlag implements Attribute { +public class AccountingFlag implements Attribute, AccessRightsOwner { /* * Для Attribute @@ -65,4 +69,11 @@ public class AccountingFlag implements Attribute { AttributeKind kind = AttributeKind.CUSTOM; @Default IndexingType indexing = IndexingType.DONT_INDEX; + + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return ObjectAttribute.possibleRights(); + } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/children/Dimension.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/children/Dimension.java index a270399ce..97a2869b3 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/children/Dimension.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/children/Dimension.java @@ -21,11 +21,13 @@ */ package com.github._1c_syntax.bsl.mdo.children; +import com.github._1c_syntax.bsl.mdo.AccessRightsOwner; import com.github._1c_syntax.bsl.mdo.Attribute; import com.github._1c_syntax.bsl.mdo.support.AttributeKind; import com.github._1c_syntax.bsl.mdo.support.IndexingType; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; import lombok.Builder; @@ -34,11 +36,13 @@ import lombok.ToString; import lombok.Value; +import java.util.List; + @Value @Builder @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) -public class Dimension implements Attribute { +public class Dimension implements Attribute, AccessRightsOwner { /* * Для MDChild @@ -85,4 +89,11 @@ public class Dimension implements Attribute { * TODO: Для регистра сведений не применимо, но не противоречит логике */ boolean useInTotals = true; + + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return ObjectAttribute.possibleRights(); + } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/children/ExtDimensionAccountingFlag.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/children/ExtDimensionAccountingFlag.java index b9e1e14a3..be03ade54 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/children/ExtDimensionAccountingFlag.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/children/ExtDimensionAccountingFlag.java @@ -21,11 +21,13 @@ */ package com.github._1c_syntax.bsl.mdo.children; +import com.github._1c_syntax.bsl.mdo.AccessRightsOwner; import com.github._1c_syntax.bsl.mdo.Attribute; import com.github._1c_syntax.bsl.mdo.support.AttributeKind; import com.github._1c_syntax.bsl.mdo.support.IndexingType; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; import lombok.Builder; @@ -34,11 +36,13 @@ import lombok.ToString; import lombok.Value; +import java.util.List; + @Value @Builder @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) -public class ExtDimensionAccountingFlag implements Attribute { +public class ExtDimensionAccountingFlag implements Attribute, AccessRightsOwner { /* * Для MDChild @@ -66,4 +70,10 @@ public class ExtDimensionAccountingFlag implements Attribute { @Default IndexingType indexing = IndexingType.DONT_INDEX; + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return ObjectAttribute.possibleRights(); + } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/children/ExternalDataSourceTable.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/children/ExternalDataSourceTable.java index 5822ab1ce..3b2700b77 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/children/ExternalDataSourceTable.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/children/ExternalDataSourceTable.java @@ -21,6 +21,7 @@ */ package com.github._1c_syntax.bsl.mdo.children; +import com.github._1c_syntax.bsl.mdo.AccessRightsOwner; import com.github._1c_syntax.bsl.mdo.Attribute; import com.github._1c_syntax.bsl.mdo.AttributeOwner; import com.github._1c_syntax.bsl.mdo.CommandOwner; @@ -33,6 +34,7 @@ import com.github._1c_syntax.bsl.mdo.support.DataLockControlMode; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.mdo.utils.LazyLoader; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; @@ -52,7 +54,9 @@ @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) public class ExternalDataSourceTable implements MDChild, ModuleOwner, CommandOwner, AttributeOwner, FormOwner, - TemplateOwner { + TemplateOwner, AccessRightsOwner { + + private static final List POSSIBLE_RIGHTS = computePossibleRighs(); /* * Для MDChild @@ -141,6 +145,13 @@ public List getAllModules() { return allModules.getOrCompute(); } + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return POSSIBLE_RIGHTS; + } + private List computeChildren() { return LazyLoader.computeChildren(this); } @@ -149,4 +160,17 @@ private List computeAllModules() { return LazyLoader.computeAllModules(this); } + private static List computePossibleRighs() { + return List.of( + RoleRight.INSERT, + RoleRight.READ, + RoleRight.UPDATE, + RoleRight.DELETE, + RoleRight.VIEW, + RoleRight.EDIT, + RoleRight.INPUT_BY_STRING, + RoleRight.INTERACTIVE_DELETE, + RoleRight.INTERACTIVE_INSERT + ); + } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/children/ExternalDataSourceTableField.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/children/ExternalDataSourceTableField.java index 0f1f3d8af..81c306acb 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/children/ExternalDataSourceTableField.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/children/ExternalDataSourceTableField.java @@ -21,11 +21,13 @@ */ package com.github._1c_syntax.bsl.mdo.children; +import com.github._1c_syntax.bsl.mdo.AccessRightsOwner; import com.github._1c_syntax.bsl.mdo.Attribute; import com.github._1c_syntax.bsl.mdo.support.AttributeKind; import com.github._1c_syntax.bsl.mdo.support.IndexingType; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; import lombok.Builder; @@ -34,11 +36,15 @@ import lombok.ToString; import lombok.Value; +import java.util.List; + @Value @Builder @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) -public class ExternalDataSourceTableField implements Attribute { +public class ExternalDataSourceTableField implements Attribute, AccessRightsOwner { + + private static final List POSSIBLE_RIGHTS = List.of(RoleRight.VIEW, RoleRight.EDIT); /* * Для Attribute @@ -65,4 +71,11 @@ public class ExternalDataSourceTableField implements Attribute { AttributeKind kind = AttributeKind.CUSTOM; @Default IndexingType indexing = IndexingType.DONT_INDEX; + + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return POSSIBLE_RIGHTS; + } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/children/HTTPServiceMethod.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/children/HTTPServiceMethod.java index b3347908a..63f90d63d 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/children/HTTPServiceMethod.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/children/HTTPServiceMethod.java @@ -21,9 +21,11 @@ */ package com.github._1c_syntax.bsl.mdo.children; +import com.github._1c_syntax.bsl.mdo.AccessRightsOwner; import com.github._1c_syntax.bsl.mdo.MDChild; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; import lombok.Builder; @@ -32,11 +34,15 @@ import lombok.ToString; import lombok.Value; +import java.util.List; + @Value @Builder @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) -public class HTTPServiceMethod implements MDChild { +public class HTTPServiceMethod implements MDChild, AccessRightsOwner { + + private static final List POSSIBLE_RIGHTS = List.of(RoleRight.USE); /* * Для MDChild @@ -70,4 +76,11 @@ public class HTTPServiceMethod implements MDChild { */ @Default String handler = ""; // TODO сделать классом + + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return POSSIBLE_RIGHTS; + } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/children/IntegrationServiceChannel.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/children/IntegrationServiceChannel.java index a55806ce0..b8471cc6f 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/children/IntegrationServiceChannel.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/children/IntegrationServiceChannel.java @@ -1,30 +1,32 @@ -/* - * This file is a part of MDClasses. - * - * Copyright (c) 2019 - 2024 - * Tymko Oleg , Maximov Valery and contributors - * - * SPDX-License-Identifier: LGPL-3.0-or-later - * - * MDClasses is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3.0 of the License, or (at your option) any later version. - * - * MDClasses is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with MDClasses. - */ -package com.github._1c_syntax.bsl.mdo.children; +/* + * This file is a part of MDClasses. + * + * Copyright (c) 2019 - 2024 + * Tymko Oleg , Maximov Valery and contributors + * + * SPDX-License-Identifier: LGPL-3.0-or-later + * + * MDClasses is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * MDClasses is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with MDClasses. + */ +package com.github._1c_syntax.bsl.mdo.children; +import com.github._1c_syntax.bsl.mdo.AccessRightsOwner; import com.github._1c_syntax.bsl.mdo.MDChild; import com.github._1c_syntax.bsl.mdo.support.MessageDirection; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; import lombok.Builder; @@ -33,11 +35,15 @@ import lombok.ToString; import lombok.Value; +import java.util.List; + @Value @Builder @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) -public class IntegrationServiceChannel implements MDChild { +public class IntegrationServiceChannel implements MDChild, AccessRightsOwner { + + private static final List POSSIBLE_RIGHTS = List.of(RoleRight.USE); /* * Для MDChild @@ -81,4 +87,11 @@ public class IntegrationServiceChannel implements MDChild { */ @Default String externalIntegrationServiceChannelName = ""; + + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return POSSIBLE_RIGHTS; + } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/children/ObjectAttribute.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/children/ObjectAttribute.java index 354167099..9d76d2bfa 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/children/ObjectAttribute.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/children/ObjectAttribute.java @@ -21,11 +21,13 @@ */ package com.github._1c_syntax.bsl.mdo.children; +import com.github._1c_syntax.bsl.mdo.AccessRightsOwner; import com.github._1c_syntax.bsl.mdo.Attribute; import com.github._1c_syntax.bsl.mdo.support.AttributeKind; import com.github._1c_syntax.bsl.mdo.support.IndexingType; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; import lombok.Builder; @@ -34,11 +36,15 @@ import lombok.ToString; import lombok.Value; +import java.util.List; + @Value @Builder @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) -public class ObjectAttribute implements Attribute { +public class ObjectAttribute implements Attribute, AccessRightsOwner { + + private static final List POSSIBLE_RIGHTS = List.of(RoleRight.VIEW, RoleRight.EDIT); /* * Для MDChild @@ -107,4 +113,11 @@ public class ObjectAttribute implements Attribute { * Заполнять из данных заполнения */ boolean fillFromFillingValue; + + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return POSSIBLE_RIGHTS; + } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/children/ObjectCommand.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/children/ObjectCommand.java index 6428e17d0..08753500f 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/children/ObjectCommand.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/children/ObjectCommand.java @@ -26,6 +26,7 @@ import com.github._1c_syntax.bsl.mdo.Module; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; import lombok.Builder; @@ -43,6 +44,8 @@ @EqualsAndHashCode(of = {"name", "uuid"}) public class ObjectCommand implements Command, MDChild { + private static final List POSSIBLE_RIGHTS = List.of(RoleRight.VIEW); + /* * Для Command */ @@ -70,4 +73,11 @@ public class ObjectCommand implements Command, MDChild { @Default MdoReference owner = MdoReference.EMPTY; + + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return POSSIBLE_RIGHTS; + } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/children/ObjectTabularSection.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/children/ObjectTabularSection.java index 7ef3ee0a0..8e46c214a 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/children/ObjectTabularSection.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/children/ObjectTabularSection.java @@ -21,10 +21,12 @@ */ package com.github._1c_syntax.bsl.mdo.children; +import com.github._1c_syntax.bsl.mdo.AccessRightsOwner; import com.github._1c_syntax.bsl.mdo.Attribute; import com.github._1c_syntax.bsl.mdo.TabularSection; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; import lombok.Builder; @@ -40,7 +42,9 @@ @Builder @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) -public class ObjectTabularSection implements TabularSection { +public class ObjectTabularSection implements TabularSection, AccessRightsOwner { + + private static final List POSSIBLE_RIGHTS = List.of(RoleRight.VIEW, RoleRight.EDIT); /* * Для TabularSection @@ -65,4 +69,11 @@ public class ObjectTabularSection implements TabularSection { @Singular List attributes; + + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return POSSIBLE_RIGHTS; + } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/children/Recalculation.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/children/Recalculation.java index 94fe666b2..94968b1e3 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/children/Recalculation.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/children/Recalculation.java @@ -1,31 +1,33 @@ -/* - * This file is a part of MDClasses. - * - * Copyright (c) 2019 - 2024 - * Tymko Oleg , Maximov Valery and contributors - * - * SPDX-License-Identifier: LGPL-3.0-or-later - * - * MDClasses is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3.0 of the License, or (at your option) any later version. - * - * MDClasses is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with MDClasses. - */ -package com.github._1c_syntax.bsl.mdo.children; +/* + * This file is a part of MDClasses. + * + * Copyright (c) 2019 - 2024 + * Tymko Oleg , Maximov Valery and contributors + * + * SPDX-License-Identifier: LGPL-3.0-or-later + * + * MDClasses is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * MDClasses is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with MDClasses. + */ +package com.github._1c_syntax.bsl.mdo.children; +import com.github._1c_syntax.bsl.mdo.AccessRightsOwner; import com.github._1c_syntax.bsl.mdo.MDChild; import com.github._1c_syntax.bsl.mdo.Module; import com.github._1c_syntax.bsl.mdo.ModuleOwner; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; import lombok.Builder; @@ -41,7 +43,7 @@ @Builder @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) -public class Recalculation implements MDChild, ModuleOwner { +public class Recalculation implements MDChild, ModuleOwner, AccessRightsOwner { /* * Для MDChild @@ -71,4 +73,10 @@ public class Recalculation implements MDChild, ModuleOwner { @Default List modules = Collections.emptyList(); + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return ObjectAttribute.possibleRights(); + } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/children/Resource.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/children/Resource.java index 77120b83f..8a3775310 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/children/Resource.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/children/Resource.java @@ -21,11 +21,13 @@ */ package com.github._1c_syntax.bsl.mdo.children; +import com.github._1c_syntax.bsl.mdo.AccessRightsOwner; import com.github._1c_syntax.bsl.mdo.Attribute; import com.github._1c_syntax.bsl.mdo.support.AttributeKind; import com.github._1c_syntax.bsl.mdo.support.IndexingType; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; import lombok.Builder; @@ -34,11 +36,13 @@ import lombok.ToString; import lombok.Value; +import java.util.List; + @Value @Builder @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) -public class Resource implements Attribute { +public class Resource implements Attribute, AccessRightsOwner { /* * Для MDChild @@ -70,4 +74,10 @@ public class Resource implements Attribute { * Свое */ + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return ObjectAttribute.possibleRights(); + } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/children/TaskAddressingAttribute.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/children/TaskAddressingAttribute.java index dc9c4a711..3c04cae5a 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/children/TaskAddressingAttribute.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/children/TaskAddressingAttribute.java @@ -21,11 +21,13 @@ */ package com.github._1c_syntax.bsl.mdo.children; +import com.github._1c_syntax.bsl.mdo.AccessRightsOwner; import com.github._1c_syntax.bsl.mdo.Attribute; import com.github._1c_syntax.bsl.mdo.support.AttributeKind; import com.github._1c_syntax.bsl.mdo.support.IndexingType; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; import lombok.Builder; @@ -34,11 +36,13 @@ import lombok.ToString; import lombok.Value; +import java.util.List; + @Value @Builder @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) -public class TaskAddressingAttribute implements Attribute { +public class TaskAddressingAttribute implements Attribute, AccessRightsOwner { /* * Для MDChild @@ -119,4 +123,11 @@ public class TaskAddressingAttribute implements Attribute { */ @Default MdoReference choiceForm = MdoReference.EMPTY; + + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return ObjectAttribute.possibleRights(); + } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/mdo/children/WebServiceOperation.java b/src/main/java/com/github/_1c_syntax/bsl/mdo/children/WebServiceOperation.java index bfcb8915b..32100f7be 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/mdo/children/WebServiceOperation.java +++ b/src/main/java/com/github/_1c_syntax/bsl/mdo/children/WebServiceOperation.java @@ -21,12 +21,14 @@ */ package com.github._1c_syntax.bsl.mdo.children; +import com.github._1c_syntax.bsl.mdo.AccessRightsOwner; import com.github._1c_syntax.bsl.mdo.ChildrenOwner; import com.github._1c_syntax.bsl.mdo.MD; import com.github._1c_syntax.bsl.mdo.MDChild; import com.github._1c_syntax.bsl.mdo.support.DataLockControlMode; import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString; import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.MdoReference; import lombok.Builder; @@ -43,7 +45,9 @@ @Builder @ToString(of = {"name", "uuid"}) @EqualsAndHashCode(of = {"name", "uuid"}) -public class WebServiceOperation implements MDChild, ChildrenOwner { +public class WebServiceOperation implements MDChild, ChildrenOwner, AccessRightsOwner { + + private static final List POSSIBLE_RIGHTS = List.of(RoleRight.USE); /* * Для MDChild @@ -106,4 +110,11 @@ public class WebServiceOperation implements MDChild, ChildrenOwner { public List getChildren() { return Collections.unmodifiableList(parameters); } + + /** + * Возвращает перечень возможных прав доступа + */ + public static List possibleRights() { + return POSSIBLE_RIGHTS; + } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/reader/designer/DesignerReader.java b/src/main/java/com/github/_1c_syntax/bsl/reader/designer/DesignerReader.java index caefa25ab..8694e7fbc 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/reader/designer/DesignerReader.java +++ b/src/main/java/com/github/_1c_syntax/bsl/reader/designer/DesignerReader.java @@ -91,7 +91,7 @@ public class DesignerReader implements MDReader { private final Path rootPath; public DesignerReader(Path path, boolean skipSupport) { - xstream = createXMLMapper(); + xstream = createXMLMapper(); rootPath = path; if (!skipSupport) { ParseSupportData.readSimple(parentConfigurationsPath()); diff --git a/src/test/java/com/github/_1c_syntax/bsl/mdclasses/helpers/RightsTest.java b/src/test/java/com/github/_1c_syntax/bsl/mdclasses/helpers/RightsTest.java new file mode 100644 index 000000000..f6c1a00e8 --- /dev/null +++ b/src/test/java/com/github/_1c_syntax/bsl/mdclasses/helpers/RightsTest.java @@ -0,0 +1,159 @@ +/* + * This file is a part of MDClasses. + * + * Copyright (c) 2019 - 2024 + * Tymko Oleg , Maximov Valery and contributors + * + * SPDX-License-Identifier: LGPL-3.0-or-later + * + * MDClasses is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * MDClasses is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with MDClasses. + */ +package com.github._1c_syntax.bsl.mdclasses.helpers; + +import com.github._1c_syntax.bsl.mdclasses.CF; +import com.github._1c_syntax.bsl.mdclasses.Configuration; +import com.github._1c_syntax.bsl.mdclasses.ConfigurationExtension; +import com.github._1c_syntax.bsl.mdclasses.MDClasses; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; +import com.github._1c_syntax.bsl.types.MdoReference; +import org.junit.jupiter.api.Test; + +import java.nio.file.Path; + +import static org.assertj.core.api.Assertions.assertThat; + +class RightsTest { + + @Test + void rightAccessCf() { + var mdc = MDClasses.createConfiguration(Path.of("src/test/resources/ext/designer/ssl_3_1/src/cf")); + assertThat(mdc).isInstanceOf(Configuration.class); + + var cf = (CF) mdc; + assertThat(Rights.rightAccess(cf, RoleRight.ADMINISTRATION)).isTrue(); + assertThat(Rights.rightAccess(cf, RoleRight.THICK_CLIENT)).isTrue(); + assertThat(Rights.rightAccess(cf, RoleRight.ALL_FUNCTIONS_MODE)).isFalse(); + assertThat(cf.rightAccess(RoleRight.WEB_CLIENT)).isTrue(); + + var mdv = cf.findChild("Document.Анкета"); + assertThat(mdv).isPresent(); + var md = mdv.get(); + assertThat(Rights.rightAccess(cf, RoleRight.DELETE, md)).isTrue(); + assertThat(Rights.rightAccess(cf, RoleRight.VIEW, md)).isTrue(); + assertThat(Rights.rightAccess(cf, RoleRight.USE, md)).isFalse(); + assertThat(cf.rightAccess(RoleRight.POSTING, md)).isTrue(); + + mdv = cf.findChild("Task.ЗадачаИсполнителя.Command.Перенаправить"); + assertThat(mdv).isPresent(); + md = mdv.get(); + assertThat(Rights.rightAccess(cf, RoleRight.VIEW, md)).isTrue(); + assertThat(Rights.rightAccess(cf, RoleRight.USE, md)).isFalse(); + assertThat(cf.rightAccess(RoleRight.START, md)).isFalse(); + + var mdoReference = MdoReference.create("Enum.ВариантыВажностиЗадачи.EnumValue.Обычная"); + assertThat(Rights.rightAccess(cf, RoleRight.VIEW, mdoReference)).isFalse(); + assertThat(Rights.rightAccess(cf, RoleRight.DELETE, mdoReference)).isFalse(); + assertThat(cf.rightAccess(RoleRight.INTERACTIVE_DELETE, mdoReference)).isFalse(); + } + + @Test + void rightAccessCfe() { + var mdc = MDClasses.createConfiguration(Path.of("src/test/resources/ext/edt/mdclasses_ext/configuration")); + assertThat(mdc).isInstanceOf(ConfigurationExtension.class); + + var cfe = (CF) mdc; + assertThat(Rights.rightAccess(cfe, RoleRight.ADMINISTRATION)).isTrue(); + assertThat(Rights.rightAccess(cfe, RoleRight.THICK_CLIENT)).isFalse(); + assertThat(Rights.rightAccess(cfe, RoleRight.DELETE)).isFalse(); + + var mdv = cfe.findChild("AccountingRegister.РегистрБухгалтерии1"); + assertThat(mdv).isPresent(); + var md = mdv.get(); + assertThat(Rights.rightAccess(cfe, RoleRight.DELETE, md)).isFalse(); + assertThat(Rights.rightAccess(cfe, RoleRight.VIEW, md)).isFalse(); + assertThat(Rights.rightAccess(cfe, RoleRight.USE, md)).isFalse(); + + var mdoReference = MdoReference.create("Catalog.Справочник1"); + assertThat(Rights.rightAccess(cfe, RoleRight.DELETE, mdoReference)).isTrue(); + assertThat(Rights.rightAccess(cfe, RoleRight.INTERACTIVE_DELETE_MARKED, mdoReference)).isTrue(); + assertThat(Rights.rightAccess(cfe, RoleRight.UPDATE_DATA_HISTORY_SETTINGS, mdoReference)).isFalse(); + } + + @Test + void rolesAccessCf() { + var mdc = MDClasses.createConfiguration(Path.of("src/test/resources/ext/edt/ssl_3_1/configuration")); + assertThat(mdc).isInstanceOf(Configuration.class); + + var cf = (CF) mdc; + assertThat(Rights.rolesAccess(cf, RoleRight.ADMINISTRATION)) + .hasSize(2) + .anyMatch(role -> role.getName().equals("АдминистраторСистемы")); + + assertThat(Rights.rolesAccess(cf, RoleRight.THICK_CLIENT)) + .hasSize(2) + .anyMatch(role -> role.getName().equals("ЗапускТолстогоКлиента")); + + assertThat(Rights.rolesAccess(cf, RoleRight.ALL_FUNCTIONS_MODE)).isEmpty(); + assertThat(cf.rolesAccess(RoleRight.ANALYTICS_SYSTEM_CLIENT)).hasSize(26); + + var mdv = cf.findChild("Document.Анкета"); + assertThat(mdv).isPresent(); + var md = mdv.get(); + assertThat(Rights.rolesAccess(cf, RoleRight.DELETE, md)).hasSize(1); + assertThat(Rights.rolesAccess(cf, RoleRight.INTERACTIVE_DELETE, md)).isEmpty(); + assertThat(Rights.rolesAccess(cf, RoleRight.VIEW, md)).hasSize(2); + assertThat(Rights.rolesAccess(cf, RoleRight.USE, md)).isEmpty(); + assertThat(cf.rolesAccess(RoleRight.INTERACTIVE_DELETE_MARKED, md)).isEmpty(); + + mdv = cf.findChild("Task.ЗадачаИсполнителя.Command.Перенаправить"); + assertThat(mdv).isPresent(); + md = mdv.get(); + assertThat(Rights.rolesAccess(cf, RoleRight.VIEW, md)).hasSize(4); + assertThat(Rights.rolesAccess(cf, RoleRight.USE, md)).isEmpty(); + assertThat(cf.rolesAccess(RoleRight.DELETE, md)).isEmpty(); + + var mdoReference = MdoReference.create("Enum.ВариантыВажностиЗадачи.EnumValue.Обычная"); + assertThat(Rights.rolesAccess(cf, RoleRight.VIEW, mdoReference)).isEmpty(); + assertThat(Rights.rolesAccess(cf, RoleRight.DELETE, mdoReference)).isEmpty(); + assertThat(cf.rolesAccess(RoleRight.INSERT, mdoReference)).isEmpty(); + } + + @Test + void rolesAccessCfe() { + var mdc = MDClasses.createConfiguration(Path.of("src/test/resources/ext/designer/mdclasses_ext/src/cf")); + assertThat(mdc).isInstanceOf(ConfigurationExtension.class); + + var cfe = (CF) mdc; + assertThat(Rights.rolesAccess(cfe, RoleRight.ADMINISTRATION)) + .hasSize(1) + .anyMatch(role -> role.getName().equals("Роль2")); + + assertThat(Rights.rolesAccess(cfe, RoleRight.THICK_CLIENT)) + .hasSize(1) + .anyMatch(role -> role.getName().equals("Роль2")); + + assertThat(Rights.rolesAccess(cfe, RoleRight.DELETE)).isEmpty(); + + var mdv = cfe.findChild("AccountingRegister.РегистрБухгалтерии1"); + assertThat(mdv).isPresent(); + var md = mdv.get(); + assertThat(Rights.rolesAccess(cfe, RoleRight.DELETE, md)).isEmpty(); + assertThat(Rights.rolesAccess(cfe, RoleRight.VIEW, md)).isEmpty(); + + var mdoReference = MdoReference.create("Catalog.Справочник1"); + assertThat(Rights.rolesAccess(cfe, RoleRight.DELETE, mdoReference)).hasSize(1); + assertThat(Rights.rolesAccess(cfe, RoleRight.INTERACTIVE_DELETE_MARKED, mdoReference)).hasSize(1); + assertThat(Rights.rolesAccess(cfe, RoleRight.UPDATE_DATA_HISTORY_SETTINGS, mdoReference)).isEmpty(); + } +} \ No newline at end of file diff --git a/src/test/java/com/github/_1c_syntax/bsl/smoke/RightTest.java b/src/test/java/com/github/_1c_syntax/bsl/smoke/RightTest.java new file mode 100644 index 000000000..fd02753b5 --- /dev/null +++ b/src/test/java/com/github/_1c_syntax/bsl/smoke/RightTest.java @@ -0,0 +1,80 @@ +/* + * This file is a part of MDClasses. + * + * Copyright (c) 2019 - 2024 + * Tymko Oleg , Maximov Valery and contributors + * + * SPDX-License-Identifier: LGPL-3.0-or-later + * + * MDClasses is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * MDClasses is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with MDClasses. + */ +package com.github._1c_syntax.bsl.smoke; + +import com.github._1c_syntax.bsl.mdo.AccessRightsOwner; +import com.github._1c_syntax.bsl.mdo.support.RoleRight; +import io.github.classgraph.ClassGraph; +import io.github.classgraph.ClassInfo; +import org.junit.jupiter.api.Test; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +class RightTest { + + @Test + void possibleRights() { + try (var scanResult = new ClassGraph() + .enableClassInfo() + .acceptPackages("com.github._1c_syntax.bsl") + .scan()) { + + var classes = scanResult.getClassesImplementing(AccessRightsOwner.class); + + assertThat(classes).hasSize(43); + + var list = classes.stream() + .filter(ci -> !ci.isInterface()) + .map(ClassInfo::getName) + .filter(name -> getPossibleRights(name).isEmpty()).toList(); + assertThat(list).isEmpty(); + } + } + + @SuppressWarnings("unchecked") + private List getPossibleRights(String className) { + Class clazz; + try { + clazz = (Class) Class.forName(className); + } catch (ClassNotFoundException e) { + return Collections.emptyList(); + } + + var value = Arrays.stream(clazz.getDeclaredMethods()) + .filter(method -> "possibleRights".equals(method.getName())) + .findFirst(); + + if (value.isEmpty()) { + return Collections.emptyList(); + } + + try { + return (List) value.get().invoke(clazz); + } catch (Exception e) { + return Collections.emptyList(); + } + } +} diff --git "a/src/test/resources/ext/edt/mdclasses_ext/configuration/src/Roles/\320\240\320\276\320\273\321\2142/Rights.rights" "b/src/test/resources/ext/edt/mdclasses_ext/configuration/src/Roles/\320\240\320\276\320\273\321\2142/Rights.rights" index e724c224c..bd961b866 100644 --- "a/src/test/resources/ext/edt/mdclasses_ext/configuration/src/Roles/\320\240\320\276\320\273\321\2142/Rights.rights" +++ "b/src/test/resources/ext/edt/mdclasses_ext/configuration/src/Roles/\320\240\320\276\320\273\321\2142/Rights.rights" @@ -114,7 +114,7 @@ ThickClient - true + false ExternalConnection