001
014
015 package com.liferay.portal.kernel.template;
016
017 import com.liferay.portal.kernel.configuration.Filter;
018 import com.liferay.portal.kernel.util.PropsKeys;
019 import com.liferay.portal.kernel.util.PropsUtil;
020 import com.liferay.portal.kernel.util.StringUtil;
021 import com.liferay.portal.kernel.util.Validator;
022 import com.liferay.portal.kernel.xml.Document;
023 import com.liferay.portal.kernel.xml.Element;
024 import com.liferay.portal.kernel.xml.SAXReaderUtil;
025
026 import java.util.Collections;
027 import java.util.List;
028
029
032 public abstract class BaseTemplateHandler implements TemplateHandler {
033
034 public List<Element> getDefaultTemplateElements() throws Exception {
035 String templatesConfigPath = getTemplatesConfigPath();
036
037 if (Validator.isNull(templatesConfigPath)) {
038 return Collections.emptyList();
039 }
040
041 Class<?> clazz = getClass();
042
043 String xml = StringUtil.read(
044 clazz.getClassLoader(), templatesConfigPath, false);
045
046 Document document = SAXReaderUtil.read(xml);
047
048 Element rootElement = document.getRootElement();
049
050 return rootElement.elements("template");
051 }
052
053 public String getTemplatesHelpPath(String language) {
054 return PropsUtil.get(
055 getTemplatesHelpPropertyKey(), new Filter(language));
056 }
057
058 public String getTemplatesHelpPropertyKey() {
059 return PropsKeys.PORTLET_DISPLAY_TEMPLATES_HELP;
060 }
061
062 protected String getTemplatesConfigPath() {
063 return null;
064 }
065
066 }