use of org.opencms.workplace.CmsAccountInfo in project opencms-core by alkacon.
the class CmsWorkplaceConfiguration method generateXml.
/**
* @see org.opencms.configuration.I_CmsXmlConfiguration#generateXml(org.dom4j.Element)
*/
public Element generateXml(Element parent) {
// generate workplace node and subnodes
Element workplaceElement = parent.addElement(N_WORKPLACE);
// add default locale
workplaceElement.addElement(N_DEFAULTLOCALE).setText(m_workplaceManager.getDefaultLocale().toString());
// add <localizedfolders> subnode
Element localizedElement = workplaceElement.addElement(N_LOCALIZEDFOLDERS);
Iterator<String> localizedIterator = m_workplaceManager.getLocalizedFolders().iterator();
while (localizedIterator.hasNext()) {
// add <resource uri=""/> element(s)
localizedElement.addElement(N_RESOURCE).addAttribute(A_URI, localizedIterator.next());
}
// add <dialoghandlers> subnode
Element dialogElement = workplaceElement.addElement(N_DIALOGHANDLERS);
Map<String, I_CmsDialogHandler> dialogs = m_workplaceManager.getDialogHandler();
String[] keys = dialogs.keySet().toArray(new String[0]);
Arrays.sort(keys);
for (int j = 0; j < keys.length; j++) {
String name = keys[j];
// add <dialoghandler> subnode with class attribute
Element dialogHandler = dialogElement.addElement(N_DIALOGHANDLER).addAttribute(A_CLASS, dialogs.get(name).getClass().getName());
I_CmsDialogHandler daialogHandlerConfig = dialogs.get(name);
CmsParameterConfiguration handlerConfig = daialogHandlerConfig.getConfiguration();
if (handlerConfig != null) {
handlerConfig.appendToXml(dialogHandler);
}
}
// add miscellaneous editor subnodes
workplaceElement.addElement(N_EDITORHANDLER).addAttribute(A_CLASS, m_workplaceManager.getEditorHandler().getClass().getName());
workplaceElement.addElement(N_EDITORACTION).addAttribute(A_CLASS, m_workplaceManager.getEditorActionHandler().getClass().getName());
if (m_workplaceManager.getPostUploadHandler() != null) {
workplaceElement.addElement(N_POSTUPLOADHANDLER).addAttribute(A_CLASS, m_workplaceManager.getPostUploadHandler().getClass().getName());
}
if (m_workplaceManager.getEditorCssHandlers().size() > 0) {
Element editorCssHandlers = workplaceElement.addElement(N_EDITORCSSHANDLERS);
Iterator<I_CmsEditorCssHandler> it = m_workplaceManager.getEditorCssHandlers().iterator();
while (it.hasNext()) {
I_CmsEditorCssHandler current = it.next();
Element handler = editorCssHandlers.addElement(N_EDITORCSSHANDLER);
handler.addAttribute(A_CLASS, current.getClass().getName());
}
}
if (m_workplaceManager.getPreEditorConditionDefinitions().size() > 0) {
Element editorPreActions = workplaceElement.addElement(N_EDITORPRECONDITIONS);
Iterator<I_CmsPreEditorActionDefinition> it = m_workplaceManager.getPreEditorConditionDefinitions().iterator();
while (it.hasNext()) {
I_CmsPreEditorActionDefinition current = it.next();
Element action = editorPreActions.addElement(N_EDITORPRECONDITION);
action.addAttribute(A_NAME, current.getResourceTypeName());
action.addAttribute(A_CLASS, current.getClass().getName());
// get the configuration parameters
CmsParameterConfiguration config = current.getConfiguration();
if ((config != null) && (config.size() > 0)) {
// append the configuration parameters
config.appendToXml(action);
}
}
}
I_CmsConfigurationParameterHandler deProvider = m_workplaceManager.getDirectEditProvider();
Element deProviderNode = workplaceElement.addElement(N_DIRECTEDITPROVIDER).addAttribute(A_CLASS, deProvider.getClass().getName());
CmsParameterConfiguration deProviderConfig = deProvider.getConfiguration();
if (deProviderConfig != null) {
deProviderConfig.appendToXml(deProviderNode);
}
// add <exportpoints> subnode
Element resourceloadersElement = workplaceElement.addElement(N_EXPORTPOINTS);
Set<CmsExportPoint> points = m_workplaceManager.getExportPoints();
Iterator<CmsExportPoint> exportPoints = points.iterator();
while (exportPoints.hasNext()) {
CmsExportPoint point = exportPoints.next();
resourceloadersElement.addElement(N_EXPORTPOINT).addAttribute(A_URI, point.getUri()).addAttribute(A_DESTINATION, point.getConfiguredDestination());
}
// add miscellaneous configuration nodes
workplaceElement.addElement(N_AUTOLOCK).setText(String.valueOf(m_workplaceManager.autoLockResources()));
String acaciaUnlock = m_workplaceManager.getAcaciaUnlock();
if (acaciaUnlock != null) {
workplaceElement.addElement(N_ACACIA_UNLOCK).setText(acaciaUnlock);
}
workplaceElement.addElement(N_XMLCONTENTAUTOCORRECTION).setText(String.valueOf(m_workplaceManager.isXmlContentAutoCorrect()));
workplaceElement.addElement(N_ENABLEUSERMGMT).setText(String.valueOf(m_workplaceManager.showUserGroupIcon()));
workplaceElement.addElement(N_DEFAULTPROPERTIESONSTRUCTURE).setText(String.valueOf(m_workplaceManager.isDefaultPropertiesOnStructure()));
workplaceElement.addElement(N_ENABLEADVANCEDPROPERTYTABS).setText(String.valueOf(m_workplaceManager.isEnableAdvancedPropertyTabs()));
// add <categoryfolder> node
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_workplaceManager.getCategoryFolder()) && !CmsCategoryService.REPOSITORY_BASE_FOLDER.equals(m_workplaceManager.getCategoryFolder())) {
workplaceElement.addElement(N_CATEGORYFOLDER).setText(String.valueOf(m_workplaceManager.getCategoryFolder()));
}
// add <categorydisplayoptions> node
if (m_workplaceManager.isDisplayCategoriesByRepository() || m_workplaceManager.isDisplayCategorySelectionCollapsed()) {
Element categoryDisplayOptions = workplaceElement.addElement(N_CATEGORYDISPLAYOPTIONS);
if (m_workplaceManager.isDisplayCategoriesByRepository()) {
categoryDisplayOptions.addAttribute(A_DISPLAY_BY_REPOSITORY, "true");
}
if (m_workplaceManager.isDisplayCategorySelectionCollapsed()) {
categoryDisplayOptions.addAttribute(A_DISPLAY_COLLAPSED, "true");
}
}
String groupTranslationClass = m_workplaceManager.getGroupTranslationClass();
if (groupTranslationClass != null) {
Element groupTranslationElement = workplaceElement.addElement(N_GROUP_TRANSLATION);
groupTranslationElement.addAttribute(A_CLASS, groupTranslationClass);
}
workplaceElement.addElement(N_MAXUPLOADSIZE).setText(String.valueOf(m_workplaceManager.getFileMaxUploadSize()));
// add <labeledfolders> resource list
Element labeledElement = workplaceElement.addElement(N_LABELEDFOLDERS);
Iterator<String> sitesFolders = m_workplaceManager.getLabelSiteFolders().iterator();
while (sitesFolders.hasNext()) {
labeledElement.addElement(N_RESOURCE).addAttribute(A_URI, sitesFolders.next());
}
// add the <galleryupload> node
workplaceElement.addElement(N_REPOSITORY_FOLDER).addAttribute(A_CLASS, m_workplaceManager.getRepositoryFolderHandler().getClass().getName());
// add <rfsfileviewsettings> node
CmsRfsFileViewer viewSettings = m_workplaceManager.getFileViewSettings();
Element fileViewElement = workplaceElement.addElement(N_RFSFILEVIEWESETTINGS);
String rootPath = viewSettings.getRootPath();
if (rootPath != null) {
fileViewElement.addElement(N_ROOTPATH).setText(rootPath);
}
String filePath = viewSettings.getFilePath();
if (filePath != null) {
fileViewElement.addElement(N_FILEPATH).setText(filePath);
}
fileViewElement.addElement(N_ENABLED).setText(String.valueOf(viewSettings.isEnabled()));
fileViewElement.addElement(N_FILEENCODING).setText(viewSettings.getFileEncoding());
fileViewElement.addElement(N_ISLOGFILE).setText(String.valueOf(viewSettings.getIsLogfile()));
fileViewElement.addElement(N_WINDOWSIZE).setText(String.valueOf(viewSettings.getWindowSize()));
// add <explorertypes> node
Element explorerTypesElement = workplaceElement.addElement(N_EXPLORERTYPES);
List<CmsExplorerTypeSettings> explorerTypes = m_workplaceManager.getWorkplaceExplorerTypeSettings();
generateExplorerTypesXml(explorerTypesElement, explorerTypes, false);
// add the <defaultaccesscontrol> node
Element defaultAccessControlElement = explorerTypesElement.addElement(N_DEFAULTACCESSCONTROL);
// create subnode <accesscontrol>
List<String> accessEntries = new ArrayList<String>();
// sort accessEntries
CmsExplorerTypeAccess access = m_workplaceManager.getDefaultAccess();
Iterator<String> iter = access.getAccessEntries().keySet().iterator();
while (iter.hasNext()) {
accessEntries.add(iter.next());
}
Collections.sort(accessEntries);
if (accessEntries.size() > 0) {
Element accessControlElement = defaultAccessControlElement.addElement(N_ACCESSCONTROL);
Iterator<String> k = accessEntries.iterator();
while (k.hasNext()) {
String key = k.next();
String value = m_workplaceManager.getDefaultAccess().getAccessEntries().get(key);
Element accessEntryElement = accessControlElement.addElement(N_ACCESSENTRY);
accessEntryElement.addAttribute(A_PRINCIPAL, key);
accessEntryElement.addAttribute(A_PERMISSIONS, value);
}
}
// add the user-infos node
if (m_workplaceManager.getUserInfoManager() != null) {
Element userInfosElement = workplaceElement.addElement(N_USERINFOS);
Iterator<CmsWorkplaceUserInfoBlock> infoBlocks = m_workplaceManager.getUserInfoManager().getBlocks().iterator();
while (infoBlocks.hasNext()) {
CmsWorkplaceUserInfoBlock block = infoBlocks.next();
Element infoBlockElement = userInfosElement.addElement(N_INFOBLOCK);
infoBlockElement.addAttribute(A_NAME, block.getTitle());
Iterator<CmsWorkplaceUserInfoEntry> itEntries = block.getEntries().iterator();
while (itEntries.hasNext()) {
CmsWorkplaceUserInfoEntry entry = itEntries.next();
Element userInfoElement = infoBlockElement.addElement(N_USERINFO);
userInfoElement.addAttribute(A_KEY, entry.getKey());
if (entry.getType() != null) {
userInfoElement.addAttribute(A_TYPE, entry.getType());
}
if (entry.getWidget() != null) {
userInfoElement.addAttribute(A_WIDGET, entry.getWidget());
}
if (entry.getParams() != null) {
userInfoElement.addAttribute(A_PARAMS, entry.getParams());
}
if (entry.getOptional() != null) {
userInfoElement.addAttribute(A_OPTIONAL, entry.getOptional());
}
}
}
}
List<CmsAccountInfo> accountInfos = m_workplaceManager.getConfiguredAccountInfos();
if (accountInfos != null) {
Element infosElement = workplaceElement.addElement(N_ACCOUNTINFOS);
for (CmsAccountInfo info : accountInfos) {
Element infoElement = infosElement.addElement(N_ACCOUNTINFO);
infoElement.addAttribute(A_FIELD, info.getField().name());
if (info.isAdditionalInfo()) {
infoElement.addAttribute(A_ADD_INFO_KEY, info.getAddInfoKey());
}
infoElement.addAttribute(A_EDITABLE, Boolean.toString(info.isEditable()));
}
}
// add the <default-preferences> user settings main node
Element defaultPreferences = workplaceElement.addElement(N_DEFAULTPREFERENCES);
Multimap<String, I_CmsPreference> prefsByTab = Multimaps.index(m_workplaceManager.getDefaultUserSettings().getPreferences().values(), new Function<I_CmsPreference, String>() {
public String apply(I_CmsPreference input) {
return input.getTab();
}
});
for (String tabName : new String[] { CmsGwtConstants.TAB_BASIC, CmsGwtConstants.TAB_EXTENDED, CmsGwtConstants.TAB_HIDDEN }) {
Element preferenceTab = defaultPreferences.addElement(N_PREFERENCE_TAB).addAttribute("name", tabName);
for (I_CmsPreference pref : prefsByTab.get(tabName)) {
Element elem = pref.createConfigurationItem();
if (elem != null) {
preferenceTab.add(elem);
}
}
}
// add the tool-manager node
Element toolManagerElement = workplaceElement.addElement(N_TOOLMANAGER);
Element rootsElement = toolManagerElement.addElement(N_ROOTS);
Iterator<CmsToolRootHandler> it = m_workplaceManager.getToolManager().getToolRoots().iterator();
while (it.hasNext()) {
CmsToolRootHandler root = it.next();
Element rootElement = rootsElement.addElement(N_ROOT);
rootElement.addElement(N_KEY).addText(root.getKey());
rootElement.addElement(N_URI).addText(root.getUri());
rootElement.addElement(N_NAME).addText(root.getName());
rootElement.addElement(N_HELPTEXT).addText(root.getHelpText());
}
String userListsMode = m_workplaceManager.getUserListModeString();
if (userListsMode != null) {
Element userListsElem = workplaceElement.addElement(N_USER_LISTS);
userListsElem.addAttribute(A_MODE, userListsMode);
}
Boolean keepAlive = m_workplaceManager.isKeepAlive(false);
if (keepAlive != null) {
workplaceElement.addElement(N_KEEP_ALIVE).setText(keepAlive.toString());
}
String defaultScope = m_workplaceManager.getGalleryDefaultScopeString();
if (defaultScope != null) {
workplaceElement.addElement(N_GALLERY_DEFAULT_SCOPE).setText(defaultScope);
}
ElementDeleteMode deleteMode = m_workplaceManager.getElementDeleteMode();
if (deleteMode != null) {
workplaceElement.addElement(N_ELEMENT_DELETE_MODE).setText(deleteMode.name());
}
CmsAdditionalLogFolderConfig.ADD_LOG_FOLDER_HELPER.generateXml(workplaceElement, m_workplaceManager.getAdditionalLogFolderConfiguration());
boolean useKeysForNewSites = CmsResourceTypeSubsitemapContentFolder.isEnableNewPageFormatByDefault();
workplaceElement.addElement(N_USE_FORMATTER_KEYS_FOR_NEW_SITES).setText("" + useKeysForNewSites);
// return the configured node
return workplaceElement;
}
use of org.opencms.workplace.CmsAccountInfo in project opencms-core by alkacon.
the class CmsUserDataFormLayout method initFields.
public void initFields(CmsUser user, EditLevel editLevel) {
m_editLevel = editLevel;
m_infos = new PropertysetItem();
for (CmsAccountInfo info : OpenCms.getWorkplaceManager().getAccountInfos()) {
String value = "";
if (user != null) {
value = info.getValue(user);
if (value == null) {
value = "";
}
}
m_infos.addItemProperty(info, new ObjectProperty<String>(value));
}
m_binder = new FieldGroup(m_infos);
for (CmsAccountInfo info : OpenCms.getWorkplaceManager().getAccountInfos()) {
addComponent(buildField(getLabel(info), info));
}
}
use of org.opencms.workplace.CmsAccountInfo in project opencms-core by alkacon.
the class CmsUserDataFormLayout method submit.
/**
* Store fields to given user.<p>
*
* @param user User to write information to
* @param cms CmsObject
* @param afterWrite runnable which gets called after writing user
* @param force force write even if data are not valid
*/
public void submit(CmsUser user, CmsObject cms, Runnable afterWrite, boolean force) {
try {
if (isValid() | force) {
if (force) {
removeValidators();
}
m_binder.commit();
PropertyUtilsBean propUtils = new PropertyUtilsBean();
for (CmsAccountInfo info : OpenCms.getWorkplaceManager().getAccountInfos()) {
boolean editable = (m_editLevel == EditLevel.all) || ((m_editLevel == EditLevel.configured) && info.isEditable());
if (editable) {
if (info.isAdditionalInfo()) {
user.setAdditionalInfo(info.getAddInfoKey(), m_infos.getItemProperty(info).getValue());
} else {
if (!CmsStringUtil.isEmptyOrWhitespaceOnly((String) m_infos.getItemProperty(info).getValue())) {
propUtils.setProperty(user, info.getField().name(), m_infos.getItemProperty(info).getValue());
}
}
}
}
cms.writeUser(user);
afterWrite.run();
}
} catch (CmsException | CommitException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
LOG.error("Unable to commit changes to user..", e);
}
}
Aggregations