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;
16  
17  import com.liferay.portal.kernel.deploy.auto.AutoDeployException;
18  import com.liferay.portal.kernel.deploy.auto.BaseAutoDeployListener;
19  import com.liferay.portal.kernel.log.Log;
20  import com.liferay.portal.kernel.log.LogFactoryUtil;
21  
22  import java.io.File;
23  
24  /**
25   * <a href="LayoutTemplateAutoDeployListener.java.html"><b><i>View Source</i>
26   * </b></a>
27   *
28   * @author Ivica Cardic
29   * @author Brian Wing Shun Chan
30   */
31  public class LayoutTemplateAutoDeployListener extends BaseAutoDeployListener {
32  
33      public LayoutTemplateAutoDeployListener() {
34          _deployer = new LayoutTemplateAutoDeployer();
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          if (!isMatchingFile(file, "WEB-INF/liferay-layout-templates.xml")) {
43              return;
44          }
45  
46          if (_log.isInfoEnabled()) {
47              _log.info("Copying layout templates for " + file.getPath());
48          }
49  
50          _deployer.autoDeploy(file.getName());
51  
52          if (_log.isInfoEnabled()) {
53              _log.info(
54                  "Layout templates for " + file.getPath() +
55                      " copied successfully. Deployment will start in a few " +
56                          "seconds.");
57          }
58      }
59  
60      private static Log _log = LogFactoryUtil.getLog(
61          LayoutTemplateAutoDeployListener.class);
62  
63      private AutoDeployer _deployer;
64  
65  }