From 51d4fca237bfa0b55755f08b63ef3aae854fe703 Mon Sep 17 00:00:00 2001
From: jensp
Date: Thu, 18 Feb 2016 13:43:04 +0000
Subject: [PATCH] CCM NG: Fixed some bugs in the application lookup
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@3875 8810af33-2d31-482b-a856-94f89814c4df
---
.../java/com/arsdigita/ui/UserBanner.java | 2 +-
.../com/arsdigita/ui/login/LoginServlet.java | 3 +-
.../arsdigita/web/CCMDispatcherServlet.java | 119 +++++++++++-------
.../com/arsdigita/ui/UIResources.properties | 2 +-
.../arsdigita/ui/UIResources_de.properties | 2 +-
.../arsdigita/ui/UIResources_en.properties | 18 +--
.../arsdigita/ui/UIResources_fr.properties | 24 ++--
.../ui/admin/AdminResources.properties | 1 +
.../ui/admin/AdminResources_de.properties | 1 +
.../ui/admin/AdminResources_en.properties | 1 +
.../ui/admin/AdminResources_fr.properties | 1 +
.../foundry/foundry/lib/global-vars.xsl | 3 +-
12 files changed, 108 insertions(+), 69 deletions(-)
diff --git a/ccm-core/src/main/java/com/arsdigita/ui/UserBanner.java b/ccm-core/src/main/java/com/arsdigita/ui/UserBanner.java
index 666272571..e7887f786 100644
--- a/ccm-core/src/main/java/com/arsdigita/ui/UserBanner.java
+++ b/ccm-core/src/main/java/com/arsdigita/ui/UserBanner.java
@@ -76,7 +76,7 @@ public class UserBanner extends SimpleComponent {
contentElem.addAttribute("screenName", user.getName());
contentElem.addAttribute("primaryEmail",
user.getPrimaryEmailAddress()
- .toString());
+ .getAddress());
contentElem.addAttribute("userID",
Long.toString(user.getPartyId()));
}
diff --git a/ccm-core/src/main/java/com/arsdigita/ui/login/LoginServlet.java b/ccm-core/src/main/java/com/arsdigita/ui/login/LoginServlet.java
index d62e4bcc7..4723a9755 100644
--- a/ccm-core/src/main/java/com/arsdigita/ui/login/LoginServlet.java
+++ b/ccm-core/src/main/java/com/arsdigita/ui/login/LoginServlet.java
@@ -441,7 +441,8 @@ public class LoginServlet extends BebopApplicationServlet {
* @return URL_MSG for logout page as String
*/
public static String getLogoutPageURL() {
- return s_loginURL + LOGOUT_PATH_INFO;
+ return s_loginURL.substring(0,
+ s_loginURL.length() - 1) + LOGOUT_PATH_INFO;
}
}
diff --git a/ccm-core/src/main/java/com/arsdigita/web/CCMDispatcherServlet.java b/ccm-core/src/main/java/com/arsdigita/web/CCMDispatcherServlet.java
index 52a88b6a5..14ee7521d 100644
--- a/ccm-core/src/main/java/com/arsdigita/web/CCMDispatcherServlet.java
+++ b/ccm-core/src/main/java/com/arsdigita/web/CCMDispatcherServlet.java
@@ -46,6 +46,7 @@ import org.libreccm.web.ApplicationType;
import java.util.Iterator;
import java.util.Set;
+import java.util.StringJoiner;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.Bean;
@@ -96,11 +97,11 @@ public class CCMDispatcherServlet extends BaseServlet {
private static final long serialVersionUID = 5292817856022435529L;
private static final Logger LOGGER = LogManager.getLogger(
- CCMDispatcherServlet.class);
+ CCMDispatcherServlet.class);
private static final String DISPATCHED_ATTRIBUTE
- = CCMDispatcherServlet.class
- .getName() + ".dispatched";
+ = CCMDispatcherServlet.class
+ .getName() + ".dispatched";
/**
* String containing the web context path portion of the WEB application
@@ -140,19 +141,19 @@ public class CCMDispatcherServlet extends BaseServlet {
@Override
protected void doService(final HttpServletRequest request,
final HttpServletResponse response)
- throws ServletException, IOException {
+ throws ServletException, IOException {
//This part replaces the index.jsp file
if (request.getPathInfo() == null
- || request.getPathInfo().isEmpty()
- || "/".equals(request.getPathInfo())) {
+ || request.getPathInfo().isEmpty()
+ || "/".equals(request.getPathInfo())) {
if (subject.isAuthenticated()) {
// User is logged in, redirect to user redirect page
throw new RedirectSignal(
- URL.there(request,
- UI.getUserRedirectURL(request)),
- false);
+ URL.there(request,
+ UI.getUserRedirectURL(request)),
+ false);
} else {
// User is *not* logged in, display public front page
throw new RedirectSignal(URL.there(request,
@@ -184,11 +185,11 @@ public class CCMDispatcherServlet extends BaseServlet {
response.sendRedirect(response.encodeRedirectURL(uri + "/"));
} else {
response.sendRedirect(response
- .encodeRedirectURL(uri + "/?" + query));
+ .encodeRedirectURL(uri + "/?" + query));
}
} else {
LOGGER.debug("Storing the path elements of the current request as "
- + "the original path elements");
+ + "the original path elements");
request.setAttribute(BaseServlet.REQUEST_URL_ATTRIBUTE,
new URL(request));
@@ -205,17 +206,17 @@ public class CCMDispatcherServlet extends BaseServlet {
// we have to create a 404 page here!
String requestUri = request.getRequestURI(); // same as ctx.getRemainingURLPart()
response.sendError(404, requestUri
- + " not found on this server.");
+ + " not found on this server.");
} else {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Found application {}; "
- + "dispatching to its servlet",
+ + "dispatching to its servlet",
spec.getAppID());
}
request.setAttribute(
- BaseApplicationServlet.APPLICATION_ID_ATTRIBUTE,
- spec.getAppID());
+ BaseApplicationServlet.APPLICATION_ID_ATTRIBUTE,
+ spec.getAppID());
request.setAttribute(DISPATCHED_ATTRIBUTE, Boolean.TRUE);
forward(spec.getTypeContextPath(),
spec.target(path),
@@ -243,12 +244,12 @@ public class CCMDispatcherServlet extends BaseServlet {
if (path.lastIndexOf(".") < path.lastIndexOf("/")) {
LOGGER.debug("The last fragment of the path has no '.', so we "
- + "assume a directory was requested; a trailing "
- + "slash is required");
+ + "assume a directory was requested; a trailing "
+ + "slash is required");
return true;
} else {
LOGGER.debug("The last fragment of the path appears to be a file "
- + "name; no trailing slash is needed");
+ + "name; no trailing slash is needed");
return false;
}
}
@@ -257,7 +258,7 @@ public class CCMDispatcherServlet extends BaseServlet {
final String target,
final HttpServletRequest request,
final HttpServletResponse response)
- throws ServletException, IOException {
+ throws ServletException, IOException {
LOGGER.debug("Forwarding by path to target \"{}\"...", target);
LOGGER.debug("The context path is: {}", contextPath);
@@ -274,7 +275,7 @@ public class CCMDispatcherServlet extends BaseServlet {
}
final ServletContext context = getServletContext().getContext(
- forwardContextPath);
+ forwardContextPath);
LOGGER.debug("forwarding from context \"{}\" to context \"{}\"...",
getServletContext(), context);
@@ -287,19 +288,19 @@ public class CCMDispatcherServlet extends BaseServlet {
private void forward(final RequestDispatcher dispatcher,
final HttpServletRequest request,
final HttpServletResponse response)
- throws ServletException, IOException {
+ throws ServletException, IOException {
LOGGER.debug("Checking if this request need to be forwarded or "
- + "included: {}", request);
+ + "included: {}", request);
if (request.getAttribute("javax.servlet.include.request_uri") == null) {
LOGGER.debug("The attribute javax.servlet.include.request_uri "
- + "is not set; forwarding {}",
+ + "is not set; forwarding {}",
request);
dispatcher.forward(request, response);
} else {
LOGGER.debug("The attribute javax.servlet.include.request_uri "
- + "is set; including {}",
+ + "is set; including {}",
request);
dispatcher.include(request, response);
}
@@ -317,9 +318,26 @@ public class CCMDispatcherServlet extends BaseServlet {
path);
}
- final CcmApplication application = appManager
- .findApplicationByPath(path);
+ final String pathTokens[];
+ if (path.startsWith("/")) {
+ pathTokens = path.substring(1).split("/");
+ } else {
+ pathTokens = path.split("/");
+ }
+ CcmApplication application = null;
+ for (int i = pathTokens.length; i > 0; i--) {
+ final String currentPath = generatePath(i, pathTokens);
+ LOGGER.debug("Trying path '{}'...", currentPath);
+ application = appManager.findApplicationByPath(currentPath);
+ if (application != null) {
+ LOGGER.debug("Found application for path '{}'.", currentPath);
+ break;
+ }
+ }
+
+// final CcmApplication application = appManager
+// .findApplicationByPath(path);
if (application == null) {
LOGGER.warn("No application found for path \"{}\".", path);
return null;
@@ -328,6 +346,17 @@ public class CCMDispatcherServlet extends BaseServlet {
}
}
+ private String generatePath(final int index, final String[] pathTokens) {
+ final StringBuffer buffer = new StringBuffer();
+ buffer.append('/');
+ for (int i = 0; i < index; i++) {
+ buffer.append(pathTokens[i]);
+ buffer.append('/');
+ }
+
+ return buffer.toString();
+ }
+
public static String getContextPath() {
return s_contextPath;
}
@@ -355,10 +384,10 @@ public class CCMDispatcherServlet extends BaseServlet {
*
* @param app
*/
- ApplicationSpec(final CcmApplication app,
+ ApplicationSpec(final CcmApplication app,
final ApplicationManager appManager) {
this.appManager = appManager;
-
+
if (app == null) {
throw new NullPointerException("app");
}
@@ -367,9 +396,9 @@ public class CCMDispatcherServlet extends BaseServlet {
m_instanceURI = app.getPrimaryUrl();
if (app.getClass().isAnnotationPresent(ServletPath.class)) {
m_typeURI = app
- .getClass()
- .getAnnotation(ServletPath.class)
- .value();
+ .getClass()
+ .getAnnotation(ServletPath.class)
+ .value();
} else {
// final ApplicationManager appManager = CDI.current().select(
// ApplicationManager.class).get();
@@ -398,21 +427,21 @@ public class CCMDispatcherServlet extends BaseServlet {
// }
final ApplicationType appType = appManager.getApplicationTypes()
- .get(app.getApplicationType());
+ .get(app.getApplicationType());
final Class extends HttpServlet> appServletClass = appType
- .servlet();
+ .servlet();
final WebServlet servletAnnotation = appServletClass
- .getAnnotation(WebServlet.class);
+ .getAnnotation(WebServlet.class);
if (servletAnnotation != null
- && servletAnnotation.urlPatterns() != null
- && servletAnnotation.urlPatterns().length > 0) {
+ && servletAnnotation.urlPatterns() != null
+ && servletAnnotation.urlPatterns().length > 0) {
if (servletAnnotation.urlPatterns()[0].endsWith("*")) {
m_typeURI = servletAnnotation
- .urlPatterns()[0]
- .substring(0,
- servletAnnotation
- .urlPatterns()[0]
- .length() - 1);
+ .urlPatterns()[0]
+ .substring(0,
+ servletAnnotation
+ .urlPatterns()[0]
+ .length() - 1);
} else {
m_typeURI = servletAnnotation.urlPatterns()[0];
}
@@ -446,7 +475,7 @@ public class CCMDispatcherServlet extends BaseServlet {
* executing in no specific context but CCM's default.
*
* @return The context path of the application's url, "" in case of
- * executing in the ROOT context.
+ * executing in the ROOT context.
*/
String getTypeContextPath() {
if (m_typeContextPath.equals("")) {
@@ -467,7 +496,7 @@ public class CCMDispatcherServlet extends BaseServlet {
String target(final String path) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Building the target path from the request "
- + "path '{}' and the spec {}",
+ + "path '{}' and the spec {}",
path,
this);
}
@@ -503,8 +532,8 @@ public class CCMDispatcherServlet extends BaseServlet {
ApplicationSpec other = (ApplicationSpec) obj;
return m_id == other.getAppID() && equal(m_instanceURI,
other.m_instanceURI)
- && equal(m_typeURI, other.m_typeURI) && equal(
- m_typeContextPath, other.m_typeContextPath);
+ && equal(m_typeURI, other.m_typeURI) && equal(
+ m_typeContextPath, other.m_typeContextPath);
}
diff --git a/ccm-core/src/main/resources/com/arsdigita/ui/UIResources.properties b/ccm-core/src/main/resources/com/arsdigita/ui/UIResources.properties
index a4c5e6e97..bdfb8ca4a 100755
--- a/ccm-core/src/main/resources/com/arsdigita/ui/UIResources.properties
+++ b/ccm-core/src/main/resources/com/arsdigita/ui/UIResources.properties
@@ -28,4 +28,4 @@ com.arsdigita.ui.admin.applications.desc.valiation.minmaxlength=The maximum leng
com.arsdigita.ui.admin.applications.url.label=URL
com.arsdigita.ui.admin.applications.title.label=Title
com.arsdigita.ui.admin.applications.desc.label=Description
-ui.change_password=Change password
+ui.admin.change_password=Change password
diff --git a/ccm-core/src/main/resources/com/arsdigita/ui/UIResources_de.properties b/ccm-core/src/main/resources/com/arsdigita/ui/UIResources_de.properties
index 66904d78a..a64ae47b8 100644
--- a/ccm-core/src/main/resources/com/arsdigita/ui/UIResources_de.properties
+++ b/ccm-core/src/main/resources/com/arsdigita/ui/UIResources_de.properties
@@ -28,4 +28,4 @@ com.arsdigita.ui.admin.applications.desc.valiation.minmaxlength=Die Beschreibung
com.arsdigita.ui.admin.applications.url.label=URL
com.arsdigita.ui.admin.applications.title.label=Bezeichnung
com.arsdigita.ui.admin.applications.desc.label=Beschreibung
-ui.change_password=Passwort \u00e4ndern
+ui.admin.change_password=Passwort \u00e4ndern
diff --git a/ccm-core/src/main/resources/com/arsdigita/ui/UIResources_en.properties b/ccm-core/src/main/resources/com/arsdigita/ui/UIResources_en.properties
index 1c13aa6af..bdfb8ca4a 100755
--- a/ccm-core/src/main/resources/com/arsdigita/ui/UIResources_en.properties
+++ b/ccm-core/src/main/resources/com/arsdigita/ui/UIResources_en.properties
@@ -20,12 +20,12 @@ ui.debug.transform.off=Hide transformation
ui.debug.xml=View document XML
ui.debug.xsl=Download XSL files
com.arsdigita.ui.admin.applications.tree.heading=Applications
-com.arsdigita.ui.admin.applications.url.validation.not_blank=
-com.arsdigita.ui.admin.applications.url.valiation.minmaxlength=
-com.arsdigita.ui.admin.applications.title.validation.not_blank=
-com.arsdigita.ui.admin.applications.title.valiation.minmaxlength=
-com.arsdigita.ui.admin.applications.desc.valiation.minmaxlength=
-com.arsdigita.ui.admin.applications.url.label=
-com.arsdigita.ui.admin.applications.title.label=
-com.arsdigita.ui.admin.applications.desc.label=
-ui.change_password=
+com.arsdigita.ui.admin.applications.url.validation.not_blank=The URL of an application instance can is mandatory.
+com.arsdigita.ui.admin.applications.url.valiation.minmaxlength=The length of an URL of an application instance must be between 1 and 100 characters.
+com.arsdigita.ui.admin.applications.title.validation.not_blank=Title is mandatory for an application instance.
+com.arsdigita.ui.admin.applications.title.valiation.minmaxlength=The minimum length of the title of an applicatio instance is one character, the maximum length are 200 characters
+com.arsdigita.ui.admin.applications.desc.valiation.minmaxlength=The maximum length of a descrption of an application instance are 4000 characters.
+com.arsdigita.ui.admin.applications.url.label=URL
+com.arsdigita.ui.admin.applications.title.label=Title
+com.arsdigita.ui.admin.applications.desc.label=Description
+ui.admin.change_password=Change password
diff --git a/ccm-core/src/main/resources/com/arsdigita/ui/UIResources_fr.properties b/ccm-core/src/main/resources/com/arsdigita/ui/UIResources_fr.properties
index cc00b5460..943eae17c 100755
--- a/ccm-core/src/main/resources/com/arsdigita/ui/UIResources_fr.properties
+++ b/ccm-core/src/main/resources/com/arsdigita/ui/UIResources_fr.properties
@@ -15,13 +15,17 @@ ui.sitemap.configure_sitemap_admin_page=TRANSLATE THIS: Configure SiteMap Admin
ui.sitemap.h4emselect_sitenode_to_view_detailsemh4=TRANSLATE THIS: Select SiteNode to View Details
(ui.sitemap.h4emselect_sitenode_to_view_detailsemh4)
ui.sitemap.configuration_menu_placeholder=TRANSLATE THIS: Configuration Menu Placeholder (ui.sitemap.configuration_menu_placeholder)
ui.sitemap.access_denied_to_sitemap=Vous n'avez pas acc\u00e8s au plan du site
-com.arsdigita.ui.admin.applications.tree.heading=
-com.arsdigita.ui.admin.applications.url.validation.not_blank=
-com.arsdigita.ui.admin.applications.url.valiation.minmaxlength=
-com.arsdigita.ui.admin.applications.title.validation.not_blank=
-com.arsdigita.ui.admin.applications.title.valiation.minmaxlength=
-com.arsdigita.ui.admin.applications.desc.valiation.minmaxlength=
-com.arsdigita.ui.admin.applications.url.label=
-com.arsdigita.ui.admin.applications.title.label=
-com.arsdigita.ui.admin.applications.desc.label=
-ui.change_password=
+com.arsdigita.ui.admin.applications.tree.heading=Applications
+com.arsdigita.ui.admin.applications.url.validation.not_blank=The URL of an application instance can is mandatory.
+com.arsdigita.ui.admin.applications.url.valiation.minmaxlength=The length of an URL of an application instance must be between 1 and 100 characters.
+com.arsdigita.ui.admin.applications.title.validation.not_blank=Title is mandatory for an application instance.
+com.arsdigita.ui.admin.applications.title.valiation.minmaxlength=The minimum length of the title of an applicatio instance is one character, the maximum length are 200 characters
+com.arsdigita.ui.admin.applications.desc.valiation.minmaxlength=The maximum length of a descrption of an application instance are 4000 characters.
+com.arsdigita.ui.admin.applications.url.label=URL
+com.arsdigita.ui.admin.applications.title.label=Title
+com.arsdigita.ui.admin.applications.desc.label=Description
+ui.admin.change_password=Change password
+ui.debug.transform.off=Hide transformation
+ui.debug.transform.on=Display transformation
+ui.debug.xml=View document XML
+ui.debug.xsl=Download XSL files
diff --git a/ccm-core/src/main/resources/com/arsdigita/ui/admin/AdminResources.properties b/ccm-core/src/main/resources/com/arsdigita/ui/admin/AdminResources.properties
index 646aa2e81..df1966002 100644
--- a/ccm-core/src/main/resources/com/arsdigita/ui/admin/AdminResources.properties
+++ b/ccm-core/src/main/resources/com/arsdigita/ui/admin/AdminResources.properties
@@ -155,3 +155,4 @@ ui.admin.groups.couldnt_find_specified_group=Couldn't find the specified group
ui.admin.tab.users_groups_roles.title=Users/Groups/Roles
ui.admin.tab.categories.title=Categories
ui.admin.tab.registry.title=Registry
+ui.admin.change_password=Change password
diff --git a/ccm-core/src/main/resources/com/arsdigita/ui/admin/AdminResources_de.properties b/ccm-core/src/main/resources/com/arsdigita/ui/admin/AdminResources_de.properties
index cde5bc1b2..dec91c645 100644
--- a/ccm-core/src/main/resources/com/arsdigita/ui/admin/AdminResources_de.properties
+++ b/ccm-core/src/main/resources/com/arsdigita/ui/admin/AdminResources_de.properties
@@ -155,3 +155,4 @@ ui.admin.groups.couldnt_find_specified_group=Konnte die spezifische Gruppe nicht
ui.admin.tab.users_groups_roles.title=Benutzer/Gruppen/Rollen
ui.admin.tab.categories.title=Kategorien
ui.admin.tab.registry.title=Registry
+ui.admin.change_password=Passwort \u00e4ndern
diff --git a/ccm-core/src/main/resources/com/arsdigita/ui/admin/AdminResources_en.properties b/ccm-core/src/main/resources/com/arsdigita/ui/admin/AdminResources_en.properties
index 405a4b6b9..150b67d63 100755
--- a/ccm-core/src/main/resources/com/arsdigita/ui/admin/AdminResources_en.properties
+++ b/ccm-core/src/main/resources/com/arsdigita/ui/admin/AdminResources_en.properties
@@ -113,3 +113,4 @@ ui.admin.groups.couldnt_find_specified_group=Couldn't find the specified group
ui.admin.tab.users_groups_roles.title=Users/Groups/Roles
ui.admin.tab.categories.title=Categories
ui.admin.tab.registry.title=Registry
+ui.admin.change_password=Change password
diff --git a/ccm-core/src/main/resources/com/arsdigita/ui/admin/AdminResources_fr.properties b/ccm-core/src/main/resources/com/arsdigita/ui/admin/AdminResources_fr.properties
index 906f8593d..3f1ddf674 100755
--- a/ccm-core/src/main/resources/com/arsdigita/ui/admin/AdminResources_fr.properties
+++ b/ccm-core/src/main/resources/com/arsdigita/ui/admin/AdminResources_fr.properties
@@ -98,3 +98,4 @@ ui.admin.groups.couldnt_find_specified_group=Impossible de trouver le groupe sp\
ui.admin.tab.users_groups_roles.title=
ui.admin.tab.categories.title=
ui.admin.tab.registry.title=
+ui.admin.change_password=Change password
diff --git a/ccm-theme-foundry/src/main/resources/themes/foundry/foundry/lib/global-vars.xsl b/ccm-theme-foundry/src/main/resources/themes/foundry/foundry/lib/global-vars.xsl
index bf023d119..cb717f819 100644
--- a/ccm-theme-foundry/src/main/resources/themes/foundry/foundry/lib/global-vars.xsl
+++ b/ccm-theme-foundry/src/main/resources/themes/foundry/foundry/lib/global-vars.xsl
@@ -93,7 +93,8 @@ processor, some are read from the configuration files of Foundry and some are de
-
+