001
014
015 package com.liferay.portal.tools.deploy;
016
017 import com.liferay.portal.kernel.plugin.PluginPackage;
018 import com.liferay.portal.kernel.util.StringBundler;
019 import com.liferay.portal.kernel.util.StringPool;
020 import com.liferay.portal.kernel.util.StringUtil;
021 import com.liferay.portal.kernel.util.Validator;
022 import com.liferay.portal.model.Plugin;
023 import com.liferay.portal.util.InitUtil;
024
025 import java.io.File;
026
027 import java.util.ArrayList;
028 import java.util.List;
029 import java.util.Map;
030
031
034 public class ThemeDeployer extends BaseDeployer {
035
036 public static void main(String[] args) {
037 InitUtil.initWithSpring();
038
039 List<String> wars = new ArrayList<String>();
040 List<String> jars = new ArrayList<String>();
041
042 for (String arg : args) {
043 if (arg.endsWith(".war")) {
044 wars.add(arg);
045 }
046 else if (arg.endsWith(".jar")) {
047 jars.add(arg);
048 }
049 }
050
051 new ThemeDeployer(wars, jars);
052 }
053
054 public ThemeDeployer() {
055 }
056
057 public ThemeDeployer(List<String> wars, List<String> jars) {
058 super(wars, jars);
059 }
060
061 @Override
062 public void checkArguments() {
063 super.checkArguments();
064
065 if (Validator.isNull(themeTaglibDTD)) {
066 throw new IllegalArgumentException(
067 "The system property deployer.theme.taglib.dtd is not set");
068 }
069
070 if (Validator.isNull(utilTaglibDTD)) {
071 throw new IllegalArgumentException(
072 "The system property deployer.util.taglib.dtd is not set");
073 }
074 }
075
076 @Override
077 public String getExtraFiltersContent(double webXmlVersion, File srcFile)
078 throws Exception {
079
080 StringBundler sb = new StringBundler(3);
081
082 String extraFiltersContent = super.getExtraFiltersContent(
083 webXmlVersion, srcFile);
084
085 sb.append(extraFiltersContent);
086
087
088
089 sb.append(getIgnoreFiltersContent(srcFile));
090
091
092
093 sb.append(getSpeedFiltersContent(srcFile));
094
095 return sb.toString();
096 }
097
098 @Override
099 public String getPluginType() {
100 return Plugin.TYPE_THEME;
101 }
102
103 @Override
104 public Map<String, String> processPluginPackageProperties(
105 File srcFile, String displayName, PluginPackage pluginPackage)
106 throws Exception {
107
108 Map<String, String> filterMap = super.processPluginPackageProperties(
109 srcFile, displayName, pluginPackage);
110
111 if (filterMap == null) {
112 return null;
113 }
114
115 String moduleArtifactId = filterMap.get("module_artifact_id");
116
117 int pos = moduleArtifactId.indexOf("-theme");
118
119 String themeId = moduleArtifactId.substring(0, pos);
120
121 filterMap.put("theme_id", themeId);
122
123 String themeName = filterMap.get("plugin_name");
124
125 filterMap.put("theme_name", stripCDATA(themeName));
126
127 String liferayVersions = filterMap.get("liferay_versions");
128
129 filterMap.put(
130 "theme_versions",
131 StringUtil.replace(liferayVersions, "liferay-version", "version"));
132
133 copyDependencyXml(
134 "liferay-look-and-feel.xml", srcFile + "/WEB-INF", filterMap, true);
135
136 return filterMap;
137 }
138
139 protected static String stripCDATA(String s) {
140 if (s == null) {
141 return s;
142 }
143
144 if (s.startsWith(StringPool.CDATA_OPEN) &&
145 s.endsWith(StringPool.CDATA_CLOSE)) {
146
147 s = s.substring(
148 StringPool.CDATA_OPEN.length(),
149 s.length() - StringPool.CDATA_CLOSE.length());
150 }
151
152 return s;
153 }
154
155 }