001    /**
002     * Copyright (c) 2000-2013 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.exploded.tomcat;
016    
017    import com.liferay.portal.kernel.deploy.auto.AutoDeployException;
018    import com.liferay.portal.kernel.deploy.auto.AutoDeployer;
019    import com.liferay.portal.kernel.log.Log;
020    import com.liferay.portal.kernel.log.LogFactoryUtil;
021    
022    import java.io.File;
023    
024    /**
025     * @author Olaf Fricke
026     * @author Brian Wing Shun Chan
027     */
028    public class ThemeExplodedTomcatListener extends BaseExplodedTomcatListener {
029    
030            public ThemeExplodedTomcatListener() {
031                    _deployer = new ThemeExplodedTomcatDeployer();
032            }
033    
034            @Override
035            protected int deploy(File file) throws AutoDeployException {
036                    if (_log.isDebugEnabled()) {
037                            _log.debug("Invoking deploy for " + file.getPath());
038                    }
039    
040                    File docBaseDir = getDocBaseDir(
041                            file, "WEB-INF/liferay-look-and-feel.xml");
042    
043                    if (docBaseDir == null) {
044                            return AutoDeployer.CODE_NOT_APPLICABLE;
045                    }
046    
047                    if (_log.isInfoEnabled()) {
048                            _log.info("Modifying themes for " + file.getPath());
049                    }
050    
051                    _deployer.explodedTomcatDeploy(file, docBaseDir, null);
052    
053                    if (_log.isInfoEnabled()) {
054                            _log.info(
055                                    "Themes for " + file.getPath() + " modified successfully");
056                    }
057    
058                    copyContextFile(file);
059    
060                    return AutoDeployer.CODE_DEFAULT;
061            }
062    
063            private static Log _log = LogFactoryUtil.getLog(
064                    ThemeExplodedTomcatListener.class);
065    
066            private ExplodedTomcatDeployer _deployer;
067    
068    }