001 /** 002 * Copyright (c) 2000-present Liferay, Inc. All rights reserved. 003 * 004 * This library is free software; you can redistribute it and/or modify it under 005 * the terms of the GNU Lesser General Public License as published by the Free 006 * Software Foundation; either version 2.1 of the License, or (at your option) 007 * any later version. 008 * 009 * This library is distributed in the hope that it will be useful, but WITHOUT 010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 011 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 012 * details. 013 */ 014 015 package com.liferay.portal.kernel.template; 016 017 import aQute.bnd.annotation.ProviderType; 018 019 import com.liferay.portal.kernel.xml.Element; 020 021 import java.util.List; 022 import java.util.Locale; 023 import java.util.Map; 024 025 /** 026 * @author Juan Fern??ndez 027 */ 028 @ProviderType 029 public interface TemplateHandler { 030 031 /** 032 * Returns the template handler's class name. 033 * 034 * @return the template handler's class name 035 */ 036 public String getClassName(); 037 038 /** 039 * Returns the elements containing the information of the portlet display 040 * templates to be installed by default. 041 * 042 * @return the elements containing the information of the portlet display 043 * templates to be installed by default. These templates are 044 * installed when registering the portlet. 045 * @throws Exception if an exception occurred assembling the default 046 * template elements 047 */ 048 public List<Element> getDefaultTemplateElements() throws Exception; 049 050 /** 051 * Returns the template handler's name. 052 * 053 * @param locale the locale of the template handler name to get 054 * @return the template handler's name 055 */ 056 public String getName(Locale locale); 057 058 /** 059 * Returns the name of the resource associated with the template. 060 * Permissions on the resource are checked when adding a new template. 061 * 062 * @return the name of the resource associated with the template 063 */ 064 public String getResourceName(); 065 066 /** 067 * Returns the restricted variables that are excluded from the template's 068 * context. 069 * 070 * @param language the template's scripting language. Acceptable values for 071 * the FreeMarker, Velocity, or XSL languages are {@link 072 * TemplateConstants.LANG_TYPE_FTL}, {@link 073 * TemplateConstants.LANG_TYPE_VM}, or {@link 074 * TemplateConstants.LANG_TYPE_XSL}, respectively. 075 * @return the restricted variables that are excluded from the template's 076 * context 077 */ 078 public String[] getRestrictedVariables(String language); 079 080 /** 081 * Returns initial template content for helping the user create a new 082 * template. 083 * 084 * @param language the template's scripting language. Acceptable values for 085 * the FreeMarker, Velocity, or XSL languages are {@link 086 * TemplateConstants.LANG_TYPE_FTL}, {@link 087 * TemplateConstants.LANG_TYPE_VM}, or {@link 088 * TemplateConstants.LANG_TYPE_XSL}, respectively. 089 * @return initial template content for helping the user create a new 090 * template 091 */ 092 public String getTemplatesHelpContent(String language); 093 094 /** 095 * Returns the path to the template's help content. 096 * 097 * @param language the template's scripting language. Acceptable values for 098 * the FreeMarker, Velocity, or XSL languages are {@link 099 * TemplateConstants.LANG_TYPE_FTL}, {@link 100 * TemplateConstants.LANG_TYPE_VM}, or {@link 101 * TemplateConstants.LANG_TYPE_XSL}, respectively. 102 * @return the path to the template's help content 103 */ 104 public String getTemplatesHelpPath(String language); 105 106 /** 107 * Returns the name of the property in <code>portal.properties</code> that 108 * defines the path to the template's help content. 109 * 110 * @return the name of the property in <code>portal.properties</code> that 111 * defines the path to the template's help content 112 */ 113 public String getTemplatesHelpPropertyKey(); 114 115 /** 116 * Returns the template's map of script variable groups for which hints are 117 * displayed in the template editor palette. 118 * 119 * <p> 120 * Script variables can be grouped arbitrarily. As examples, a group of 121 * entity fields could be mapped to the keyword <code>Fields</code>, or a 122 * group of general variables portal variables could be mapped to the phrase 123 * <code>General Variables</code>, etc. 124 * </p> 125 * 126 * @param classPK the primary key of the entity that defines the variable 127 * groups for the template. For example, consider specifying the 128 * primary key of the structure associated to the template. 129 * @param language the template's scripting language. Acceptable values for 130 * the FreeMarker, Velocity, or XSL languages are {@link 131 * TemplateConstants.LANG_TYPE_FTL}, {@link 132 * TemplateConstants.LANG_TYPE_VM}, or {@link 133 * TemplateConstants.LANG_TYPE_XSL}, respectively. 134 * @param locale the locale of the variable groups to get 135 * @return the template's map of script variable groups for which hints are 136 * displayed in the template editor palette 137 * @throws Exception if an exception occurred retrieving the template 138 * variable groups 139 */ 140 public Map<String, TemplateVariableGroup> getTemplateVariableGroups( 141 long classPK, String language, Locale locale) 142 throws Exception; 143 144 }