1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
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  import com.liferay.portal.util.Portal;
21  
22  import java.io.File;
23  
24  /**
25   * <a href="PortletExplodedTomcatListener.java.html"><b><i>View Source</i></b>
26   * </a>
27   *
28   * @author Olaf Fricke
29   * @author Brian Wing Shun Chan
30   */
31  public class PortletExplodedTomcatListener extends BaseExplodedTomcatListener {
32  
33      public PortletExplodedTomcatListener() {
34          _deployer = new PortletExplodedTomcatDeployer();
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          ExplodedTomcatDeployer deployer = null;
43  
44          File docBaseDir = getDocBaseDir(file, "index.php");
45  
46          if (docBaseDir != null) {
47              deployer = getPhpDeployer();
48          }
49          else {
50              docBaseDir = getDocBaseDir(
51                  file, "WEB-INF/" + Portal.PORTLET_XML_FILE_NAME_STANDARD);
52  
53              if (docBaseDir != null) {
54                  deployer = _deployer;
55              }
56              else {
57                  return;
58              }
59          }
60  
61          if (_log.isInfoEnabled()) {
62              _log.info("Modifying portlets for " + file.getPath());
63          }
64  
65          deployer.explodedTomcatDeploy(file, docBaseDir, null);
66  
67          if (_log.isInfoEnabled()) {
68              _log.info(
69                  "Portlets for " + file.getPath() + " modified successfully");
70          }
71  
72          copyContextFile(file);
73      }
74  
75      protected ExplodedTomcatDeployer getPhpDeployer()
76          throws AutoDeployException {
77  
78          if (_phpDeployer == null) {
79              _phpDeployer = new PHPPortletExplodedTomcatDeployer();
80          }
81  
82          return _phpDeployer;
83      }
84  
85      private static Log _log = LogFactoryUtil.getLog(
86          PortletExplodedTomcatListener.class);
87  
88      private ExplodedTomcatDeployer _deployer;
89      private PHPPortletExplodedTomcatDeployer _phpDeployer;
90  
91  }