mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 06:07:57 +01:00
Fix Apache Proxy configuration property.
This commit is contained in:
parent
5cb2289cbc
commit
37b4298579
@ -18,29 +18,51 @@
|
|||||||
|
|
||||||
package com.wisemapping.filter;
|
package com.wisemapping.filter;
|
||||||
|
|
||||||
import com.wisemapping.exceptions.GoogleChromeFrameRequiredException;
|
|
||||||
import com.wisemapping.exceptions.UnsupportedBrowserException;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.core.env.ConfigurableEnvironment;
|
||||||
|
import org.springframework.core.env.Environment;
|
||||||
|
import org.springframework.core.env.MutablePropertySources;
|
||||||
|
import org.springframework.core.env.PropertySource;
|
||||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.servlet.http.HttpSession;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
|
||||||
public class RequestPropertiesInterceptor extends HandlerInterceptorAdapter {
|
public class RequestPropertiesInterceptor extends HandlerInterceptorAdapter {
|
||||||
private Map<String, String> attributes;
|
@Value("${google.analytics.enabled}")
|
||||||
|
private Boolean analyticsEnabled;
|
||||||
|
|
||||||
|
@Value("${google.analytics.account}")
|
||||||
|
private String analyticsAccount;
|
||||||
|
|
||||||
|
@Value("${google.ads.enabled}")
|
||||||
|
private Boolean adsEnabled;
|
||||||
|
|
||||||
|
@Value("${site.homepage}")
|
||||||
|
private String siteHomepage;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
Environment env;
|
||||||
|
|
||||||
public boolean preHandle(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, Object object) throws Exception {
|
public boolean preHandle(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, Object object) throws Exception {
|
||||||
for (String key : attributes.keySet()) {
|
|
||||||
request.setAttribute(key, attributes.get(key));
|
request.setAttribute("google.analytics.enabled", analyticsEnabled);
|
||||||
|
request.setAttribute("google.analytics.account", analyticsAccount);
|
||||||
|
request.setAttribute("google.ads.enabled", adsEnabled);
|
||||||
|
request.setAttribute("site.homepage", siteHomepage);
|
||||||
|
|
||||||
|
final String baseUrl;
|
||||||
|
if (env.containsProperty("site.baseurl")) {
|
||||||
|
baseUrl = env.getProperty("site.baseurl");
|
||||||
|
} else {
|
||||||
|
baseUrl = request.getRequestURL().toString().replace(request.getRequestURI(), request.getContextPath());
|
||||||
}
|
}
|
||||||
|
request.setAttribute("site.baseurl", baseUrl);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAttributes(Map<String, String> attributes) {
|
|
||||||
this.attributes = attributes;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import org.apache.commons.lang.StringEscapeUtils;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.core.env.Environment;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
@ -37,12 +38,14 @@ import java.util.Map;
|
|||||||
|
|
||||||
final public class NotificationService {
|
final public class NotificationService {
|
||||||
|
|
||||||
|
public static final String DEFAULT_WISE_URL = "http://localhost:8080/wisemapping";
|
||||||
@Autowired
|
@Autowired
|
||||||
private Mailer mailer;
|
private Mailer mailer;
|
||||||
private String baseUrl;
|
|
||||||
private NotifierFilter notificationFilter;
|
private NotifierFilter notificationFilter;
|
||||||
|
|
||||||
|
private String baseUrl;
|
||||||
|
|
||||||
public NotificationService() {
|
public NotificationService() {
|
||||||
this.notificationFilter = new NotifierFilter();
|
this.notificationFilter = new NotifierFilter();
|
||||||
}
|
}
|
||||||
@ -64,8 +67,8 @@ final public class NotificationService {
|
|||||||
model.put("mindmap", mindmap);
|
model.put("mindmap", mindmap);
|
||||||
model.put("message", "message");
|
model.put("message", "message");
|
||||||
model.put("ownerName", user.getFirstname());
|
model.put("ownerName", user.getFirstname());
|
||||||
model.put("mapEditUrl", baseUrl + "/c/maps/" + mindmap.getId() + "/edit");
|
model.put("mapEditUrl", getBaseUrl() + "/c/maps/" + mindmap.getId() + "/edit");
|
||||||
model.put("baseUrl", baseUrl);
|
model.put("baseUrl", getBaseUrl());
|
||||||
model.put("senderMail", user.getEmail());
|
model.put("senderMail", user.getEmail());
|
||||||
model.put("message", message);
|
model.put("message", message);
|
||||||
model.put("supportEmail", mailer.getSupportEmail());
|
model.put("supportEmail", mailer.getSupportEmail());
|
||||||
@ -83,7 +86,7 @@ final public class NotificationService {
|
|||||||
final String messageBody =
|
final String messageBody =
|
||||||
"<p>Someone, most likely you, requested a new password for your WiseMapping account. </p>\n" +
|
"<p>Someone, most likely you, requested a new password for your WiseMapping account. </p>\n" +
|
||||||
"<p><strong>Here is your new password: " + temporalPassword + "</strong></p>\n" +
|
"<p><strong>Here is your new password: " + temporalPassword + "</strong></p>\n" +
|
||||||
"<p>You can login clicking <a href=\"" + this.baseUrl + "/c/login\">here</a>. We strongly encourage you to change the password as soon as possible.</p>";
|
"<p>You can login clicking <a href=\"" + getBaseUrl() + "/c/login\">here</a>. We strongly encourage you to change the password as soon as possible.</p>";
|
||||||
|
|
||||||
sendTemplateMail(user, mailSubject, messageTitle, messageBody);
|
sendTemplateMail(user, mailSubject, messageTitle, messageBody);
|
||||||
}
|
}
|
||||||
@ -112,7 +115,7 @@ final public class NotificationService {
|
|||||||
model.put("firstName", user.getFirstname());
|
model.put("firstName", user.getFirstname());
|
||||||
model.put("messageTitle", messageTitle);
|
model.put("messageTitle", messageTitle);
|
||||||
model.put("messageBody", messageBody);
|
model.put("messageBody", messageBody);
|
||||||
model.put("baseUrl", this.baseUrl);
|
model.put("baseUrl", getBaseUrl());
|
||||||
model.put("supportEmail", mailer.getSupportEmail());
|
model.put("supportEmail", mailer.getSupportEmail());
|
||||||
|
|
||||||
mailer.sendEmail(mailer.getServerSenderEmail(), user.getEmail(), mailSubject, model, "baseLayout.vm");
|
mailer.sendEmail(mailer.getServerSenderEmail(), user.getEmail(), mailSubject, model, "baseLayout.vm");
|
||||||
@ -127,10 +130,6 @@ final public class NotificationService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBaseUrl(String baseUrl) {
|
|
||||||
this.baseUrl = baseUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMailer(Mailer mailer) {
|
public void setMailer(Mailer mailer) {
|
||||||
this.mailer = mailer;
|
this.mailer = mailer;
|
||||||
}
|
}
|
||||||
@ -227,6 +226,17 @@ final public class NotificationService {
|
|||||||
return retValue;
|
return retValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getBaseUrl() {
|
||||||
|
if ("${site.baseurl}".equals(baseUrl)) {
|
||||||
|
baseUrl = DEFAULT_WISE_URL;
|
||||||
|
System.err.println("Warning: site.baseurl has not being configured. Mail site references could be not properly sent. Using :" + baseUrl);
|
||||||
|
}
|
||||||
|
return baseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBaseUrl(String baseUrl) {
|
||||||
|
this.baseUrl = baseUrl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,8 +80,10 @@ google.recaptcha.publicKey = 6LeQ4tISAAAAALzCGKNgRv8UqsDx7Cb0vq4wbJBr
|
|||||||
# etc.
|
# etc.
|
||||||
admin.user = admin@wisemapping.org
|
admin.user = admin@wisemapping.org
|
||||||
|
|
||||||
# Site URL. This url will be used during sharing emails and public views.
|
# Base URL where WiseMapping is deployed. By default, It will be automatically inferred.
|
||||||
site.baseurl = http://localhost:8080/wisemapping
|
# If you are planning to put wisemapping behind an Apache using an Apache Proxy setup, you must enable this property.
|
||||||
|
# site.baseurl = http:///example.com:8080/wisemapping
|
||||||
|
|
||||||
|
|
||||||
# Site Homepage URL. This will be used as URL for homepage location.
|
# Site Homepage URL. This will be used as URL for homepage location.
|
||||||
site.homepage = c/home
|
site.homepage = c/home
|
||||||
|
@ -7,9 +7,6 @@
|
|||||||
http://www.springframework.org/schema/context
|
http://www.springframework.org/schema/context
|
||||||
http://www.springframework.org/schema/context/spring-context-3.1.xsd">
|
http://www.springframework.org/schema/context/spring-context-3.1.xsd">
|
||||||
|
|
||||||
<context:property-placeholder location="/WEB-INF/app.properties"/>
|
|
||||||
|
|
||||||
|
|
||||||
<bean id="wiseDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
|
<bean id="wiseDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
|
||||||
<property name="driverClassName" value="${database.driver}"/>
|
<property name="driverClassName" value="${database.driver}"/>
|
||||||
<property name="url" value="${database.url}"/>
|
<property name="url" value="${database.url}"/>
|
||||||
|
@ -11,8 +11,6 @@
|
|||||||
http://www.springframework.org/schema/context
|
http://www.springframework.org/schema/context
|
||||||
http://www.springframework.org/schema/context/spring-context.xsd">
|
http://www.springframework.org/schema/context/spring-context.xsd">
|
||||||
|
|
||||||
<context:property-placeholder location="/WEB-INF/app.properties"/>
|
|
||||||
|
|
||||||
<bean id="encoder"
|
<bean id="encoder"
|
||||||
class="com.wisemapping.security.CustomPasswordEncoder"/>
|
class="com.wisemapping.security.CustomPasswordEncoder"/>
|
||||||
|
|
||||||
@ -72,9 +70,4 @@
|
|||||||
<property name="userService" ref="userService"/>
|
<property name="userService" ref="userService"/>
|
||||||
<property name="adminUser" value="${admin.user}"/>
|
<property name="adminUser" value="${admin.user}"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<beans profile="heroku">
|
|
||||||
<context:property-placeholder location="/WEB-INF/heroku.properties"/>
|
|
||||||
</beans>
|
|
||||||
|
|
||||||
</beans>
|
</beans>
|
@ -1,8 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns:context="http://www.springframework.org/schema/context"
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||||
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
|
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
|
||||||
|
|
||||||
|
<context:property-placeholder location="/WEB-INF/app.properties" ignore-unresolvable="true"/>
|
||||||
|
|
||||||
<bean id="mailer" class="com.wisemapping.mail.Mailer" scope ="singleton">
|
<bean id="mailer" class="com.wisemapping.mail.Mailer" scope ="singleton">
|
||||||
<constructor-arg index="0" value="${mail.serverSendEmail}"/>
|
<constructor-arg index="0" value="${mail.serverSendEmail}"/>
|
||||||
|
@ -14,9 +14,7 @@
|
|||||||
<context:component-scan base-package="com.wisemapping.ncontroller"/>
|
<context:component-scan base-package="com.wisemapping.ncontroller"/>
|
||||||
<context:annotation-config/>
|
<context:annotation-config/>
|
||||||
<mvc:annotation-driven/>
|
<mvc:annotation-driven/>
|
||||||
<context:property-placeholder
|
<context:property-placeholder location="/WEB-INF/app.properties" ignore-unresolvable="true"/>
|
||||||
location="/WEB-INF/app.properties"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- Interceptors Registration -->
|
<!-- Interceptors Registration -->
|
||||||
<mvc:interceptors>
|
<mvc:interceptors>
|
||||||
@ -38,18 +36,8 @@
|
|||||||
</set>
|
</set>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
<bean id="userLocaleInterceptor" class="com.wisemapping.filter.UserLocaleInterceptor">
|
<bean id="userLocaleInterceptor" class="com.wisemapping.filter.UserLocaleInterceptor"/>
|
||||||
</bean>
|
<bean id="requestInterceptor" class="com.wisemapping.filter.RequestPropertiesInterceptor"/>
|
||||||
<bean id="requestInterceptor" class="com.wisemapping.filter.RequestPropertiesInterceptor">
|
|
||||||
<property name="attributes">
|
|
||||||
<map>
|
|
||||||
<entry key="google.analytics.enabled" value="${google.analytics.enabled}"/>
|
|
||||||
<entry key="google.analytics.account" value="${google.analytics.account}"/>
|
|
||||||
<entry key="google.ads.enabled" value="${google.ads.enabled}"/>
|
|
||||||
<entry key="site.homepage" value="${site.homepage}"/>
|
|
||||||
</map>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
</mvc:interceptors>
|
</mvc:interceptors>
|
||||||
|
|
||||||
|
|
||||||
@ -110,10 +98,4 @@
|
|||||||
</list>
|
</list>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<beans profile="heroku">
|
|
||||||
<context:property-placeholder
|
|
||||||
location="/WEB-INF/heroku.properties"
|
|
||||||
/>
|
|
||||||
</beans>
|
|
||||||
</beans>
|
</beans>
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<base href="${baseURL}/">
|
<base href="${requestScope['site.baseurl']}/">
|
||||||
<!--[if lt IE 9]>
|
<!--[if lt IE 9]>
|
||||||
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
@ -2,6 +2,3 @@
|
|||||||
<%@taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
<%@taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||||
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||||
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||||
|
|
||||||
<c:set var="baseURL" value="${fn:replace(pageContext.request.requestURL, pageContext.request.requestURI, pageContext.request.contextPath)}" />
|
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
<%--@elvariable id="mapXml" type="com.wisemapping.model.User"--%>
|
<%--@elvariable id="mapXml" type="com.wisemapping.model.User"--%>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<base href="${baseURL}/">
|
<base href="${requestScope['site.baseurl']}/">
|
||||||
<title><spring:message code="SITE.TITLE"/> - <c:out value="${mindmap.title}"/></title>
|
<title><spring:message code="SITE.TITLE"/> - <c:out value="${mindmap.title}"/></title>
|
||||||
<!--[if lt IE 9]>
|
<!--[if lt IE 9]>
|
||||||
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<base href="${baseURL}/">
|
<base href="{requestScope['site.baseurl']}/">
|
||||||
<title><spring:message code="SITE.TITLE"/> - ${mindmap.title} </title>
|
<title><spring:message code="SITE.TITLE"/> - ${mindmap.title} </title>
|
||||||
|
|
||||||
<!--[if lt IE 9]>
|
<!--[if lt IE 9]>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<base href="${baseURL}/">
|
<base href="${requestScope['site.baseurl']}/">
|
||||||
<title><spring:message code="SITE.TITLE"/> - <spring:message code="MY_WISEMAPS"/></title>
|
<title><spring:message code="SITE.TITLE"/> - <spring:message code="MY_WISEMAPS"/></title>
|
||||||
<!--[if lt IE 9]>
|
<!--[if lt IE 9]>
|
||||||
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<base href="${baseURL}/">
|
<base href="${requestScope['site.baseurl']}/">
|
||||||
<title><spring:message code="SITE.TITLE"/> - ${mindmap.title} </title>
|
<title><spring:message code="SITE.TITLE"/> - ${mindmap.title} </title>
|
||||||
|
|
||||||
<!--[if lt IE 9]>
|
<!--[if lt IE 9]>
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<base href="${baseURL}/">
|
<base href="${requestScope['site.baseurl']}/">
|
||||||
<title>
|
<title>
|
||||||
<spring:message code="SITE.TITLE"/>-
|
<spring:message code="SITE.TITLE"/>-
|
||||||
<c:choose>
|
<c:choose>
|
||||||
|
Loading…
Reference in New Issue
Block a user