1
22
23 package com.liferay.portal.deploy.auto;
24
25 import com.liferay.portal.deploy.DeployUtil;
26 import com.liferay.portal.kernel.deploy.auto.AutoDeployException;
27 import com.liferay.portal.kernel.plugin.PluginPackage;
28 import com.liferay.portal.kernel.util.Validator;
29
30 import java.io.File;
31
32 import java.util.HashMap;
33 import java.util.Map;
34 import java.util.Properties;
35
36
41 public class WAIAutoDeployer extends PortletAutoDeployer {
42
43 protected WAIAutoDeployer() throws AutoDeployException {
44 try {
45 jars.add(DeployUtil.getResourcePath("portals-bridges.jar"));
46 }
47 catch (Exception e) {
48 throw new AutoDeployException(e);
49 }
50 }
51
52 protected void copyXmls(
53 File srcFile, String displayName, PluginPackage pluginPackage)
54 throws Exception {
55
56 super.copyXmls(srcFile, displayName, pluginPackage);
57
58 String portletName = displayName;
59
60 if (pluginPackage != null) {
61 portletName = pluginPackage.getName();
62 }
63
64 Map<String, String> filterMap = new HashMap<String, String>();
65
66 filterMap.put("portlet_name", displayName);
67 filterMap.put("portlet_title", portletName);
68 filterMap.put("restore_current_view", "false");
69
70 if (pluginPackage != null) {
71 Properties settings = pluginPackage.getDeploymentSettings();
72
73 filterMap.put(
74 "portlet_class",
75 settings.getProperty(
76 "wai.portlet", "com.liferay.util.bridges.wai.WAIPortlet"));
77
78 filterMap.put(
79 "friendly_url_mapper_class",
80 settings.getProperty(
81 "wai.friendly.url.mapper",
82 "com.liferay.util.bridges.wai.WAIFriendlyURLMapper"));
83 }
84 else {
85 filterMap.put(
86 "portlet_class", "com.liferay.util.bridges.wai.WAIPortlet");
87
88 filterMap.put(
89 "friendly_url_mapper_class",
90 "com.liferay.util.bridges.wai.WAIFriendlyURLMapper");
91 }
92
93 _setInitParams(filterMap, pluginPackage);
94
95 copyDependencyXml(
96 "liferay-display.xml", srcFile + "/WEB-INF", filterMap);
97 copyDependencyXml(
98 "liferay-portlet.xml", srcFile + "/WEB-INF", filterMap);
99 copyDependencyXml(
100 "portlet.xml", srcFile + "/WEB-INF", filterMap);
101 copyDependencyXml(
102 "normal_window_state.jsp", srcFile + "/WEB-INF/jsp/liferay/wai");
103 copyDependencyXml("iframe.jsp", srcFile + "/WEB-INF/jsp/liferay/wai");
104
105 }
106
107 private void _setInitParams(
108 Map<String, String> filterMap, PluginPackage pluginPackage) {
109
110 for (int i = 0; i < _INIT_PARAM_NAMES.length; i++) {
111 String name = _INIT_PARAM_NAMES[i];
112
113 String value = null;
114
115 if (pluginPackage != null) {
116 pluginPackage.getDeploymentSettings().getProperty(name);
117 }
118
119 if (Validator.isNull(value)) {
120 value = _INIT_PARAM_DEFAULT_VALUES[i];
121 }
122
123 filterMap.put("init_param_name_" + i, name);
124 filterMap.put("init_param_value_" + i, value);
125 }
126 }
127
128 private static String[] _INIT_PARAM_NAMES = new String[] {
129 "wai.connector", "wai.connector.iframe.height.extra"
130 };
131
132 private static String[] _INIT_PARAM_DEFAULT_VALUES = new String[] {
133 "iframe", "40"
134 };
135
136 }