Skip to content

Commit

Permalink
LPS-27142 TCK deploys its test wars as 2.3, so let's remove support e…
Browse files Browse the repository at this point in the history
…xcept for TCK
  • Loading branch information
brianchandotcom committed May 9, 2012
1 parent 4adb170 commit 73bd8bf
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 23 deletions.
53 changes: 36 additions & 17 deletions portal-impl/src/com/liferay/portal/tools/deploy/BaseDeployer.java
Expand Up @@ -960,7 +960,8 @@ public String getDisplayName(File srcFile) {
return displayName;
}

public String getExtraContent(File srcFile, String displayName)
public String getExtraContent(
double webXmlVersion, File srcFile, String displayName)
throws Exception {

StringBundler sb = new StringBundler();
Expand All @@ -969,6 +970,13 @@ public String getExtraContent(File srcFile, String displayName)
sb.append(displayName);
sb.append("</display-name>");

if (webXmlVersion < 2.4) {
sb.append("<context-param>");
sb.append("<param-name>liferay-invoker-enabled</param-name>");
sb.append("<param-value>false</param-value>");
sb.append("</context-param>");
}

sb.append("<listener>");
sb.append("<listener-class>");
sb.append("com.liferay.portal.kernel.servlet.");
Expand Down Expand Up @@ -1005,7 +1013,7 @@ public String getExtraContent(File srcFile, String displayName)
hasTaglib = true;
}

if (hasTaglib) {
if (hasTaglib && (webXmlVersion > 2.3)) {
sb.append("<jsp-config>");
}

Expand Down Expand Up @@ -1077,7 +1085,7 @@ public String getExtraContent(File srcFile, String displayName)
sb.append("</taglib>");
}

if (hasTaglib) {
if (hasTaglib && (webXmlVersion > 2.3)) {
sb.append("</jsp-config>");
}

Expand Down Expand Up @@ -1298,25 +1306,26 @@ public String getServletContextIncludeFiltersContent(
double webXmlVersion, File srcFile)
throws Exception {

boolean servletContextIncludeFiltersEnabled = true;
if (webXmlVersion < 2.4) {
return StringPool.BLANK;
}

Properties properties = getPluginPackageProperties(srcFile);

if (properties != null) {
servletContextIncludeFiltersEnabled = GetterUtil.getBoolean(
properties.getProperty(
"servlet-context-include-filters-enabled"), true);
if (properties == null) {
return StringPool.BLANK;
}

if (servletContextIncludeFiltersEnabled) {
String servletContextIncludeFiltersContent = FileUtil.read(
DeployUtil.getResourcePath(
"servlet-context-include-filters-web.xml"));
if (!GetterUtil.getBoolean(
properties.getProperty(
"servlet-context-include-filters-enabled"), true)) {

return servletContextIncludeFiltersContent;
return StringPool.BLANK;
}

return StringPool.BLANK;
return FileUtil.read(
DeployUtil.getResourcePath(
"servlet-context-include-filters-web.xml"));
}

public String getSessionFiltersContent() throws Exception {
Expand Down Expand Up @@ -1754,7 +1763,7 @@ public String updateLiferayWebXml(
y = x;
}
else {
if (liferayWebXmlEnabled) {
if (liferayWebXmlEnabled && (webXmlVersion > 2.3)) {
webXmlFiltersContent = webXmlContent.substring(x, y + 17);

y = y + 17;
Expand All @@ -1765,6 +1774,15 @@ public String updateLiferayWebXml(
}
}

if (webXmlVersion < 2.4) {
webXmlContent =
webXmlContent.substring(0, x) +
getExtraFiltersContent(webXmlVersion, srcFile) +
webXmlContent.substring(y);

return webXmlContent;
}

String filtersContent =
webXmlFiltersContent +
getExtraFiltersContent(webXmlVersion, srcFile);
Expand Down Expand Up @@ -1817,7 +1835,7 @@ public void updateWebXml(
double webXmlVersion = GetterUtil.getDouble(
rootElement.attributeValue("version"), 2.3);

if (webXmlVersion <= 2.3) {
if (!PropsValues.TCK_URL && (webXmlVersion <= 2.3)) {
throw new AutoDeployException(
webXml.getName() +
" must be updated to the Servlet 2.4 specification");
Expand Down Expand Up @@ -1853,7 +1871,8 @@ public void updateWebXml(

// Merge content

String extraContent = getExtraContent(srcFile, displayName);
String extraContent = getExtraContent(
webXmlVersion, srcFile, displayName);

int pos = content.indexOf("<listener>");

Expand Down
Expand Up @@ -112,7 +112,8 @@ public void copyXmls(
}

@Override
public String getExtraContent(File srcFile, String displayName)
public String getExtraContent(
double webXmlVersion, File srcFile, String displayName)
throws Exception {

StringBundler sb = new StringBundler();
Expand Down Expand Up @@ -150,7 +151,8 @@ public String getExtraContent(File srcFile, String displayName)
sb.append("</listener>");
}

String extraContent = super.getExtraContent(srcFile, displayName);
String extraContent = super.getExtraContent(
webXmlVersion, srcFile, displayName);

sb.append(extraContent);

Expand Down
Expand Up @@ -16,6 +16,9 @@

import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.servlet.filters.invoker.FilterMapping;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.PropsKeys;
import com.liferay.portal.kernel.util.PropsUtil;
import com.liferay.portal.kernel.util.StringPool;

import java.io.IOException;
Expand All @@ -24,6 +27,7 @@

import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
Expand Down Expand Up @@ -85,9 +89,19 @@ public FilterConfig getFilterConfig() {
public void init(FilterConfig filterConfig) {
_filterConfig = filterConfig;

_filterMapping = new FilterMapping(
this, filterConfig, new ArrayList<String>(0),
new ArrayList<String>(0));
if (_TCK_URL) {
ServletContext servletContext = _filterConfig.getServletContext();

_invokerEnabled = GetterUtil.get(
servletContext.getInitParameter("liferay-invoker-enabled"),
true);

if (!_invokerEnabled) {
_filterMapping = new FilterMapping(
this, filterConfig, new ArrayList<String>(0),
new ArrayList<String>(0));
}
}

LiferayFilterTracker.addLiferayFilter(this);
}
Expand Down Expand Up @@ -182,9 +196,12 @@ protected void processFilter(

private static final String _DEPTHER = "DEPTHER";

private static final boolean _TCK_URL = GetterUtil.getBoolean(
PropsUtil.get(PropsKeys.TCK_URL));

private FilterConfig _filterConfig;
private boolean _filterEnabled = true;
private FilterMapping _filterMapping;
private boolean _invokerEnabled;
private boolean _invokerEnabled = true;

}

0 comments on commit 73bd8bf

Please sign in to comment.