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