cmsuserdataexportdialog.java
来自「找了很久才找到到源代码」· Java 代码 · 共 449 行 · 第 1/2 页
JAVA
449 行
CmsUser user = (CmsUser)itUsers.next();
if (!exportUsers.containsKey(user.getId())) {
exportUsers.put(user.getId(), user);
}
}
}
return exportUsers;
}
/**
* Returns a map with the users to export added.<p>
*
* @param exportUsers the map to add the users
* @return a map with the users to export added
* @throws CmsException if getting groups or users of group failed
*/
public Map getExportUsersFromGroups(Map exportUsers) throws CmsException {
List groups = getGroups();
if (groups != null && groups.size() > 0) {
Iterator itGroups = groups.iterator();
while (itGroups.hasNext()) {
List groupUsers = getCms().getUsersOfGroup((String)itGroups.next());
Iterator itGroupUsers = groupUsers.iterator();
while (itGroupUsers.hasNext()) {
CmsUser groupUser = (CmsUser)itGroupUsers.next();
if (!exportUsers.containsKey(groupUser.getId())) {
exportUsers.put(groupUser.getId(), groupUser);
}
}
}
}
return exportUsers;
}
/**
* Returns a map with the users to export added.<p>
*
* @param exportUsers the map to add the users
* @return a map with the users to export added
* @throws CmsException if getting roles or users of role failed
*/
public Map getExportUsersFromRoles(Map exportUsers) throws CmsException {
List roles = getRoles();
if (roles != null && roles.size() > 0) {
Iterator itRoles = roles.iterator();
while (itRoles.hasNext()) {
List roleUsers = OpenCms.getRoleManager().getUsersOfRole(
getCms(),
CmsRole.valueOfGroupName((String)itRoles.next()),
true,
false);
Iterator itRoleUsers = roleUsers.iterator();
while (itRoleUsers.hasNext()) {
CmsUser roleUser = (CmsUser)itRoleUsers.next();
// contains
if (exportUsers.get(roleUser.getId()) == null) {
exportUsers.put(roleUser.getId(), roleUser);
}
}
}
}
return exportUsers;
}
/**
* Returns the JavaScript code to execute during the load of the dialog.<p>
*
* @return the JavaScript code to execute
*/
public String getOnloadJavaScript() {
StringBuffer result = new StringBuffer(256);
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_paramExportfile)) {
result.append("javascript:window.open(\"");
result.append(getJsp().link("/system/workplace/admin/accounts/imexport_user_data/dodownload.jsp?"));
result.append("servletUrl=");
result.append(getJsp().link("/system/workplace/admin/workplace/logfileview/downloadTrigger.jsp"));
result.append("&filePath=").append(getParamExportfile());
result.append("\", \"download\", \"width=300,height=130,left=100,top=100,menubar=no,status=no,toolbar=no\");");
}
return result.toString();
}
/**
* Returns the export file.<p>
*
* @return the export file
*/
public String getParamExportfile() {
return m_paramExportfile;
}
/**
* @see org.opencms.workplace.tools.CmsToolDialog#pageBody(int, java.lang.String, java.lang.String)
*/
public String pageBody(int segment, String className, String parameters) {
if (parameters != null) {
if (parameters.lastIndexOf("onload") != -1) {
// get substring until onload='
String subParameters = parameters.substring(0, parameters.lastIndexOf("onload") + 8);
subParameters += getOnloadJavaScript();
// get the rest of the old parameter string
subParameters += parameters.substring(parameters.lastIndexOf("onload") + 8);
parameters = subParameters;
}
}
return super.pageBody(segment, className, parameters);
}
/**
* Sets the export file.<p>
*
* @param paramExportfile the export file to set
*/
public void setParamExportfile(String paramExportfile) {
m_paramExportfile = paramExportfile;
}
/**
* Creates the dialog HTML for all defined widgets of the named dialog (page).<p>
*
* This overwrites the method from the super class to create a layout variation for the widgets.<p>
*
* @param dialog the dialog (page) to get the HTML for
* @return the dialog HTML for all defined widgets of the named dialog (page)
*/
protected String createDialogHtml(String dialog) {
StringBuffer result = new StringBuffer(1024);
result.append(createWidgetTableStart());
// show error header once if there were validation errors
result.append(createWidgetErrorHeader());
if (dialog.equals(PAGES[0])) {
// create the widgets for the first dialog page
result.append(dialogBlockStart(key(Messages.GUI_USERDATA_EXPORT_LABEL_HINT_BLOCK_0)));
result.append(key(Messages.GUI_USERDATA_EXPORT_LABEL_HINT_TEXT_0));
result.append(dialogBlockEnd());
result.append(dialogBlockStart(key(Messages.GUI_USERDATA_EXPORT_LABEL_GROUPS_BLOCK_0)));
result.append(createWidgetTableStart());
result.append(createDialogRowsHtml(0, 0));
result.append(createWidgetTableEnd());
result.append(dialogBlockEnd());
result.append(dialogBlockStart(key(Messages.GUI_USERDATA_EXPORT_LABEL_ROLES_BLOCK_0)));
result.append(createWidgetTableStart());
result.append(createDialogRowsHtml(1, 1));
result.append(createWidgetTableEnd());
result.append(dialogBlockEnd());
}
result.append(createWidgetTableEnd());
return result.toString();
}
/**
* @see org.opencms.workplace.tools.accounts.A_CmsUserDataImexportDialog#defineWidgets()
*/
protected void defineWidgets() {
initExportObject();
setKeyPrefix(KEY_PREFIX);
addWidget(new CmsWidgetDialogParameter(
this,
"groups",
PAGES[0],
new CmsGroupWidget(null, null, getParamOufqn())));
addWidget(new CmsWidgetDialogParameter(this, "roles", PAGES[0], new CmsSelectWidget(getSelectRoles())));
}
/**
* @see org.opencms.workplace.tools.accounts.A_CmsUserDataImexportDialog#getPageArray()
*/
protected String[] getPageArray() {
return PAGES;
}
/**
* Initializes the message info object to work with depending on the dialog state and request parameters.<p>
*/
protected void initExportObject() {
try {
if (CmsStringUtil.isEmpty(getParamAction()) || CmsDialog.DIALOG_INITIAL.equals(getParamAction())) {
// create a new list
setGroups(new ArrayList());
setRoles(new ArrayList());
} else {
// this is not the initial call, get the message info object from session
setGroups((List)((Map)getDialogObject()).get("groups"));
setRoles((List)((Map)getDialogObject()).get("roles"));
}
} catch (Exception e) {
// create a new list
setGroups(new ArrayList());
setRoles(new ArrayList());
}
}
/**
* @see org.opencms.workplace.CmsWorkplace#initWorkplaceRequestValues(org.opencms.workplace.CmsWorkplaceSettings, javax.servlet.http.HttpServletRequest)
*/
protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest request) {
// initialize parameters and dialog actions in super implementation
super.initWorkplaceRequestValues(settings, request);
HashMap objectsMap = new HashMap();
objectsMap.put("groups", getGroups());
objectsMap.put("roles", getRoles());
// save the current state of the message (may be changed because of the widget values)
setDialogObject(objectsMap);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?