001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portal.deploy.auto;
022:
023: import com.liferay.portal.deploy.DeployUtil;
024: import com.liferay.portal.kernel.deploy.auto.AutoDeployException;
025: import com.liferay.portal.kernel.plugin.PluginPackage;
026: import com.liferay.portal.kernel.util.Validator;
027:
028: import java.io.File;
029:
030: import java.util.HashMap;
031: import java.util.Map;
032: import java.util.Properties;
033:
034: /**
035: * <a href="WAIAutoDeployer.java.html"><b><i>View Source</i></b></a>
036: *
037: * @author Jorge Ferrer
038: *
039: */
040: public class WAIAutoDeployer extends PortletAutoDeployer {
041:
042: protected WAIAutoDeployer() throws AutoDeployException {
043: try {
044: jars.add(DeployUtil.getResourcePath("portals-bridges.jar"));
045: } catch (Exception e) {
046: throw new AutoDeployException(e);
047: }
048: }
049:
050: protected void copyXmls(File srcFile, String displayName,
051: PluginPackage pluginPackage) throws Exception {
052:
053: super .copyXmls(srcFile, displayName, pluginPackage);
054:
055: String portletName = displayName;
056:
057: if (pluginPackage != null) {
058: portletName = pluginPackage.getName();
059: }
060:
061: Map filterMap = new HashMap();
062:
063: filterMap.put("portlet_name", displayName);
064: filterMap.put("portlet_title", portletName);
065: filterMap.put("restore_current_view", "false");
066:
067: if (pluginPackage != null) {
068: Properties settings = pluginPackage.getDeploymentSettings();
069:
070: filterMap.put("portlet_class", settings.getProperty(
071: "wai.portlet",
072: "com.liferay.util.bridges.wai.WAIPortlet"));
073:
074: filterMap
075: .put(
076: "friendly_url_mapper_class",
077: settings
078: .getProperty(
079: "wai.friendly.url.mapper",
080: "com.liferay.portlet.WAIFriendlyURLMapper"));
081: } else {
082: filterMap.put("portlet_class",
083: "com.liferay.util.bridges.wai.WAIPortlet");
084:
085: filterMap.put("friendly_url_mapper_class",
086: "com.liferay.portlet.WAIFriendlyURLMapper");
087: }
088:
089: _setInitParams(filterMap, pluginPackage);
090:
091: copyDependencyXml("liferay-display.xml", srcFile + "/WEB-INF",
092: filterMap);
093: copyDependencyXml("liferay-portlet.xml", srcFile + "/WEB-INF",
094: filterMap);
095: copyDependencyXml("portlet.xml", srcFile + "/WEB-INF",
096: filterMap);
097: copyDependencyXml("normal_window_state.jsp", srcFile
098: + "/WEB-INF/jsp/liferay/wai");
099: copyDependencyXml("iframe.jsp", srcFile
100: + "/WEB-INF/jsp/liferay/wai");
101:
102: }
103:
104: private void _setInitParams(Map filterMap,
105: PluginPackage pluginPackage) {
106: for (int i = 0; i < _INIT_PARAM_NAMES.length; i++) {
107: String name = _INIT_PARAM_NAMES[i];
108:
109: String value = null;
110:
111: if (pluginPackage != null) {
112: pluginPackage.getDeploymentSettings().getProperty(name);
113: }
114:
115: if (Validator.isNull(value)) {
116: value = _INIT_PARAM_DEFAULT_VALUES[i];
117: }
118:
119: filterMap.put("init_param_name_" + i, name);
120: filterMap.put("init_param_value_" + i, value);
121: }
122: }
123:
124: private static String[] _INIT_PARAM_NAMES = new String[] {
125: "wai.connector", "wai.connector.iframe.height.extra" };
126:
127: private static String[] _INIT_PARAM_DEFAULT_VALUES = new String[] {
128: "iframe", "40" };
129:
130: }
|