diff --git a/ccm-core/src/main/java/org/libreccm/mvc/facelets/CcmThemeUrlConnection.java b/ccm-core/src/main/java/org/libreccm/mvc/facelets/CcmThemeUrlConnection.java index 30bcda28f..3006ab4c4 100644 --- a/ccm-core/src/main/java/org/libreccm/mvc/facelets/CcmThemeUrlConnection.java +++ b/ccm-core/src/main/java/org/libreccm/mvc/facelets/CcmThemeUrlConnection.java @@ -69,12 +69,12 @@ class CcmThemeUrlConnection extends URLConnection { super(url); this.themes = themes; - final String urlStr = url.toString(); + final String urlPath = url.getPath(); - if (urlStr.startsWith("/")) { - path = urlStr.substring(1); + if (urlPath.startsWith("/")) { + path = urlPath.substring(1); } else { - path = urlStr; + path = urlPath; } } diff --git a/ccm-core/src/main/java/org/libreccm/mvc/facelets/CcmThemeUrlStreamHandler.java b/ccm-core/src/main/java/org/libreccm/mvc/facelets/CcmThemeUrlStreamHandler.java index 2242bf47e..b25face03 100644 --- a/ccm-core/src/main/java/org/libreccm/mvc/facelets/CcmThemeUrlStreamHandler.java +++ b/ccm-core/src/main/java/org/libreccm/mvc/facelets/CcmThemeUrlStreamHandler.java @@ -26,7 +26,9 @@ import java.net.URLConnection; import java.net.URLStreamHandler; /** - * + * Implementation of {@link URLStreamHandler} for handling URLs to LibreCCM + * theme templates. + * * @author Jens Pelzetter */ class CcmThemeUrlStreamHandler extends URLStreamHandler { diff --git a/ccm-core/src/main/java/org/libreccm/mvc/facelets/CcmThemeViewResource.java b/ccm-core/src/main/java/org/libreccm/mvc/facelets/CcmThemeViewResource.java index 4d70648c2..5e005b679 100644 --- a/ccm-core/src/main/java/org/libreccm/mvc/facelets/CcmThemeViewResource.java +++ b/ccm-core/src/main/java/org/libreccm/mvc/facelets/CcmThemeViewResource.java @@ -27,7 +27,8 @@ import java.net.URL; import javax.faces.application.ViewResource; /** - * + * A {@link ViewResource} implementation for templates from LibreCCM themes. + * * @author Jens Pelzetter */ class CcmThemeViewResource extends ViewResource { @@ -36,13 +37,28 @@ class CcmThemeViewResource extends ViewResource { private final Themes themes; + /** + * Constructor for the {@code ViewResource} instance. + * + * @param themes Interface to the theme system + * @param path The path of the template. + */ public CcmThemeViewResource(final Themes themes, final String path) { this.themes = themes; this.path = path; } + /** + * Gets the URL of the URL of the template as {@code ViewResource}. + * + * @return The URL of the {@code ViewResource}. + */ @Override public URL getURL() { + // The URL build here is a "pseudo" URL. Most of the parts of the URL + // are no relevant. An special URLStreamHandler implementation is + // also passed to the URL. This URLStreamHandler implementation takes + // care of retrieving the template from the theme. try { return new URL( "libreccm", diff --git a/ccm-core/src/main/java/org/libreccm/mvc/facelets/package-info.java b/ccm-core/src/main/java/org/libreccm/mvc/facelets/package-info.java new file mode 100644 index 000000000..335aff91a --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/mvc/facelets/package-info.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2020 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +/** + * Integration of the LibreCCM theme system with the Facelet ViewEngine of + * Eclipse Krazo. + */ +package org.libreccm.mvc.facelets;