Search in sources :

Example 6 with SearchFolder

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());
        }
    }
}
Also used : AppFolder(com.haulmont.cuba.core.entity.AppFolder) User(com.haulmont.cuba.security.entity.User) UserSession(com.haulmont.cuba.security.global.UserSession) SearchFolder(com.haulmont.cuba.security.entity.SearchFolder) AppFolder(com.haulmont.cuba.core.entity.AppFolder) SearchFolder(com.haulmont.cuba.security.entity.SearchFolder) Folder(com.haulmont.cuba.core.entity.Folder)

Example 7 with SearchFolder

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);
        }
    }
}
Also used : AppFolder(com.haulmont.cuba.core.entity.AppFolder) AbstractSearchFolder(com.haulmont.cuba.core.entity.AbstractSearchFolder) SearchFolder(com.haulmont.cuba.security.entity.SearchFolder) AppFolder(com.haulmont.cuba.core.entity.AppFolder) AbstractSearchFolder(com.haulmont.cuba.core.entity.AbstractSearchFolder) SearchFolder(com.haulmont.cuba.security.entity.SearchFolder) Folder(com.haulmont.cuba.core.entity.Folder)

Example 8 with SearchFolder

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();
}
Also used : DsContextImplementation(com.haulmont.cuba.gui.data.impl.DsContextImplementation) HashMap(java.util.HashMap) FilterEntity(com.haulmont.cuba.security.entity.FilterEntity) AbstractSearchFolder(com.haulmont.cuba.core.entity.AbstractSearchFolder) SearchFolder(com.haulmont.cuba.security.entity.SearchFolder) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo) WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) Filter(com.haulmont.cuba.gui.components.Filter)

Aggregations

SearchFolder (com.haulmont.cuba.security.entity.SearchFolder)8 AbstractSearchFolder (com.haulmont.cuba.core.entity.AbstractSearchFolder)6 AppFolder (com.haulmont.cuba.core.entity.AppFolder)3 Folder (com.haulmont.cuba.core.entity.Folder)3 MetaClass (com.haulmont.chile.core.model.MetaClass)1 EntityManager (com.haulmont.cuba.core.EntityManager)1 Transaction (com.haulmont.cuba.core.Transaction)1 FoldersService (com.haulmont.cuba.core.app.FoldersService)1 Filter (com.haulmont.cuba.gui.components.Filter)1 WindowConfig (com.haulmont.cuba.gui.config.WindowConfig)1 WindowInfo (com.haulmont.cuba.gui.config.WindowInfo)1 DsContextImplementation (com.haulmont.cuba.gui.data.impl.DsContextImplementation)1 Presentations (com.haulmont.cuba.gui.presentations.Presentations)1 FilterEntity (com.haulmont.cuba.security.entity.FilterEntity)1 User (com.haulmont.cuba.security.entity.User)1 UserSession (com.haulmont.cuba.security.global.UserSession)1 CubaTree (com.haulmont.cuba.web.toolkit.ui.CubaTree)1 ShortcutListener (com.vaadin.event.ShortcutListener)1 HashMap (java.util.HashMap)1 StopWatch (org.perf4j.StopWatch)1