001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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    }