a_cmsuserslist.java
来自「找了很久才找到到源代码」· Java 代码 · 共 741 行 · 第 1/3 页
JAVA
741 行
Map params = new HashMap();
params.put(A_CmsEditUserDialog.PARAM_USERID, userId);
params.put(A_CmsOrgUnitDialog.PARAM_OUFQN, getParamOufqn());
// set action parameter to initial dialog call
params.put(CmsDialog.PARAM_ACTION, CmsDialog.DIALOG_INITIAL);
if (getParamListAction().equals(LIST_ACTION_ROLE)) {
getToolManager().jspForwardTool(this, getCurrentToolPath() + "/edit/role", params);
} else if (getParamListAction().equals(LIST_DEFACTION_EDIT)) {
// forward to the edit user screen
getToolManager().jspForwardTool(this, getCurrentToolPath() + "/edit", params);
} else if (m_editActionIds.contains(getParamListAction())) {
getToolManager().jspForwardTool(this, getCurrentToolPath() + "/edit/user", params);
} else if (getParamListAction().equals(LIST_ACTION_GROUPS)) {
getToolManager().jspForwardTool(this, getCurrentToolPath() + "/edit/groups", params);
} else if (m_deleteActionIds.contains(getParamListAction())) {
getToolManager().jspForwardTool(this, getCurrentToolPath() + "/edit/delete", params);
} else if (getParamListAction().equals(LIST_ACTION_ACTIVATE)) {
// execute the activate action
try {
CmsUser user = readUser(userName);
user.setEnabled(true);
getCms().writeUser(user);
} catch (CmsException e) {
throw new CmsRuntimeException(Messages.get().container(Messages.ERR_ACTIVATE_USER_1, userName), e);
}
} else if (getParamListAction().equals(LIST_ACTION_DEACTIVATE)) {
// execute the activate action
try {
CmsUser user = readUser(userName);
user.setEnabled(false);
getCms().writeUser(user);
} catch (CmsException e) {
throw new CmsRuntimeException(Messages.get().container(Messages.ERR_DEACTIVATE_USER_1, userName), e);
}
} else {
throwListUnsupportedActionException();
}
listSave();
}
/**
* Returns the organizational unit fqn parameter value.<p>
*
* @return the organizational unit fqn parameter value
*/
public String getParamOufqn() {
return m_paramOufqn;
}
/**
* 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;
}
/**
* @see org.opencms.workplace.list.A_CmsListDialog#fillDetails(java.lang.String)
*/
protected void fillDetails(String detailId) {
// get content
List users = getList().getAllContent();
Iterator itUsers = users.iterator();
while (itUsers.hasNext()) {
CmsListItem item = (CmsListItem)itUsers.next();
String userName = item.get(LIST_COLUMN_LOGIN).toString();
StringBuffer html = new StringBuffer(512);
try {
if (detailId.equals(LIST_DETAIL_ADDRESS)) {
CmsUser user = readUser(userName);
// address
html.append(user.getAddress());
if (user.getCity() != null) {
html.append("<br>");
if (user.getZipcode() != null) {
html.append(user.getZipcode());
html.append(" ");
}
html.append(user.getCity());
}
if (user.getCountry() != null) {
html.append("<br>");
html.append(user.getCountry());
}
} else if (detailId.equals(LIST_DETAIL_GROUPS)) {
// groups
List groups = getCms().getGroupsOfUser(userName, true, true);
Iterator itGroups = groups.iterator();
while (itGroups.hasNext()) {
CmsGroup group = (CmsGroup)itGroups.next();
if (group.getOuFqn().equals(getParamOufqn())) {
html.append(group.getSimpleName());
} else {
html.append(group.getDisplayName(getCms(), getLocale()));
}
if (itGroups.hasNext()) {
html.append("<br>");
}
html.append("\n");
}
} else if (detailId.equals(LIST_DETAIL_ROLES)) {
// roles
boolean otherOuRole = false;
List roles = OpenCms.getRoleManager().getRolesOfUser(getCms(), userName, "/", true, true, false);
Iterator itRoles = roles.iterator();
while (itRoles.hasNext()) {
CmsRole role = (CmsRole)itRoles.next();
if (!role.getOuFqn().equals(getParamOufqn())) {
otherOuRole = true;
break;
}
}
itRoles = roles.iterator();
while (itRoles.hasNext()) {
CmsRole role = (CmsRole)itRoles.next();
if (!otherOuRole) {
html.append(role.getName(getLocale()));
} else {
html.append(role.getDisplayName(getCms(), getLocale()));
}
if (itRoles.hasNext()) {
html.append("<br>");
}
html.append("\n");
}
} else {
continue;
}
} catch (Exception e) {
// noop
}
item.set(detailId, html.toString());
}
}
/**
* Returns the path the group icon.<p>
*
* @return the path to the group icon
*/
protected abstract String getGroupIcon();
/**
* @see org.opencms.workplace.list.A_CmsListDialog#getListItems()
*/
protected List getListItems() throws CmsException {
List ret = new ArrayList();
// get content
List users = getUsers();
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_DISPLAY, user.getSimpleName());
item.set(LIST_COLUMN_NAME, user.getFullName());
item.set(LIST_COLUMN_EMAIL, user.getEmail());
item.set(LIST_COLUMN_LASTLOGIN, new Date(user.getLastlogin()));
ret.add(item);
}
return ret;
}
/**
* Returns the path the role edit icon.<p>
*
* @return the path to the role edit icon
*/
protected String getRoleIcon() {
return PATH_BUTTONS + "role.png";
}
/**
* Returns the path the switch user icon.<p>
*
* @return the path to the switch user icon
*/
protected String getSwitchIcon() {
return PATH_BUTTONS + "user_switch.png";
}
/**
* Returns a list of users.<p>
*
* @return the list of all users
*
* @throws CmsException if something goes wrong
*/
protected abstract List getUsers() throws CmsException;
/**
* @see org.opencms.workplace.CmsWorkplace#initMessages()
*/
protected void initMessages() {
// add specific dialog resource bundle
addMessages(Messages.get().getBundleName());
// add default resource bundles
super.initMessages();
}
/**
* Reads the user.<p>
*
* @param name the name of the user to read
*
* @return the user
*
* @throws CmsException if something goes wrong
*/
protected abstract CmsUser readUser(String name) throws CmsException;
/**
* @see org.opencms.workplace.list.A_CmsListDialog#setColumns(org.opencms.workplace.list.CmsListMetadata)
*/
protected void setColumns(CmsListMetadata metadata) {
// create column for edit
CmsListColumnDefinition editCol = new CmsListColumnDefinition(LIST_COLUMN_EDIT);
editCol.setName(Messages.get().container(Messages.GUI_USERS_LIST_COLS_EDIT_0));
editCol.setHelpText(Messages.get().container(Messages.GUI_USERS_LIST_COLS_EDIT_HELP_0));
editCol.setWidth("20");
editCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
editCol.setSorteable(false);
// add edit action
setEditAction(editCol);
m_editActionIds.addAll(editCol.getDirectActionIds());
// add it to the list definition
metadata.addColumn(editCol);
// create column for group edition
CmsListColumnDefinition groupCol = new CmsListColumnDefinition(LIST_COLUMN_GROUPS);
groupCol.setName(Messages.get().container(Messages.GUI_USERS_LIST_COLS_GROUPS_0));
groupCol.setHelpText(Messages.get().container(Messages.GUI_USERS_LIST_COLS_GROUPS_HELP_0));
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?