cmsuserdataimportlist.java
来自「找了很久才找到到源代码」· Java 代码 · 共 826 行 · 第 1/3 页
JAVA
826 行
List roles = CmsStringUtil.splitAsList(getParamRoles(), ",");
Iterator itRoles = roles.iterator();
while (itRoles.hasNext()) {
OpenCms.getRoleManager().addUserToRole(
getCms(),
CmsRole.valueOfGroupName((String)itRoles.next()),
createdUser.getName());
}
}
break;
}
} catch (CmsException e) {
// noop
}
}
}
Map params = new HashMap();
params.put(A_CmsOrgUnitDialog.PARAM_OUFQN, getParamOufqn());
params.put(CmsDialog.PARAM_ACTION, CmsDialog.DIALOG_INITIAL);
try {
getToolManager().jspForwardTool(this, getParentPath(), params);
} catch (ServletException e) {
throw new CmsRuntimeException(Messages.get().container(Messages.ERR_FORWARDING_TO_PARENT_TOOL_0), e);
} catch (IOException e) {
throw new CmsRuntimeException(Messages.get().container(Messages.ERR_FORWARDING_TO_PARENT_TOOL_0), e);
}
} else {
throwListUnsupportedActionException();
}
listSave();
}
/**
* Returns the paramGroups.<p>
*
* @return the paramGroups
*/
public String getParamGroups() {
return m_paramGroups;
}
/**
* Returns the paramImportfile.<p>
*
* @return the paramImportfile
*/
public String getParamImportfile() {
return m_paramImportfile;
}
/**
* Returns the paramPassword.<p>
*
* @return the paramPassword
*/
public String getParamPassword() {
return m_paramPassword;
}
/**
* Returns the paramRoles.<p>
*
* @return the paramRoles
*/
public String getParamRoles() {
return m_paramRoles;
}
/**
* Returns the reasons.<p>
*
* @return the reasons
*/
public Map getReasons() {
return m_reasons;
}
/**
* Sets the paramGroups.<p>
*
* @param paramGroups the paramGroups to set
*/
public void setParamGroups(String paramGroups) {
m_paramGroups = paramGroups;
}
/**
* Sets the paramImportfile.<p>
*
* @param paramImportfile the paramImportfile to set
*/
public void setParamImportfile(String paramImportfile) {
m_paramImportfile = paramImportfile;
}
/**
* Sets the paramPassword.<p>
*
* @param paramPassword the paramPassword to set
*/
public void setParamPassword(String paramPassword) {
m_paramPassword = paramPassword;
}
/**
* Sets the paramRoles.<p>
*
* @param paramRoles the paramRoles to set
*/
public void setParamRoles(String paramRoles) {
m_paramRoles = paramRoles;
}
/**
* Sets the reasons.<p>
*
* @param reasons the reasons to set
*/
public void setReasons(Map reasons) {
m_reasons = reasons;
}
/**
* @see org.opencms.workplace.list.A_CmsListDialog#customHtmlEnd()
*/
protected String customHtmlEnd() {
StringBuffer result = new StringBuffer(512);
result.append(super.customHtmlEnd());
result.append("<form name='actions' method='post' action='");
result.append(getDialogRealUri());
result.append("' class='nomargin' onsubmit=\"return submitAction('ok', null, 'actions');\">\n");
result.append(allParamsAsHidden());
result.append(dialogButtonRow(HTML_START));
result.append("<input name='");
result.append(IMPORT_ACTION);
result.append("' type='button' value='");
result.append(key(org.opencms.workplace.Messages.GUI_DIALOG_BUTTON_OK_0));
result.append("' onclick=\"submitAction('");
result.append(IMPORT_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(1024);
result.append(dialogBlockStart(key(Messages.GUI_USERDATA_IMPORT_LABEL_HINT_BLOCK_0)));
result.append(key(Messages.GUI_IMPORTLISTCSV_IMPORT_LABEL_HINT_TEXT_0));
result.append(dialogBlockEnd());
result.append("<div class=\"dialogspacer\" unselectable=\"on\"> </div>");
return result.toString();
}
/**
* @see org.opencms.workplace.tools.accounts.A_CmsUsersList#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_DISPLAY).toString();
StringBuffer html = new StringBuffer(512);
try {
if (detailId.equals(LIST_DETAIL_REASON) && m_reasons != null && m_reasons.containsKey(userName)) {
html.append(m_reasons.get(userName));
} else {
html.append(key(Messages.GUI_IMPORTLISTCSV_VALID_USER_0));
}
} catch (Exception e) {
// noop
}
item.set(detailId, html.toString());
}
}
/**
* @see org.opencms.workplace.tools.accounts.A_CmsUsersList#getGroupIcon()
*/
protected String getGroupIcon() {
return null;
}
/**
* @see org.opencms.workplace.tools.accounts.A_CmsUsersList#getListItems()
*/
protected List getListItems() {
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.getName());
item.set(LIST_COLUMN_DISPLAY, user.getName());
if (isAlreadyAvailable(user.getName())) {
if (m_reasons == null) {
m_reasons = new HashMap();
}
m_reasons.put(
user.getName(),
Messages.get().container(Messages.GUI_IMPORTLISTCSV_ALREADY_EXISTS_0).key(getLocale()));
}
if (m_reasons != null && m_reasons.containsKey(user.getName())) {
item.set(LIST_COLUMN_VALIDATION_HIDDEN, "invalid");
} else {
item.set(LIST_COLUMN_VALIDATION_HIDDEN, "valid");
}
ret.add(item);
}
return ret;
}
/**
* @see org.opencms.workplace.tools.accounts.A_CmsUsersList#getUsers()
*/
protected List getUsers() {
String separator = null;
List values = null;
m_uploadFile = new File(m_paramImportfile);
FileReader fileReader;
BufferedReader bufferedReader;
List users = null;
try {
fileReader = new FileReader(m_uploadFile);
bufferedReader = new BufferedReader(fileReader);
String line;
boolean headline = true;
while ((line = bufferedReader.readLine()) != null) {
if (users == null) {
users = new ArrayList();
}
if (separator == null) {
separator = CmsXsltUtil.getPreferredDelimiter(line);
}
List lineValues = CmsStringUtil.splitAsList(line, separator);
if (headline) {
values = new ArrayList();
Iterator itLineValues = lineValues.iterator();
while (itLineValues.hasNext()) {
values.add(itLineValues.next());
}
headline = false;
} else if (values != null) {
CmsUser curUser = new CmsUser();
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?