use of org.springframework.extensions.config.ConfigElement in project acs-community-packaging by Alfresco.
the class ImportDialog method getEncoding.
/**
* @return Returns the encoding currently selected
*/
public String getEncoding() {
if (encoding == null) {
ConfigService configSvc = Application.getConfigService(FacesContext.getCurrentInstance());
Config config = configSvc.getConfig("Import Dialog");
if (config != null) {
ConfigElement defaultEncCfg = config.getConfigElement("default-encoding");
if (defaultEncCfg != null) {
String value = defaultEncCfg.getValue();
if (value != null) {
encoding = value.trim();
}
}
}
if (encoding == null || encoding.length() == 0) {
// if not configured, set to a sensible default for most character sets
encoding = "UTF-8";
}
}
return encoding;
}
use of org.springframework.extensions.config.ConfigElement in project acs-community-packaging by Alfresco.
the class ImportDialog method getEncodings.
public List<SelectItem> getEncodings() {
if ((this.encodings == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
FacesContext context = FacesContext.getCurrentInstance();
this.encodings = new ArrayList<SelectItem>(3);
ConfigService svc = Application.getConfigService(context);
Config cfg = svc.getConfig("Import Dialog");
if (cfg != null) {
ConfigElement typesCfg = cfg.getConfigElement("encodings");
if (typesCfg != null) {
for (ConfigElement child : typesCfg.getChildren()) {
String encoding = child.getAttribute("name");
if (encoding != null) {
this.encodings.add(new SelectItem(encoding, encoding));
}
}
} else {
logger.warn("Could not find 'encodings' configuration element");
}
} else {
encodings = UICharsetSelector.getCharsetEncodingList();
}
}
return this.encodings;
}
use of org.springframework.extensions.config.ConfigElement in project acs-community-packaging by Alfresco.
the class CreateSpaceWizard method getFolderTypes.
/**
* Returns a list of UIListItem objects representing the folder types
* and also constructs the list of descriptions for each type
*
* @return List of UIListItem components
*/
@SuppressWarnings("unchecked")
public List<UIListItem> getFolderTypes() {
if ((this.folderTypes == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
FacesContext context = FacesContext.getCurrentInstance();
this.folderTypes = new ArrayList<UIListItem>(2);
this.folderTypeDescriptions = new ArrayList<UIDescription>(2);
// add the well known 'container space' type to start with
UIListItem defaultItem = new UIListItem();
String defaultLabel = Application.getMessage(context, "container");
defaultItem.setValue(ContentModel.TYPE_FOLDER.toString());
defaultItem.setLabel(defaultLabel);
defaultItem.setTooltip(defaultLabel);
defaultItem.setImage(DEFAULT_SPACE_TYPE_ICON_PATH);
this.folderTypes.add(defaultItem);
UIDescription defaultDesc = new UIDescription();
defaultDesc.setControlValue(ContentModel.TYPE_FOLDER.toString());
defaultDesc.setText(Application.getMessage(context, "container_desc"));
this.folderTypeDescriptions.add(defaultDesc);
// add any configured content sub-types to the list
Config wizardCfg = Application.getConfigService(FacesContext.getCurrentInstance()).getConfig("Space Wizards");
if (wizardCfg != null) {
ConfigElement typesCfg = wizardCfg.getConfigElement("folder-types");
if (typesCfg != null) {
for (ConfigElement child : typesCfg.getChildren()) {
QName idQName = Repository.resolveToQName(child.getAttribute("name"));
if (idQName != null) {
TypeDefinition typeDef = this.getDictionaryService().getType(idQName);
if (typeDef != null) {
if (this.getDictionaryService().isSubClass(typeDef.getName(), ContentModel.TYPE_FOLDER)) {
// try and get the label from config
String label = Utils.getDisplayLabel(context, child);
// if there wasn't a client based label try and get it from the dictionary
if (label == null) {
label = typeDef.getTitle(this.getDictionaryService());
}
// finally use the localname if we still haven't found a label
if (label == null) {
label = idQName.getLocalName();
}
// resolve a description string for the type
String description = Utils.getDescription(context, child);
// if we don't have a local description just use the label
if (description == null) {
description = label;
}
// extract the icon to use from the config
String icon = child.getAttribute("icon");
if (icon == null || icon.length() == 0) {
icon = DEFAULT_SPACE_TYPE_ICON_PATH;
}
UIListItem item = new UIListItem();
item.setValue(idQName.toString());
item.setLabel(label);
item.setTooltip(label);
item.setImage(icon);
this.folderTypes.add(item);
UIDescription desc = new UIDescription();
desc.setControlValue(idQName.toString());
desc.setText(description);
this.folderTypeDescriptions.add(desc);
} else {
logger.warn("Failed to add '" + child.getAttribute("name") + "' to the list of folder types as the type is not a subtype of cm:folder");
}
} else {
logger.warn("Failed to add '" + child.getAttribute("name") + "' to the list of folder types as the type is not recognised");
}
} else {
logger.warn("Failed to add '" + child.getAttribute("name") + "' to the list of folder types as the prefix can not be resolved");
}
}
} else {
logger.warn("Could not find 'folder-types' configuration element");
}
} else {
logger.warn("Could not find 'Space Wizards' configuration section");
}
}
return this.folderTypes;
}
use of org.springframework.extensions.config.ConfigElement in project acs-community-packaging by Alfresco.
the class CreateSpaceWizard method getIcons.
/**
* Returns a list of icons to allow the user to select from.
* The list can change according to the type of space being created.
*
* @return A list of icons
*/
@SuppressWarnings("unchecked")
public List<UIListItem> getIcons() {
// NOTE: we can't cache this list as it depends on the space type
// which the user can change during the advanced space wizard
List<UIListItem> icons = null;
List<String> iconNames = new ArrayList<String>(8);
QName type = QName.createQName(this.spaceType);
String typePrefixForm = type.toPrefixString(this.getNamespaceService());
Config config = Application.getConfigService(FacesContext.getCurrentInstance()).getConfig(typePrefixForm + " icons");
if (config != null) {
ConfigElement iconsCfg = config.getConfigElement("icons");
if (iconsCfg != null) {
boolean first = true;
for (ConfigElement icon : iconsCfg.getChildren()) {
String iconName = icon.getAttribute("name");
String iconPath = icon.getAttribute("path");
if (iconName != null && iconPath != null) {
if (first) {
// if this is the first icon create the list and make
// the first icon in the list the default
icons = new ArrayList<UIListItem>(iconsCfg.getChildCount());
if (this.icon == null) {
// set the default if it is not already
this.icon = iconName;
}
first = false;
}
UIListItem item = new UIListItem();
item.setValue(iconName);
item.setImage(iconPath);
icons.add(item);
iconNames.add(iconName);
}
}
}
}
// if we didn't find any icons display one default choice
if (icons == null) {
icons = new ArrayList<UIListItem>(1);
this.icon = DEFAULT_SPACE_ICON_NAME;
UIListItem item = new UIListItem();
item.setValue(DEFAULT_SPACE_ICON_NAME);
item.setImage("/images/icons/space-icon-default.gif");
icons.add(item);
iconNames.add(DEFAULT_SPACE_ICON_NAME);
}
// current list of icons about to be displayed
if (iconNames.contains(this.icon) == false) {
this.icon = iconNames.get(0);
}
return icons;
}
use of org.springframework.extensions.config.ConfigElement in project acs-community-packaging by Alfresco.
the class StartWorkflowWizard method getExcludedWorkflows.
/**
* Get the Names of globally excluded workflow-names.
*
* @return The names of the workflows to exclude.
*/
protected List<String> getExcludedWorkflows() {
if ((excludedWorkflows == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
FacesContext fc = FacesContext.getCurrentInstance();
ConfigElement config = Application.getConfigService(fc).getGlobalConfig().getConfigElement("excluded-workflows");
if (config != null) {
StringTokenizer t = new StringTokenizer(config.getValue().trim(), ", ");
excludedWorkflows = new ArrayList<String>(t.countTokens());
while (t.hasMoreTokens()) {
String wfName = t.nextToken();
excludedWorkflows.add(wfName);
}
} else {
excludedWorkflows = Collections.emptyList();
}
}
return excludedWorkflows;
}
Aggregations