001
014
015 package com.liferay.portal.deploy.auto;
016
017 import com.liferay.portal.kernel.deploy.auto.AutoDeployException;
018 import com.liferay.portal.kernel.plugin.PluginPackage;
019 import com.liferay.portal.kernel.portlet.DefaultFriendlyURLMapper;
020 import com.liferay.portal.kernel.util.FileUtil;
021 import com.liferay.portal.kernel.util.Validator;
022 import com.liferay.util.bridges.wai.WAIPortlet;
023
024 import java.io.File;
025
026 import java.util.HashMap;
027 import java.util.Map;
028 import java.util.Properties;
029
030
034 public class WAIAutoDeployer extends PortletAutoDeployer {
035
036 protected WAIAutoDeployer() throws AutoDeployException {
037 try {
038 addRequiredJar(jars, "portals-bridges.jar");
039 }
040 catch (Exception e) {
041 throw new AutoDeployException(e);
042 }
043 }
044
045 protected void copyXmls(
046 File srcFile, String displayName, PluginPackage pluginPackage)
047 throws Exception {
048
049 super.copyXmls(srcFile, displayName, pluginPackage);
050
051
052
053
054
055
056 FileUtil.delete(srcFile + "/META-INF/context.xml");
057
058 String portletName = displayName;
059
060 if (pluginPackage != null) {
061 portletName = pluginPackage.getName();
062 }
063
064 Map<String, String> filterMap = new HashMap<String, String>();
065
066 filterMap.put("portlet_name", displayName);
067 filterMap.put("portlet_title", portletName);
068
069 if (pluginPackage != null) {
070 Properties deploymentSettings =
071 pluginPackage.getDeploymentSettings();
072
073 filterMap.put(
074 "portlet_class",
075 deploymentSettings.getProperty(
076 "wai.portlet", WAIPortlet.class.getName()));
077
078 filterMap.put(
079 "friendly_url_mapper_class",
080 deploymentSettings.getProperty(
081 "wai.friendly.url.mapper",
082 DefaultFriendlyURLMapper.class.getName()));
083
084 filterMap.put(
085 "friendly_url_mapping",
086 deploymentSettings.getProperty(
087 "wai.friendly.url.mapping", "waiapp"));
088
089 filterMap.put(
090 "friendly_url_routes",
091 deploymentSettings.getProperty(
092 "wai.friendly.url.routes",
093 "com/liferay/util/bridges/wai/" +
094 "wai-friendly-url-routes.xml"));
095 }
096 else {
097 filterMap.put("portlet_class", WAIPortlet.class.getName());
098
099 filterMap.put(
100 "friendly_url_mapper_class",
101 DefaultFriendlyURLMapper.class.getName());
102
103 filterMap.put("friendly_url_mapping", "waiapp");
104
105 filterMap.put(
106 "friendly_url_routes",
107 "com/liferay/util/bridges/wai/wai-friendly-url-routes.xml");
108 }
109
110 _setInitParams(filterMap, pluginPackage);
111
112 copyDependencyXml(
113 "liferay-display.xml", srcFile + "/WEB-INF", filterMap);
114 copyDependencyXml(
115 "liferay-portlet.xml", srcFile + "/WEB-INF", filterMap);
116 copyDependencyXml(
117 "portlet.xml", srcFile + "/WEB-INF", filterMap);
118 copyDependencyXml("iframe.jsp", srcFile + "/WEB-INF/jsp/liferay/wai");
119 }
120
121 private void _setInitParams(
122 Map<String, String> filterMap, PluginPackage pluginPackage) {
123
124 for (int i = 0; i < _INIT_PARAM_NAMES.length; i++) {
125 String name = _INIT_PARAM_NAMES[i];
126
127 String value = null;
128
129 if (pluginPackage != null) {
130 Properties deploymentSettings =
131 pluginPackage.getDeploymentSettings();
132
133 value = deploymentSettings.getProperty(name);
134 }
135
136 if (Validator.isNull(value)) {
137 value = _INIT_PARAM_DEFAULT_VALUES[i];
138 }
139
140 filterMap.put("init_param_name_" + i, name);
141 filterMap.put("init_param_value_" + i, value);
142 }
143 }
144
145 private static String[] _INIT_PARAM_NAMES = new String[] {
146 "wai.connector.iframe.height.default"
147 };
148
149 private static String[] _INIT_PARAM_DEFAULT_VALUES = new String[] {
150 "500"
151 };
152
153 }