use of org.springframework.extensions.config.ConfigService in project acs-community-packaging by Alfresco.
the class BaseActionWizard method getTransformers.
/**
* Returns the transformers that are available
*
* @return List of SelectItem objects representing the available transformers
*/
public List<SelectItem> getTransformers() {
if ((this.transformers == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
Config wizardCfg = svc.getConfig("Action Wizards");
if (wizardCfg != null) {
ConfigElement transformersCfg = wizardCfg.getConfigElement("transformers");
if (transformersCfg != null) {
FacesContext context = FacesContext.getCurrentInstance();
Map<String, String> mimeTypes = this.getMimetypeService().getDisplaysByMimetype();
this.transformers = new ArrayList<SelectItem>();
for (ConfigElement child : transformersCfg.getChildren()) {
String id = child.getAttribute("name");
// try and get the display label from config
String label = Utils.getDisplayLabel(context, child);
// if there wasn't a client based label get it from the mime type service
if (label == null) {
label = mimeTypes.get(id);
}
// if there is still no label use the raw mimetype
if (label == null) {
label = id;
}
this.transformers.add(new SelectItem(id, label));
}
// make sure the list is sorted by the label
QuickSort sorter = new QuickSort(this.transformers, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
} else {
logger.warn("Could not find 'transformers' configuration element");
}
} else {
logger.warn("Could not find 'Action Wizards' configuration section");
}
}
return this.transformers;
}
use of org.springframework.extensions.config.ConfigService 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.ConfigService 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.ConfigService in project acs-community-packaging by Alfresco.
the class Application method getErrorPage.
/**
* Retrieves the configured error page for the application
*
* @param context The Spring context
* @return The configured error page or null if the configuration is missing
*/
public static String getErrorPage(ApplicationContext context) {
String errorPage = null;
ConfigService svc = (ConfigService) context.getBean(BEAN_CONFIG_SERVICE);
ClientConfigElement clientConfig = (ClientConfigElement) svc.getGlobalConfig().getConfigElement(ClientConfigElement.CONFIG_ELEMENT_ID);
if (clientConfig != null) {
errorPage = clientConfig.getErrorPage();
}
return errorPage;
}
use of org.springframework.extensions.config.ConfigService in project acs-community-packaging by Alfresco.
the class AlfrescoNavigationHandler method handleDispatch.
private void handleDispatch(FacesContext context, String fromAction, String outcome, Node dispatchNode) {
if (dispatchNode != null) {
if (logger.isDebugEnabled())
logger.debug("Found node with type '" + dispatchNode.getType().toString() + "' in dispatch context");
// get the current view id
String viewId = context.getViewRoot().getViewId();
// see if there is any navigation config for the node type
ConfigService configSvc = Application.getConfigService(context);
NavigationConfigElement navigationCfg = null;
try {
Config nodeConfig = configSvc.getConfig(dispatchNode);
navigationCfg = (NavigationConfigElement) nodeConfig.getConfigElement(NavigationElementReader.ELEMENT_NAVIGATION);
} catch (InvalidNodeRefException e) {
if (logger.isDebugEnabled())
logger.debug("Invalid node reference: " + dispatchNode);
}
if (navigationCfg != null) {
// see if there is config for the current view state
NavigationResult navResult = navigationCfg.getOverride(viewId, outcome);
if (navResult != null) {
if (logger.isDebugEnabled())
logger.debug("Found navigation config: " + navResult);
if (navResult.isOutcome()) {
navigate(context, fromAction, navResult.getResult());
} else {
String newViewId = navResult.getResult();
if (newViewId.equals(viewId) == false) {
if (logger.isDebugEnabled())
logger.debug("Dispatching to new view id: " + newViewId);
goToView(context, newViewId);
} else {
if (logger.isDebugEnabled())
logger.debug("New view id is the same as the current one so setting outcome to null");
navigate(context, fromAction, null);
}
}
} else {
if (logger.isDebugEnabled())
logger.debug("No override configuration found for current view or outcome");
navigate(context, fromAction, outcome);
}
} else {
if (logger.isDebugEnabled())
logger.debug("No navigation configuration found for node");
navigate(context, fromAction, outcome);
}
// reset the dispatch context
((NavigationBean) context.getExternalContext().getSessionMap().get(NavigationBean.BEAN_NAME)).resetDispatchContext();
} else {
if (logger.isDebugEnabled())
logger.debug("No dispatch context found");
// pass off to the original handler
navigate(context, fromAction, outcome);
}
}
Aggregations