Search in sources :

Example 1 with PermissionConfig

use of com.haulmont.cuba.gui.config.PermissionConfig in project cuba by cuba-platform.

the class EntityPermissionTargetsDatasource method loadData.

@Override
protected void loadData(Map<String, Object> params) {
    if (permissionDs == null)
        return;
    if (targets == null) {
        targets = new ArrayList<>();
        PermissionConfig permissionConfig = AppBeans.get(PermissionConfig.class);
        List<OperationPermissionTarget> entities = permissionConfig.getEntities(userSessionSource.getLocale());
        for (OperationPermissionTarget target : entities) {
            try {
                OperationPermissionTarget cloneTarget = target.clone();
                loadPermissionVariants(cloneTarget);
                attachListener(cloneTarget);
                targets.add(cloneTarget);
            } catch (CloneNotSupportedException e) {
                throw new RuntimeException("Can't clone permission target", e);
            }
        }
    }
    data.clear();
    targets.stream().filter(permittedEntityFilter).filter(t -> permissionsFilter == null || permissionsFilter.test(t)).forEach(t -> data.put(t.getId(), t));
}
Also used : OperationPermissionTarget(com.haulmont.cuba.gui.app.security.entity.OperationPermissionTarget) PermissionVariant(com.haulmont.cuba.gui.app.security.entity.PermissionVariant) StringUtils(org.apache.commons.lang.StringUtils) java.util(java.util) Predicate(java.util.function.Predicate) CollectionDatasourceImpl(com.haulmont.cuba.gui.data.impl.CollectionDatasourceImpl) AppBeans(com.haulmont.cuba.core.global.AppBeans) UserSessionSource(com.haulmont.cuba.core.global.UserSessionSource) MetaClass(com.haulmont.chile.core.model.MetaClass) PermissionValue(com.haulmont.cuba.gui.app.security.role.edit.PermissionValue) UserSession(com.haulmont.cuba.security.global.UserSession) Permission(com.haulmont.cuba.security.entity.Permission) EntityOp(com.haulmont.cuba.security.entity.EntityOp) PermissionConfig(com.haulmont.cuba.gui.config.PermissionConfig) CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource) PermissionConfig(com.haulmont.cuba.gui.config.PermissionConfig) OperationPermissionTarget(com.haulmont.cuba.gui.app.security.entity.OperationPermissionTarget)

Example 2 with PermissionConfig

use of com.haulmont.cuba.gui.config.PermissionConfig in project cuba by cuba-platform.

the class MultiplePermissionTargetsDatasource method loadData.

@Override
protected void loadData(Map<String, Object> params) {
    if (permissionDs == null)
        return;
    if (targets == null) {
        targets = new ArrayList<>();
        PermissionConfig permissionConfig = AppBeans.get(PermissionConfig.class);
        List<MultiplePermissionTarget> entityAttrs = permissionConfig.getEntityAttributes(AppBeans.get(UserSessionSource.class).getLocale());
        for (MultiplePermissionTarget target : entityAttrs) {
            try {
                MultiplePermissionTarget cloneTarget = target.clone();
                loadPermissionVariants(cloneTarget);
                attachListener(cloneTarget);
                targets.add(cloneTarget);
            } catch (CloneNotSupportedException e) {
                throw new RuntimeException(e);
            }
        }
    }
    clear();
    targets.stream().filter(permittedEntityFilter).filter(t -> permissionsFilter == null || permissionsFilter.test(t)).forEach(t -> data.put(t.getId(), t));
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) java.util(java.util) AttributePermissionVariant(com.haulmont.cuba.gui.app.security.entity.AttributePermissionVariant) Predicate(java.util.function.Predicate) CollectionDatasourceImpl(com.haulmont.cuba.gui.data.impl.CollectionDatasourceImpl) PropertyPermissionValue(com.haulmont.cuba.gui.app.security.role.edit.PropertyPermissionValue) AppBeans(com.haulmont.cuba.core.global.AppBeans) UserSessionSource(com.haulmont.cuba.core.global.UserSessionSource) MetaClass(com.haulmont.chile.core.model.MetaClass) MultiplePermissionTarget(com.haulmont.cuba.gui.app.security.entity.MultiplePermissionTarget) UserSession(com.haulmont.cuba.security.global.UserSession) Permission(com.haulmont.cuba.security.entity.Permission) EntityOp(com.haulmont.cuba.security.entity.EntityOp) PermissionConfig(com.haulmont.cuba.gui.config.PermissionConfig) CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource) PermissionConfig(com.haulmont.cuba.gui.config.PermissionConfig) MultiplePermissionTarget(com.haulmont.cuba.gui.app.security.entity.MultiplePermissionTarget)

Aggregations

MetaClass (com.haulmont.chile.core.model.MetaClass)2 AppBeans (com.haulmont.cuba.core.global.AppBeans)2 UserSessionSource (com.haulmont.cuba.core.global.UserSessionSource)2 PermissionConfig (com.haulmont.cuba.gui.config.PermissionConfig)2 CollectionDatasource (com.haulmont.cuba.gui.data.CollectionDatasource)2 CollectionDatasourceImpl (com.haulmont.cuba.gui.data.impl.CollectionDatasourceImpl)2 EntityOp (com.haulmont.cuba.security.entity.EntityOp)2 Permission (com.haulmont.cuba.security.entity.Permission)2 UserSession (com.haulmont.cuba.security.global.UserSession)2 java.util (java.util)2 Predicate (java.util.function.Predicate)2 StringUtils (org.apache.commons.lang.StringUtils)2 AttributePermissionVariant (com.haulmont.cuba.gui.app.security.entity.AttributePermissionVariant)1 MultiplePermissionTarget (com.haulmont.cuba.gui.app.security.entity.MultiplePermissionTarget)1 OperationPermissionTarget (com.haulmont.cuba.gui.app.security.entity.OperationPermissionTarget)1 PermissionVariant (com.haulmont.cuba.gui.app.security.entity.PermissionVariant)1 PermissionValue (com.haulmont.cuba.gui.app.security.role.edit.PermissionValue)1 PropertyPermissionValue (com.haulmont.cuba.gui.app.security.role.edit.PropertyPermissionValue)1