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
pull/2/head
jensp 2016-02-18 13:43:04 +00:00
parent 433b5eab2d
commit 51d4fca237
12 changed files with 108 additions and 69 deletions

View File

@ -76,7 +76,7 @@ public class UserBanner extends SimpleComponent {
contentElem.addAttribute("screenName", user.getName()); contentElem.addAttribute("screenName", user.getName());
contentElem.addAttribute("primaryEmail", contentElem.addAttribute("primaryEmail",
user.getPrimaryEmailAddress() user.getPrimaryEmailAddress()
.toString()); .getAddress());
contentElem.addAttribute("userID", contentElem.addAttribute("userID",
Long.toString(user.getPartyId())); Long.toString(user.getPartyId()));
} }

View File

@ -441,7 +441,8 @@ public class LoginServlet extends BebopApplicationServlet {
* @return URL_MSG for logout page as String * @return URL_MSG for logout page as String
*/ */
public static String getLogoutPageURL() { public static String getLogoutPageURL() {
return s_loginURL + LOGOUT_PATH_INFO; return s_loginURL.substring(0,
s_loginURL.length() - 1) + LOGOUT_PATH_INFO;
} }
} }

View File

@ -46,6 +46,7 @@ import org.libreccm.web.ApplicationType;
import java.util.Iterator; import java.util.Iterator;
import java.util.Set; import java.util.Set;
import java.util.StringJoiner;
import javax.enterprise.context.spi.CreationalContext; import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.Bean; import javax.enterprise.inject.spi.Bean;
@ -96,11 +97,11 @@ public class CCMDispatcherServlet extends BaseServlet {
private static final long serialVersionUID = 5292817856022435529L; private static final long serialVersionUID = 5292817856022435529L;
private static final Logger LOGGER = LogManager.getLogger( private static final Logger LOGGER = LogManager.getLogger(
CCMDispatcherServlet.class); CCMDispatcherServlet.class);
private static final String DISPATCHED_ATTRIBUTE private static final String DISPATCHED_ATTRIBUTE
= CCMDispatcherServlet.class = CCMDispatcherServlet.class
.getName() + ".dispatched"; .getName() + ".dispatched";
/** /**
* String containing the web context path portion of the WEB application * String containing the web context path portion of the WEB application
@ -140,19 +141,19 @@ public class CCMDispatcherServlet extends BaseServlet {
@Override @Override
protected void doService(final HttpServletRequest request, protected void doService(final HttpServletRequest request,
final HttpServletResponse response) final HttpServletResponse response)
throws ServletException, IOException { throws ServletException, IOException {
//This part replaces the index.jsp file //This part replaces the index.jsp file
if (request.getPathInfo() == null if (request.getPathInfo() == null
|| request.getPathInfo().isEmpty() || request.getPathInfo().isEmpty()
|| "/".equals(request.getPathInfo())) { || "/".equals(request.getPathInfo())) {
if (subject.isAuthenticated()) { if (subject.isAuthenticated()) {
// User is logged in, redirect to user redirect page // User is logged in, redirect to user redirect page
throw new RedirectSignal( throw new RedirectSignal(
URL.there(request, URL.there(request,
UI.getUserRedirectURL(request)), UI.getUserRedirectURL(request)),
false); false);
} else { } else {
// User is *not* logged in, display public front page // User is *not* logged in, display public front page
throw new RedirectSignal(URL.there(request, throw new RedirectSignal(URL.there(request,
@ -184,11 +185,11 @@ public class CCMDispatcherServlet extends BaseServlet {
response.sendRedirect(response.encodeRedirectURL(uri + "/")); response.sendRedirect(response.encodeRedirectURL(uri + "/"));
} else { } else {
response.sendRedirect(response response.sendRedirect(response
.encodeRedirectURL(uri + "/?" + query)); .encodeRedirectURL(uri + "/?" + query));
} }
} else { } else {
LOGGER.debug("Storing the path elements of the current request as " 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, request.setAttribute(BaseServlet.REQUEST_URL_ATTRIBUTE,
new URL(request)); new URL(request));
@ -205,17 +206,17 @@ public class CCMDispatcherServlet extends BaseServlet {
// we have to create a 404 page here! // we have to create a 404 page here!
String requestUri = request.getRequestURI(); // same as ctx.getRemainingURLPart() String requestUri = request.getRequestURI(); // same as ctx.getRemainingURLPart()
response.sendError(404, requestUri response.sendError(404, requestUri
+ " not found on this server."); + " not found on this server.");
} else { } else {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Found application {}; " LOGGER.debug("Found application {}; "
+ "dispatching to its servlet", + "dispatching to its servlet",
spec.getAppID()); spec.getAppID());
} }
request.setAttribute( request.setAttribute(
BaseApplicationServlet.APPLICATION_ID_ATTRIBUTE, BaseApplicationServlet.APPLICATION_ID_ATTRIBUTE,
spec.getAppID()); spec.getAppID());
request.setAttribute(DISPATCHED_ATTRIBUTE, Boolean.TRUE); request.setAttribute(DISPATCHED_ATTRIBUTE, Boolean.TRUE);
forward(spec.getTypeContextPath(), forward(spec.getTypeContextPath(),
spec.target(path), spec.target(path),
@ -243,12 +244,12 @@ public class CCMDispatcherServlet extends BaseServlet {
if (path.lastIndexOf(".") < path.lastIndexOf("/")) { if (path.lastIndexOf(".") < path.lastIndexOf("/")) {
LOGGER.debug("The last fragment of the path has no '.', so we " LOGGER.debug("The last fragment of the path has no '.', so we "
+ "assume a directory was requested; a trailing " + "assume a directory was requested; a trailing "
+ "slash is required"); + "slash is required");
return true; return true;
} else { } else {
LOGGER.debug("The last fragment of the path appears to be a file " 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; return false;
} }
} }
@ -257,7 +258,7 @@ public class CCMDispatcherServlet extends BaseServlet {
final String target, final String target,
final HttpServletRequest request, final HttpServletRequest request,
final HttpServletResponse response) final HttpServletResponse response)
throws ServletException, IOException { throws ServletException, IOException {
LOGGER.debug("Forwarding by path to target \"{}\"...", target); LOGGER.debug("Forwarding by path to target \"{}\"...", target);
LOGGER.debug("The context path is: {}", contextPath); LOGGER.debug("The context path is: {}", contextPath);
@ -274,7 +275,7 @@ public class CCMDispatcherServlet extends BaseServlet {
} }
final ServletContext context = getServletContext().getContext( final ServletContext context = getServletContext().getContext(
forwardContextPath); forwardContextPath);
LOGGER.debug("forwarding from context \"{}\" to context \"{}\"...", LOGGER.debug("forwarding from context \"{}\" to context \"{}\"...",
getServletContext(), context); getServletContext(), context);
@ -287,19 +288,19 @@ public class CCMDispatcherServlet extends BaseServlet {
private void forward(final RequestDispatcher dispatcher, private void forward(final RequestDispatcher dispatcher,
final HttpServletRequest request, final HttpServletRequest request,
final HttpServletResponse response) final HttpServletResponse response)
throws ServletException, IOException { throws ServletException, IOException {
LOGGER.debug("Checking if this request need to be forwarded or " LOGGER.debug("Checking if this request need to be forwarded or "
+ "included: {}", request); + "included: {}", request);
if (request.getAttribute("javax.servlet.include.request_uri") == null) { if (request.getAttribute("javax.servlet.include.request_uri") == null) {
LOGGER.debug("The attribute javax.servlet.include.request_uri " LOGGER.debug("The attribute javax.servlet.include.request_uri "
+ "is not set; forwarding {}", + "is not set; forwarding {}",
request); request);
dispatcher.forward(request, response); dispatcher.forward(request, response);
} else { } else {
LOGGER.debug("The attribute javax.servlet.include.request_uri " LOGGER.debug("The attribute javax.servlet.include.request_uri "
+ "is set; including {}", + "is set; including {}",
request); request);
dispatcher.include(request, response); dispatcher.include(request, response);
} }
@ -317,9 +318,26 @@ public class CCMDispatcherServlet extends BaseServlet {
path); path);
} }
final CcmApplication application = appManager final String pathTokens[];
.findApplicationByPath(path); 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) { if (application == null) {
LOGGER.warn("No application found for path \"{}\".", path); LOGGER.warn("No application found for path \"{}\".", path);
return null; 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() { public static String getContextPath() {
return s_contextPath; return s_contextPath;
} }
@ -367,9 +396,9 @@ public class CCMDispatcherServlet extends BaseServlet {
m_instanceURI = app.getPrimaryUrl(); m_instanceURI = app.getPrimaryUrl();
if (app.getClass().isAnnotationPresent(ServletPath.class)) { if (app.getClass().isAnnotationPresent(ServletPath.class)) {
m_typeURI = app m_typeURI = app
.getClass() .getClass()
.getAnnotation(ServletPath.class) .getAnnotation(ServletPath.class)
.value(); .value();
} else { } else {
// final ApplicationManager appManager = CDI.current().select( // final ApplicationManager appManager = CDI.current().select(
// ApplicationManager.class).get(); // ApplicationManager.class).get();
@ -398,21 +427,21 @@ public class CCMDispatcherServlet extends BaseServlet {
// } // }
final ApplicationType appType = appManager.getApplicationTypes() final ApplicationType appType = appManager.getApplicationTypes()
.get(app.getApplicationType()); .get(app.getApplicationType());
final Class<? extends HttpServlet> appServletClass = appType final Class<? extends HttpServlet> appServletClass = appType
.servlet(); .servlet();
final WebServlet servletAnnotation = appServletClass final WebServlet servletAnnotation = appServletClass
.getAnnotation(WebServlet.class); .getAnnotation(WebServlet.class);
if (servletAnnotation != null if (servletAnnotation != null
&& servletAnnotation.urlPatterns() != null && servletAnnotation.urlPatterns() != null
&& servletAnnotation.urlPatterns().length > 0) { && servletAnnotation.urlPatterns().length > 0) {
if (servletAnnotation.urlPatterns()[0].endsWith("*")) { if (servletAnnotation.urlPatterns()[0].endsWith("*")) {
m_typeURI = servletAnnotation m_typeURI = servletAnnotation
.urlPatterns()[0] .urlPatterns()[0]
.substring(0, .substring(0,
servletAnnotation servletAnnotation
.urlPatterns()[0] .urlPatterns()[0]
.length() - 1); .length() - 1);
} else { } else {
m_typeURI = servletAnnotation.urlPatterns()[0]; m_typeURI = servletAnnotation.urlPatterns()[0];
} }
@ -446,7 +475,7 @@ public class CCMDispatcherServlet extends BaseServlet {
* executing in no specific context but CCM's default. * executing in no specific context but CCM's default.
* *
* @return The context path of the application's url, "" in case of * @return The context path of the application's url, "" in case of
* executing in the ROOT context. * executing in the ROOT context.
*/ */
String getTypeContextPath() { String getTypeContextPath() {
if (m_typeContextPath.equals("")) { if (m_typeContextPath.equals("")) {
@ -467,7 +496,7 @@ public class CCMDispatcherServlet extends BaseServlet {
String target(final String path) { String target(final String path) {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Building the target path from the request " LOGGER.debug("Building the target path from the request "
+ "path '{}' and the spec {}", + "path '{}' and the spec {}",
path, path,
this); this);
} }
@ -503,8 +532,8 @@ public class CCMDispatcherServlet extends BaseServlet {
ApplicationSpec other = (ApplicationSpec) obj; ApplicationSpec other = (ApplicationSpec) obj;
return m_id == other.getAppID() && equal(m_instanceURI, return m_id == other.getAppID() && equal(m_instanceURI,
other.m_instanceURI) other.m_instanceURI)
&& equal(m_typeURI, other.m_typeURI) && equal( && equal(m_typeURI, other.m_typeURI) && equal(
m_typeContextPath, other.m_typeContextPath); m_typeContextPath, other.m_typeContextPath);
} }

View File

@ -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.url.label=URL
com.arsdigita.ui.admin.applications.title.label=Title com.arsdigita.ui.admin.applications.title.label=Title
com.arsdigita.ui.admin.applications.desc.label=Description com.arsdigita.ui.admin.applications.desc.label=Description
ui.change_password=Change password ui.admin.change_password=Change password

View File

@ -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.url.label=URL
com.arsdigita.ui.admin.applications.title.label=Bezeichnung com.arsdigita.ui.admin.applications.title.label=Bezeichnung
com.arsdigita.ui.admin.applications.desc.label=Beschreibung com.arsdigita.ui.admin.applications.desc.label=Beschreibung
ui.change_password=Passwort \u00e4ndern ui.admin.change_password=Passwort \u00e4ndern

View File

@ -20,12 +20,12 @@ ui.debug.transform.off=Hide transformation
ui.debug.xml=View document XML ui.debug.xml=View document XML
ui.debug.xsl=Download XSL files ui.debug.xsl=Download XSL files
com.arsdigita.ui.admin.applications.tree.heading=Applications com.arsdigita.ui.admin.applications.tree.heading=Applications
com.arsdigita.ui.admin.applications.url.validation.not_blank= 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= 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= com.arsdigita.ui.admin.applications.title.validation.not_blank=Title is mandatory for an application instance.
com.arsdigita.ui.admin.applications.title.valiation.minmaxlength= 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= 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= com.arsdigita.ui.admin.applications.url.label=URL
com.arsdigita.ui.admin.applications.title.label= com.arsdigita.ui.admin.applications.title.label=Title
com.arsdigita.ui.admin.applications.desc.label= com.arsdigita.ui.admin.applications.desc.label=Description
ui.change_password= ui.admin.change_password=Change password

View File

@ -15,13 +15,17 @@ ui.sitemap.configure_sitemap_admin_page=TRANSLATE THIS: Configure SiteMap Admin
ui.sitemap.h4emselect_sitenode_to_view_detailsemh4=TRANSLATE THIS: <h4><em>Select SiteNode to View Details</em></h4> (ui.sitemap.h4emselect_sitenode_to_view_detailsemh4) ui.sitemap.h4emselect_sitenode_to_view_detailsemh4=TRANSLATE THIS: <h4><em>Select SiteNode to View Details</em></h4> (ui.sitemap.h4emselect_sitenode_to_view_detailsemh4)
ui.sitemap.configuration_menu_placeholder=TRANSLATE THIS: Configuration Menu Placeholder (ui.sitemap.configuration_menu_placeholder) 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 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.tree.heading=Applications
com.arsdigita.ui.admin.applications.url.validation.not_blank= 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= 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= com.arsdigita.ui.admin.applications.title.validation.not_blank=Title is mandatory for an application instance.
com.arsdigita.ui.admin.applications.title.valiation.minmaxlength= 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= 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= com.arsdigita.ui.admin.applications.url.label=URL
com.arsdigita.ui.admin.applications.title.label= com.arsdigita.ui.admin.applications.title.label=Title
com.arsdigita.ui.admin.applications.desc.label= com.arsdigita.ui.admin.applications.desc.label=Description
ui.change_password= 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

View File

@ -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.users_groups_roles.title=Users/Groups/Roles
ui.admin.tab.categories.title=Categories ui.admin.tab.categories.title=Categories
ui.admin.tab.registry.title=Registry ui.admin.tab.registry.title=Registry
ui.admin.change_password=Change password

View File

@ -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.users_groups_roles.title=Benutzer/Gruppen/Rollen
ui.admin.tab.categories.title=Kategorien ui.admin.tab.categories.title=Kategorien
ui.admin.tab.registry.title=Registry ui.admin.tab.registry.title=Registry
ui.admin.change_password=Passwort \u00e4ndern

View File

@ -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.users_groups_roles.title=Users/Groups/Roles
ui.admin.tab.categories.title=Categories ui.admin.tab.categories.title=Categories
ui.admin.tab.registry.title=Registry ui.admin.tab.registry.title=Registry
ui.admin.change_password=Change password

View File

@ -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.users_groups_roles.title=
ui.admin.tab.categories.title= ui.admin.tab.categories.title=
ui.admin.tab.registry.title= ui.admin.tab.registry.title=
ui.admin.change_password=Change password

View File

@ -93,7 +93,8 @@ processor, some are read from the configuration files of Foundry and some are de
</p> </p>
</foundry:doc-desc> </foundry:doc-desc>
</foundry:doc> </foundry:doc>
<xsl:param name="theme-prefix"/> <xsl:param name="theme-prefix"
select="concat($context-prefix, '/themes/libreccm-default')"/>
<foundry:doc section="devel" type="env-var"> <foundry:doc section="devel" type="env-var">
<foundry:doc-desc> <foundry:doc-desc>