Search in sources :

Example 1 with Security

use of com.haulmont.cuba.core.global.Security in project cuba by cuba-platform.

the class WebTree method setDatasource.

@Override
public void setDatasource(HierarchicalDatasource datasource) {
    Preconditions.checkNotNullArgument(datasource, "datasource is null");
    if (this.datasource != null) {
        throw new UnsupportedOperationException("Changing datasource is not supported by the Tree component");
    }
    this.datasource = datasource;
    this.hierarchyProperty = datasource.getHierarchyPropertyName();
    collectionDsListenersWrapper = createCollectionDsListenersWrapper();
    component.setContainerDataSource(new HierarchicalDsWrapper(datasource, collectionDsListenersWrapper));
    tryToAssignCaptionProperty();
    Security security = AppBeans.get(Security.NAME);
    if (security.isSpecificPermitted(ShowInfoAction.ACTION_PERMISSION)) {
        ShowInfoAction action = (ShowInfoAction) getAction(ShowInfoAction.ACTION_ID);
        if (action == null) {
            action = new ShowInfoAction();
            addAction(action);
        }
        action.setDatasource(datasource);
    }
    collectionDsListenersWrapper.bind(datasource);
    for (Action action : getActions()) {
        action.refreshState();
    }
    assignAutoDebugId();
}
Also used : ShowInfoAction(com.haulmont.cuba.gui.components.ShowInfoAction) ShowInfoAction(com.haulmont.cuba.gui.components.ShowInfoAction) Action(com.haulmont.cuba.gui.components.Action) Security(com.haulmont.cuba.core.global.Security) HierarchicalDsWrapper(com.haulmont.cuba.web.gui.data.HierarchicalDsWrapper)

Example 2 with Security

use of com.haulmont.cuba.core.global.Security in project cuba by cuba-platform.

the class WebFileUploadField method applyPermissions.

protected void applyPermissions() {
    Security security = beanLocator.get(Security.NAME);
    if (!security.isEntityOpPermitted(FileDescriptor.class, EntityOp.UPDATE)) {
        component.setUploadButtonEnabled(false);
        component.setClearButtonEnabled(false);
    }
    if (!security.isEntityOpPermitted(FileDescriptor.class, EntityOp.READ)) {
        component.setFileNameButtonEnabled(false);
    }
}
Also used : Security(com.haulmont.cuba.core.global.Security) FileDescriptor(com.haulmont.cuba.core.entity.FileDescriptor)

Example 3 with Security

use of com.haulmont.cuba.core.global.Security in project cuba by cuba-platform.

the class DiffTreeDatasource method loadPropertyDiff.

protected Node<EntityPropertyDiff> loadPropertyDiff(EntityPropertyDiff propertyDiff) {
    Node<EntityPropertyDiff> diffNode = null;
    if (propertyDiff != null) {
        Security security = AppBeans.get(Security.NAME);
        MetaClass propMetaClass = metadata.getClassNN(propertyDiff.getMetaClassName());
        if (!security.isEntityOpPermitted(propMetaClass, EntityOp.READ) || !security.isEntityAttrPermitted(propMetaClass, propertyDiff.getPropertyName(), EntityAttrAccess.VIEW)) {
            return null;
        }
        diffNode = new Node<>(propertyDiff);
        if (propertyDiff instanceof EntityClassPropertyDiff) {
            EntityClassPropertyDiff classPropertyDiff = (EntityClassPropertyDiff) propertyDiff;
            for (EntityPropertyDiff childPropertyDiff : classPropertyDiff.getPropertyDiffs()) {
                Node<EntityPropertyDiff> childPropDiffNode = loadPropertyDiff(childPropertyDiff);
                if (childPropDiffNode != null)
                    diffNode.addChild(childPropDiffNode);
            }
        } else if (propertyDiff instanceof EntityCollectionPropertyDiff) {
            EntityCollectionPropertyDiff collectionPropertyDiff = (EntityCollectionPropertyDiff) propertyDiff;
            for (EntityPropertyDiff childPropertyDiff : collectionPropertyDiff.getAddedEntities()) {
                Node<EntityPropertyDiff> childPropDiffNode = loadPropertyDiff(childPropertyDiff);
                if (childPropDiffNode != null)
                    diffNode.addChild(childPropDiffNode);
            }
            for (EntityPropertyDiff childPropertyDiff : collectionPropertyDiff.getModifiedEntities()) {
                Node<EntityPropertyDiff> childPropDiffNode = loadPropertyDiff(childPropertyDiff);
                if (childPropDiffNode != null)
                    diffNode.addChild(childPropDiffNode);
            }
            for (EntityPropertyDiff childPropertyDiff : collectionPropertyDiff.getRemovedEntities()) {
                Node<EntityPropertyDiff> childPropDiffNode = loadPropertyDiff(childPropertyDiff);
                if (childPropDiffNode != null)
                    diffNode.addChild(childPropDiffNode);
            }
        }
    }
    return diffNode;
}
Also used : MetaClass(com.haulmont.chile.core.model.MetaClass) EntityCollectionPropertyDiff(com.haulmont.cuba.core.entity.diff.EntityCollectionPropertyDiff) EntityClassPropertyDiff(com.haulmont.cuba.core.entity.diff.EntityClassPropertyDiff) Node(com.haulmont.bali.datastruct.Node) Security(com.haulmont.cuba.core.global.Security) EntityPropertyDiff(com.haulmont.cuba.core.entity.diff.EntityPropertyDiff)

Aggregations

Security (com.haulmont.cuba.core.global.Security)3 Node (com.haulmont.bali.datastruct.Node)1 MetaClass (com.haulmont.chile.core.model.MetaClass)1 FileDescriptor (com.haulmont.cuba.core.entity.FileDescriptor)1 EntityClassPropertyDiff (com.haulmont.cuba.core.entity.diff.EntityClassPropertyDiff)1 EntityCollectionPropertyDiff (com.haulmont.cuba.core.entity.diff.EntityCollectionPropertyDiff)1 EntityPropertyDiff (com.haulmont.cuba.core.entity.diff.EntityPropertyDiff)1 Action (com.haulmont.cuba.gui.components.Action)1 ShowInfoAction (com.haulmont.cuba.gui.components.ShowInfoAction)1 HierarchicalDsWrapper (com.haulmont.cuba.web.gui.data.HierarchicalDsWrapper)1