use of com.haulmont.cuba.security.entity.SearchFolder in project cuba by cuba-platform.
the class FoldersServiceBean method checkImportPermissions.
protected void checkImportPermissions(Folder folder) {
UserSession userSession = userSessionSource.getUserSession();
if (folder instanceof SearchFolder) {
SearchFolder searchFolder = (SearchFolder) folder;
User currentUser = userSession.getCurrentOrSubstitutedUser();
if (searchFolder.getUser() != null && !currentUser.equals(searchFolder.getUser())) {
throw new AccessDeniedException(PermissionType.ENTITY_OP, Folder.class.getSimpleName());
}
if (searchFolder.getUser() == null && !userSession.isSpecificPermitted("cuba.gui.searchFolder.global")) {
throw new AccessDeniedException(PermissionType.ENTITY_OP, Folder.class.getSimpleName());
}
}
if (folder instanceof AppFolder) {
if (!userSession.isSpecificPermitted("cuba.gui.appFolder.global")) {
throw new AccessDeniedException(PermissionType.ENTITY_OP, Folder.class.getSimpleName());
}
}
}
use of com.haulmont.cuba.security.entity.SearchFolder in project cuba by cuba-platform.
the class CubaFoldersPane method fillTree.
protected void fillTree(Tree tree, List<? extends Folder> folders, Object rootItemId) {
if (rootItemId != null) {
tree.addItem(rootItemId);
}
for (Folder folder : folders) {
tree.addItem(folder);
setFolderTreeItemCaption(tree, folder);
if (webConfig.getShowFolderIcons()) {
if (folder instanceof SearchFolder) {
if (BooleanUtils.isTrue(((SearchFolder) folder).getIsSet())) {
tree.setItemIcon(folder, WebComponentsHelper.getIcon("icons/set-small.png"));
} else {
tree.setItemIcon(folder, WebComponentsHelper.getIcon("icons/search-folder-small.png"));
}
} else if (folder instanceof AppFolder) {
tree.setItemIcon(folder, WebComponentsHelper.getIcon("icons/app-folder-small.png"));
}
}
}
for (Folder folder : folders) {
if (folder.getParent() == null) {
tree.setParent(folder, rootItemId);
} else {
if (tree.getItem(folder.getParent()) != null)
tree.setParent(folder, folder.getParent());
else
tree.setParent(folder, rootItemId);
}
}
for (Folder folder : folders) {
if (!tree.hasChildren(folder)) {
tree.setChildrenAllowed(folder, false);
}
}
}
use of com.haulmont.cuba.security.entity.SearchFolder in project cuba by cuba-platform.
the class FoldersBean method openFolder.
@Override
public void openFolder(AbstractSearchFolder folder) {
if (StringUtils.isBlank(folder.getFilterComponentId())) {
log.warn("Unable to open folder: componentId is blank");
return;
}
String[] strings = ValuePathHelper.parse(folder.getFilterComponentId());
String screenId = strings[0];
WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
WindowInfo windowInfo = windowConfig.getWindowInfo(screenId);
Map<String, Object> params = new HashMap<>();
WindowParams.DISABLE_AUTO_REFRESH.set(params, true);
WindowParams.DISABLE_RESUME_SUSPENDED.set(params, true);
if (!StringUtils.isBlank(folder.getTabName())) {
WindowParams.DESCRIPTION.set(params, messages.getMainMessage(folder.getTabName()));
} else {
WindowParams.DESCRIPTION.set(params, messages.getMainMessage(folder.getName()));
}
WindowParams.FOLDER_ID.set(params, folder.getId());
com.haulmont.cuba.gui.components.Window window = App.getInstance().getWindowManager().openWindow(windowInfo, OpenType.NEW_TAB, params);
Filter filterComponent = null;
if (strings.length > 1) {
String filterComponentId = StringUtils.join(Arrays.copyOfRange(strings, 1, strings.length), '.');
filterComponent = (Filter) window.getComponentNN(filterComponentId);
FilterEntity filterEntity = metadata.create(FilterEntity.class);
filterEntity.setFolder(folder);
filterEntity.setComponentId(folder.getFilterComponentId());
filterEntity.setName(folder.getLocName());
filterEntity.setXml(folder.getFilterXml());
filterEntity.setApplyDefault(BooleanUtils.isNotFalse(folder.getApplyDefault()));
if (folder instanceof SearchFolder) {
filterEntity.setIsSet(((SearchFolder) folder).getIsSet());
}
filterComponent.setFilterEntity(filterEntity);
filterComponent.switchFilterMode(FilterDelegate.FilterMode.GENERIC_MODE);
}
if (filterComponent != null && folder instanceof SearchFolder) {
final SearchFolder searchFolder = (SearchFolder) folder;
if (searchFolder.getPresentation() != null) {
((com.haulmont.cuba.gui.components.Component.HasPresentations) filterComponent.getApplyTo()).applyPresentation(searchFolder.getPresentation().getId());
}
}
((DsContextImplementation) window.getDsContext()).resumeSuspended();
}
Aggregations