1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.deploy.auto.exploded.tomcat;
16  
17  import com.liferay.portal.kernel.deploy.auto.AutoDeployException;
18  import com.liferay.portal.kernel.log.Log;
19  import com.liferay.portal.kernel.log.LogFactoryUtil;
20  
21  import java.io.File;
22  
23  /**
24   * <a href="LayoutTemplateExplodedTomcatListener.java.html"><b><i>View Source
25   * </i></b></a>
26   *
27   * @author Olaf Fricke
28   * @author Brian Wing Shun Chan
29   */
30  public class LayoutTemplateExplodedTomcatListener
31      extends BaseExplodedTomcatListener {
32  
33      public LayoutTemplateExplodedTomcatListener() {
34          _deployer = new LayoutTemplateExplodedTomcatDeployer();
35      }
36  
37      public void deploy(File file) throws AutoDeployException {
38          if (_log.isDebugEnabled()) {
39              _log.debug("Invoking deploy for " + file.getPath());
40          }
41  
42          File docBaseDir = getDocBaseDir(
43              file, "WEB-INF/liferay-layout-templates.xml");
44  
45          if (docBaseDir == null) {
46              return;
47          }
48  
49          if (_log.isInfoEnabled()) {
50              _log.info("Modifying layout templates for " + file.getPath());
51          }
52  
53          _deployer.explodedTomcatDeploy(file, docBaseDir, null);
54  
55          if (_log.isInfoEnabled()) {
56              _log.info(
57                  "Layout templates for " + file.getPath() +
58                      " modified successfully");
59          }
60  
61          copyContextFile(file);
62      }
63  
64      private static Log _log = LogFactoryUtil.getLog(
65          LayoutTemplateExplodedTomcatListener.class);
66  
67      private ExplodedTomcatDeployer _deployer;
68  
69  }