⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmsgroupdependencieslist.java

📁 cms是开源的框架
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        result.append("', form);\" class='dialogbutton'>\n");
        if (getList().getTotalSize() > 0) {
            result.append("<input name='");
            result.append(TRANSFER_ACTION);
            result.append("' type='button' value='");
            result.append(Messages.get().container(Messages.GUI_DEPENDENCIES_BUTTON_TRANSFER_0).key(getLocale()));
            result.append("' onclick=\"submitAction('");
            result.append(TRANSFER_ACTION);
            result.append("', form);\" class='dialogbutton'>\n");
        }
        dialogButtonsHtml(result, BUTTON_CANCEL, "");
        result.append(dialogButtonRow(HTML_END));
        result.append("</form>\n");
        return result.toString();
    }

    /**
     * @see org.opencms.workplace.list.A_CmsListDialog#customHtmlStart()
     */
    protected String customHtmlStart() {

        StringBuffer result = new StringBuffer(512);
        result.append(dialogBlockStart(Messages.get().container(Messages.GUI_GROUP_DEPENDENCIES_NOTICE_0).key(
            getLocale())));
        if (getCurrentToolPath().indexOf("/edit/") < 0) {
            result.append(key(Messages.GUI_GROUP_DEPENDENCIES_SELECTED_GROUPS_0));
            result.append(":<br>\n");
            List users = CmsStringUtil.splitAsList(getGroupName(), CmsHtmlList.ITEM_SEPARATOR, true);
            result.append("<ul>\n");
            Iterator it = users.iterator();
            while (it.hasNext()) {
                String name = (String)it.next();
                result.append("<li>");
                result.append(name);
                result.append("</li>\n");
            }
            result.append("</ul>\n");
        }
        if (getList().getTotalSize() > 0) {
            result.append(key(Messages.GUI_GROUP_DEPENDENCIES_NOTICE_TEXT_0));
        } else {
            result.append(key(Messages.GUI_GROUP_DEPENDENCIES_DELETE_0));
        }
        result.append(dialogBlockEnd());
        return result.toString();
    }

    /**
     * @see org.opencms.workplace.list.A_CmsListDialog#fillDetails(java.lang.String)
     */
    protected void fillDetails(String detailId) {

        // no-op
    }

    /**
     * @see org.opencms.workplace.list.A_CmsListDialog#getListItems()
     */
    protected List getListItems() throws CmsException {

        CmsIdentifiableObjectContainer ret = new CmsIdentifiableObjectContainer(true, false);
        Iterator itGroups = CmsStringUtil.splitAsList(getParamGroupid(), CmsHtmlList.ITEM_SEPARATOR, true).iterator();
        getCms().getRequestContext().saveSiteRoot();
        getCms().getRequestContext().setSiteRoot("/");
        while (itGroups.hasNext()) {
            CmsGroup group = getCms().readGroup(new CmsUUID(itGroups.next().toString()));
            // get content
            List resources = getCms().getResourcesForPrincipal(group.getId(), null, true);
            Iterator itRes = resources.iterator();
            while (itRes.hasNext()) {
                CmsResource resource = (CmsResource)itRes.next();
                CmsListItem item = (CmsListItem)ret.getObject(resource.getResourceId().toString());
                if (item == null) {
                    item = getList().newItem(resource.getResourceId().toString());
                    item.set(LIST_COLUMN_NAME, resource.getRootPath());
                    item.set(LIST_COLUMN_TYPE, new Integer(resource.getTypeId()));
                    Iterator itAces = getCms().getAccessControlEntries(resource.getRootPath(), false).iterator();
                    while (itAces.hasNext()) {
                        CmsAccessControlEntry ace = (CmsAccessControlEntry)itAces.next();
                        if (ace.getPrincipal().equals(group.getId())) {
                            if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(ace.getPermissions().getPermissionString())) {
                                item.set(LIST_COLUMN_PERMISSIONS, group.getName()
                                    + ": "
                                    + ace.getPermissions().getPermissionString());
                            }
                            break;
                        }
                    }
                    ret.addIdentifiableObject(item.getId(), item);
                } else {
                    String oldData = (String)item.get(LIST_COLUMN_PERMISSIONS);
                    Iterator itAces = getCms().getAccessControlEntries(resource.getRootPath(), false).iterator();
                    while (itAces.hasNext()) {
                        CmsAccessControlEntry ace = (CmsAccessControlEntry)itAces.next();
                        if (ace.getPrincipal().equals(group.getId())) {
                            if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(ace.getPermissions().getPermissionString())) {
                                String data = group.getName() + ": " + ace.getPermissions().getPermissionString();
                                if (oldData != null) {
                                    data = oldData + ", " + data;
                                }
                                item.set(LIST_COLUMN_PERMISSIONS, data);
                            }
                            break;
                        }
                    }
                }
            }
            // add users
            Iterator itUsers = getCms().getUsersOfGroup(group.getName()).iterator();
            while (itUsers.hasNext()) {
                CmsUser user = (CmsUser)itUsers.next();
                CmsListItem item = (CmsListItem)ret.getObject(user.getId().toString());
                if (item == null) {
                    item = getList().newItem(user.getId().toString());
                    item.set(LIST_COLUMN_NAME, user.getName());
                    item.set(LIST_COLUMN_PERMISSIONS, "--");
                    ret.addIdentifiableObject(item.getId(), item);
                }
            }
            // add child groups
            Iterator itChilds = getCms().getChild(group.getName()).iterator();
            while (itChilds.hasNext()) {
                CmsGroup child = (CmsGroup)itChilds.next();
                CmsListItem item = (CmsListItem)ret.getObject(child.getId().toString());
                if (item == null) {
                    item = getList().newItem(child.getId().toString());
                    item.set(LIST_COLUMN_NAME, child.getName());
                    item.set(LIST_COLUMN_PERMISSIONS, "--");
                    ret.addIdentifiableObject(item.getId(), item);
                }
            }
        }
        getCms().getRequestContext().restoreSiteRoot();
        return ret.elementList();
    }

    /**
     * @see org.opencms.workplace.CmsWorkplace#initMessages()
     */
    protected void initMessages() {

        // add specific dialog resource bundle
        addMessages(Messages.get().getBundleName());
        // add cms dialog resource bundle
        addMessages(org.opencms.workplace.Messages.get().getBundleName());
        // add default resource bundles
        super.initMessages();
    }

    /**
     * @see org.opencms.workplace.list.A_CmsListDialog#initWorkplaceRequestValues(org.opencms.workplace.CmsWorkplaceSettings, javax.servlet.http.HttpServletRequest)
     */
    protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest request) {

        super.initWorkplaceRequestValues(settings, request);
        if (DELETE_ACTION.equals(getParamAction())) {
            setAction(ACTION_DELETE);
        } else if (TRANSFER_ACTION.equals(getParamAction())) {
            setAction(ACTION_TRANSFER);
        }
    }

    /**
     * @see org.opencms.workplace.list.A_CmsListDialog#setColumns(org.opencms.workplace.list.CmsListMetadata)
     */
    protected void setColumns(CmsListMetadata metadata) {

        // create column for edit
        CmsListColumnDefinition iconCol = new CmsListColumnDefinition(LIST_COLUMN_ICON);
        iconCol.setName(Messages.get().container(Messages.GUI_GROUP_DEPENDENCIES_LIST_COLS_ICON_0));
        iconCol.setHelpText(Messages.get().container(Messages.GUI_GROUP_DEPENDENCIES_LIST_COLS_ICON_HELP_0));
        iconCol.setWidth("20");
        iconCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
        iconCol.setListItemComparator(new CmsListItemActionIconComparator());

        // add icon actions
        setIconActions(iconCol);

        // add it to the list definition
        metadata.addColumn(iconCol);

        // add column for name
        CmsListColumnDefinition nameCol = new CmsListColumnDefinition(LIST_COLUMN_NAME);
        nameCol.setName(Messages.get().container(Messages.GUI_GROUP_DEPENDENCIES_LIST_COLS_NAME_0));
        nameCol.setWidth("80%");
        metadata.addColumn(nameCol);

        // add column for permissions
        CmsListColumnDefinition permissionsCol = new CmsListColumnDefinition(LIST_COLUMN_PERMISSIONS);
        permissionsCol.setName(Messages.get().container(Messages.GUI_GROUP_DEPENDENCIES_LIST_COLS_PERMISSIONS_0));
        permissionsCol.setWidth("20%");
        metadata.addColumn(permissionsCol);

        // add column for type
        CmsListColumnDefinition typeCol = new CmsListColumnDefinition(LIST_COLUMN_TYPE);
        typeCol.setName(new CmsMessageContainer(null, "type"));
        typeCol.setVisible(false);
        metadata.addColumn(typeCol);
    }

    /**
     * Sets the right icon actions for the dialog.<p>
     * 
     * @param iconCol the column to set the actions
     */
    protected void setIconActions(CmsListColumnDefinition iconCol) {

        // add resource icon action
        CmsListDirectAction resourceIconAction = new CmsDependencyIconAction(
            LIST_ACTION_ICON,
            CmsDependencyIconActionType.RESOURCE,
            getCms());
        resourceIconAction.setName(Messages.get().container(Messages.GUI_GROUP_DEPENDENCIES_LIST_ACTION_RES_NAME_0));
        resourceIconAction.setHelpText(Messages.get().container(Messages.GUI_GROUP_DEPENDENCIES_LIST_ACTION_RES_HELP_0));
        resourceIconAction.setEnabled(false);
        iconCol.addDirectAction(resourceIconAction);

        // add group icon action
        CmsListDirectAction groupIconAction = new CmsDependencyIconAction(
            LIST_ACTION_ICON,
            CmsDependencyIconActionType.GROUP,
            getCms());
        groupIconAction.setName(Messages.get().container(Messages.GUI_GROUP_DEPENDENCIES_LIST_ACTION_GRP_NAME_0));
        groupIconAction.setHelpText(Messages.get().container(Messages.GUI_GROUP_DEPENDENCIES_LIST_ACTION_GRP_HELP_0));
        groupIconAction.setEnabled(false);
        iconCol.addDirectAction(groupIconAction);

        // add group icon action
        CmsListDirectAction userIconAction = new CmsDependencyIconAction(
            LIST_ACTION_ICON,
            CmsDependencyIconActionType.USER,
            getCms());
        userIconAction.setName(Messages.get().container(Messages.GUI_GROUP_DEPENDENCIES_LIST_ACTION_USR_NAME_0));
        userIconAction.setHelpText(Messages.get().container(Messages.GUI_GROUP_DEPENDENCIES_LIST_ACTION_USR_HELP_0));
        userIconAction.setEnabled(false);
        iconCol.addDirectAction(userIconAction);
    }

    /**
     * @see org.opencms.workplace.list.A_CmsListDialog#setIndependentActions(org.opencms.workplace.list.CmsListMetadata)
     */
    protected void setIndependentActions(CmsListMetadata metadata) {

        // no-op
    }

    /**
     * @see org.opencms.workplace.list.A_CmsListDialog#setMultiActions(org.opencms.workplace.list.CmsListMetadata)
     */
    protected void setMultiActions(CmsListMetadata metadata) {

        // no-op
    }

    /**
     * @see org.opencms.workplace.list.A_CmsListDialog#validateParamaters()
     */
    protected void validateParamaters() throws Exception {

        // test the needed parameters
        m_groupName = "";
        Iterator itGroups = CmsStringUtil.splitAsList(getParamGroupid(), CmsHtmlList.ITEM_SEPARATOR, true).iterator();
        while (itGroups.hasNext()) {
            CmsUUID id = new CmsUUID(itGroups.next().toString());
            m_groupName += getCms().readGroup(id).getName();
            if (itGroups.hasNext()) {
                m_groupName += CmsHtmlList.ITEM_SEPARATOR;
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -