From 073d547a1d415ebc59668937cf4dd12bc54c68e5 Mon Sep 17 00:00:00 2001 From: Georgy Litvinov Date: Fri, 24 May 2024 11:06:37 +0200 Subject: [PATCH 1/3] Added context path runtime property --- .../vedit/controller/BaseEditController.java | 3 ++- .../vitro/webapp/config/ContextPath.java | 23 +++++++++++++++++++ .../webapp/controller/VitroHttpServlet.java | 5 ++-- .../admin/StartupStatusController.java | 3 ++- .../authenticate/BaseLoginServlet.java | 4 ++-- .../ForgotPasswordController.java | 7 +++--- .../authenticate/LoginRedirector.java | 9 ++++---- .../authenticate/LogoutRedirector.java | 5 ++-- .../dumprestore/DumpModelsAction.java | 4 ++-- .../webapp/controller/edit/Authenticate.java | 7 +++--- .../controller/edit/DeletePageController.java | 3 ++- .../edit/EntityRetryController.java | 5 ++-- .../controller/edit/MenuManagementEdit.java | 4 ++-- .../edit/OntologyEditController.java | 3 ++- .../freemarker/ContactFormController.java | 4 +++- .../freemarker/ContactMailController.java | 3 ++- .../freemarker/FreemarkerSetup.java | 3 ++- .../grefine/JSONReconcileServlet.java | 5 ++-- .../VTwo/EditConfigurationUtils.java | 5 ++-- .../EditRequestDispatchController.java | 3 ++- .../config/FreemarkerConfigurationImpl.java | 4 +++- .../searchengine/solr/SolrSearchEngine.java | 3 ++- .../edit/EditConfigurationTemplateModel.java | 5 ++-- .../vitro/webapp/web/widgets/LoginWidget.java | 5 ++-- .../config/example.runtime.properties | 3 +++ 25 files changed, 88 insertions(+), 40 deletions(-) create mode 100644 api/src/main/java/edu/cornell/mannlib/vitro/webapp/config/ContextPath.java diff --git a/api/src/main/java/edu/cornell/mannlib/vedit/controller/BaseEditController.java b/api/src/main/java/edu/cornell/mannlib/vedit/controller/BaseEditController.java index 93a27e0e97..019893a089 100644 --- a/api/src/main/java/edu/cornell/mannlib/vedit/controller/BaseEditController.java +++ b/api/src/main/java/edu/cornell/mannlib/vedit/controller/BaseEditController.java @@ -31,6 +31,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.permissions.PermissionSets; import edu.cornell.mannlib.vitro.webapp.auth.policy.EntityPolicyController; import edu.cornell.mannlib.vitro.webapp.beans.PermissionSet; +import edu.cornell.mannlib.vitro.webapp.config.ContextPath; import edu.cornell.mannlib.vitro.webapp.controller.Controllers; import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; @@ -222,7 +223,7 @@ protected WebappDaoFactory getWebappDaoFactory(String userURI) { } public String getDefaultLandingPage(HttpServletRequest request) { - return (request.getContextPath() + DEFAULT_LANDING_PAGE); + return (ContextPath.getPath(request) + DEFAULT_LANDING_PAGE); } protected static void addAccessAttributes(HttpServletRequest req, String entityURI, AccessObjectType aot) { diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/config/ContextPath.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/config/ContextPath.java new file mode 100644 index 0000000000..4b7d1d87be --- /dev/null +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/config/ContextPath.java @@ -0,0 +1,23 @@ +package edu.cornell.mannlib.vitro.webapp.config; + +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public class ContextPath { + static final Log log = LogFactory.getLog(ContextPath.class); + + public static String getPath(HttpServletRequest request) { + String path = ConfigurationProperties.getInstance().getProperty("context.path"); + log.debug(String.format("Custom path %s, request path %s", path, request.getContextPath())); + return path == null ? request.getContextPath() : path; + } + + public static String getPath(ServletContext ctx) { + String path = ConfigurationProperties.getInstance().getProperty("context.path"); + log.debug(String.format("Custom path %s, ctx path %s", path, ctx.getContextPath())); + return path == null ? ctx.getContextPath() : path; + } +} diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/VitroHttpServlet.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/VitroHttpServlet.java index 90205db49d..d7221d11e2 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/VitroHttpServlet.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/VitroHttpServlet.java @@ -30,6 +30,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest; import edu.cornell.mannlib.vitro.webapp.beans.DisplayMessage; import edu.cornell.mannlib.vitro.webapp.beans.ResourceBean; +import edu.cornell.mannlib.vitro.webapp.config.ContextPath; import edu.cornell.mannlib.vitro.webapp.controller.authenticate.LogoutRedirector; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder; import edu.cornell.mannlib.vitro.webapp.i18n.I18n; @@ -155,7 +156,7 @@ public static void redirectToInsufficientAuthorizationPage( try { DisplayMessage.setMessage(request, I18n.bundle(request).text("insufficient_authorization")); - response.sendRedirect(request.getContextPath()); + response.sendRedirect(ContextPath.getPath(request)); } catch (IOException e) { log.error("Could not redirect to show insufficient authorization."); } @@ -196,7 +197,7 @@ private static String assembleLoginUrlWithReturn( } catch (UnsupportedEncodingException e) { log.error("Really? No UTF-8 encoding?", e); } - return request.getContextPath() + Controllers.AUTHENTICATE + return ContextPath.getPath(request) + Controllers.AUTHENTICATE + "?afterLogin=" + encodedAfterLoginUrl; } diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/StartupStatusController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/StartupStatusController.java index 2a755d1d3d..a338b7d88c 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/StartupStatusController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/StartupStatusController.java @@ -7,6 +7,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest; +import edu.cornell.mannlib.vitro.webapp.config.ContextPath; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; @@ -40,7 +41,7 @@ protected ResponseValues processRequest(VitroRequest vreq) { } private String getContextPath() { - String cp = getServletContext().getContextPath(); + String cp = ContextPath.getPath(getServletContext()); if ((cp == null) || cp.isEmpty()) { return "The application"; } else { diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/BaseLoginServlet.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/BaseLoginServlet.java index aa9a112090..b5f8019f5e 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/BaseLoginServlet.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/BaseLoginServlet.java @@ -10,7 +10,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - +import edu.cornell.mannlib.vitro.webapp.config.ContextPath; import edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean; import edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean.MLevel; import edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean.Message; @@ -66,6 +66,6 @@ protected String figureHomePageUrl(HttpServletRequest req) { String uri = req.getRequestURI(); int authLength = url.length() - uri.length(); String auth = url.substring(0, authLength); - return auth + req.getContextPath(); + return auth + ContextPath.getPath(req); } } diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/ForgotPasswordController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/ForgotPasswordController.java index 1ee5f7d380..0fc79aa37e 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/ForgotPasswordController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/ForgotPasswordController.java @@ -21,6 +21,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.CaptchaServiceBean; import edu.cornell.mannlib.vitro.webapp.beans.UserAccount; import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; +import edu.cornell.mannlib.vitro.webapp.config.ContextPath; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder; @@ -224,7 +225,7 @@ private void setCommonValues(Map dataContext, VitroRequest vreq) dataContext.put("forgotPasswordUrl", getForgotPasswordUrl(vreq)); dataContext.put("contactUrl", getContactUrl(vreq)); - dataContext.put("contextPath", vreq.getContextPath()); + dataContext.put("contextPath", ContextPath.getPath(vreq)); dataContext.put("emailConfigured", FreemarkerEmailFactory.isConfigured(vreq)); dataContext.put("emailValue", ""); dataContext.put("contactEmailConfigured", StringUtils.isNotBlank(appBean.getContactMail())); @@ -355,7 +356,7 @@ private Date calculateExpirationDate() { * @return The URL for the "Forgot Password" page as a string. */ private String getForgotPasswordUrl(VitroRequest request) { - String contextPath = request.getContextPath(); + String contextPath = ContextPath.getPath(request); return contextPath + "/forgotPassword"; } @@ -366,7 +367,7 @@ private String getForgotPasswordUrl(VitroRequest request) { * @return The URL for the "Contact" page as a string. */ private String getContactUrl(VitroRequest request) { - String contextPath = request.getContextPath(); + String contextPath = ContextPath.getPath(request); return contextPath + "/contact"; } diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/LoginRedirector.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/LoginRedirector.java index ca4ba5056e..12032eff83 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/LoginRedirector.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/LoginRedirector.java @@ -20,6 +20,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyHelper; import edu.cornell.mannlib.vitro.webapp.beans.DisplayMessage; import edu.cornell.mannlib.vitro.webapp.beans.UserAccount; +import edu.cornell.mannlib.vitro.webapp.config.ContextPath; import edu.cornell.mannlib.vitro.webapp.controller.Controllers; import edu.cornell.mannlib.vitro.webapp.i18n.I18n; import edu.cornell.mannlib.vitro.webapp.i18n.I18nBundle; @@ -157,12 +158,12 @@ private boolean canSeeSiteAdminPage() { } private boolean isLoginPage(String page) { - return ((page != null) && page.endsWith(request.getContextPath() + return ((page != null) && page.endsWith(ContextPath.getPath(request) + Controllers.LOGIN)); } private String getSiteAdminPageUrl() { - String contextPath = request.getContextPath(); + String contextPath = ContextPath.getPath(request); return contextPath + Controllers.SITE_ADMIN; } @@ -172,7 +173,7 @@ private boolean isSelfEditorWithIndividual() { private String getAssociatedIndividualHomePage() { try { - return request.getContextPath() + "/individual?uri=" + return ContextPath.getPath(request) + "/individual?uri=" + URLEncoder.encode(uriOfAssociatedIndividual, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new IllegalStateException("No UTF-8 encoding? Really?", e); @@ -180,7 +181,7 @@ private String getAssociatedIndividualHomePage() { } private String getApplicationHomePageUrl() { - String contextPath = request.getContextPath(); + String contextPath = ContextPath.getPath(request); if (contextPath.equals("")) { return "/"; } diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/LogoutRedirector.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/LogoutRedirector.java index 88965f8551..2ff8f1d65d 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/LogoutRedirector.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/LogoutRedirector.java @@ -10,6 +10,7 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; +import edu.cornell.mannlib.vitro.webapp.config.ContextPath; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -34,7 +35,7 @@ public static String getRedirectUrl(HttpServletRequest request, if ((referringUri == null) || (getRestrictedPageUris(request).contains(referringUri))) { log.debug("Sending to home page."); - return request.getContextPath(); + return ContextPath.getPath(request); } else { log.debug("Sending back to referring page."); return referrer; @@ -43,7 +44,7 @@ public static String getRedirectUrl(HttpServletRequest request, private static String figureUriFromUrl(HttpServletRequest request, String referrer) { - String postContext = breakBeforeContextPath(request.getContextPath(), + String postContext = breakBeforeContextPath(ContextPath.getPath(request), referrer); String uri = removeQueryString(postContext); log.debug("referrer='" + referrer + "', uri='" + uri + "'"); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/datatools/dumprestore/DumpModelsAction.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/datatools/dumprestore/DumpModelsAction.java index 63f0779d13..aed96c6874 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/datatools/dumprestore/DumpModelsAction.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/datatools/dumprestore/DumpModelsAction.java @@ -12,7 +12,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - +import edu.cornell.mannlib.vitro.webapp.config.ContextPath; import edu.cornell.mannlib.vitro.webapp.controller.datatools.dumprestore.DumpRestoreController.BadRequestException; import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService; import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService; @@ -46,7 +46,7 @@ class DumpModelsAction extends AbstractDumpRestoreAction { void redirectToFilename() throws IOException { String filename = which + N_QUADS_EXTENSION; - String urlPath = req.getContextPath() + req.getServletPath() + String urlPath = ContextPath.getPath(req) + req.getServletPath() + ACTION_DUMP; resp.sendRedirect(urlPath + "/" + filename + "?" + queryString); } diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/Authenticate.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/Authenticate.java index 68e07a7fe8..db134f7200 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/Authenticate.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/Authenticate.java @@ -31,6 +31,7 @@ import edu.cornell.mannlib.vedit.beans.LoginStatusBean; import edu.cornell.mannlib.vedit.beans.LoginStatusBean.AuthenticationSource; import edu.cornell.mannlib.vitro.webapp.beans.UserAccount; +import edu.cornell.mannlib.vitro.webapp.config.ContextPath; import edu.cornell.mannlib.vitro.webapp.controller.Controllers; import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; @@ -192,10 +193,10 @@ private void recordLoginProcessPages(HttpServletRequest request) { if (afterLoginUrl != null) { bean.setAfterLoginUrl(afterLoginUrl); - bean.setLoginPageUrl(request.getContextPath() + Controllers.LOGIN); + bean.setLoginPageUrl(ContextPath.getPath(request) + Controllers.LOGIN); } else if (doReturn) { bean.setAfterLoginUrl(referrer); - bean.setLoginPageUrl(request.getContextPath() + Controllers.LOGIN); + bean.setLoginPageUrl(ContextPath.getPath(request) + Controllers.LOGIN); } else { bean.setAfterLoginUrl(referrer); bean.setLoginPageUrl(referrer); @@ -230,7 +231,7 @@ private String whereDidWeComeFrom(HttpServletRequest request) { if (referrer != null) { return referrer; } else { - return request.getContextPath() + Controllers.LOGIN; + return ContextPath.getPath(request) + Controllers.LOGIN; } } diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/DeletePageController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/DeletePageController.java index 727f209dbc..7f09ab56d5 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/DeletePageController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/DeletePageController.java @@ -25,6 +25,7 @@ import org.apache.jena.shared.Lock; import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission; +import edu.cornell.mannlib.vitro.webapp.config.ContextPath; import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary; @@ -50,7 +51,7 @@ protected void doPost(HttpServletRequest rawRequest, HttpServletResponse resp) if(pageUri != null) { doDeletePage(pageUri, vreq, resp); } - resp.sendRedirect(rawRequest.getContextPath() + REDIRECT_URL); + resp.sendRedirect(ContextPath.getPath(rawRequest) + REDIRECT_URL); } protected void doGet(HttpServletRequest rawRequest, HttpServletResponse resp) throws ServletException, IOException { diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/EntityRetryController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/EntityRetryController.java index 9bbcf58e92..0dbe76dc78 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/EntityRetryController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/EntityRetryController.java @@ -46,6 +46,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl; import edu.cornell.mannlib.vitro.webapp.beans.VClass; import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup; +import edu.cornell.mannlib.vitro.webapp.config.ContextPath; import edu.cornell.mannlib.vitro.webapp.controller.Controllers; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao; @@ -68,7 +69,7 @@ public void doPost (HttpServletRequest request, HttpServletResponse response) { } VitroRequest vreq = new VitroRequest(request); - String siteAdminUrl = vreq.getContextPath() + Controllers.SITE_ADMIN; + String siteAdminUrl = ContextPath.getPath(vreq) + Controllers.SITE_ADMIN; //create an EditProcessObject for this and put it in the session EditProcessObject epo = super.createEpo(request); @@ -332,7 +333,7 @@ public void doForward(HttpServletRequest request, HttpServletResponse response, } } else { try { - String siteAdminUrl = request.getContextPath() + Controllers.SITE_ADMIN; + String siteAdminUrl = ContextPath.getPath(request) + Controllers.SITE_ADMIN; response.sendRedirect(siteAdminUrl); } catch (IOException e) { log.error("EntityInsertPageForwarder could not redirect to about page."); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/MenuManagementEdit.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/MenuManagementEdit.java index f187c3fc1c..4d3695f36c 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/MenuManagementEdit.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/MenuManagementEdit.java @@ -24,7 +24,7 @@ import org.apache.jena.rdf.model.Resource; import org.apache.jena.rdf.model.ResourceFactory; import org.apache.jena.shared.Lock; - +import edu.cornell.mannlib.vitro.webapp.config.ContextPath; import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary; @@ -57,7 +57,7 @@ protected void doPost(HttpServletRequest rawRequest, HttpServletResponse resp) } //Need to redirect correctly if(!isReorder(command)){ - resp.sendRedirect(rawRequest.getContextPath() + REDIRECT_URL); + resp.sendRedirect(ContextPath.getPath(rawRequest) + REDIRECT_URL); } else { } diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/OntologyEditController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/OntologyEditController.java index cfe7f6e8ad..cf1a0d2fee 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/OntologyEditController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/OntologyEditController.java @@ -20,6 +20,7 @@ import edu.cornell.mannlib.vedit.controller.BaseEditController; import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission; import edu.cornell.mannlib.vitro.webapp.beans.Ontology; +import edu.cornell.mannlib.vitro.webapp.config.ContextPath; import edu.cornell.mannlib.vitro.webapp.controller.Controllers; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao; @@ -84,7 +85,7 @@ public void doPost (HttpServletRequest req, HttpServletResponse response) { // See OntologyDaoJena.ontologyFromOntologyResource() comments String realURI = OntologyDaoJena.adjustOntologyURI(o.getURI()); request.setAttribute("realURI", realURI); - request.setAttribute("exportURL", request.getContextPath() + Controllers.EXPORT_RDF); + request.setAttribute("exportURL", ContextPath.getPath(request) + Controllers.EXPORT_RDF); request.setAttribute("epoKey",epo.getKey()); request.setAttribute("title","Ontology Control Panel"); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ContactFormController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ContactFormController.java index 68168b9249..da7227c725 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ContactFormController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ContactFormController.java @@ -10,6 +10,8 @@ import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; import edu.cornell.mannlib.vitro.webapp.beans.CaptchaServiceBean; +import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; +import edu.cornell.mannlib.vitro.webapp.config.ContextPath; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues; @@ -61,7 +63,7 @@ else if (StringUtils.isBlank(appBean.getContactMail())) { else { CaptchaServiceBean.addCaptchaRelatedFieldsToPageContext(body); - body.put("contextPath", vreq.getContextPath()); + body.put("contextPath", ContextPath.getPath(vreq)); body.put("formAction", "submitFeedback"); if (vreq.getHeader("Referer") == null) { diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ContactMailController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ContactMailController.java index 9361d51974..b7f2a617a0 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ContactMailController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ContactMailController.java @@ -30,6 +30,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; import edu.cornell.mannlib.vitro.webapp.beans.CaptchaImplementation; import edu.cornell.mannlib.vitro.webapp.beans.CaptchaServiceBean; +import edu.cornell.mannlib.vitro.webapp.config.ContextPath; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.TemplateProcessingHelper.TemplateProcessingException; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; @@ -102,7 +103,7 @@ protected ResponseValues processRequest(VitroRequest vreq) throws IOException { String errorMsg = validateInput(webusername, webuseremail, comments, captchaInput, captchaId, vreq); if (errorMsg != null) { - return errorParametersNotValid(errorMsg, webusername, webuseremail, comments, vreq.getContextPath()); + return errorParametersNotValid(errorMsg, webusername, webuseremail, comments, ContextPath.getPath(vreq)); } String spamReason = checkForSpam(comments, formType); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerSetup.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerSetup.java index 2314d6c674..27f13a3ce6 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerSetup.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerSetup.java @@ -6,6 +6,7 @@ import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; +import edu.cornell.mannlib.vitro.webapp.config.ContextPath; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -17,7 +18,7 @@ public class FreemarkerSetup implements ServletContextListener { public void contextInitialized(ServletContextEvent event) { ServletContext sc = event.getServletContext(); FreemarkerComponentGenerator.setServletContext(sc); - UrlBuilder.contextPath = sc.getContextPath(); + UrlBuilder.contextPath = ContextPath.getPath(sc); log.info("Freemarker templating system initialized."); } diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/grefine/JSONReconcileServlet.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/grefine/JSONReconcileServlet.java index 8469d377e9..d5e9e2b2a2 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/grefine/JSONReconcileServlet.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/grefine/JSONReconcileServlet.java @@ -28,6 +28,7 @@ import edu.cornell.mannlib.vitro.webapp.application.ApplicationUtils; import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; +import edu.cornell.mannlib.vitro.webapp.config.ContextPath; import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchEngine; @@ -202,8 +203,8 @@ protected ObjectNode getMetadata(HttpServletRequest req, HttpServletResponse res if (serverPort == 8080) { urlBuf.append(":").append(serverPort); } - if (req.getContextPath() != null) { - urlBuf.append(req.getContextPath()); + if (ContextPath.getPath(req) != null) { + urlBuf.append(ContextPath.getPath(req)); } viewJson.put("url", urlBuf.toString() + "/individual?uri={{id}}"); json.put("view", viewJson); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/edit/n3editing/VTwo/EditConfigurationUtils.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/edit/n3editing/VTwo/EditConfigurationUtils.java index 63164c0ddc..642b92a050 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/edit/n3editing/VTwo/EditConfigurationUtils.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/edit/n3editing/VTwo/EditConfigurationUtils.java @@ -22,6 +22,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty; import edu.cornell.mannlib.vitro.webapp.beans.VClass; +import edu.cornell.mannlib.vitro.webapp.config.ContextPath; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; @@ -172,7 +173,7 @@ public static String getFormUrl(VitroRequest vreq) { } public static String getEditUrl(VitroRequest vreq) { - return vreq.getContextPath() + getEditUrlWithoutContext(vreq); + return ContextPath.getPath(vreq) + getEditUrlWithoutContext(vreq); } public static String getEditUrlWithoutContext(VitroRequest vreq) { @@ -180,7 +181,7 @@ public static String getEditUrlWithoutContext(VitroRequest vreq) { } public static String getCancelUrlBase(VitroRequest vreq) { - return vreq.getContextPath() + "/postEditCleanupController"; + return ContextPath.getPath(vreq) + "/postEditCleanupController"; } diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/edit/n3editing/controller/EditRequestDispatchController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/edit/n3editing/controller/EditRequestDispatchController.java index 2bdd3fd789..7cfc2efb00 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/edit/n3editing/controller/EditRequestDispatchController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/edit/n3editing/controller/EditRequestDispatchController.java @@ -29,6 +29,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.FauxProperty; import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.beans.Property; +import edu.cornell.mannlib.vitro.webapp.config.ContextPath; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder; @@ -505,7 +506,7 @@ private ResponseValues doHelp(VitroRequest vreq, String message){ //Get submission url private String getSubmissionUrl(VitroRequest vreq) { - return vreq.getContextPath() + "/edit/process"; + return ContextPath.getPath(vreq) + "/edit/process"; } diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/freemarker/config/FreemarkerConfigurationImpl.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/freemarker/config/FreemarkerConfigurationImpl.java index 10e2d9926e..ceae3ce8ee 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/freemarker/config/FreemarkerConfigurationImpl.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/freemarker/config/FreemarkerConfigurationImpl.java @@ -22,6 +22,8 @@ import org.apache.commons.logging.LogFactory; import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; +import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; +import edu.cornell.mannlib.vitro.webapp.config.ContextPath; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Route; @@ -300,7 +302,7 @@ private Map getSiteUrls(ServletContext ctx, Map urls = new HashMap(); // Templates use this to construct urls. - urls.put("base", ctx.getContextPath()); + urls.put("base", ContextPath.getPath(ctx)); urls.put("home", UrlBuilder.getHomeUrl()); urls.put("about", UrlBuilder.getUrl(Route.ABOUT)); urls.put("search", UrlBuilder.getUrl(Route.SEARCH)); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/searchengine/solr/SolrSearchEngine.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/searchengine/solr/SolrSearchEngine.java index e7ec7fd569..3db3e2b749 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/searchengine/solr/SolrSearchEngine.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/searchengine/solr/SolrSearchEngine.java @@ -20,6 +20,7 @@ import org.apache.solr.client.solrj.response.QueryResponse; import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; +import edu.cornell.mannlib.vitro.webapp.config.ContextPath; import edu.cornell.mannlib.vitro.webapp.modules.Application; import edu.cornell.mannlib.vitro.webapp.modules.ComponentStartupStatus; import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchEngine; @@ -51,7 +52,7 @@ public void startup(Application application, ComponentStartupStatus css) { + "runtime.properties. Vitro application needs the URL of " + "a solr server that it can use to index its data. It " + "should be something like http://localhost:${port}" - + ctx.getContextPath() + "solr"); + + ContextPath.getPath(ctx) + "solr"); return; } diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/web/templatemodels/edit/EditConfigurationTemplateModel.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/web/templatemodels/edit/EditConfigurationTemplateModel.java index 577229162e..853ef79664 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/web/templatemodels/edit/EditConfigurationTemplateModel.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/web/templatemodels/edit/EditConfigurationTemplateModel.java @@ -26,6 +26,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty; import edu.cornell.mannlib.vitro.webapp.beans.Property; import edu.cornell.mannlib.vitro.webapp.beans.VClass; +import edu.cornell.mannlib.vitro.webapp.config.ContextPath; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.ParamMap; @@ -715,11 +716,11 @@ public String getCancelUrl() { //Get confirm deletion url public String getDeleteProcessingUrl() { - return vreq.getContextPath() + "/deletePropertyController"; + return ContextPath.getPath(vreq) + "/deletePropertyController"; } public String getDeleteIndividualProcessingUrl() { - return vreq.getContextPath() + "/deleteIndividualController"; + return ContextPath.getPath(vreq) + "/deleteIndividualController"; } //TODO: Check if this logic is correct and delete prohibited does not expect a specific value diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/web/widgets/LoginWidget.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/web/widgets/LoginWidget.java index 2c03190f8e..8fb6dcc56a 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/web/widgets/LoginWidget.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/web/widgets/LoginWidget.java @@ -15,6 +15,7 @@ import edu.cornell.mannlib.vedit.beans.LoginStatusBean; import edu.cornell.mannlib.vitro.webapp.beans.UserAccount; import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; +import edu.cornell.mannlib.vitro.webapp.config.ContextPath; import edu.cornell.mannlib.vitro.webapp.controller.authenticate.LoginInProcessFlag; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Route; @@ -191,7 +192,7 @@ private boolean isOutdatedLoginProcessBean(HttpServletRequest request) { * What's the URL for this servlet? */ private String getAuthenticateUrl(HttpServletRequest request) { - String contextPath = request.getContextPath(); + String contextPath = ContextPath.getPath(request); return contextPath + "/authenticate"; } @@ -199,7 +200,7 @@ private String getAuthenticateUrl(HttpServletRequest request) { * What's the URL for this servlet, with the cancel parameter added? */ private String getCancelUrl(HttpServletRequest request) { - String contextPath = request.getContextPath(); + String contextPath = ContextPath.getPath(request); String urlParams = "?cancel=true"; return contextPath + "/authenticate" + urlParams; } diff --git a/home/src/main/resources/config/example.runtime.properties b/home/src/main/resources/config/example.runtime.properties index cae4534fc5..0e45125fc0 100644 --- a/home/src/main/resources/config/example.runtime.properties +++ b/home/src/main/resources/config/example.runtime.properties @@ -22,6 +22,9 @@ # Vitro.defaultNamespace = http://vivo.mydomain.edu/individual/ +# In case Vitro is behind proxy you might want to avoid redirects by overriding +# context path to empty string or other custom value +#context.path = # # URL of Solr context used in local Vitro search. This will usually consist of: # scheme + server_name + port + "solr" + solr_core_name From b690134f19896526b9948ec41e471e751d348d68 Mon Sep 17 00:00:00 2001 From: Georgy Litvinov Date: Thu, 26 Sep 2024 12:59:33 +0200 Subject: [PATCH 2/3] replaced getContextPath with ContextPath.getPath --- .../webapp/controller/OntologyController.java | 7 +- .../user/UserAccountsUserController.java | 8 +- .../freemarker/FreemarkerHttpServlet.java | 3 +- .../individual/IndividualRequestAnalyzer.java | 4 +- .../filters/StartupStatusDisplayFilter.java | 3 +- .../URLRewritingHttpServletResponse.java | 14 +- .../vitro/webapp/web/widgets/LoginWidget.java | 2 +- .../servlet/LinkedDataFragmentServlet.java | 3 +- .../VitroLinkedDataFragmentServlet.java | 5 +- .../URLRewritingHttpServletResponseTest.java | 452 ++---------------- .../config/example.runtime.properties | 2 +- webapp/src/main/webapp/admin/log4j.jsp | 3 +- webapp/src/main/webapp/js/commentsForm.jsp | 7 - .../edit/specific/ents_edit_head.jsp | 3 +- .../webapp/templates/page/headContent.jsp | 3 +- 15 files changed, 65 insertions(+), 454 deletions(-) delete mode 100644 webapp/src/main/webapp/js/commentsForm.jsp diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/OntologyController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/OntologyController.java index e7fe124a4b..300b8eeae1 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/OntologyController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/OntologyController.java @@ -27,6 +27,7 @@ import org.apache.jena.shared.Lock; import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; +import edu.cornell.mannlib.vitro.webapp.config.ContextPath; import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess; import edu.cornell.mannlib.vitro.webapp.utils.jena.JenaOutputUtils; import edu.cornell.mannlib.vitro.webapp.web.ContentType; @@ -45,7 +46,7 @@ public void doGet(HttpServletRequest req, HttpServletResponse res) super.doGet(req, res); //get URL without hostname or servlet context - String url = req.getRequestURI().substring(req.getContextPath().length()); + String url = req.getRequestURI().substring(ContextPath.getPath(req).length()); String redirectURL = checkForRedirect ( url, req.getHeader("accept") ); @@ -218,11 +219,11 @@ private void doRedirect(HttpServletRequest req, HttpServletResponse res, String hn = req.getHeader("Host"); if (req.isSecure()) { res.setHeader("Location", res.encodeURL("https://" + hn - + req.getContextPath() + redirectURL)); + + ContextPath.getPath(req) + redirectURL)); log.info("doRedirect by using HTTPS"); } else { res.setHeader("Location", res.encodeURL("http://" + hn - + req.getContextPath() + redirectURL)); + + ContextPath.getPath(req) + redirectURL)); log.info("doRedirect by using HTTP"); } res.setStatus(res.SC_SEE_OTHER); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsUserController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsUserController.java index 9abe5f2698..d8a9018916 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsUserController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsUserController.java @@ -14,6 +14,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission; import edu.cornell.mannlib.vitro.webapp.beans.DisplayMessage; import edu.cornell.mannlib.vitro.webapp.beans.UserAccount; +import edu.cornell.mannlib.vitro.webapp.config.ContextPath; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.authenticate.Authenticator; import edu.cornell.mannlib.vitro.webapp.controller.authenticate.Authenticator.LoginNotPermitted; @@ -151,14 +152,15 @@ private ResponseValues showLoginRedirection(VitroRequest vreq, * Bridge the gap. */ private String stripContextPath(VitroRequest vreq, String uri) { - if ((uri == null) || uri.isEmpty() || uri.equals(vreq.getContextPath())) { + String contextPath = ContextPath.getPath(vreq); + if ((uri == null) || uri.isEmpty() || uri.equals(contextPath)) { return "/"; } if (uri.contains("://")) { return uri; } - if (uri.startsWith(vreq.getContextPath() + '/')) { - return uri.substring(vreq.getContextPath().length()); + if (uri.startsWith(contextPath + '/')) { + return uri.substring(contextPath.length()); } return uri; } diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerHttpServlet.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerHttpServlet.java index 13b3c56758..280b2a31b3 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerHttpServlet.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerHttpServlet.java @@ -26,6 +26,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest; import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; import edu.cornell.mannlib.vitro.webapp.beans.DisplayMessage; +import edu.cornell.mannlib.vitro.webapp.config.ContextPath; import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.TemplateProcessingHelper.TemplateProcessingException; @@ -485,7 +486,7 @@ private String normalizeServletName(String name) { } protected MainMenu getDisplayModelMenu(VitroRequest vreq){ - String url = vreq.getRequestURI().substring(vreq.getContextPath().length()); + String url = vreq.getRequestURI().substring(ContextPath.getPath(vreq).length()); return vreq.getWebappDaoFactory().getMenuDao().getMainMenu(url); } diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualRequestAnalyzer.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualRequestAnalyzer.java index 2ac6831f6e..65a9053dbf 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualRequestAnalyzer.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualRequestAnalyzer.java @@ -16,6 +16,7 @@ import org.apache.commons.logging.LogFactory; import edu.cornell.mannlib.vitro.webapp.beans.Individual; +import edu.cornell.mannlib.vitro.webapp.config.ContextPath; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.web.ContentType; @@ -42,8 +43,7 @@ public IndividualRequestAnalyzer(VitroRequest vreq, this.vreq = vreq; // get URL without hostname or servlet context - this.url = vreq.getRequestURI().substring( - vreq.getContextPath().length()); + this.url = vreq.getRequestURI().substring(ContextPath.getPath(vreq).length()); this.analysisContext = analysisContext; } diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/StartupStatusDisplayFilter.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/StartupStatusDisplayFilter.java index ae900957f7..e1130f8e0e 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/StartupStatusDisplayFilter.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/StartupStatusDisplayFilter.java @@ -22,6 +22,7 @@ import org.apache.commons.lang3.StringUtils; import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; +import edu.cornell.mannlib.vitro.webapp.config.ContextPath; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess; import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus; @@ -107,7 +108,7 @@ private void displayStartupStatus(ServletRequest req, ServletResponse resp) } private String getContextPath() { - String cp = ctx.getContextPath(); + String cp = ContextPath.getPath(ctx); if ((cp == null) || cp.isEmpty()) { return "The application"; } else { diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/URLRewritingHttpServletResponse.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/URLRewritingHttpServletResponse.java index 15141337cc..60e2c0012c 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/URLRewritingHttpServletResponse.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/URLRewritingHttpServletResponse.java @@ -5,21 +5,19 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import java.util.regex.Pattern; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponseWrapper; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess; import edu.cornell.mannlib.vitro.webapp.utils.NamespaceMapper; import edu.cornell.mannlib.vitro.webapp.utils.NamespaceMapperFactory; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; public class URLRewritingHttpServletResponse extends HttpServletResponseWrapper/*implements HttpServletResponse */{ @@ -28,15 +26,12 @@ public class URLRewritingHttpServletResponse extends HttpServletResponseWrapper/ private HttpServletResponse _response; private ServletContext _context; private WebappDaoFactory wadf; - private int contextPathDepth; - private Pattern slashPattern = Pattern.compile("/"); public URLRewritingHttpServletResponse(HttpServletResponse response, HttpServletRequest request, ServletContext context) { super(response); this._response = response; this._context = context; - this.wadf = ModelAccess.on(context).getWebappDaoFactory(); - this.contextPathDepth = slashPattern.split(request.getContextPath()).length-1; + this.wadf = ModelAccess.getInstance().getWebappDaoFactory(); } /** for testing. */ @@ -69,7 +64,6 @@ public String encodeURL(String inUrl) { if( log.isDebugEnabled() ){ log.debug("START"); log.debug("charEncoding: " + this.getCharacterEncoding() ); - log.debug("contextPathDepth," + contextPathDepth); log.debug("nsMap," + nsMap); log.debug("wadf.getDefaultNamespace(), " + wadf.getDefaultNamespace()); log.debug("externallyLinkedNamespaces " + externallyLinkedNamespaces); @@ -80,7 +74,6 @@ public String encodeURL(String inUrl) { inUrl, this.getCharacterEncoding(), /*wadf.getPortalDao().isSinglePortal()*/ true, - contextPathDepth, nsMap, wadf.getDefaultNamespace(), externallyLinkedNamespaces @@ -100,7 +93,6 @@ protected String encodeForVitro( String inUrl, String characterEncoding, Boolean isSInglePortal, - int contextPathDepth, NamespaceMapper nsMap, String defaultNamespace, List externalNamespaces) { diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/web/widgets/LoginWidget.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/web/widgets/LoginWidget.java index 8fb6dcc56a..98ffc1cf63 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/web/widgets/LoginWidget.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/web/widgets/LoginWidget.java @@ -209,7 +209,7 @@ private String getCancelUrl(HttpServletRequest request) { * What's the password recovery URL for this servlet? */ private String getForgotPasswordUrl(HttpServletRequest request) { - String contextPath = request.getContextPath(); + String contextPath = ContextPath.getPath(request); return contextPath + "/forgotPassword"; } diff --git a/api/src/main/java/org/linkeddatafragments/servlet/LinkedDataFragmentServlet.java b/api/src/main/java/org/linkeddatafragments/servlet/LinkedDataFragmentServlet.java index ef7785009d..9815d0d655 100644 --- a/api/src/main/java/org/linkeddatafragments/servlet/LinkedDataFragmentServlet.java +++ b/api/src/main/java/org/linkeddatafragments/servlet/LinkedDataFragmentServlet.java @@ -1,6 +1,7 @@ package org.linkeddatafragments.servlet; import com.fasterxml.jackson.databind.JsonNode; +import edu.cornell.mannlib.vitro.webapp.config.ContextPath; import org.apache.jena.riot.Lang; import org.linkeddatafragments.config.ConfigReader; import org.linkeddatafragments.datasource.DataSourceFactory; @@ -128,7 +129,7 @@ public void destroy() * @throws IOException */ private IDataSource getDataSource(HttpServletRequest request) throws DataSourceNotFoundException { - String contextPath = request.getContextPath(); + String contextPath = ContextPath.getPath(request); String requestURI = request.getRequestURI(); String path = contextPath == null diff --git a/api/src/main/java/org/vivoweb/linkeddatafragments/servlet/VitroLinkedDataFragmentServlet.java b/api/src/main/java/org/vivoweb/linkeddatafragments/servlet/VitroLinkedDataFragmentServlet.java index e4427d82e9..74d40d2758 100644 --- a/api/src/main/java/org/vivoweb/linkeddatafragments/servlet/VitroLinkedDataFragmentServlet.java +++ b/api/src/main/java/org/vivoweb/linkeddatafragments/servlet/VitroLinkedDataFragmentServlet.java @@ -40,6 +40,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.Ontology; import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; +import edu.cornell.mannlib.vitro.webapp.config.ContextPath; import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet; import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao; import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess; @@ -103,7 +104,7 @@ public void init(ServletConfig servletConfig) throws ServletException { MIMEParse.register(Lang.NTRIPLES.getHeaderString()); MIMEParse.register(Lang.RDFXML.getHeaderString()); - HtmlTriplePatternFragmentWriterImpl.setContextPath(servletConfig.getServletContext().getContextPath()); + HtmlTriplePatternFragmentWriterImpl.setContextPath(ContextPath.getPath(ctx)); } catch (Exception e) { throw new ServletException(e); } @@ -133,7 +134,7 @@ private boolean configurationPresent() { } private IDataSource getDataSource(HttpServletRequest request) throws DataSourceNotFoundException { - String contextPath = request.getContextPath(); + String contextPath = ContextPath.getPath(request); String requestURI = request.getRequestURI(); String path = contextPath == null diff --git a/api/src/test/java/edu/cornell/mannlib/vitro/webapp/filters/URLRewritingHttpServletResponseTest.java b/api/src/test/java/edu/cornell/mannlib/vitro/webapp/filters/URLRewritingHttpServletResponseTest.java index 88ed7472ae..e4bceea623 100644 --- a/api/src/test/java/edu/cornell/mannlib/vitro/webapp/filters/URLRewritingHttpServletResponseTest.java +++ b/api/src/test/java/edu/cornell/mannlib/vitro/webapp/filters/URLRewritingHttpServletResponseTest.java @@ -25,36 +25,17 @@ public class URLRewritingHttpServletResponseTest { protected void urlEncodingStyleA(String urlToEncode, String expectedUrlResult ){ URLRewritingHttpServletResponse urhsr = new URLRewritingHttpServletResponse(new stubs.javax.servlet.http.HttpServletResponseStub()); - ListexternalNamespaces = new ArrayList(); + ListexternalNamespaces = new ArrayList<>(); externalNamespaces.add("http://vivo.med.cornell.edu/individual/"); String actual = urhsr.encodeForVitro(urlToEncode, "UTF-8", - true, 1, + true, getMockNamespaceMapper(), "http://vivo.cornell.edu/individual/", externalNamespaces); Assert.assertEquals(expectedUrlResult, actual); } - /* - * Style A is for sites that are running behind apache httpd at a - * URL like http://caruso.mannlib.cornell.edu/ with no portals. - */ - protected void urlEncodingStyleB(String urlToEncode, String expectedUrlResult){ - URLRewritingHttpServletResponse urhsr = new URLRewritingHttpServletResponse(new stubs.javax.servlet.http.HttpServletResponseStub()); - - ListexternalNamespaces = new ArrayList(); - externalNamespaces.add("http://vivo.med.cornell.edu/individual/"); - - String actual = urhsr.encodeForVitro(urlToEncode, "UTF-8", - true, 0, - getMockNamespaceMapper(), - "http://vivo.cornell.edu/individual/", - externalNamespaces); - Assert.assertEquals(expectedUrlResult, actual); - } - - @Test public void test40984(){ urlEncodingStyleA( "/vivo/js/jquery-1.12.4.min.js", "/vivo/js/jquery-1.12.4.min.js"); } @@ -287,9 +268,6 @@ public void test39153(){ urlEncodingStyleA( public void test39472(){ urlEncodingStyleA( "/vivo/js/extensions/String.js", "/vivo/js/extensions/String.js"); } @Test - public void test394730(){ urlEncodingStyleA( "/vivo/js/jquery-1.12.4.min.js", - "/vivo/js/jquery-1.12.4.min.js"); } - @Test public void test39473(){ urlEncodingStyleA( "/vivo/js/jquery_plugins/jquery.bgiframe.pack.js", "/vivo/js/jquery_plugins/jquery.bgiframe.pack.js"); } @@ -302,67 +280,14 @@ public void test39475(){ urlEncodingStyleA( "/vivo/js/jquery_plugins/ui.datepicker.js", "/vivo/js/jquery_plugins/ui.datepicker.js"); } @Test - public void test14958(){ urlEncodingStyleA( "/vivo/js/jquery-1.12.4.min.js", - "/vivo/js/jquery-1.12.4.min.js"); } - @Test - public void test14968(){ urlEncodingStyleA( - "/vivo/js/jquery_plugins/getURLParam.js", - "/vivo/js/jquery_plugins/getURLParam.js"); } - @Test - public void test14972(){ urlEncodingStyleA( - "/vivo/js/jquery_plugins/colorAnimations.js", - "/vivo/js/jquery_plugins/colorAnimations.js"); } - @Test - public void test14979(){ urlEncodingStyleA( - "/vivo/js/propertyGroupSwitcher.js", - "/vivo/js/propertyGroupSwitcher.js"); } - @Test - public void test14980(){ urlEncodingStyleA( "/vivo/js/controls.js", - "/vivo/js/controls.js"); } - @Test - public void test14982(){ urlEncodingStyleA( - "/vivo/js/jquery_plugins/jquery.form.js", - "/vivo/js/jquery_plugins/jquery.form.js"); } - @Test - public void test14986(){ urlEncodingStyleA( - "/vivo/js/tiny_mce/tiny_mce.js", "/vivo/js/tiny_mce/tiny_mce.js"); } - @Test - public void test14999(){ urlEncodingStyleA( - "/vivo/entityEdit?uri=http%3a%2f%2fbogus.com%2findividual%2fn3671", - "/vivo/entityEdit?uri=http%3A%2F%2Fbogus.com%2Findividual%2Fn3671"); } - @Test - public void test15011(){ urlEncodingStyleA( - "/vivo/themes/vivo-basic/site_icons/visualization/ajax-loader.gif", - "/vivo/themes/vivo-basic/site_icons/visualization/ajax-loader.gif"); } - @Test - public void test15014(){ urlEncodingStyleA( - "/vivo/visualization?render_mode=dynamic&container=vis_container&vis=person_pub_count&vis_mode=short&uri=http%3a%2f%2fbogus.com%2findividual%2fn3671", - "/vivo/visualization?render_mode=dynamic&container=vis_container&vis=person_pub_count&vis_mode=short&uri=http%3A%2F%2Fbogus.com%2Findividual%2Fn3671"); - } - @Test - public void test15143(){ urlEncodingStyleA( - "/vivo/js/imageUpload/imageUploadUtils.js", - "/vivo/js/imageUpload/imageUploadUtils.js"); } - @Test public void test184670(){ urlEncodingStyleA( "/vivo/js/jquery-ui/css/smoothness/jquery-ui-1.12.1.css", "/vivo/js/jquery-ui/css/smoothness/jquery-ui-1.12.1.css"); } @Test - public void test18467(){ urlEncodingStyleA( - "/vivo/edit/forms/css/customForm.css", - "/vivo/edit/forms/css/customForm.css"); } - @Test public void test184680(){ urlEncodingStyleA( "/vivo/edit/forms/css/customFormWithAutocomplete.css", "/vivo/edit/forms/css/customFormWithAutocomplete.css"); } @Test - public void test18468(){ urlEncodingStyleA( - "/vivo/js/jquery_plugins/thickbox/thickbox.css", - "/vivo/js/jquery_plugins/thickbox/thickbox.css"); } - @Test - public void test18472(){ urlEncodingStyleA( - "/vivo/edit/processRdfForm2.jsp", "/vivo/edit/processRdfForm2.jsp"); } - @Test public void test18506(){ urlEncodingStyleA( "/vivo/individual?uri=", "/vivo/individual?uri="); } @Test @@ -370,24 +295,6 @@ public void test18512(){ urlEncodingStyleA( "/vivo/autocomplete?tokenize=true&stem=true", "/vivo/autocomplete?tokenize=true&stem=true"); } @Test - public void test18516(){ urlEncodingStyleA( - "/vivo/js/extensions/String.js", "/vivo/js/extensions/String.js"); } - @Test - public void test18543(){ urlEncodingStyleA( "/vivo/js/jquery-1.12.4.min.js", - "/vivo/js/jquery-1.12.4.min.js"); } - @Test - public void test185440(){ urlEncodingStyleA( - "/vivo/js/jquery_plugins/jquery.bgiframe.pack.js", - "/vivo/js/jquery_plugins/jquery.bgiframe.pack.js"); } - @Test - public void test18544(){ urlEncodingStyleA( - "/vivo/js/jquery_plugins/thickbox/thickbox-compressed.js", - "/vivo/js/jquery_plugins/thickbox/thickbox-compressed.js"); } - @Test - public void test18545(){ urlEncodingStyleA( - "/vivo/js/jquery_plugins/ui.datepicker.js", - "/vivo/js/jquery_plugins/ui.datepicker.js"); } - @Test public void test18546(){ urlEncodingStyleA( "/vivo/js/jquery-ui/js/jquery-ui-1.12.1.min.js", "/vivo/js/jquery-ui/js/jquery-ui-1.12.1.min.js"); } @@ -399,386 +306,95 @@ public void test18547(){ urlEncodingStyleA( "/vivo/edit/forms/js/customFormWithAutocomplete.js", "/vivo/edit/forms/js/customFormWithAutocomplete.js"); } @Test - public void test27127(){ urlEncodingStyleA( - "/vivo/js/jquery_plugins/thickbox/thickbox.css", - "/vivo/js/jquery_plugins/thickbox/thickbox.css"); } - @Test public void test27130(){ urlEncodingStyleA( "/vivo/edit/processDatapropRdfForm.jsp", "/vivo/edit/processDatapropRdfForm.jsp"); } @Test - public void test271590(){ urlEncodingStyleA( - "/vivo/js/extensions/String.js", "/vivo/js/extensions/String.js"); } - @Test - public void test27159(){ urlEncodingStyleA( "/vivo/js/jquery-1.12.4.min.js", - "/vivo/js/jquery-1.12.4.min.js"); } - @Test - public void test27160(){ urlEncodingStyleA( - "/vivo/js/jquery_plugins/jquery.bgiframe.pack.js", - "/vivo/js/jquery_plugins/jquery.bgiframe.pack.js"); } - @Test - public void test27161(){ urlEncodingStyleA( - "/vivo/js/jquery_plugins/thickbox/thickbox-compressed.js", - "/vivo/js/jquery_plugins/thickbox/thickbox-compressed.js"); } - @Test - public void test27166(){ urlEncodingStyleA( - "/vivo/js/jquery_plugins/ui.datepicker.js", - "/vivo/js/jquery_plugins/ui.datepicker.js"); } - @Test - public void test14842(){ urlEncodingStyleA( - "/vivo/js/jquery_plugins/thickbox/thickbox.css", - "/vivo/js/jquery_plugins/thickbox/thickbox.css"); } - @Test - public void test14846(){ urlEncodingStyleA( - "/vivo/edit/processDatapropRdfForm.jsp", - "/vivo/edit/processDatapropRdfForm.jsp"); } - @Test - public void test148510(){ urlEncodingStyleA( - "/vivo/js/extensions/String.js", "/vivo/js/extensions/String.js"); } - @Test - public void test14851(){ urlEncodingStyleA( "/vivo/js/jquery-1.12.4.min.js", - "/vivo/js/jquery-1.12.4.min.js"); } - @Test - public void test14852(){ urlEncodingStyleA( - "/vivo/js/jquery_plugins/jquery.bgiframe.pack.js", - "/vivo/js/jquery_plugins/jquery.bgiframe.pack.js"); } - @Test - public void test148530(){ urlEncodingStyleA( - "/vivo/js/jquery_plugins/thickbox/thickbox-compressed.js", - "/vivo/js/jquery_plugins/thickbox/thickbox-compressed.js"); } - @Test - public void test14853(){ urlEncodingStyleA( - "/vivo/js/jquery_plugins/ui.datepicker.js", - "/vivo/js/jquery_plugins/ui.datepicker.js"); } - @Test - public void test43748(){ urlEncodingStyleA( - "/vivo/js/jquery-ui/css/smoothness/jquery-ui-1.12.1.css", - "/vivo/js/jquery-ui/css/smoothness/jquery-ui-1.12.1.css"); } - @Test - public void test43749(){ urlEncodingStyleA( - "/vivo/edit/forms/css/customForm.css", - "/vivo/edit/forms/css/customForm.css"); } - @Test - public void test437500(){ urlEncodingStyleA( - "/vivo/edit/forms/css/customFormWithAutocomplete.css", - "/vivo/edit/forms/css/customFormWithAutocomplete.css"); } - @Test - public void test43750(){ urlEncodingStyleA( - "/vivo/js/jquery_plugins/thickbox/thickbox.css", - "/vivo/js/jquery_plugins/thickbox/thickbox.css"); } - @Test - public void test437540(){ urlEncodingStyleA( - "/vivo/edit/processRdfForm2.jsp", "/vivo/edit/processRdfForm2.jsp"); } - @Test - public void test43754(){ urlEncodingStyleA( "/vivo/individual?uri=", - "/vivo/individual?uri="); } - @Test - public void test43757(){ urlEncodingStyleA( - "/vivo/autocomplete?tokenize=true&stem=true", - "/vivo/autocomplete?tokenize=true&stem=true"); } - @Test - public void test43760(){ urlEncodingStyleA( - "/vivo/js/extensions/String.js", "/vivo/js/extensions/String.js"); } - @Test - public void test437610(){ urlEncodingStyleA( "/vivo/js/jquery-1.12.4.min.js", - "/vivo/js/jquery-1.12.4.min.js"); } - @Test - public void test43761(){ urlEncodingStyleA( - "/vivo/js/jquery_plugins/jquery.bgiframe.pack.js", - "/vivo/js/jquery_plugins/jquery.bgiframe.pack.js"); } - @Test - public void test43762(){ urlEncodingStyleA( - "/vivo/js/jquery_plugins/thickbox/thickbox-compressed.js", - "/vivo/js/jquery_plugins/thickbox/thickbox-compressed.js"); } - @Test - public void test437630(){ urlEncodingStyleA( - "/vivo/js/jquery_plugins/ui.datepicker.js", - "/vivo/js/jquery_plugins/ui.datepicker.js"); } - @Test - public void test43763(){ urlEncodingStyleA( - "/vivo/js/jquery-ui/js/jquery-ui-1.12.1.min.js", - "/vivo/js/jquery-ui/js/jquery-ui-1.12.1.min.js"); } - @Test - public void test437640(){ urlEncodingStyleA( - "/vivo/js/customFormUtils.js", "/vivo/js/customFormUtils.js"); } - @Test - public void test43764(){ urlEncodingStyleA( - "/vivo/edit/forms/js/customFormWithAutocomplete.js", - "/vivo/edit/forms/js/customFormWithAutocomplete.js"); } - @Test - public void test14550(){ urlEncodingStyleA( - "/vivo/js/jquery-ui/css/smoothness/jquery-ui-1.12.1.css", - "/vivo/js/jquery-ui/css/smoothness/jquery-ui-1.12.1.css"); } - @Test - public void test14551(){ urlEncodingStyleA( - "/vivo/edit/forms/css/customForm.css", - "/vivo/edit/forms/css/customForm.css"); } - @Test - public void test1455200(){ urlEncodingStyleA( - "/vivo/edit/forms/css/customFormWithAutocomplete.css", - "/vivo/edit/forms/css/customFormWithAutocomplete.css"); } - @Test - public void test14552(){ urlEncodingStyleA( - "/vivo/js/jquery_plugins/thickbox/thickbox.css", - "/vivo/js/jquery_plugins/thickbox/thickbox.css"); } - @Test - public void test14556(){ urlEncodingStyleA( - "/vivo/edit/processRdfForm2.jsp", "/vivo/edit/processRdfForm2.jsp"); } - @Test - public void test14557(){ urlEncodingStyleA( "/vivo/individual?uri=", - "/vivo/individual?uri="); } - @Test - public void test145610(){ urlEncodingStyleA( - "/vivo/autocomplete?tokenize=true&stem=true", - "/vivo/autocomplete?tokenize=true&stem=true"); } - @Test public void test14561(){ urlEncodingStyleA( "/vivo/admin/sparqlquery", "/vivo/admin/sparqlquery"); } @Test - public void test14565(){ urlEncodingStyleA( - "/vivo/js/extensions/String.js", "/vivo/js/extensions/String.js"); } - @Test - public void test145650(){ urlEncodingStyleA( "/vivo/js/jquery-1.12.4.min.js", - "/vivo/js/jquery-1.12.4.min.js"); } - @Test - public void test145660(){ urlEncodingStyleA( - "/vivo/js/jquery_plugins/jquery.bgiframe.pack.js", - "/vivo/js/jquery_plugins/jquery.bgiframe.pack.js"); } - @Test - public void test14566(){ urlEncodingStyleA( - "/vivo/js/jquery_plugins/thickbox/thickbox-compressed.js", - "/vivo/js/jquery_plugins/thickbox/thickbox-compressed.js"); } - @Test - public void test14567(){ urlEncodingStyleA( - "/vivo/js/jquery_plugins/ui.datepicker.js", - "/vivo/js/jquery_plugins/ui.datepicker.js"); } - @Test - public void test145680(){ urlEncodingStyleA( - "/vivo/js/jquery-ui/js/jquery-ui-1.12.1.min.js", - "/vivo/js/jquery-ui/js/jquery-ui-1.12.1.min.js"); } - @Test - public void test14568(){ urlEncodingStyleA( - "/vivo/js/customFormUtils.js", "/vivo/js/customFormUtils.js"); } - @Test public void test145690(){ urlEncodingStyleA( "/vivo/js/browserUtils.js", "/vivo/js/browserUtils.js"); } - @Test - public void test14569(){ urlEncodingStyleA( - "/vivo/edit/forms/js/customFormWithAutocomplete.js", - "/vivo/edit/forms/js/customFormWithAutocomplete.js"); } - @Test - public void test29078(){ urlEncodingStyleA( - "/vivo/js/jquery_plugins/thickbox/thickbox.css", - "/vivo/js/jquery_plugins/thickbox/thickbox.css"); } - @Test - public void test29081(){ urlEncodingStyleA( - "/vivo/edit/processDatapropRdfForm.jsp", - "/vivo/edit/processDatapropRdfForm.jsp"); } - @Test - public void test29084(){ urlEncodingStyleA( - "/vivo/js/extensions/String.js", "/vivo/js/extensions/String.js"); } - @Test - public void test29085(){ urlEncodingStyleA( "/vivo/js/jquery-1.12.4.min.js", - "/vivo/js/jquery-1.12.4.min.js"); } - @Test - public void test290860(){ urlEncodingStyleA( - "/vivo/js/jquery_plugins/jquery.bgiframe.pack.js", - "/vivo/js/jquery_plugins/jquery.bgiframe.pack.js"); } - @Test - public void test29086(){ urlEncodingStyleA( - "/vivo/js/jquery_plugins/thickbox/thickbox-compressed.js", - "/vivo/js/jquery_plugins/thickbox/thickbox-compressed.js"); } - @Test - public void test29087(){ urlEncodingStyleA( - "/vivo/js/jquery_plugins/ui.datepicker.js", - "/vivo/js/jquery_plugins/ui.datepicker.js"); } - - - @Test - public void test35560(){ urlEncodingStyleB( "/js/jquery-1.12.4.min.js", - "/js/jquery-1.12.4.min.js"); } + public void test35560(){ urlEncodingStyleA("/js/jquery-1.12.4.min.js", "/js/jquery-1.12.4.min.js"); } @Test - public void test35562(){ urlEncodingStyleB( - "/js/jquery_plugins/getURLParam.js", - "/js/jquery_plugins/getURLParam.js"); } + public void test35562(){ urlEncodingStyleA("/js/jquery_plugins/getURLParam.js", "/js/jquery_plugins/getURLParam.js"); } @Test - public void test35564(){ urlEncodingStyleB( - "/js/jquery_plugins/colorAnimations.js", - "/js/jquery_plugins/colorAnimations.js"); } + public void test35564(){ urlEncodingStyleA("/js/jquery_plugins/colorAnimations.js", "/js/jquery_plugins/colorAnimations.js"); } @Test - public void test35568(){ urlEncodingStyleB( - "/js/propertyGroupSwitcher.js", "/js/propertyGroupSwitcher.js"); } + public void test35568(){ urlEncodingStyleA("/js/propertyGroupSwitcher.js", "/js/propertyGroupSwitcher.js"); } @Test - public void test35617(){ urlEncodingStyleB( "/js/controls.js", - "/js/controls.js"); } + public void test35617(){ urlEncodingStyleA("/js/controls.js", "/js/controls.js"); } @Test - public void test35618(){ urlEncodingStyleB( - "/js/jquery_plugins/jquery.form.js", - "/js/jquery_plugins/jquery.form.js"); } + public void test35618(){ urlEncodingStyleA("/js/jquery_plugins/jquery.form.js", "/js/jquery_plugins/jquery.form.js"); } @Test - public void test356180(){ urlEncodingStyleB( - "/js/tiny_mce/tiny_mce.js", "/js/tiny_mce/tiny_mce.js"); } + public void test356180(){ urlEncodingStyleA("/js/tiny_mce/tiny_mce.js", "/js/tiny_mce/tiny_mce.js"); } @Test - public void test37150(){ urlEncodingStyleB( - "/entityEdit?uri=http%3a%2f%2fbogus.com%2findividual%2fn3671", - "/entityEdit?uri=http%3A%2F%2Fbogus.com%2Findividual%2Fn3671"); } + public void test37150(){ urlEncodingStyleA("/entityEdit?uri=http%3a%2f%2fbogus.com%2findividual%2fn3671", "/entityEdit?uri=http%3A%2F%2Fbogus.com%2Findividual%2Fn3671"); } @Test - public void test37402(){ urlEncodingStyleB( - "/themes/vivo-basic/site_icons/visualization/ajax-loader.gif", - "/themes/vivo-basic/site_icons/visualization/ajax-loader.gif"); } + public void test37402(){ urlEncodingStyleA("/themes/vivo-basic/site_icons/visualization/ajax-loader.gif", "/themes/vivo-basic/site_icons/visualization/ajax-loader.gif"); } @Test - public void test37403(){ urlEncodingStyleB( - "/visualization?render_mode=dynamic&container=vis_container&vis=person_pub_count&vis_mode=short&uri=http%3a%2f%2fbogus.com%2findividual%2fn3671", - "/visualization?render_mode=dynamic&container=vis_container&vis=person_pub_count&vis_mode=short&uri=http%3A%2F%2Fbogus.com%2Findividual%2Fn3671"); + public void test37403(){ urlEncodingStyleA("/visualization?render_mode=dynamic&container=vis_container&vis=person_pub_count&vis_mode=short&uri=http%3a%2f%2fbogus.com%2findividual%2fn3671", "/visualization?render_mode=dynamic&container=vis_container&vis=person_pub_count&vis_mode=short&uri=http%3A%2F%2Fbogus.com%2Findividual%2Fn3671"); } @Test - public void test38667(){ urlEncodingStyleB( - "/js/imageUpload/imageUploadUtils.js", - "/js/imageUpload/imageUploadUtils.js"); } - @Test - public void test47087(){ urlEncodingStyleB( - "entityEdit?uri=http%3a%2f%2fxmlns.com%2ffoaf%2f0.1%2fAgent", - "entityEdit?uri=http%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2FAgent"); - } + public void test38667(){ urlEncodingStyleA("/js/imageUpload/imageUploadUtils.js", "/js/imageUpload/imageUploadUtils.js"); } @Test - public void test47088(){ urlEncodingStyleB( - "/vclassEdit?uri=http%3a%2f%2fxmlns.com%2ffoaf%2f0.1%2fAgent", - "/vclassEdit?uri=http%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2FAgent"); } + public void test47088(){ urlEncodingStyleA("/vclassEdit?uri=http%3a%2f%2fxmlns.com%2ffoaf%2f0.1%2fAgent", "/vclassEdit?uri=http%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2FAgent"); } @Test - public void test470910(){ urlEncodingStyleB( - "entityEdit?uri=http%3a%2f%2fxmlns.com%2ffoaf%2f0.1%2fPerson", - "entityEdit?uri=http%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2FPerson"); + public void test470910(){ urlEncodingStyleA("entityEdit?uri=http%3a%2f%2fxmlns.com%2ffoaf%2f0.1%2fPerson", "entityEdit?uri=http%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2FPerson"); } @Test - public void test47091(){ urlEncodingStyleB( - "/vclassEdit?uri=http%3a%2f%2fxmlns.com%2ffoaf%2f0.1%2fPerson", - "/vclassEdit?uri=http%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2FPerson"); } + public void test47091(){ urlEncodingStyleA("/vclassEdit?uri=http%3a%2f%2fxmlns.com%2ffoaf%2f0.1%2fPerson", "/vclassEdit?uri=http%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2FPerson"); } @Test - public void test470930(){ urlEncodingStyleB( - "entityEdit?uri=http%3a%2f%2fwww.w3.org%2f2002%2f07%2fowl%23Thing", - "entityEdit?uri=http%3A%2F%2Fwww.w3.org%2F2002%2F07%2Fowl%23Thing"); + public void test47093(){ urlEncodingStyleA("/vclassEdit?uri=http%3a%2f%2fwww.w3.org%2f2002%2f07%2fowl%23Thing", "/vclassEdit?uri=http%3A%2F%2Fwww.w3.org%2F2002%2F07%2Fowl%23Thing"); } @Test - public void test47093(){ urlEncodingStyleB( - "/vclassEdit?uri=http%3a%2f%2fwww.w3.org%2f2002%2f07%2fowl%23Thing", - "/vclassEdit?uri=http%3A%2F%2Fwww.w3.org%2F2002%2F07%2Fowl%23Thing"); + public void test04993(){ urlEncodingStyleA("vclassEdit?uri=http%3a%2f%2fvitro.mannlib.cornell.edu%2fns%2fbnode%23-20981c46%3a12c18866689%3a-7d2e", "vclassEdit?uri=http%3A%2F%2Fvitro.mannlib.cornell.edu%2Fns%2Fbnode%23-20981c46%3A12c18866689%3A-7d2e"); } @Test - public void test04993(){ urlEncodingStyleB( - "vclassEdit?uri=http%3a%2f%2fvitro.mannlib.cornell.edu%2fns%2fbnode%23-20981c46%3a12c18866689%3a-7d2e", - "vclassEdit?uri=http%3A%2F%2Fvitro.mannlib.cornell.edu%2Fns%2Fbnode%23-20981c46%3A12c18866689%3A-7d2e"); + public void test04994(){ urlEncodingStyleA("vclassEdit?uri=http%3a%2f%2fvitro.mannlib.cornell.edu%2fns%2fbnode%23-20981c46%3a12c18866689%3a-7dad", "vclassEdit?uri=http%3A%2F%2Fvitro.mannlib.cornell.edu%2Fns%2Fbnode%23-20981c46%3A12c18866689%3A-7dad"); } @Test - public void test04994(){ urlEncodingStyleB( - "vclassEdit?uri=http%3a%2f%2fvitro.mannlib.cornell.edu%2fns%2fbnode%23-20981c46%3a12c18866689%3a-7dad", - "vclassEdit?uri=http%3A%2F%2Fvitro.mannlib.cornell.edu%2Fns%2Fbnode%23-20981c46%3A12c18866689%3A-7dad"); + public void test04995(){ urlEncodingStyleA("vclassEdit?uri=http%3a%2f%2fvitro.mannlib.cornell.edu%2fns%2fbnode%23-20981c46%3a12c18866689%3a-7d31", "vclassEdit?uri=http%3A%2F%2Fvitro.mannlib.cornell.edu%2Fns%2Fbnode%23-20981c46%3A12c18866689%3A-7d31"); } @Test - public void test04995(){ urlEncodingStyleB( - "vclassEdit?uri=http%3a%2f%2fvitro.mannlib.cornell.edu%2fns%2fbnode%23-20981c46%3a12c18866689%3a-7d31", - "vclassEdit?uri=http%3A%2F%2Fvitro.mannlib.cornell.edu%2Fns%2Fbnode%23-20981c46%3A12c18866689%3A-7d31"); + public void test04996(){ urlEncodingStyleA("vclassEdit?uri=http%3a%2f%2fvitro.mannlib.cornell.edu%2fns%2fbnode%23-20981c46%3a12c18866689%3a-7db7", "vclassEdit?uri=http%3A%2F%2Fvitro.mannlib.cornell.edu%2Fns%2Fbnode%23-20981c46%3A12c18866689%3A-7db7"); } @Test - public void test04996(){ urlEncodingStyleB( - "vclassEdit?uri=http%3a%2f%2fvitro.mannlib.cornell.edu%2fns%2fbnode%23-20981c46%3a12c18866689%3a-7db7", - "vclassEdit?uri=http%3A%2F%2Fvitro.mannlib.cornell.edu%2Fns%2Fbnode%23-20981c46%3A12c18866689%3A-7db7"); + public void test04997(){ urlEncodingStyleA("vclassEdit?uri=http%3a%2f%2fvitro.mannlib.cornell.edu%2fns%2fbnode%23-20981c46%3a12c18866689%3a-7df2", "vclassEdit?uri=http%3A%2F%2Fvitro.mannlib.cornell.edu%2Fns%2Fbnode%23-20981c46%3A12c18866689%3A-7df2"); } @Test - public void test04997(){ urlEncodingStyleB( - "vclassEdit?uri=http%3a%2f%2fvitro.mannlib.cornell.edu%2fns%2fbnode%23-20981c46%3a12c18866689%3a-7df2", - "vclassEdit?uri=http%3A%2F%2Fvitro.mannlib.cornell.edu%2Fns%2Fbnode%23-20981c46%3A12c18866689%3A-7df2"); - } - @Test - public void test04999(){ urlEncodingStyleB( - "vclassEdit?uri=http%3a%2f%2fxmlns.com%2ffoaf%2f0.1%2fOrganization", - "vclassEdit?uri=http%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2FOrganization"); - } - @Test - public void test05000(){ urlEncodingStyleB( - "vclassEdit?uri=http%3a%2f%2fxmlns.com%2ffoaf%2f0.1%2fPerson", - "vclassEdit?uri=http%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2FPerson"); - } - @Test - public void test13898(){ urlEncodingStyleB( - "entityEdit?uri=http%3a%2f%2fvitro.mannlib.cornell.edu%2fns%2fvitro%2fpublic%23File", - "entityEdit?uri=http%3A%2F%2Fvitro.mannlib.cornell.edu%2Fns%2Fvitro%2Fpublic%23File"); - } - @Test - public void test13899(){ urlEncodingStyleB( - "/vclassEdit?uri=http%3a%2f%2fvitro.mannlib.cornell.edu%2fns%2fvitro%2fpublic%23File", - "/vclassEdit?uri=http%3A%2F%2Fvitro.mannlib.cornell.edu%2Fns%2Fvitro%2Fpublic%23File"); - } - @Test - public void test28454(){ urlEncodingStyleB( - "entityEdit?uri=http%3a%2f%2fwww.w3.org%2f2002%2f07%2fowl%23Thing", - "entityEdit?uri=http%3A%2F%2Fwww.w3.org%2F2002%2F07%2Fowl%23Thing"); - } - @Test - public void test28458(){ urlEncodingStyleB( - "/vclassEdit?uri=http%3a%2f%2fwww.w3.org%2f2002%2f07%2fowl%23Thing", - "/vclassEdit?uri=http%3A%2F%2Fwww.w3.org%2F2002%2F07%2Fowl%23Thing"); - } - @Test - public void test38687(){ urlEncodingStyleB( - "vclassEdit?uri=http%3a%2f%2fvitro.mannlib.cornell.edu%2fns%2fbnode%23-20981c46%3a12c18866689%3a-7d75", - "vclassEdit?uri=http%3A%2F%2Fvitro.mannlib.cornell.edu%2Fns%2Fbnode%23-20981c46%3A12c18866689%3A-7d75"); + public void test04999(){ urlEncodingStyleA("vclassEdit?uri=http%3a%2f%2fxmlns.com%2ffoaf%2f0.1%2fOrganization", "vclassEdit?uri=http%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2FOrganization"); } + @Test - public void test38693(){ urlEncodingStyleB( - "vclassEdit?uri=http%3a%2f%2fvitro.mannlib.cornell.edu%2fns%2fbnode%23-20981c46%3a12c18866689%3a-7d76", - "vclassEdit?uri=http%3A%2F%2Fvitro.mannlib.cornell.edu%2Fns%2Fbnode%23-20981c46%3A12c18866689%3A-7d76"); + public void test13898(){ urlEncodingStyleA("entityEdit?uri=http%3a%2f%2fvitro.mannlib.cornell.edu%2fns%2fvitro%2fpublic%23File", "entityEdit?uri=http%3A%2F%2Fvitro.mannlib.cornell.edu%2Fns%2Fvitro%2Fpublic%23File"); } @Test - public void test38694(){ urlEncodingStyleB( - "vclassEdit?uri=http%3a%2f%2fvivoweb.org%2fontology%2fcore%23AbstractInformation", - "vclassEdit?uri=http%3A%2F%2Fvivoweb.org%2Fontology%2Fcore%23AbstractInformation"); + public void test13899(){ urlEncodingStyleA("/vclassEdit?uri=http%3a%2f%2fvitro.mannlib.cornell.edu%2fns%2fvitro%2fpublic%23File", "/vclassEdit?uri=http%3A%2F%2Fvitro.mannlib.cornell.edu%2Fns%2Fvitro%2Fpublic%23File"); } @Test - public void test38695(){ urlEncodingStyleB( - "vclassEdit?uri=http%3a%2f%2fvitro.mannlib.cornell.edu%2fns%2fbnode%23-20981c46%3a12c18866689%3a-7d77", - "vclassEdit?uri=http%3A%2F%2Fvitro.mannlib.cornell.edu%2Fns%2Fbnode%23-20981c46%3A12c18866689%3A-7d77"); + public void test38687(){ urlEncodingStyleA("vclassEdit?uri=http%3a%2f%2fvitro.mannlib.cornell.edu%2fns%2fbnode%23-20981c46%3a12c18866689%3a-7d75", "vclassEdit?uri=http%3A%2F%2Fvitro.mannlib.cornell.edu%2Fns%2Fbnode%23-20981c46%3A12c18866689%3A-7d75"); } @Test - public void test38696(){ urlEncodingStyleB( - "vclassEdit?uri=http%3a%2f%2fpurl.org%2fontology%2fbibo%2fThesisDegree", - "vclassEdit?uri=http%3A%2F%2Fpurl.org%2Fontology%2Fbibo%2FThesisDegree"); + public void test38693(){ urlEncodingStyleA("vclassEdit?uri=http%3a%2f%2fvitro.mannlib.cornell.edu%2fns%2fbnode%23-20981c46%3a12c18866689%3a-7d76", "vclassEdit?uri=http%3A%2F%2Fvitro.mannlib.cornell.edu%2Fns%2Fbnode%23-20981c46%3A12c18866689%3A-7d76"); } @Test - public void test43123(){ urlEncodingStyleB( - "vclassEdit?uri=http%3a%2f%2fxmlns.com%2ffoaf%2f0.1%2fPerson", - "vclassEdit?uri=http%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2FPerson"); + public void test38694(){ urlEncodingStyleA("vclassEdit?uri=http%3a%2f%2fvivoweb.org%2fontology%2fcore%23AbstractInformation", "vclassEdit?uri=http%3A%2F%2Fvivoweb.org%2Fontology%2Fcore%23AbstractInformation"); } @Test - public void test43124(){ urlEncodingStyleB( - "vclassEdit?uri=http%3a%2f%2fvivoweb.org%2fontology%2fcore%23Postdoc", - "vclassEdit?uri=http%3A%2F%2Fvivoweb.org%2Fontology%2Fcore%23Postdoc"); + public void test38695(){ urlEncodingStyleA("vclassEdit?uri=http%3a%2f%2fvitro.mannlib.cornell.edu%2fns%2fbnode%23-20981c46%3a12c18866689%3a-7d77", "vclassEdit?uri=http%3A%2F%2Fvitro.mannlib.cornell.edu%2Fns%2Fbnode%23-20981c46%3A12c18866689%3A-7d77"); } @Test - public void test59983(){ urlEncodingStyleB( - "propertyEdit?uri=http%3a%2f%2fpurl.org%2fdc%2fterms%2fcontributor", - "propertyEdit?uri=http%3A%2F%2Fpurl.org%2Fdc%2Fterms%2Fcontributor"); + public void test38696(){ urlEncodingStyleA("vclassEdit?uri=http%3a%2f%2fpurl.org%2fontology%2fbibo%2fThesisDegree", "vclassEdit?uri=http%3A%2F%2Fpurl.org%2Fontology%2Fbibo%2FThesisDegree"); } + @Test - public void test17004(){ urlEncodingStyleB( - "ingest?action=outputModel&modelName=http%3a%2f%2fvitro.mannlib.cornell.edu%2fdefault%2fvitro-kb-2", - "ingest?action=outputModel&modelName=http%3A%2F%2Fvitro.mannlib.cornell.edu%2Fdefault%2Fvitro-kb-2"); + public void test43124(){ urlEncodingStyleA("vclassEdit?uri=http%3a%2f%2fvivoweb.org%2fontology%2fcore%23Postdoc", "vclassEdit?uri=http%3A%2F%2Fvivoweb.org%2Fontology%2Fcore%23Postdoc"); } @Test - public void test17017(){ urlEncodingStyleB( - "ingest?action=outputModel&modelName=http%3a%2f%2fvitro.mannlib.cornell.edu%2fdefault%2fvitro-kb-inf", - "ingest?action=outputModel&modelName=http%3A%2F%2Fvitro.mannlib.cornell.edu%2Fdefault%2Fvitro-kb-inf"); - } - @Test - public void test17021(){ urlEncodingStyleB( - "ingest?action=outputModel&modelName=http%3a%2f%2fvitro.mannlib.cornell.edu%2fdefault%2fvitro-kb-userAccounts", - "ingest?action=outputModel&modelName=http%3A%2F%2Fvitro.mannlib.cornell.edu%2Fdefault%2Fvitro-kb-userAccounts"); - } - @Test - public void test17033(){ urlEncodingStyleB( - "ingest?action=outputModel&modelName=http%3a%2f%2fvitro.mannlib.cornell.edu%2fdefault%2fvitro-kb-displayMetadata", - "ingest?action=outputModel&modelName=http%3A%2F%2Fvitro.mannlib.cornell.edu%2Fdefault%2Fvitro-kb-displayMetadata"); + public void test59983(){ urlEncodingStyleA("propertyEdit?uri=http%3a%2f%2fpurl.org%2fdc%2fterms%2fcontributor", "propertyEdit?uri=http%3A%2F%2Fpurl.org%2Fdc%2Fterms%2Fcontributor"); } public NamespaceMapper getMockNamespaceMapper(){ diff --git a/home/src/main/resources/config/example.runtime.properties b/home/src/main/resources/config/example.runtime.properties index 0e45125fc0..92d6b4126b 100644 --- a/home/src/main/resources/config/example.runtime.properties +++ b/home/src/main/resources/config/example.runtime.properties @@ -24,7 +24,7 @@ Vitro.defaultNamespace = http://vivo.mydomain.edu/individual/ # In case Vitro is behind proxy you might want to avoid redirects by overriding # context path to empty string or other custom value -#context.path = +#context.path = # # URL of Solr context used in local Vitro search. This will usually consist of: # scheme + server_name + port + "solr" + solr_core_name diff --git a/webapp/src/main/webapp/admin/log4j.jsp b/webapp/src/main/webapp/admin/log4j.jsp index d0b6ff6f32..e736b2e5ce 100644 --- a/webapp/src/main/webapp/admin/log4j.jsp +++ b/webapp/src/main/webapp/admin/log4j.jsp @@ -1,6 +1,7 @@ <%-- $This file is distributed under the terms of the license in LICENSE$ --%> <%@ page import="edu.cornell.mannlib.vitro.webapp.controller.Controllers" %> +<%@ page import="edu.cornell.mannlib.vitro.webapp.config.ContextPath"%> <%@ page import="org.apache.log4j.*" %> <%@ page import="java.util.*" %> @@ -51,7 +52,7 @@ try { out.write("

" + notes + "

"); // output category information in a form with a simple table - out.write("
"); + out.write(""); out.write("\r\n"); out.write(" \r\n"); out.write(" \r\n"); diff --git a/webapp/src/main/webapp/js/commentsForm.jsp b/webapp/src/main/webapp/js/commentsForm.jsp deleted file mode 100644 index 711d26e194..0000000000 --- a/webapp/src/main/webapp/js/commentsForm.jsp +++ /dev/null @@ -1,7 +0,0 @@ -<%-- $This file is distributed under the terms of the license in LICENSE$ --%> - -<% - String contextPath = request.getContextPath(); -%> - - diff --git a/webapp/src/main/webapp/templates/edit/specific/ents_edit_head.jsp b/webapp/src/main/webapp/templates/edit/specific/ents_edit_head.jsp index 23d65fce28..591cb6ba54 100644 --- a/webapp/src/main/webapp/templates/edit/specific/ents_edit_head.jsp +++ b/webapp/src/main/webapp/templates/edit/specific/ents_edit_head.jsp @@ -1,9 +1,10 @@ <%-- $This file is distributed under the terms of the license in LICENSE$ --%> +<%@ page import="edu.cornell.mannlib.vitro.webapp.config.ContextPath"%> <% request.setAttribute("dwrDisabled", Boolean.FALSE); -String context = request.getContextPath(); +String context = ContextPath.getPath(request); %> diff --git a/webapp/src/main/webapp/templates/page/headContent.jsp b/webapp/src/main/webapp/templates/page/headContent.jsp index e53ba32db5..83d97408ca 100644 --- a/webapp/src/main/webapp/templates/page/headContent.jsp +++ b/webapp/src/main/webapp/templates/page/headContent.jsp @@ -7,6 +7,7 @@ <%@ page import="edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean"%> <%@ page import="org.apache.commons.logging.Log" %> <%@ page import="org.apache.commons.logging.LogFactory" %> +<%@ page import="edu.cornell.mannlib.vitro.webapp.config.ContextPath"%> <%! public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.templates.page.headContent.jsp"); %> @@ -14,7 +15,7 @@ VitroRequest vreq = new VitroRequest(request); String themeDir = vreq.getAppBean().getThemeDir(); - themeDir = vreq.getContextPath() + '/' + themeDir; + themeDir = ContextPath.getPath(vreq) + '/' + themeDir; %> From dbdf160f73e179edec7ed4bc61f9e80058f7d27e Mon Sep 17 00:00:00 2001 From: Georgy Litvinov Date: Mon, 28 Oct 2024 15:04:07 +0100 Subject: [PATCH 3/3] removed not needed imports --- .../webapp/controller/freemarker/ContactFormController.java | 1 - .../webapp/freemarker/config/FreemarkerConfigurationImpl.java | 1 - 2 files changed, 2 deletions(-) diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ContactFormController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ContactFormController.java index da7227c725..bc3eba2190 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ContactFormController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ContactFormController.java @@ -10,7 +10,6 @@ import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; import edu.cornell.mannlib.vitro.webapp.beans.CaptchaServiceBean; -import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; import edu.cornell.mannlib.vitro.webapp.config.ContextPath; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/freemarker/config/FreemarkerConfigurationImpl.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/freemarker/config/FreemarkerConfigurationImpl.java index ceae3ce8ee..4f3f41596c 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/freemarker/config/FreemarkerConfigurationImpl.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/freemarker/config/FreemarkerConfigurationImpl.java @@ -22,7 +22,6 @@ import org.apache.commons.logging.LogFactory; import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; -import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; import edu.cornell.mannlib.vitro.webapp.config.ContextPath; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
Logger