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.exploded.tomcat;
016    
017    import com.liferay.portal.kernel.deploy.auto.AutoDeployException;
018    import com.liferay.portal.kernel.log.Log;
019    import com.liferay.portal.kernel.log.LogFactoryUtil;
020    import com.liferay.portal.util.Portal;
021    
022    import java.io.File;
023    
024    /**
025     * @author Gregory Amerson
026     */
027    public class HookExplodedTomcatListener extends BaseExplodedTomcatListener {
028    
029            public HookExplodedTomcatListener() {
030                    _deployer = new HookExplodedTomcatDeployer();
031            }
032    
033            @Override
034            protected void deploy(File file) throws AutoDeployException {
035                    if (_log.isDebugEnabled()) {
036                            _log.debug("Invoking deploy for " + file.getPath());
037                    }
038    
039                    File docBaseDir = getDocBaseDir(
040                            file, "WEB-INF/" + Portal.PORTLET_XML_FILE_NAME_STANDARD);
041    
042                    if (docBaseDir != null) {
043                            return;
044                    }
045    
046                    docBaseDir = getDocBaseDir(file, "WEB-INF/liferay-hook.xml");
047    
048                    if (docBaseDir == null) {
049                            return;
050                    }
051    
052                    if (_log.isInfoEnabled()) {
053                            _log.info("Modifying hook for " + file.getPath());
054                    }
055    
056                    _deployer.explodedTomcatDeploy(file, docBaseDir, null);
057    
058                    if (_log.isInfoEnabled()) {
059                            _log.info("Hook for " + file.getPath() + " modified successfully");
060                    }
061    
062                    copyContextFile(file);
063            }
064    
065            private static Log _log = LogFactoryUtil.getLog(
066                    HookExplodedTomcatListener.class);
067    
068            private ExplodedTomcatDeployer _deployer;
069    
070    }