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.ThemeDeployer;
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 ThemeAutoDeployer extends ThemeDeployer implements AutoDeployer {
036    
037            public ThemeAutoDeployer() {
038                    try {
039                            baseDir = PrefsPropsUtil.getString(
040                                    PropsKeys.AUTO_DEPLOY_DEPLOY_DIR,
041                                    PropsValues.AUTO_DEPLOY_DEPLOY_DIR);
042                            destDir = DeployUtil.getAutoDeployDestDir();
043                            appServerType = ServerDetector.getServerId();
044                            themeTaglibDTD = DeployUtil.getResourcePath("liferay-theme.tld");
045                            utilTaglibDTD = DeployUtil.getResourcePath("liferay-util.tld");
046                            unpackWar = PrefsPropsUtil.getBoolean(
047                                    PropsKeys.AUTO_DEPLOY_UNPACK_WAR,
048                                    PropsValues.AUTO_DEPLOY_UNPACK_WAR);
049                            filePattern = StringPool.BLANK;
050                            jbossPrefix = PrefsPropsUtil.getString(
051                                    PropsKeys.AUTO_DEPLOY_JBOSS_PREFIX,
052                                    PropsValues.AUTO_DEPLOY_JBOSS_PREFIX);
053                            tomcatLibDir = PrefsPropsUtil.getString(
054                                    PropsKeys.AUTO_DEPLOY_TOMCAT_LIB_DIR,
055                                    PropsValues.AUTO_DEPLOY_TOMCAT_LIB_DIR);
056    
057                            List<String> jars = new ArrayList<String>();
058    
059                            addExtJar(jars, "ext-util-java.jar");
060                            addExtJar(jars, "ext-util-taglib.jar");
061                            addRequiredJar(jars, "util-java.jar");
062                            addRequiredJar(jars, "util-taglib.jar");
063    
064                            this.jars = jars;
065    
066                            checkArguments();
067                    }
068                    catch (Exception e) {
069                            _log.error(e);
070                    }
071            }
072    
073            public void autoDeploy(String file) throws AutoDeployException {
074                    List<String> wars = new ArrayList<String>();
075    
076                    wars.add(file);
077    
078                    this.wars = wars;
079    
080                    try {
081                            deploy();
082                    }
083                    catch (Exception e) {
084                            throw new AutoDeployException(e);
085                    }
086            }
087    
088            private static Log _log = LogFactoryUtil.getLog(ThemeAutoDeployer.class);
089    
090    }