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 LayoutTemplateExplodedTomcatListener
029            extends BaseExplodedTomcatListener {
030    
031            public LayoutTemplateExplodedTomcatListener() {
032                    _deployer = new LayoutTemplateExplodedTomcatDeployer();
033            }
034    
035            @Override
036            protected int deploy(File file) throws AutoDeployException {
037                    if (_log.isDebugEnabled()) {
038                            _log.debug("Invoking deploy for " + file.getPath());
039                    }
040    
041                    File docBaseDir = getDocBaseDir(
042                            file, "WEB-INF/liferay-layout-templates.xml");
043    
044                    if (docBaseDir == null) {
045                            return AutoDeployer.CODE_NOT_APPLICABLE;
046                    }
047    
048                    if (_log.isInfoEnabled()) {
049                            _log.info("Modifying layout templates for " + file.getPath());
050                    }
051    
052                    _deployer.explodedTomcatDeploy(file, docBaseDir, null);
053    
054                    if (_log.isInfoEnabled()) {
055                            _log.info(
056                                    "Layout templates for " + file.getPath() +
057                                            " modified successfully");
058                    }
059    
060                    copyContextFile(file);
061    
062                    return AutoDeployer.CODE_DEFAULT;
063            }
064    
065            private static Log _log = LogFactoryUtil.getLog(
066                    LayoutTemplateExplodedTomcatListener.class);
067    
068            private ExplodedTomcatDeployer _deployer;
069    
070    }