001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.deploy.auto;
016    
017    import com.liferay.portal.deploy.DeployUtil;
018    import com.liferay.portal.kernel.deploy.auto.AutoDeployException;
019    import com.liferay.portal.kernel.log.Log;
020    import com.liferay.portal.kernel.log.LogFactoryUtil;
021    import com.liferay.portal.kernel.util.PropsKeys;
022    import com.liferay.portal.kernel.util.ServerDetector;
023    import com.liferay.portal.kernel.util.StringPool;
024    import com.liferay.portal.tools.deploy.PortletDeployer;
025    import com.liferay.portal.util.PrefsPropsUtil;
026    import com.liferay.portal.util.PropsValues;
027    
028    import java.util.ArrayList;
029    import java.util.List;
030    
031    /**
032     * @author Ivica Cardic
033     * @author Brian Wing Shun Chan
034     */
035    public class PortletAutoDeployer
036            extends PortletDeployer implements AutoDeployer {
037    
038            public PortletAutoDeployer() {
039                    try {
040                            baseDir = PrefsPropsUtil.getString(
041                                    PropsKeys.AUTO_DEPLOY_DEPLOY_DIR,
042                                    PropsValues.AUTO_DEPLOY_DEPLOY_DIR);
043                            destDir = DeployUtil.getAutoDeployDestDir();
044                            appServerType = ServerDetector.getServerId();
045                            auiTaglibDTD = DeployUtil.getResourcePath("liferay-aui.tld");
046                            portletTaglibDTD = DeployUtil.getResourcePath(
047                                    "liferay-portlet.tld");
048                            portletExtTaglibDTD = DeployUtil.getResourcePath(
049                                    "liferay-portlet-ext.tld");
050                            securityTaglibDTD = DeployUtil.getResourcePath(
051                                    "liferay-security.tld");
052                            themeTaglibDTD = DeployUtil.getResourcePath("liferay-theme.tld");
053                            uiTaglibDTD = DeployUtil.getResourcePath("liferay-ui.tld");
054                            utilTaglibDTD = DeployUtil.getResourcePath("liferay-util.tld");
055                            unpackWar = PrefsPropsUtil.getBoolean(
056                                    PropsKeys.AUTO_DEPLOY_UNPACK_WAR,
057                                    PropsValues.AUTO_DEPLOY_UNPACK_WAR);
058                            filePattern = StringPool.BLANK;
059                            jbossPrefix = PrefsPropsUtil.getString(
060                                    PropsKeys.AUTO_DEPLOY_JBOSS_PREFIX,
061                                    PropsValues.AUTO_DEPLOY_JBOSS_PREFIX);
062                            tomcatLibDir = PrefsPropsUtil.getString(
063                                    PropsKeys.AUTO_DEPLOY_TOMCAT_LIB_DIR,
064                                    PropsValues.AUTO_DEPLOY_TOMCAT_LIB_DIR);
065    
066                            List<String> jars = new ArrayList<String>();
067    
068                            addExtJar(jars, "ext-util-bridges.jar");
069                            addExtJar(jars, "ext-util-java.jar");
070                            addExtJar(jars, "ext-util-taglib.jar");
071                            addRequiredJar(jars, "util-bridges.jar");
072                            addRequiredJar(jars, "util-java.jar");
073                            addRequiredJar(jars, "util-taglib.jar");
074    
075                            this.jars = jars;
076    
077                            checkArguments();
078                    }
079                    catch (Exception e) {
080                            _log.error(e);
081                    }
082            }
083    
084            public void autoDeploy(String file) throws AutoDeployException {
085                    List<String> wars = new ArrayList<String>();
086    
087                    wars.add(file);
088    
089                    this.wars = wars;
090    
091                    try {
092                            deploy();
093                    }
094                    catch (Exception e) {
095                            throw new AutoDeployException(e);
096                    }
097            }
098    
099            private static Log _log = LogFactoryUtil.getLog(PortletAutoDeployer.class);
100    
101    }