a_cmsgroupslist.java
来自「找了很久才找到到源代码」· Java 代码 · 共 678 行 · 第 1/3 页
JAVA
678 行
* @see org.opencms.workplace.list.A_CmsListDialog#executeListSingleActions()
*/
public void executeListSingleActions() throws IOException, ServletException, CmsRuntimeException {
String groupId = getSelectedItem().getId();
String groupName = getSelectedItem().get(LIST_COLUMN_NAME).toString();
Map params = new HashMap();
params.put(A_CmsEditGroupDialog.PARAM_GROUPID, groupId);
params.put(A_CmsOrgUnitDialog.PARAM_OUFQN, m_paramOufqn);
params.put(A_CmsEditGroupDialog.PARAM_GROUPNAME, groupName);
// set action parameter to initial dialog call
params.put(CmsDialog.PARAM_ACTION, CmsDialog.DIALOG_INITIAL);
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/group", params);
} else if (getParamListAction().equals(LIST_ACTION_USERS)) {
getToolManager().jspForwardTool(this, getCurrentToolPath() + "/edit/users", 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 {
CmsGroup group = getCms().readGroup(groupName);
group.setEnabled(true);
getCms().writeGroup(group);
} catch (CmsException e) {
throw new CmsRuntimeException(Messages.get().container(Messages.ERR_ACTIVATE_GROUP_1, groupName), e);
}
} else if (getParamListAction().equals(LIST_ACTION_DEACTIVATE)) {
// execute the activate action
try {
CmsGroup group = getCms().readGroup(groupName);
group.setEnabled(false);
getCms().writeGroup(group);
} catch (CmsException e) {
throw new CmsRuntimeException(Messages.get().container(Messages.ERR_DEACTIVATE_GROUP_1, groupName), 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 groups = getList().getAllContent();
Iterator itGroups = groups.iterator();
while (itGroups.hasNext()) {
CmsListItem item = (CmsListItem)itGroups.next();
String groupName = item.get(LIST_COLUMN_NAME).toString();
StringBuffer html = new StringBuffer(512);
try {
if (detailId.equals(LIST_DETAIL_USERS)) {
// users
List users = getCms().getUsersOfGroup(groupName, true);
Iterator itUsers = users.iterator();
while (itUsers.hasNext()) {
CmsUser user = (CmsUser)itUsers.next();
if (user.getOuFqn().equals(getParamOufqn())) {
html.append(user.getFullName());
} else {
html.append(user.getDisplayName(getCms(), getLocale()));
}
if (itUsers.hasNext()) {
html.append("<br>");
}
html.append("\n");
}
} else if (detailId.equals(LIST_DETAIL_CHILDREN)) {
// childen
Iterator itChildren = getCms().getChildren(groupName, false).iterator();
while (itChildren.hasNext()) {
CmsGroup group = (CmsGroup)itChildren.next();
if (group.getOuFqn().equals(getParamOufqn())) {
html.append(group.getSimpleName());
} else {
html.append(group.getDisplayName(getCms(), getLocale()));
}
if (itChildren.hasNext()) {
html.append("<br>");
}
html.append("\n");
}
} else if (detailId.equals(LIST_DETAIL_PARENT)) {
// parent
CmsGroup parent = getCms().readGroup(getCms().readGroup(groupName).getParentId());
html.append(parent.getName());
} else if (detailId.equals(LIST_DETAIL_SET_PERM)) {
// folder permissions
String storedSiteRoot = getCms().getRequestContext().getSiteRoot();
try {
getCms().getRequestContext().setSiteRoot("/");
CmsGroup group = getCms().readGroup(groupName);
Iterator itRes = getCms().getResourcesForPrincipal(group.getId(), null, false).iterator();
while (itRes.hasNext()) {
CmsResource resource = (CmsResource)itRes.next();
html.append(resource.getRootPath());
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())) {
html.append(" (" + ace.getPermissions().getPermissionString() + ")");
}
break;
}
}
if (itRes.hasNext()) {
html.append("<br>");
}
html.append("\n");
}
} finally {
getCms().getRequestContext().setSiteRoot(storedSiteRoot);
}
} else {
continue;
}
} catch (Exception e) {
// ignore
}
item.set(detailId, html.toString());
}
}
/**
* Returns a list of groups.<p>
*
* @return the list of all groups
*
* @throws CmsException if something goes wrong
*/
protected abstract List getGroups() throws CmsException;
/**
* @see org.opencms.workplace.list.A_CmsListDialog#getListItems()
*/
protected List getListItems() throws CmsException {
List ret = new ArrayList();
// get content
List groups = getGroups();
Iterator itGroups = groups.iterator();
while (itGroups.hasNext()) {
CmsGroup group = (CmsGroup)itGroups.next();
CmsListItem item = getList().newItem(group.getId().toString());
item.set(LIST_COLUMN_NAME, group.getName());
item.set(LIST_COLUMN_DISPLAY, group.getSimpleName());
item.set(LIST_COLUMN_DESCRIPTION, group.getDescription(getLocale()));
ret.add(item);
}
return ret;
}
/**
* @see org.opencms.workplace.CmsWorkplace#initMessages()
*/
protected void initMessages() {
// add specific dialog resource bundle
addMessages(Messages.get().getBundleName());
// add default resource bundles
super.initMessages();
}
/**
* @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_GROUPS_LIST_COLS_EDIT_0));
editCol.setHelpText(Messages.get().container(Messages.GUI_GROUPS_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 usersCol = new CmsListColumnDefinition(LIST_COLUMN_USERS);
usersCol.setName(Messages.get().container(Messages.GUI_GROUPS_LIST_COLS_USERS_0));
usersCol.setHelpText(Messages.get().container(Messages.GUI_GROUPS_LIST_COLS_USERS_HELP_0));
usersCol.setWidth("20");
usersCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
usersCol.setSorteable(false);
// add groups action
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?