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