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();
}
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);
}
}
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;
}
Aggregations