001
014
015 package com.liferay.portal.deploy.auto;
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.deploy.auto.BaseAutoDeployListener;
020 import com.liferay.portal.kernel.log.Log;
021 import com.liferay.portal.kernel.log.LogFactoryUtil;
022 import com.liferay.portal.kernel.util.Portal;
023
024 import java.io.File;
025
026
033 public class PortletAutoDeployListener extends BaseAutoDeployListener {
034
035 @Override
036 protected AutoDeployer buildAutoDeployer() throws AutoDeployException {
037 AutoDeployer autoDeployer = null;
038
039 if (_portletDeployer) {
040 autoDeployer = new PortletAutoDeployer();
041 }
042 else if (_mvcDeployer) {
043 autoDeployer = new MVCPortletAutoDeployer();
044 }
045 else if (_waiDeployer) {
046 if (_log.isInfoEnabled()) {
047 _log.info("Deploying package as a web application");
048 }
049
050 autoDeployer = new WAIAutoDeployer();
051 }
052
053 if (autoDeployer == null) {
054 throw new AutoDeployException("Unable to find an auto deployer");
055 }
056
057 if (_log.isDebugEnabled()) {
058 Class<?> clazz = autoDeployer.getClass();
059
060 _log.debug("Using deployer " + clazz.getName());
061 }
062
063 return new ThreadSafeAutoDeployer(autoDeployer);
064 }
065
066 @Override
067 protected String getPluginPathInfoMessage(File file) {
068 return "Copying portlets for " + file.getPath();
069 }
070
071 @Override
072 protected String getSuccessMessage(File file) {
073 return "Portlets for " + file.getPath() + " copied successfully";
074 }
075
076 @Override
077 protected boolean isDeployable(File file) throws AutoDeployException {
078 PluginAutoDeployListenerHelper pluginAutoDeployListenerHelper =
079 new PluginAutoDeployListenerHelper(file);
080
081 if (pluginAutoDeployListenerHelper.isMatchingFile(
082 "WEB-INF/" + Portal.PORTLET_XML_FILE_NAME_STANDARD)) {
083
084 _portletDeployer = true;
085
086 return true;
087 }
088
089 if (pluginAutoDeployListenerHelper.isMatchingFile("index_mvc.jsp")) {
090 _mvcDeployer = true;
091
092 return true;
093 }
094
095 if (!pluginAutoDeployListenerHelper.isExtPlugin() &&
096 !pluginAutoDeployListenerHelper.isHookPlugin() &&
097 !pluginAutoDeployListenerHelper.isMatchingFile(
098 "WEB-INF/liferay-layout-templates.xml") &&
099 !pluginAutoDeployListenerHelper.isThemePlugin() &&
100 !pluginAutoDeployListenerHelper.isWebPlugin() &&
101 file.getName().endsWith(".war")) {
102
103 _waiDeployer = true;
104
105 return true;
106 }
107
108 return false;
109 }
110
111 private static final Log _log = LogFactoryUtil.getLog(
112 PortletAutoDeployListener.class);
113
114 private boolean _mvcDeployer;
115 private boolean _portletDeployer;
116 private boolean _waiDeployer;
117
118 }