You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2021/10/07 10:03:08 UTC
[myfaces-tobago] branch master updated: feat: Suspend Portlet
support
This is an automated email from the ASF dual-hosted git repository.
lofwyr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git
The following commit(s) were added to refs/heads/master by this push:
new a66ef15 feat: Suspend Portlet support
a66ef15 is described below
commit a66ef15e0ce8500aa93864e47d9b1cd8cfd134e6
Author: Udo Schnurpfeil <ud...@irian.eu>
AuthorDate: Thu Oct 7 11:51:52 2021 +0200
feat: Suspend Portlet support
issue: TOBAGO-2095
---
pom.xml | 28 -----------
.../org/apache/myfaces/tobago/context/Markup.java | 2 -
.../internal/renderkit/renderer/FileRenderer.java | 2 +-
.../internal/renderkit/renderer/PageRenderer.java | 44 ++++-------------
.../tobago/internal/util/ResponseUtils.java | 27 -----------
.../myfaces/tobago/portlet/PortletUtils.java | 55 ----------------------
.../tobago/webapp/LogoutActionListener.java | 5 --
.../main/webapp/content/000-intro/70-faq/FAQ.xhtml | 3 +-
8 files changed, 12 insertions(+), 154 deletions(-)
diff --git a/pom.xml b/pom.xml
index d65efda..76daa8d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -472,12 +472,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.apache.portals</groupId>
- <artifactId>portlet-api_2.0_spec</artifactId>
- <version>1.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>1.3.5</version>
@@ -566,28 +560,6 @@
<groupId>jakarta.el</groupId>
<artifactId>jakarta.el-api</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.portals</groupId>
- <artifactId>portlet-api_2.0_spec</artifactId>
- </dependency>
-
- <!-- you may want to add this for debugging -->
-<!--
- <dependency>
- <groupId>org.jboss.portletbridge</groupId>
- <artifactId>portletbridge-api</artifactId>
- <version>3.2.1.Final</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.portletbridge</groupId>
- <artifactId>portletbridge-impl</artifactId>
- <version>3.2.1.Final</version>
- <scope>provided</scope>
- </dependency>
--->
-
</dependencies>
<scm>
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/context/Markup.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/context/Markup.java
index 3b912d1..15f17bf 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/context/Markup.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/context/Markup.java
@@ -104,7 +104,6 @@ public final class Markup implements Serializable, Iterable<String> {
public static final Markup OUTLINE_SUCCESS = valueOf("outlineSuccess");
public static final Markup OUTLINE_WARNING = valueOf("outlineWarning");
public static final Markup PILL = valueOf("pill");
- public static final Markup PORTLET = valueOf("portlet");
public static final Markup PRIMARY = valueOf("primary");
public static final Markup READONLY = valueOf("readonly");
public static final Markup REQUIRED = valueOf("required");
@@ -167,7 +166,6 @@ public final class Markup implements Serializable, Iterable<String> {
public static final String STRING_OUTLINE_SUCCESS = "outlineSuccess";
public static final String STRING_OUTLINE_WARNING = "outlineWarning";
public static final String STRING_PILL = "pill";
- public static final String STRING_PORTLET = "portlet";
public static final String STRING_PRIMARY = "primary";
public static final String STRING_READONLY = "readonly";
public static final String STRING_REQUIRED = "required";
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/FileRenderer.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/FileRenderer.java
index 925624e..e476873 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/FileRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/FileRenderer.java
@@ -117,7 +117,7 @@ public class FileRenderer<T extends AbstractUIFile>
LOG.error("clientId='" + clientId + "'", e);
component.setValid(false);
}
- } else { // todo: PortletRequest
+ } else {
LOG.warn("Unsupported request type: " + request.getClass().getName());
}
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/PageRenderer.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/PageRenderer.java
index 4ee07d4..052b7ef 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/PageRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/PageRenderer.java
@@ -38,7 +38,6 @@ import org.apache.myfaces.tobago.internal.util.CookieUtils;
import org.apache.myfaces.tobago.internal.util.HtmlRendererUtils;
import org.apache.myfaces.tobago.internal.util.ResponseUtils;
import org.apache.myfaces.tobago.internal.util.StringUtils;
-import org.apache.myfaces.tobago.portlet.PortletUtils;
import org.apache.myfaces.tobago.renderkit.RendererBase;
import org.apache.myfaces.tobago.renderkit.css.BootstrapClass;
import org.apache.myfaces.tobago.renderkit.css.TobagoClass;
@@ -62,8 +61,6 @@ import javax.faces.component.UIOutput;
import javax.faces.component.UIViewRoot;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
-import javax.portlet.MimeResponse;
-import javax.portlet.ResourceURL;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@@ -136,15 +133,6 @@ public class PageRenderer<T extends AbstractUIPage> extends RendererBase<T> {
final UIViewRoot viewRoot = facesContext.getViewRoot();
final String viewId = viewRoot.getViewId();
final String formAction = externalContext.encodeActionURL(viewHandler.getActionURL(facesContext, viewId));
- final String partialAction;
- final boolean portlet = PortletUtils.isPortletApiAvailable() && response instanceof MimeResponse;
- if (portlet) {
- final MimeResponse mimeResponse = (MimeResponse) response;
- final ResourceURL resourceURL = mimeResponse.createResourceURL();
- partialAction = externalContext.encodeResourceURL(resourceURL.toString());
- } else {
- partialAction = null;
- }
final String contentType = writer.getContentTypeWithCharSet();
ResponseUtils.ensureContentTypeHeader(facesContext, contentType);
@@ -164,13 +152,11 @@ public class PageRenderer<T extends AbstractUIPage> extends RendererBase<T> {
final String title = component.getLabel();
final Locale locale = viewRoot.getLocale();
- if (!portlet) {
- writer.startElement(HtmlElements.HTML);
- if (locale != null) {
- final String language = locale.getLanguage();
- if (language != null) {
- writer.writeAttribute(HtmlAttributes.LANG, language, false);
- }
+ writer.startElement(HtmlElements.HTML);
+ if (locale != null) {
+ final String language = locale.getLanguage();
+ if (language != null) {
+ writer.writeAttribute(HtmlAttributes.LANG, language, false);
}
}
writer.writeClassAttribute(spread);
@@ -228,10 +214,8 @@ public class PageRenderer<T extends AbstractUIPage> extends RendererBase<T> {
writer.endElement(HtmlElements.HEAD);
- if (!portlet) {
- writer.startElement(HtmlElements.BODY);
- writer.writeClassAttribute(spread);
- }
+ writer.startElement(HtmlElements.BODY);
+ writer.writeClassAttribute(spread);
writer.startElement(HtmlElements.TOBAGO_PAGE);
@@ -248,12 +232,6 @@ public class PageRenderer<T extends AbstractUIPage> extends RendererBase<T> {
writer.startElement(HtmlElements.FORM);
writer.writeClassAttribute(spread);
writer.writeAttribute(HtmlAttributes.ACTION, formAction, true);
- if (partialAction != null) {
- writer.writeAttribute(DataAttributes.PARTIAL_ACTION, partialAction, true);
- }
- if (LOG.isDebugEnabled()) {
- LOG.debug("partial action = " + partialAction);
- }
writer.writeIdAttribute(component.getFormId(facesContext));
writer.writeAttribute(HtmlAttributes.METHOD, getMethod(component), false);
final String enctype = tobagoContext.getEnctype();
@@ -327,8 +305,6 @@ public class PageRenderer<T extends AbstractUIPage> extends RendererBase<T> {
final String clientId = component.getClientId(facesContext);
final Application application = facesContext.getApplication();
final ViewHandler viewHandler = application.getViewHandler();
- final Object response = facesContext.getExternalContext().getResponse();
- final boolean portlet = PortletUtils.isPortletApiAvailable() && response instanceof MimeResponse;
final boolean ajax = facesContext.getPartialViewContext().isAjaxRequest();
// placeholder for menus
@@ -359,10 +335,8 @@ public class PageRenderer<T extends AbstractUIPage> extends RendererBase<T> {
bodyResource.encodeAll(facesContext);
}
- if (!portlet) {
- writer.endElement(HtmlElements.BODY);
- writer.endElement(HtmlElements.HTML);
- }
+ writer.endElement(HtmlElements.BODY);
+ writer.endElement(HtmlElements.HTML);
AccessKeyLogger.logStatus(facesContext);
}
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/ResponseUtils.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/ResponseUtils.java
index 75676db..05a5c90 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/ResponseUtils.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/ResponseUtils.java
@@ -23,12 +23,10 @@ import org.apache.myfaces.tobago.context.TobagoContext;
import org.apache.myfaces.tobago.context.UserAgent;
import org.apache.myfaces.tobago.internal.config.ContentSecurityPolicy;
import org.apache.myfaces.tobago.internal.context.Nonce;
-import org.apache.myfaces.tobago.portlet.PortletUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.faces.context.FacesContext;
-import javax.portlet.MimeResponse;
import javax.servlet.http.HttpServletResponse;
import java.lang.invoke.MethodHandles;
import java.util.Map;
@@ -45,8 +43,6 @@ public final class ResponseUtils {
final Object response = facesContext.getExternalContext().getResponse();
if (response instanceof HttpServletResponse) {
ensureNoCacheHeader((HttpServletResponse) response);
- } else if (PortletUtils.isPortletApiAvailable() && response instanceof MimeResponse) {
- ensureNoCacheHeader((MimeResponse) response);
}
}
@@ -57,17 +53,10 @@ public final class ResponseUtils {
response.setDateHeader("max-age", 0);
}
- public static void ensureNoCacheHeader(final MimeResponse response) {
- // TODO validate this
- response.getCacheControl().setExpirationTime(0);
- }
-
public static void ensureContentTypeHeader(final FacesContext facesContext, final String contentType) {
final Object response = facesContext.getExternalContext().getResponse();
if (response instanceof HttpServletResponse) {
ensureContentTypeHeader((HttpServletResponse) response, contentType);
- } else if (PortletUtils.isPortletApiAvailable() && response instanceof MimeResponse) {
- ensureContentTypeHeader((MimeResponse) response, contentType);
}
}
@@ -86,17 +75,6 @@ public final class ResponseUtils {
}
}
- public static void ensureContentTypeHeader(final MimeResponse response, final String contentType) {
- final String responseContentType = response.getContentType();
- if (!StringUtils.equalsIgnoreCaseAndWhitespace(responseContentType, contentType)) {
- response.setContentType(contentType);
- if (LOG.isDebugEnabled()) {
- LOG.debug("Response already contains Header Content-Type '" + responseContentType
- + "'. Overwriting with '" + contentType + "'");
- }
- }
- }
-
public static void ensureContentSecurityPolicyHeader(
final FacesContext facesContext, final ContentSecurityPolicy contentSecurityPolicy) {
final Object response = facesContext.getExternalContext().getResponse();
@@ -129,11 +107,6 @@ public final class ResponseUtils {
for (final String cspHeader : cspHeaders) {
servletResponse.setHeader(cspHeader, builder.toString());
}
- } else if (PortletUtils.isPortletApiAvailable() && response instanceof MimeResponse) {
- // TODO Portlet
- if (contentSecurityPolicy.getMode() != ContentSecurityPolicy.Mode.OFF) {
- LOG.warn("CSP not implemented for Portlet!");
- }
}
}
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/portlet/PortletUtils.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/portlet/PortletUtils.java
deleted file mode 100644
index 77f6a74..0000000
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/portlet/PortletUtils.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.tobago.portlet;
-
-import javax.portlet.PortletRequest;
-
-/**
- * Static utility class for portlet-related operations.
- */
-public final class PortletUtils {
-
- private static final boolean PORTLET_API_AVAILABLE;
-
- static {
- boolean result;
- try {
- result = PortletRequest.class != null;
- } catch (final NoClassDefFoundError e) {
- result = false;
- }
- PORTLET_API_AVAILABLE = result;
- }
-
- private PortletUtils() {
- // avoid instantiation
- }
-
- /**
- * The Portlet API is optional in the class path. We are only allowed to check instance of e. g. PortletRequest,
- * if the API exists.
- *
- * @return Are the Portlet classes available?
- */
- public static boolean isPortletApiAvailable() {
- return PORTLET_API_AVAILABLE;
- }
-
-}
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/LogoutActionListener.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/LogoutActionListener.java
index e155c59..4d49c21 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/LogoutActionListener.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/LogoutActionListener.java
@@ -19,7 +19,6 @@
package org.apache.myfaces.tobago.webapp;
-import org.apache.myfaces.tobago.portlet.PortletUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -29,7 +28,6 @@ import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ActionEvent;
import javax.faces.event.ActionListener;
-import javax.portlet.PortletSession;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
@@ -47,9 +45,6 @@ public class LogoutActionListener implements ActionListener {
if (session instanceof HttpSession) {
((HttpSession) session).invalidate();
}
- if (PortletUtils.isPortletApiAvailable() && session instanceof PortletSession) {
- ((PortletSession) session).invalidate();
- }
}
final String forward = externalContext.getRequestContextPath() + "/";
try {
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/000-intro/70-faq/FAQ.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/000-intro/70-faq/FAQ.xhtml
index b849f92..bc75d8b 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/000-intro/70-faq/FAQ.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/000-intro/70-faq/FAQ.xhtml
@@ -535,7 +535,8 @@ java -jar ~/Downloads/wlp-developers-runtime-8.5.5.0.jar</demo-highlight>
There is a basic example for portlets in the GIT repository in the sub-folder
tobago-example/tobago-example-portlet
There is no specific configuration to use Tobago in Portlets.
- The portlet stuff is currently not active, so the example is removed in Tobago 4.
+ The portlet stuff is currently not active, so the example is removed in Tobago 4
+ and the implementation is removed in Tobago 5.
</p>
</tc:section>