a_cmsroleuserslist.java
来自「找了很久才找到到源代码」· Java 代码 · 共 488 行 · 第 1/2 页
JAVA
488 行
/*
* File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/accounts/A_CmsRoleUsersList.java,v $
* Date : $Date: 2007-08-13 16:29:46 $
* Version: $Revision: 1.3 $
*
* This library is part of OpenCms -
* the Open Source Content Management System
*
* Copyright (c) 2002 - 2007 Alkacon Software GmbH (http://www.alkacon.com)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* For further information about Alkacon Software GmbH, please see the
* company website: http://www.alkacon.com
*
* For further information about OpenCms, please see the
* project website: http://www.opencms.org
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.opencms.workplace.tools.accounts;
import org.opencms.file.CmsUser;
import org.opencms.i18n.CmsMessageContainer;
import org.opencms.jsp.CmsJspActionElement;
import org.opencms.main.CmsException;
import org.opencms.main.OpenCms;
import org.opencms.security.CmsOrganizationalUnit;
import org.opencms.security.CmsRole;
import org.opencms.workplace.CmsWorkplace;
import org.opencms.workplace.list.A_CmsListDialog;
import org.opencms.workplace.list.CmsListColumnAlignEnum;
import org.opencms.workplace.list.CmsListColumnDefinition;
import org.opencms.workplace.list.CmsListDirectAction;
import org.opencms.workplace.list.CmsListIndependentAction;
import org.opencms.workplace.list.CmsListItem;
import org.opencms.workplace.list.CmsListItemDetails;
import org.opencms.workplace.list.CmsListItemDetailsFormatter;
import org.opencms.workplace.list.CmsListMetadata;
import org.opencms.workplace.list.CmsListOrderEnum;
import org.opencms.workplace.tools.A_CmsHtmlIconButton;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* Generalized role users view.<p>
*
* @author Raphael Schnuck
*
* @version $Revision: 1.3 $
*
* @since 6.5.6
*/
public abstract class A_CmsRoleUsersList extends A_CmsListDialog {
/** list action id constant. */
public static final String LIST_ACTION_ICON = "ai";
/** list column id constant. */
public static final String LIST_COLUMN_FULLNAME = "cf";
/** list column id constant. */
public static final String LIST_COLUMN_ICON = "ci";
/** list column id constant. */
public static final String LIST_COLUMN_LOGIN = "cl";
/** list column id constant. */
public static final String LIST_COLUMN_NAME = "cn";
/** list column id constant. */
public static final String LIST_COLUMN_ORGUNIT = "co";
/** list column id constant. */
public static final String LIST_COLUMN_STATE = "cs";
/** list item detail id constant. */
public static final String LIST_DETAIL_ORGUNIT = "dou";
/** Path to the list buttons. */
public static final String PATH_BUTTONS = "tools/accounts/buttons/";
/** Cached value. */
private Boolean m_hasUsersInOtherOus;
/** Stores the value of the request parameter for the organizational unit fqn. */
private String m_paramOufqn;
/** Stores the value of the request parameter for the role name. */
private String m_paramRole;
/**
* Public constructor.<p>
*
* @param jsp an initialized JSP action element
* @param listId the id of the list
* @param listName the name of the list
* @param searchable searchable flag
*/
protected A_CmsRoleUsersList(
CmsJspActionElement jsp,
String listId,
CmsMessageContainer listName,
boolean searchable) {
super(jsp, listId, listName, LIST_COLUMN_LOGIN, CmsListOrderEnum.ORDER_ASCENDING, searchable ? LIST_COLUMN_NAME
: null);
}
/**
* Returns the organizational unit fqn parameter value.<p>
*
* @return the organizational unit fqn parameter value
*/
public String getParamOufqn() {
return m_paramOufqn;
}
/**
* Returns the role name parameter value.<p>
*
* @return the role name parameter value
*/
public String getParamRole() {
return m_paramRole;
}
/**
* Returns if the list of users has users of other organizational units.<p>
*
* @return if the list of users has users of other organizational units
*/
public boolean hasUsersInOtherOus() {
if (m_hasUsersInOtherOus == null) {
// lazzy initialization
m_hasUsersInOtherOus = Boolean.FALSE;
try {
Iterator itUsers = getUsers(true).iterator();
while (itUsers.hasNext()) {
CmsUser user = (CmsUser)itUsers.next();
if (!user.getOuFqn().equals(getParamOufqn())) {
m_hasUsersInOtherOus = Boolean.TRUE;
break;
}
}
} catch (Exception e) {
// ignore
}
}
return m_hasUsersInOtherOus.booleanValue();
}
/**
* Sets the organizational unit fqn parameter value.<p>
*
* @param ouFqn the organizational unit fqn parameter value
*/
public void setParamOufqn(String ouFqn) {
if (ouFqn == null) {
ouFqn = "";
}
m_paramOufqn = ouFqn;
}
/**
* Sets the role name parameter value.<p>
*
* @param roleName the role name parameter value
*/
public void setParamRole(String roleName) {
m_paramRole = roleName;
}
/**
* @see org.opencms.workplace.list.A_CmsListDialog#fillDetails(java.lang.String)
*/
protected void fillDetails(String detailId) {
// noop
}
/**
* @see org.opencms.workplace.list.A_CmsListDialog#getListItems()
*/
protected List getListItems() throws CmsException {
List ret = new ArrayList();
boolean withOtherOus = hasUsersInOtherOus()
&& getList().getMetadata().getItemDetailDefinition(LIST_DETAIL_ORGUNIT).isVisible();
// get content
List users = getUsers(withOtherOus);
Iterator itUsers = users.iterator();
while (itUsers.hasNext()) {
CmsUser user = (CmsUser)itUsers.next();
CmsListItem item = getList().newItem(user.getId().toString());
item.set(LIST_COLUMN_LOGIN, user.getName());
item.set(LIST_COLUMN_NAME, user.getSimpleName());
item.set(LIST_COLUMN_ORGUNIT, CmsOrganizationalUnit.SEPARATOR + user.getOuFqn());
item.set(LIST_COLUMN_FULLNAME, user.getFullName());
ret.add(item);
}
return ret;
}
/**
* Returns a list of users to display.<p>
*
* @param withOtherOus if not set only users of the current ou should be returned
*
* @return a list of <code><{@link CmsUser}</code>s
*
* @throws CmsException if something goes wrong
*/
protected abstract List getUsers(boolean withOtherOus) throws CmsException;
/**
* @see org.opencms.workplace.list.A_CmsListDialog#initializeDetail(java.lang.String)
*/
protected void initializeDetail(String detailId) {
super.initializeDetail(detailId);
if (detailId.equals(LIST_DETAIL_ORGUNIT)) {
boolean visible = hasUsersInOtherOus()
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?