From c74694be873d9ec9f557bed9377b6d29c15b3dc8 Mon Sep 17 00:00:00 2001 From: Will Ezell Date: Thu, 9 Jan 2025 16:54:10 -0600 Subject: [PATCH] Issue 30288 small fixes (#30289) This pull request includes several changes across different files, focusing on updating health check paths, improving error handling, and removing outdated JSP files. The most important changes include modifying Kubernetes health check configurations, enhancing error handling in the `CMSFilter` class, and cleaning up old JSP files. ### Kubernetes Configuration Updates: * [`docker/k8s-aws-eks-manifest-examples/alb.yaml`](diffhunk://#diff-183dd63ca7f7d70f78b13d9811fa2d67e3ae037897c9f9d9e7f37e48083a4b40L29-R29): Updated the health check path to `/api/v1/alive`. * [`docker/k8s-aws-eks-manifest-examples/statefulset.yaml`](diffhunk://#diff-4afce029dc91e63bc9ec03ef86772471786be1a649c63676b2cbef411c28f23dL105-R105): Updated the startup, liveness, and readiness probe paths to `/api/v1/heavy` and `/api/v1/light`, and adjusted the failure threshold for liveness probes. [[1]](diffhunk://#diff-4afce029dc91e63bc9ec03ef86772471786be1a649c63676b2cbef411c28f23dL105-R105) [[2]](diffhunk://#diff-4afce029dc91e63bc9ec03ef86772471786be1a649c63676b2cbef411c28f23dL114-R123) ### Error Handling Improvements: * [`dotCMS/src/main/java/com/dotmarketing/filters/CMSFilter.java`](diffhunk://#diff-fc826560595be523f8e9b63d8bf2a7b2b1f940876edb013298c79f1b66bc4914R60-R66): Enhanced error handling to log `ClientAbortException` without throwing it again. ### Codebase Cleanup: * Removed outdated JSP files, including `init.jsp`, `sub_nav.jsp`, `unlock_container.jsp`, `unlock_contentlet.jsp`, and `unlock_htmlpage.jsp`. [[1]](diffhunk://#diff-a39cd0ae99f45175cd71212e757a0dda96acd2d640850a9dbdd9cf194ffe9931L1-L27) [[2]](diffhunk://#diff-e9647830e52bbfc94b9b4c57be61fffb142f87966f2a2e159949f6805ed5c3f5L1-L2) [[3]](diffhunk://#diff-36f4ab5425e2ebcb57812003969b83ff412f2ae31a251729656cbfd769391de6L1-L108) [[4]](diffhunk://#diff-956c5ffd29059f3a75b219c7644b29373f1181b74bd2d82f1a4b6d49aba2e3c1L1-L138) [[5]](diffhunk://#diff-a7ae9b56c296565c4ab1d17e10d5c0c16d03ca6de4050af3110e635670dfb493L1-L115) ### Code Enhancements: * [`dotCMS/src/main/java/com/dotcms/rest/api/v1/maintenance/JVMInfoResource.java`](diffhunk://#diff-c7bbf72c2a19d4b781e1758ec24a8f5145403525a14a414d2d8b6aec6417fd0aR38-R42): Introduced a new pattern `obfuscateBasePattern` for obfuscating sensitive information and updated the `obfuscateIfNeeded` method to use this new pattern. [[1]](diffhunk://#diff-c7bbf72c2a19d4b781e1758ec24a8f5145403525a14a414d2d8b6aec6417fd0aR38-R42) [[2]](diffhunk://#diff-c7bbf72c2a19d4b781e1758ec24a8f5145403525a14a414d2d8b6aec6417fd0aL190-R195) * [`dotCMS/src/main/java/com/dotmarketing/portlets/languagesmanager/business/LanguageFactoryImpl.java`](diffhunk://#diff-212db36a5f82c8a09383e28a982ace46ac4cdab908bfc595208127a22a8f6334L138-R138): Improved the `getLanguage` method to handle language IDs containing hyphens. * [`dotCMS/src/main/java/com/dotmarketing/portlets/templates/business/TemplateFactoryImpl.java`](diffhunk://#diff-30db473047bf01b113d2ea4e19f591cd5d08cc41516f01e5bb1ec5be9131dfd7L738-R742): Simplified SQL query to remove MS SQL-specific code. --------- Co-authored-by: Daniel Silva Co-authored-by: Jose Castro --- docker/k8s-aws-eks-manifest-examples/alb.yaml | 2 +- .../statefulset.yaml | 8 +- .../api/v1/maintenance/JVMInfoResource.java | 31 ++-- .../com/dotmarketing/filters/CMSFilter.java | 7 + .../webapp/html/portlet/ext/director/init.jsp | 27 ---- .../html/portlet/ext/director/sub_nav.jsp | 2 - .../portlet/ext/director/unlock_container.jsp | 108 -------------- .../ext/director/unlock_contentlet.jsp | 138 ------------------ .../portlet/ext/director/unlock_htmlpage.jsp | 115 --------------- .../html/portlet/ext/director/unlock_link.jsp | 112 -------------- .../webapp/html/portlet/ext/director/view.jsp | 10 -- .../dotmarketing/util/UtilMethodsITest.java | 18 +++ 12 files changed, 49 insertions(+), 529 deletions(-) delete mode 100644 dotCMS/src/main/webapp/html/portlet/ext/director/init.jsp delete mode 100644 dotCMS/src/main/webapp/html/portlet/ext/director/sub_nav.jsp delete mode 100644 dotCMS/src/main/webapp/html/portlet/ext/director/unlock_container.jsp delete mode 100644 dotCMS/src/main/webapp/html/portlet/ext/director/unlock_contentlet.jsp delete mode 100644 dotCMS/src/main/webapp/html/portlet/ext/director/unlock_htmlpage.jsp delete mode 100644 dotCMS/src/main/webapp/html/portlet/ext/director/unlock_link.jsp delete mode 100644 dotCMS/src/main/webapp/html/portlet/ext/director/view.jsp diff --git a/docker/k8s-aws-eks-manifest-examples/alb.yaml b/docker/k8s-aws-eks-manifest-examples/alb.yaml index 5a2d51a4db71..99172f738fb4 100644 --- a/docker/k8s-aws-eks-manifest-examples/alb.yaml +++ b/docker/k8s-aws-eks-manifest-examples/alb.yaml @@ -26,7 +26,7 @@ metadata: alb.ingress.kubernetes.io/backend-protocol: HTTP alb.ingress.kubernetes.io/healthcheck-protocol: HTTP alb.ingress.kubernetes.io/healthcheck-port: '8082' - alb.ingress.kubernetes.io/healthcheck-path: /api/v1/appconfiguration + alb.ingress.kubernetes.io/healthcheck-path: /api/v1/alive alb.ingress.kubernetes.io/healthcheck-interval-seconds: '30' alb.ingress.kubernetes.io/healthcheck-timeout-seconds: '5' alb.ingress.kubernetes.io/success-codes: '200' diff --git a/docker/k8s-aws-eks-manifest-examples/statefulset.yaml b/docker/k8s-aws-eks-manifest-examples/statefulset.yaml index 753c352b03da..ea3ca66e90a7 100644 --- a/docker/k8s-aws-eks-manifest-examples/statefulset.yaml +++ b/docker/k8s-aws-eks-manifest-examples/statefulset.yaml @@ -102,7 +102,7 @@ spec: fi; ln -s /data/shared/assets/.backup /data/local/dotsecure/backup; startupProbe: httpGet: - path: /api/v1/appconfiguration + path: /api/v1/heavy port: 8082 initialDelaySeconds: 30 periodSeconds: 5 @@ -111,16 +111,16 @@ spec: timeoutSeconds: 1 livenessProbe: httpGet: - path: /api/v1/appconfiguration + path: /api/v1/light port: 8082 initialDelaySeconds: 1 periodSeconds: 30 successThreshold: 1 - failureThreshold: 1 + failureThreshold: 3 timeoutSeconds: 10 readinessProbe: httpGet: - path: /api/v1/appconfiguration + path: /api/v1/light port: 8082 initialDelaySeconds: 1 periodSeconds: 10 diff --git a/dotCMS/src/main/java/com/dotcms/rest/api/v1/maintenance/JVMInfoResource.java b/dotCMS/src/main/java/com/dotcms/rest/api/v1/maintenance/JVMInfoResource.java index b170a0dfecbf..05e138edf77a 100644 --- a/dotCMS/src/main/java/com/dotcms/rest/api/v1/maintenance/JVMInfoResource.java +++ b/dotCMS/src/main/java/com/dotcms/rest/api/v1/maintenance/JVMInfoResource.java @@ -10,6 +10,16 @@ import com.dotmarketing.util.UtilMethods; import com.liferay.portal.util.ReleaseInfo; import io.vavr.control.Try; +import org.glassfish.jersey.server.JSONP; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import java.io.IOException; import java.io.Serializable; import java.lang.management.ManagementFactory; @@ -20,23 +30,18 @@ import java.util.Map; import java.util.Properties; import java.util.regex.Pattern; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import org.glassfish.jersey.server.JSONP; - @Path("/v1/jvm") @SuppressWarnings("serial") public class JVMInfoResource implements Serializable { + private static final String DEFAULT_OBFUSCATE_PATTERN = "passw|pass|passwd|secret|key|token"; + + public static final Pattern obfuscateBasePattern = Pattern.compile(DEFAULT_OBFUSCATE_PATTERN, + Pattern.CASE_INSENSITIVE); + public static final Pattern obfuscatePattern = Pattern.compile( - Config.getStringProperty("OBFUSCATE_SYSTEM_ENVIRONMENTAL_VARIABLES", "passw|pass|passwd|secret|key|token"), + Config.getStringProperty("OBFUSCATE_SYSTEM_ENVIRONMENTAL_VARIABLES", DEFAULT_OBFUSCATE_PATTERN), Pattern.CASE_INSENSITIVE); @Path("/") @@ -187,7 +192,9 @@ private Map getReleaseInfo(){ public static String obfuscateIfNeeded(final String key, final Object valueObject) { final String value = (String) valueObject; if(UtilMethods.isEmpty(value)) return ""; - return obfuscatePattern.matcher(key).find() ? obfuscate(value) : value; + return obfuscateBasePattern.matcher(key).find() || obfuscatePattern.matcher(key).find() + ? obfuscate(value) + : value; } private static String obfuscate(final String value) { diff --git a/dotCMS/src/main/java/com/dotmarketing/filters/CMSFilter.java b/dotCMS/src/main/java/com/dotmarketing/filters/CMSFilter.java index 2125bc4faa03..a19c8ac2f5ef 100644 --- a/dotCMS/src/main/java/com/dotmarketing/filters/CMSFilter.java +++ b/dotCMS/src/main/java/com/dotmarketing/filters/CMSFilter.java @@ -57,6 +57,13 @@ public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) try { doFilterInternal(req, res, chain); + } catch (Exception e) { + if (e.getClass().getCanonicalName().contains("ClientAbortException")) { + Logger.info(this.getClass(), "ClientAbortException: " + ((HttpServletRequest) req).getRequestURI()); + Logger.debug(this.getClass(), "ClientAbortException: " + e.getMessage()); + } else { + throw e; + } } finally { DbConnectionFactory.closeSilently(); } diff --git a/dotCMS/src/main/webapp/html/portlet/ext/director/init.jsp b/dotCMS/src/main/webapp/html/portlet/ext/director/init.jsp deleted file mode 100644 index 20d60e5efe29..000000000000 --- a/dotCMS/src/main/webapp/html/portlet/ext/director/init.jsp +++ /dev/null @@ -1,27 +0,0 @@ -<% -/** - * Copyright (c) 2000-2002 Liferay Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -%> - -<%@ include file="/html/common/init.jsp" %> - - \ No newline at end of file diff --git a/dotCMS/src/main/webapp/html/portlet/ext/director/sub_nav.jsp b/dotCMS/src/main/webapp/html/portlet/ext/director/sub_nav.jsp deleted file mode 100644 index 7bde1ba11f27..000000000000 --- a/dotCMS/src/main/webapp/html/portlet/ext/director/sub_nav.jsp +++ /dev/null @@ -1,2 +0,0 @@ -<%@ include file="/html/portlet/ext/contentlet/init.jsp" %> - diff --git a/dotCMS/src/main/webapp/html/portlet/ext/director/unlock_container.jsp b/dotCMS/src/main/webapp/html/portlet/ext/director/unlock_container.jsp deleted file mode 100644 index 830252ba13b4..000000000000 --- a/dotCMS/src/main/webapp/html/portlet/ext/director/unlock_container.jsp +++ /dev/null @@ -1,108 +0,0 @@ -<%@ include file="/html/portlet/ext/director/init.jsp" %> - -<%@ page import="com.dotmarketing.portlets.containers.model.Container" %> -<%@ page import="com.dotmarketing.factories.InodeFactory" %> -<%@ page import="com.dotmarketing.util.UtilMethods" %> - - -<% -Container container; -if (request.getAttribute(com.dotmarketing.util.WebKeys.CONTAINER_EDIT)!=null) { - container = (Container) request.getAttribute(com.dotmarketing.util.WebKeys.CONTAINER_EDIT); -} -else { - container = (Container) com.dotmarketing.factories.InodeFactory.getInode(request.getParameter("inode"),Container.class); -} -String referer = (request.getParameter("referer") != null ) ? java.net.URLDecoder.decode(request.getParameter("referer"),"UTF-8") : ""; -%> -<%@page import="com.dotmarketing.util.DateUtil"%> -<%@page import="java.util.HashMap"%> -
" method="post" id="fm"> - - - - - - - - " /> - - -<% - String userName= "unknown"; - String userFullName= "unknown"; - try{ - com.liferay.portal.model.User userMod = com.liferay.portal.ejb.UserManagerUtil.getUserById(container.getModUser()); - userName = userMod.getEmailAddress(); - userFullName = userMod.getFullName(); - } - catch(Exception e){ - - } - - SimpleDateFormat sdf = new SimpleDateFormat("h:mm aa, MMMM d?, yyyy"); - String modDate = sdf.format(container.getModDate()); - modDate = modDate.replaceAll("\\?", "th"); - String sinceMessage = ""; - HashMap diffDates = DateUtil.diffDates(container.getModDate(), new Date()); - if (0 < diffDates.get(DateUtil.DIFF_YEARS)) { - sinceMessage = LanguageUtil.get(pageContext, "more-than-a-year-ago"); - } else if (48 < diffDates.get(DateUtil.DIFF_HOURS)) { - sinceMessage = LanguageUtil.get(pageContext, "2-days-ago"); - } else if (24 < diffDates.get(DateUtil.DIFF_HOURS)) { - sinceMessage = LanguageUtil.get(pageContext, "1-day-ago--") + modDate + ")."; - } else if (8 < diffDates.get(DateUtil.DIFF_HOURS)) { - sinceMessage = "" + diffDates.get(DateUtil.DIFF_HOURS) +" " +LanguageUtil.get(pageContext, "hours-ago--") + modDate + ")."; - } else if (1 <= diffDates.get(DateUtil.DIFF_HOURS)) { - sinceMessage = "" + diffDates.get(DateUtil.DIFF_HOURS) +" "+ LanguageUtil.get(pageContext, "hour-s--and") + diffDates.get(DateUtil.DIFF_MINUTES) + " " +LanguageUtil.get(pageContext, "minute-s--ago--") + modDate + ")."; - } else if (diffDates.get(DateUtil.DIFF_HOURS) < 1) { - sinceMessage = "" + diffDates.get(DateUtil.DIFF_MINUTES)+" " + LanguageUtil.get(pageContext, "minute-s--ago--") + modDate + ")."; - } -%> - -
-

<%= LanguageUtil.get(pageContext, "Alert") %>

-

<%= LanguageUtil.format(pageContext, "locked-asset-message", new LanguageWrapper[]{new LanguageWrapper("", "Container", ""), new LanguageWrapper("", userName, ""), new LanguageWrapper("", userFullName, ""), new LanguageWrapper("", sinceMessage, "")}) %>

-

<%= LanguageUtil.get(pageContext, "Would-you-like-to-unlock-it-to-proceed") %>

-
- <%= LanguageUtil.get(pageContext, "Title") %>: - <%=container.getTitle()%>
- - <%= LanguageUtil.get(pageContext, "Description") %>: - <%=container.getFriendlyName()%> -
-
 
-
- - -
-
- -
- -
- - - - - - - - - diff --git a/dotCMS/src/main/webapp/html/portlet/ext/director/unlock_contentlet.jsp b/dotCMS/src/main/webapp/html/portlet/ext/director/unlock_contentlet.jsp deleted file mode 100644 index 46447d1d3a9e..000000000000 --- a/dotCMS/src/main/webapp/html/portlet/ext/director/unlock_contentlet.jsp +++ /dev/null @@ -1,138 +0,0 @@ -<%@ include file="/html/portlet/ext/director/init.jsp" %> - -<%@ page import="com.dotmarketing.portlets.contentlet.model.Contentlet" %> -<%@ page import="com.dotmarketing.portlets.containers.model.Container" %> -<%@ page import="com.dotmarketing.util.UtilMethods" %> - -<% -Contentlet contentlet; -if (request.getAttribute(com.dotmarketing.util.WebKeys.CONTENTLET_EDIT)!=null) { - contentlet = (Contentlet) request.getAttribute(com.dotmarketing.util.WebKeys.CONTENTLET_EDIT); -} -else { - ContentletAPI contentletAPI = APILocator.getContentletAPI(); - contentlet = (Contentlet) contentletAPI.find(request.getParameter("inode"), user, true); - -} -String assetName ="Contentlet"; -try{ -Structure s = contentlet.getStructure(); - assetName = s.getName(); -} -catch(Exception e){ - if(contentlet != null){ - Logger.debug(this, "Contentlet "+ contentlet.getInode() + " does not know its structure"); - } - else{ - Logger.error(this, "Contentlet is null"); - } -} -String referer = (request.getParameter("referer") != null ) ? java.net.URLDecoder.decode(request.getParameter("referer"),"UTF-8") : ""; - -%> -<%@page import="com.dotmarketing.business.APILocator"%> -<%@page import="com.dotmarketing.portlets.contentlet.business.ContentletAPI"%> -<%@page import="com.dotmarketing.business.UserAPI"%> -<%@page import="com.dotmarketing.business.RoleAPI"%> -<%@page import="com.dotmarketing.business.VersionableAPI"%> -<%@page import="com.dotmarketing.util.DateUtil"%> -<%@page import="java.util.HashMap"%> -<%@page import="com.dotmarketing.portlets.structure.model.Structure"%> -<%@page import="com.dotmarketing.util.Logger"%> -
" method="post" id="fm"> - - - - - - - - - - " /> - - -<% - String userName= "unknown"; - String userFullName= "unknown"; - try{ - com.liferay.portal.model.User userMod = com.liferay.portal.ejb.UserManagerUtil.getUserById(contentlet.getModUser()); - userName = userMod.getEmailAddress(); - userFullName = userMod.getFullName(); - } - catch(Exception e){ - - } - - SimpleDateFormat sdf = new SimpleDateFormat("h:mm aa, MMMM d?, yyyy",LanguageUtil.getLocale(pageContext)); - String modDate = sdf.format(contentlet.getModDate()); - modDate = modDate.replaceAll("\\?", "th"); - String sinceMessage = ""; - HashMap diffDates = DateUtil.diffDates(contentlet.getModDate(), new Date()); - if (0 < diffDates.get(DateUtil.DIFF_YEARS)) { - sinceMessage = LanguageUtil.get(pageContext, "more-than-a-year-ago"); - } else if (48 < diffDates.get(DateUtil.DIFF_HOURS)) { - sinceMessage = LanguageUtil.get(pageContext, "2-days-ago"); - } else if (24 < diffDates.get(DateUtil.DIFF_HOURS)) { - sinceMessage = LanguageUtil.get(pageContext, "1-day-ago--") + modDate + ")."; - } else if (8 < diffDates.get(DateUtil.DIFF_HOURS)) { - sinceMessage = "" + diffDates.get(DateUtil.DIFF_HOURS) +" " +LanguageUtil.get(pageContext, "hours-ago--") + modDate + ")."; - } else if (1 <= diffDates.get(DateUtil.DIFF_HOURS)) { - sinceMessage = "" + diffDates.get(DateUtil.DIFF_HOURS) +" "+ LanguageUtil.get(pageContext, "hour-s--and") + diffDates.get(DateUtil.DIFF_MINUTES) + " " +LanguageUtil.get(pageContext, "minute-s--ago--") + modDate + ")."; - } else if (diffDates.get(DateUtil.DIFF_HOURS) < 1) { - sinceMessage = "" + diffDates.get(DateUtil.DIFF_MINUTES)+" " + LanguageUtil.get(pageContext, "minute-s--ago--") + modDate + ")."; - } - - User systemUser = APILocator.getUserAPI().getSystemUser(); - boolean isUserCMSAdmin = APILocator.getRoleAPI().doesUserHaveRole(user, APILocator.getRoleAPI().loadCMSAdminRole()); - String lockedUserId = APILocator.getVersionableAPI().getLockedBy(contentlet); -%> - -
-

<%= LanguageUtil.get(pageContext, "Alert") %>

-

<%= LanguageUtil.format(pageContext, "locked-asset-message", new LanguageWrapper[]{new LanguageWrapper("", "" + assetName + "", ""), new LanguageWrapper("", userName, ""), new LanguageWrapper("", userFullName, ""), new LanguageWrapper("", "
" + sinceMessage, "")}) %>

- <%if(user.getUserId().equals(systemUser.getUserId()) || isUserCMSAdmin || user.getUserId().equals(lockedUserId)){ %> -

<%= LanguageUtil.get(pageContext, "Would-you-like-to-unlock-it-to-proceed") %>

- <%} %> -
- <%= LanguageUtil.get(pageContext, "Title") %>: - <%=contentlet.getTitle()%>
- -
-
 
-
- <%if(user.getUserId().equals(systemUser.getUserId()) || isUserCMSAdmin || user.getUserId().equals(lockedUserId)){ %> - - <%} %> - -
-
- -
- -
- - - - - - - - - diff --git a/dotCMS/src/main/webapp/html/portlet/ext/director/unlock_htmlpage.jsp b/dotCMS/src/main/webapp/html/portlet/ext/director/unlock_htmlpage.jsp deleted file mode 100644 index f7ba8ba139da..000000000000 --- a/dotCMS/src/main/webapp/html/portlet/ext/director/unlock_htmlpage.jsp +++ /dev/null @@ -1,115 +0,0 @@ -<%@ include file="/html/portlet/ext/director/init.jsp" %> -<%@ page import="com.dotmarketing.util.UtilMethods" %> - -<%@ page import="com.dotmarketing.factories.InodeFactory" %> -<%@ page import="com.dotmarketing.util.UtilMethods" %> -<%@ page import="com.dotmarketing.portlets.htmlpageasset.model.IHTMLPage" %> - - -<% -IHTMLPage htmlPage; -if (request.getAttribute(com.dotmarketing.util.WebKeys.HTMLPAGE_EDIT)!=null) { - htmlPage = (IHTMLPage) request.getAttribute(com.dotmarketing.util.WebKeys.HTMLPAGE_EDIT); -} -else { - htmlPage = (IHTMLPage) com.dotmarketing.factories.InodeFactory.getInode(request.getParameter("inode"),IHTMLPage.class); -} -String referer = (request.getParameter("referer") != null ) ? java.net.URLDecoder.decode(request.getParameter("referer"),"UTF-8") : "" ; - -%> -<%@page import="com.dotmarketing.util.DateUtil"%> -<%@page import="java.util.HashMap"%> -
" method="post" id="fm"> - - - - - - - - " /> - - -<% - String userName= "unknown"; - String userFullName= "unknown"; - try{ - com.liferay.portal.model.User userMod = com.liferay.portal.ejb.UserManagerUtil.getUserById(htmlPage.getModUser()); - userName = userMod.getEmailAddress(); - userFullName = userMod.getFullName(); - } - catch(Exception e){ - - } - - SimpleDateFormat sdf = new SimpleDateFormat("h:mm aa, MMMM d?, yyyy"); - String modDate = sdf.format(htmlPage.getModDate()); - modDate = modDate.replaceAll("\\?", "th"); - String sinceMessage = ""; - HashMap diffDates = DateUtil.diffDates(htmlPage.getModDate(), new Date()); - if (0 < diffDates.get(DateUtil.DIFF_YEARS)) { - sinceMessage = LanguageUtil.get(pageContext, "more-than-a-year-ago"); - } else if (48 < diffDates.get(DateUtil.DIFF_HOURS)) { - sinceMessage = LanguageUtil.get(pageContext, "2-days-ago"); - } else if (24 < diffDates.get(DateUtil.DIFF_HOURS)) { - sinceMessage = LanguageUtil.get(pageContext, "1-day-ago--") + modDate + ")."; - } else if (8 < diffDates.get(DateUtil.DIFF_HOURS)) { - sinceMessage = "" + diffDates.get(DateUtil.DIFF_HOURS) +" " +LanguageUtil.get(pageContext, "hours-ago--") + modDate + ")."; - } else if (1 <= diffDates.get(DateUtil.DIFF_HOURS)) { - sinceMessage = "" + diffDates.get(DateUtil.DIFF_HOURS) +" "+ LanguageUtil.get(pageContext, "hour-s--and") + diffDates.get(DateUtil.DIFF_MINUTES) + " " +LanguageUtil.get(pageContext, "minute-s--ago--") + modDate + ")."; - } else if (diffDates.get(DateUtil.DIFF_HOURS) < 1) { - sinceMessage = "" + diffDates.get(DateUtil.DIFF_MINUTES)+" " + LanguageUtil.get(pageContext, "minute-s--ago--") + modDate + ")."; - } -%> - -
-

<%= LanguageUtil.get(pageContext, "Alert") %>

-

<%= LanguageUtil.format(pageContext, "locked-asset-message", new LanguageWrapper[]{new LanguageWrapper("", "HTML-Page", ""), new LanguageWrapper("", userName, ""), new LanguageWrapper("", userFullName, ""), new LanguageWrapper("", sinceMessage, "")}) %>

-

<%= LanguageUtil.get(pageContext, "Would-you-like-to-unlock-it-to-proceed") %>

-
- <%= LanguageUtil.get(pageContext, "Page-URL") %>: - <%=htmlPage.getPageUrl()%>
- - <%= LanguageUtil.get(pageContext, "Title") %>: - <%=htmlPage.getTitle()%>
- - <%= LanguageUtil.get(pageContext, "Description") %>: - <%=htmlPage.getFriendlyName()%> -
-
 
-
- - -
-
- -
- -
- - - - - - - - - diff --git a/dotCMS/src/main/webapp/html/portlet/ext/director/unlock_link.jsp b/dotCMS/src/main/webapp/html/portlet/ext/director/unlock_link.jsp deleted file mode 100644 index 641ffc11fe91..000000000000 --- a/dotCMS/src/main/webapp/html/portlet/ext/director/unlock_link.jsp +++ /dev/null @@ -1,112 +0,0 @@ -<%@ include file="/html/portlet/ext/director/init.jsp" %> - -<%@ page import="com.dotmarketing.portlets.links.model.Link" %> -<%@ page import="com.dotmarketing.factories.InodeFactory" %> -<%@ page import="com.dotmarketing.util.UtilMethods" %> - -<% -Link link; -if (request.getAttribute(com.dotmarketing.util.WebKeys.LINK_EDIT)!=null) { - link = (Link) request.getAttribute(com.dotmarketing.util.WebKeys.LINK_EDIT); -} -else { - link = (Link) com.dotmarketing.factories.InodeFactory.getInode(request.getParameter("inode"),Link.class); -} -String referer = (request.getParameter("referer") != null ) ? java.net.URLDecoder.decode(request.getParameter("referer"),"UTF-8") : ""; -%> -<%@page import="com.dotmarketing.util.DateUtil"%> -<%@page import="java.util.HashMap"%> -
" method="post" id="fm"> - - - -"> -"> - - - - - - " /> - - -<% - String userName= "unknown"; - String userFullName= "unknown"; - try{ - com.liferay.portal.model.User userMod = com.liferay.portal.ejb.UserManagerUtil.getUserById(link.getModUser()); - userName = userMod.getEmailAddress(); - userFullName = userMod.getFullName(); - } - catch(Exception e){ - - } - - SimpleDateFormat sdf = new SimpleDateFormat("h:mm aa, MMMM d?, yyyy"); - String modDate = sdf.format(link.getModDate()); - modDate = modDate.replaceAll("\\?", "th"); - String sinceMessage = ""; - HashMap diffDates = DateUtil.diffDates(link.getModDate(), new Date()); - if (0 < diffDates.get(DateUtil.DIFF_YEARS)) { - sinceMessage = LanguageUtil.get(pageContext, "more-than-a-year-ago"); - } else if (48 < diffDates.get(DateUtil.DIFF_HOURS)) { - sinceMessage = LanguageUtil.get(pageContext, "2-days-ago"); - } else if (24 < diffDates.get(DateUtil.DIFF_HOURS)) { - sinceMessage = LanguageUtil.get(pageContext, "1-day-ago--") + modDate + ")."; - } else if (8 < diffDates.get(DateUtil.DIFF_HOURS)) { - sinceMessage = "" + diffDates.get(DateUtil.DIFF_HOURS) +" " +LanguageUtil.get(pageContext, "hours-ago--") + modDate + ")."; - } else if (1 <= diffDates.get(DateUtil.DIFF_HOURS)) { - sinceMessage = "" + diffDates.get(DateUtil.DIFF_HOURS) +" "+ LanguageUtil.get(pageContext, "hour-s--and") + diffDates.get(DateUtil.DIFF_MINUTES) + " " +LanguageUtil.get(pageContext, "minute-s--ago--") + modDate + ")."; - } else if (diffDates.get(DateUtil.DIFF_HOURS) < 1) { - sinceMessage = "" + diffDates.get(DateUtil.DIFF_MINUTES)+" " + LanguageUtil.get(pageContext, "minute-s--ago--") + modDate + ")."; - } -%> - -
-

<%= LanguageUtil.get(pageContext, "Alert") %>

-

<%= LanguageUtil.format(pageContext, "locked-asset-message", new LanguageWrapper[]{new LanguageWrapper("", "Link", ""), new LanguageWrapper("", userName, ""), new LanguageWrapper("", userFullName, ""), new LanguageWrapper("", sinceMessage, "")}) %>

-

<%= LanguageUtil.get(pageContext, "Would-you-like-to-unlock-it-to-proceed") %>

-
- <%= LanguageUtil.get(pageContext, "Title") %>: - <%=link.getTitle()%>
- - <%= LanguageUtil.get(pageContext, "URL") %>: - <%=link.getProtocal()%><%=link.getUrl()%> -
-
 
-
- - -
-
- -
- -
- - - - - - - - - diff --git a/dotCMS/src/main/webapp/html/portlet/ext/director/view.jsp b/dotCMS/src/main/webapp/html/portlet/ext/director/view.jsp deleted file mode 100644 index ad720d3d9ff0..000000000000 --- a/dotCMS/src/main/webapp/html/portlet/ext/director/view.jsp +++ /dev/null @@ -1,10 +0,0 @@ -<%@ include file="/html/portlet/ext/director/init.jsp" %> - - - - - -
- Directory -
<%= LanguageUtil.get(pageContext, "For-Dotmarketing-internal-use") %> -
\ No newline at end of file diff --git a/dotcms-integration/src/test/java/com/dotmarketing/util/UtilMethodsITest.java b/dotcms-integration/src/test/java/com/dotmarketing/util/UtilMethodsITest.java index 2ea510070739..c7e3639a9a4f 100644 --- a/dotcms-integration/src/test/java/com/dotmarketing/util/UtilMethodsITest.java +++ b/dotcms-integration/src/test/java/com/dotmarketing/util/UtilMethodsITest.java @@ -1,6 +1,8 @@ package com.dotmarketing.util; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import com.dotcms.util.IntegrationTestInitService; import com.dotmarketing.business.APILocator; @@ -61,4 +63,20 @@ public void test_dateToHTMLDate_USPacificTimeZone() } } + + + @Test + public void test_isSet_with_null_object() { + String obj=null; + assertFalse(UtilMethods.isSet(() -> obj.toString())); + } + + + @Test + public void test_isEmpty_with_null_object() { + String obj=null; + assertTrue(UtilMethods.isEmpty(() -> obj.toString())); + } + + }