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 public 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 @Override
046 public void copyXmls(
047 File srcFile, String displayName, PluginPackage pluginPackage)
048 throws Exception {
049
050 super.copyXmls(srcFile, displayName, pluginPackage);
051
052
053
054
055
056
057 FileUtil.delete(srcFile + "/META-INF/context.xml");
058
059 String portletName = displayName;
060
061 if (pluginPackage != null) {
062 portletName = pluginPackage.getName();
063 }
064
065 Map<String, String> filterMap = new HashMap<String, String>();
066
067 filterMap.put("portlet_name", displayName);
068 filterMap.put("portlet_title", portletName);
069
070 if (pluginPackage != null) {
071 Properties deploymentSettings =
072 pluginPackage.getDeploymentSettings();
073
074 filterMap.put(
075 "portlet_class",
076 deploymentSettings.getProperty(
077 "wai.portlet", WAIPortlet.class.getName()));
078
079 filterMap.put(
080 "friendly_url_mapper_class",
081 deploymentSettings.getProperty(
082 "wai.friendly.url.mapper",
083 DefaultFriendlyURLMapper.class.getName()));
084
085 filterMap.put(
086 "friendly_url_mapping",
087 deploymentSettings.getProperty(
088 "wai.friendly.url.mapping", "waiapp"));
089
090 filterMap.put(
091 "friendly_url_routes",
092 deploymentSettings.getProperty(
093 "wai.friendly.url.routes",
094 "com/liferay/util/bridges/wai/" +
095 "wai-friendly-url-routes.xml"));
096 }
097 else {
098 filterMap.put("portlet_class", WAIPortlet.class.getName());
099
100 filterMap.put(
101 "friendly_url_mapper_class",
102 DefaultFriendlyURLMapper.class.getName());
103
104 filterMap.put("friendly_url_mapping", "waiapp");
105
106 filterMap.put(
107 "friendly_url_routes",
108 "com/liferay/util/bridges/wai/wai-friendly-url-routes.xml");
109 }
110
111 _setInitParams(filterMap, pluginPackage);
112
113 copyDependencyXml(
114 "liferay-display.xml", srcFile + "/WEB-INF", filterMap);
115 copyDependencyXml(
116 "liferay-portlet.xml", srcFile + "/WEB-INF", filterMap);
117 copyDependencyXml("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 final String[] _INIT_PARAM_DEFAULT_VALUES = new String[] {
146 "500"
147 };
148
149 private static final String[] _INIT_PARAM_NAMES = new String[] {
150 "wai.connector.iframe.height.default"
151 };
152
153 }