use of org.springframework.extensions.config.Config in project acs-community-packaging by Alfresco.
the class BaseActionWizard method getImageTransformers.
/**
* Returns the image transformers that are available
*
* @return List of SelectItem objects representing the available image transformers
*/
public List<SelectItem> getImageTransformers() {
if ((this.imageTransformers == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
Config wizardCfg = svc.getConfig("Action Wizards");
if (wizardCfg != null) {
ConfigElement transformersCfg = wizardCfg.getConfigElement("image-transformers");
if (transformersCfg != null) {
FacesContext context = FacesContext.getCurrentInstance();
Map<String, String> mimeTypes = this.getMimetypeService().getDisplaysByMimetype();
this.imageTransformers = 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.imageTransformers.add(new SelectItem(id, label));
}
// make sure the list is sorted by the label
QuickSort sorter = new QuickSort(this.imageTransformers, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
} else {
logger.warn("Could not find 'image-transformers' configuration element");
}
} else {
logger.warn("Could not find 'Action Wizards' configuration section");
}
}
return this.imageTransformers;
}
use of org.springframework.extensions.config.Config in project acs-community-packaging by Alfresco.
the class BaseActionWizard method getAddableAspects.
/**
* Returns a list of aspects that can be added
*
* @return List of SelectItem objects representing the aspects that can be added
*/
public List<SelectItem> getAddableAspects() {
if ((this.addableAspects == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
// get the list of common aspects
this.addableAspects = new ArrayList<SelectItem>();
this.addableAspects.addAll(getCommonAspects());
// get those aspects configured to appear only in the remove aspect action
ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
Config wizardCfg = svc.getConfig("Action Wizards");
if (wizardCfg != null) {
ConfigElement aspectsCfg = wizardCfg.getConfigElement("aspects-add");
if (aspectsCfg != null) {
List<SelectItem> aspects = readAspectsConfig(FacesContext.getCurrentInstance(), aspectsCfg);
this.addableAspects.addAll(aspects);
} else {
logger.warn("Could not find 'aspects-add' configuration element");
}
} else {
logger.warn("Could not find 'Action Wizards' configuration section");
}
// make sure the list is sorted by the label
QuickSort sorter = new QuickSort(this.addableAspects, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
}
return this.addableAspects;
}
use of org.springframework.extensions.config.Config in project acs-community-packaging by Alfresco.
the class BaseActionWizard method getCommonAspects.
/**
* Returns the aspects that are available in all scenarios i.e. add, remove and test
*
* @return List of SelectItem objects representing the available aspects
*/
protected List<SelectItem> getCommonAspects() {
if ((this.commonAspects == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
Config wizardCfg = svc.getConfig("Action Wizards");
if (wizardCfg != null) {
ConfigElement aspectsCfg = wizardCfg.getConfigElement("aspects");
if (aspectsCfg != null) {
this.commonAspects = readAspectsConfig(FacesContext.getCurrentInstance(), aspectsCfg);
} else {
logger.warn("Could not find 'aspects' configuration element");
}
} else {
logger.warn("Could not find 'Action Wizards' configuration section");
}
}
return this.commonAspects;
}
use of org.springframework.extensions.config.Config in project acs-community-packaging by Alfresco.
the class BaseActionWizard method getObjectTypes.
/**
* @return Returns a list of object types to allow the user to select from
*/
public List<SelectItem> getObjectTypes() {
if ((this.objectTypes == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
FacesContext context = FacesContext.getCurrentInstance();
// add the well known object type to start with
this.objectTypes = new ArrayList<SelectItem>(5);
// add any configured content or folder sub-types to the list
ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
Config wizardCfg = svc.getConfig("Action Wizards");
if (wizardCfg != null) {
ConfigElement typesCfg = wizardCfg.getConfigElement("specialise-types");
if (typesCfg != null) {
for (ConfigElement child : typesCfg.getChildren()) {
QName idQName = Repository.resolveToQName(child.getAttribute("name"));
TypeDefinition typeDef = this.getDictionaryService().getType(idQName);
// the content or folder type itself
if (typeDef != null && typeDef.getName().equals(ContentModel.TYPE_CONTENT) == false && typeDef.getName().equals(ContentModel.TYPE_FOLDER) == false && (this.getDictionaryService().isSubClass(typeDef.getName(), ContentModel.TYPE_CONTENT) || this.getDictionaryService().isSubClass(typeDef.getName(), ContentModel.TYPE_FOLDER))) {
// try and get the display 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, just use the localname
if (label == null) {
label = idQName.getLocalName();
}
this.objectTypes.add(new SelectItem(idQName.toString(), label));
}
}
// make sure the list is sorted by the label
QuickSort sorter = new QuickSort(this.objectTypes, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
// add the select an action item at the start of the list
this.objectTypes.add(0, new SelectItem("null", Application.getMessage(FacesContext.getCurrentInstance(), "select_a_type")));
} else {
logger.warn("Could not find 'specialise-types' configuration element");
}
} else {
logger.warn("Could not find 'Action Wizards' configuration section");
}
}
return this.objectTypes;
}
use of org.springframework.extensions.config.Config in project acs-community-packaging by Alfresco.
the class BaseActionWizard method getRemovableAspects.
/**
* Returns a list of aspects that can be removed
*
* @return List of SelectItem objects representing the aspects that can be removed
*/
public List<SelectItem> getRemovableAspects() {
if ((this.removableAspects == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
// get the list of common aspects
this.removableAspects = new ArrayList<SelectItem>();
this.removableAspects.addAll(getCommonAspects());
// get those aspects configured to appear only in the remove aspect action
ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
Config wizardCfg = svc.getConfig("Action Wizards");
if (wizardCfg != null) {
ConfigElement aspectsCfg = wizardCfg.getConfigElement("aspects-remove");
if (aspectsCfg != null) {
List<SelectItem> aspects = readAspectsConfig(FacesContext.getCurrentInstance(), aspectsCfg);
this.removableAspects.addAll(aspects);
} else {
logger.warn("Could not find 'aspects-remove' configuration element");
}
} else {
logger.warn("Could not find 'Action Wizards' configuration section");
}
// make sure the list is sorted by the label
QuickSort sorter = new QuickSort(this.removableAspects, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
}
return this.removableAspects;
}
Aggregations