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