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