001
014
015 package com.liferay.portal.kernel.portletdisplaytemplate;
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 BasePortletDisplayTemplateHandler
033 implements PortletDisplayTemplateHandler {
034
035 public List<Element> getDefaultTemplateElements() throws Exception {
036 String templatesConfigPath = getTemplatesConfigPath();
037
038 if (Validator.isNull(templatesConfigPath)) {
039 return Collections.emptyList();
040 }
041
042 Class<?> clazz = getClass();
043
044 String xml = StringUtil.read(
045 clazz.getClassLoader(), templatesConfigPath, false);
046
047 Document document = SAXReaderUtil.read(xml);
048
049 Element rootElement = document.getRootElement();
050
051 return rootElement.elements("template");
052 }
053
054 public String getTemplatesHelpPath(String language) {
055 return PropsUtil.get(
056 getTemplatesHelpPropertyKey(), new Filter(language));
057 }
058
059 public String getTemplatesHelpPropertyKey() {
060 return PropsKeys.PORTLET_DISPLAY_TEMPLATES_HELP;
061 }
062
063 protected String getTemplatesConfigPath() {
064 return null;
065 }
066
067 }