1
22
23 package com.liferay.portal.tools.deploy;
24
25 import com.liferay.portal.kernel.plugin.PluginPackage;
26 import com.liferay.portal.kernel.util.StringUtil;
27 import com.liferay.portal.kernel.util.Validator;
28 import com.liferay.portal.model.Plugin;
29 import com.liferay.portal.util.InitUtil;
30 import com.liferay.util.TextFormatter;
31
32 import java.io.File;
33
34 import java.util.ArrayList;
35 import java.util.HashMap;
36 import java.util.List;
37 import java.util.Map;
38 import java.util.Properties;
39
40
46 public class ThemeDeployer extends BaseDeployer {
47
48 public static void main(String[] args) {
49 InitUtil.initWithSpring();
50
51 List<String> wars = new ArrayList<String>();
52 List<String> jars = new ArrayList<String>();
53
54 for (String arg : args) {
55 if (arg.endsWith(".war")) {
56 wars.add(arg);
57 }
58 else if (arg.endsWith(".jar")) {
59 jars.add(arg);
60 }
61 }
62
63 new ThemeDeployer(wars, jars);
64 }
65
66 protected ThemeDeployer() {
67 }
68
69 protected ThemeDeployer(List<String> wars, List<String> jars) {
70 super(wars, jars);
71 }
72
73 protected void checkArguments() {
74 super.checkArguments();
75
76 if (Validator.isNull(themeTaglibDTD)) {
77 throw new IllegalArgumentException(
78 "The system property deployer.theme.taglib.dtd is not set");
79 }
80
81 if (Validator.isNull(utilTaglibDTD)) {
82 throw new IllegalArgumentException(
83 "The system property deployer.util.taglib.dtd is not set");
84 }
85 }
86
87 protected String getExtraContent(
88 double webXmlVersion, File srcFile, String displayName)
89 throws Exception {
90
91 StringBuilder sb = new StringBuilder();
92
93 String extraContent = super.getExtraContent(
94 webXmlVersion, srcFile, displayName);
95
96 sb.append(extraContent);
97
98
100 sb.append("<listener>");
101 sb.append("<listener-class>");
102 sb.append("com.liferay.portal.kernel.servlet.ThemeContextListener");
103 sb.append("</listener-class>");
104 sb.append("</listener>");
105
106
108 sb.append(getSpeedFiltersContent(srcFile));
109
110 return sb.toString();
111 }
112
113 protected void processPluginPackageProperties(
114 File srcFile, String displayName, PluginPackage pluginPackage)
115 throws Exception {
116
117 if (pluginPackage == null) {
118 return;
119 }
120
121 Properties properties = getPluginPackageProperties(srcFile);
122
123 if ((properties == null) || (properties.size() == 0)) {
124 return;
125 }
126
127 String moduleGroupId = pluginPackage.getGroupId();
128 String moduleArtifactId = pluginPackage.getArtifactId();
129 String moduleVersion = pluginPackage.getVersion();
130
131 String pluginName = pluginPackage.getName();
132 String pluginType = pluginPackage.getTypes().get(0);
133 String pluginTypeName = TextFormatter.format(
134 pluginType, TextFormatter.J);
135
136 if (!pluginType.equals(Plugin.TYPE_THEME)) {
137 return;
138 }
139
140 String tags = getPluginPackageTagsXml(pluginPackage.getTags());
141 String shortDescription = pluginPackage.getShortDescription();
142 String longDescription = pluginPackage.getLongDescription();
143 String changeLog = pluginPackage.getChangeLog();
144 String pageURL = pluginPackage.getPageURL();
145 String author = pluginPackage.getAuthor();
146 String licenses = getPluginPackageLicensesXml(
147 pluginPackage.getLicenses());
148 String liferayVersions = getPluginPackageLiferayVersionsXml(
149 pluginPackage.getLiferayVersions());
150
151 int pos = moduleArtifactId.indexOf("-theme");
152
153 String themeId = moduleArtifactId.substring(0, pos);
154 String themeName = pluginName;
155
156 Map<String, String> filterMap = new HashMap<String, String>();
157
158 filterMap.put("module_group_id", moduleGroupId);
159 filterMap.put("module_artifact_id", moduleArtifactId);
160 filterMap.put("module_version", moduleVersion);
161
162 filterMap.put("plugin_name", pluginName);
163 filterMap.put("plugin_type", pluginType);
164 filterMap.put("plugin_type_name", pluginTypeName);
165
166 filterMap.put("tags", tags);
167 filterMap.put("short_description", shortDescription);
168 filterMap.put("long_description", longDescription);
169 filterMap.put("change_log", changeLog);
170 filterMap.put("page_url", pageURL);
171 filterMap.put("author", author);
172 filterMap.put("licenses", licenses);
173 filterMap.put("liferay_versions", liferayVersions);
174
175 filterMap.put("theme_id", themeId);
176 filterMap.put("theme_name", themeName);
177 filterMap.put(
178 "theme_versions",
179 StringUtil.replace(liferayVersions, "liferay-version", "version"));
180
181 copyDependencyXml(
182 "liferay-look-and-feel.xml", srcFile + "/WEB-INF", filterMap, true);
183 copyDependencyXml(
184 "liferay-plugin-package.xml", srcFile + "/WEB-INF", filterMap,
185 true);
186 }
187
188 }