]> git.mxchange.org Git - jcore-utils.git/blobdiff - src/org/mxchange/jcoreee/utils/FacesUtils.java
Continued:
[jcore-utils.git] / src / org / mxchange / jcoreee / utils / FacesUtils.java
diff --git a/src/org/mxchange/jcoreee/utils/FacesUtils.java b/src/org/mxchange/jcoreee/utils/FacesUtils.java
deleted file mode 100644 (file)
index 35e0b28..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2016 - 2018 Free Software Foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jcoreee.utils;
-
-import java.io.Serializable;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-
-/**
- * An utilities class for JavaEE applications, entities and EJBs and more
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class FacesUtils implements Serializable {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 19_863_546_716_250L;
-
-       /**
-        * Generates a "base URL" for for example mail templates. For JSF
-        * pages/templates this is not needed.
-        * <p>
-        * @return Base URL
-        */
-       public static String generateBaseUrl () {
-               // Get external context
-               ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
-
-               // Get request scheme and such ...
-               String scheme = context.getRequestScheme();
-               String serverName = context.getRequestServerName();
-               String contextPath = context.getRequestContextPath();
-               String servletPath = context.getRequestServletPath();
-               int port = context.getRequestServerPort();
-
-               // Is the path null?
-               if (null == scheme) {
-                       // Throw NPE
-                       throw new NullPointerException("context.requestScheme is null"); //NOI18N
-               } else if (null == serverName) {
-                       // And throw again ...
-                       throw new NullPointerException("context.requestServerName is null"); //NOI18N
-               }
-
-               if (null == contextPath) {
-                       // Set to empty string
-                       contextPath = ""; //NOI18N
-               }
-
-               if (null == servletPath) {
-                       // Set to empty string
-                       servletPath = ""; //NOI18N
-               }
-
-               // Init variable
-               String baseUrl;
-
-               // Unusual port found?
-               if ((port != 80) && (port != 443)) {
-                       // Construct full URL
-                       baseUrl = String.format("%s://%s:%d%s%s", scheme, serverName, port, contextPath, servletPath); //NOI18N
-               } else {
-                       // Construct full URL
-                       baseUrl = String.format("%s://%s%s%s", scheme, serverName, contextPath, servletPath); //NOI18N
-               }
-
-               // Return it
-               return baseUrl;
-       }
-
-       /**
-        * No instances from this class are required
-        */
-       private FacesUtils () {
-               // Is this null?
-               if (FacesContext.getCurrentInstance() == null) {
-                       // Okay, don't allow any usage
-                       throw new NullPointerException("Cannot access FacesContext, maybe you have tried to use this class from an EJB?"); //NOI18N
-               }
-       }
-
-}