mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-21 21:57:56 +01:00
Remove notifier to send emails.
This commit is contained in:
parent
f68a3ac7bc
commit
119eb03f53
@ -1,20 +1,20 @@
|
||||
/*
|
||||
* Copyright [2015] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
* Copyright [2015] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.wisemapping.mail;
|
||||
|
||||
@ -22,8 +22,11 @@ import com.wisemapping.filter.SupportedUserAgent;
|
||||
import com.wisemapping.model.Collaboration;
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.util.VelocityEngineUtils;
|
||||
import com.wisemapping.util.VelocityEngineWrapper;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang.StringEscapeUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -36,17 +39,17 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
final public class NotificationService {
|
||||
final private static Logger logger = Logger.getLogger(Mailer.class);
|
||||
final private static String DEFAULT_WISE_URL = "http://localhost:8080/wisemapping";
|
||||
private VelocityEngineWrapper velocityEngineWrapper;
|
||||
|
||||
public static final String DEFAULT_WISE_URL = "http://localhost:8080/wisemapping";
|
||||
@Autowired
|
||||
private Mailer mailer;
|
||||
|
||||
private final NotifierFilter notificationFilter;
|
||||
|
||||
private String baseUrl;
|
||||
|
||||
public NotificationService() {
|
||||
this.notificationFilter = new NotifierFilter();
|
||||
NotifierFilter notificationFilter = new NotifierFilter();
|
||||
}
|
||||
|
||||
public void newCollaboration(@NotNull Collaboration collaboration, @NotNull Mindmap mindmap, @NotNull User user, @Nullable String message) {
|
||||
@ -90,6 +93,13 @@ final public class NotificationService {
|
||||
sendTemplateMail(user, mailSubject, messageTitle, messageBody);
|
||||
}
|
||||
|
||||
private void logErrorMessage(final Map model,
|
||||
@NotNull final String templateMail) {
|
||||
final String messageBody = VelocityEngineUtils.mergeTemplateIntoString(velocityEngineWrapper.getVelocityEngine(), "/mail/" + templateMail, model);
|
||||
logger.error("Unexpected editor error => " + messageBody);
|
||||
}
|
||||
|
||||
|
||||
public void passwordChanged(@NotNull User user) {
|
||||
final String mailSubject = "[WiseMapping] Your password has been changed";
|
||||
final String messageTitle = "Your password has been changed successfully";
|
||||
@ -154,9 +164,13 @@ final public class NotificationService {
|
||||
// }
|
||||
}
|
||||
|
||||
public void setVelocityEngineWrapper(VelocityEngineWrapper engine) {
|
||||
this.velocityEngineWrapper = engine;
|
||||
}
|
||||
|
||||
public void reportJavascriptException(@Nullable Mindmap mindmap, @Nullable User user, @Nullable String jsErrorMsg, @NotNull HttpServletRequest request) {
|
||||
|
||||
final Map<String, String> model = new HashMap<String, String>();
|
||||
final Map<String, String> model = new HashMap<>();
|
||||
model.put("errorMsg", jsErrorMsg);
|
||||
try {
|
||||
model.put("mapXML", StringEscapeUtils.escapeXml(mindmap == null ? "map not found" : mindmap.getXmlStr()));
|
||||
@ -166,10 +180,10 @@ final public class NotificationService {
|
||||
model.put("mapId", Integer.toString(mindmap.getId()));
|
||||
model.put("mapTitle", mindmap.getTitle());
|
||||
|
||||
sendNotification(model, user, request);
|
||||
logError(model, user, request);
|
||||
}
|
||||
|
||||
private void sendNotification(@NotNull Map<String, String> model, @Nullable User user, @NotNull HttpServletRequest request) {
|
||||
private void logError(@NotNull Map<String, String> model, @Nullable User user, @NotNull HttpServletRequest request) {
|
||||
model.put("fullName", (user != null ? user.getFullName() : "'anonymous'"));
|
||||
final String userEmail = user != null ? user.getEmail() : "'anonymous'";
|
||||
|
||||
@ -180,37 +194,19 @@ final public class NotificationService {
|
||||
model.put("method", request.getMethod());
|
||||
model.put("remoteAddress", request.getRemoteAddr());
|
||||
|
||||
try {
|
||||
final String errorReporterEmail = mailer.getErrorReporterEmail();
|
||||
if (errorReporterEmail != null && !errorReporterEmail.isEmpty()) {
|
||||
|
||||
if (!notificationFilter.hasBeenSend(userEmail, model)) {
|
||||
mailer.sendEmail(mailer.getServerSenderEmail(), errorReporterEmail, "[WiseMapping] Bug from '" + (user != null ? user.getEmail() + "'" : "'anonymous'"), model,
|
||||
"errorNotification.vm");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
handleException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void reportJavaException(@NotNull Throwable exception, @Nullable User user, @NotNull String content, @NotNull HttpServletRequest request) {
|
||||
final Map<String, String> model = new HashMap<String, String>();
|
||||
model.put("errorMsg", stackTraceToString(exception));
|
||||
model.put("mapXML", StringEscapeUtils.escapeXml(content));
|
||||
|
||||
sendNotification(model, user, request);
|
||||
logErrorMessage(model,
|
||||
"errorNotification.vm");
|
||||
}
|
||||
|
||||
public void reportJavaException(@NotNull Throwable exception, @Nullable User user, @NotNull HttpServletRequest request) {
|
||||
final Map<String, String> model = new HashMap<String, String>();
|
||||
model.put("errorMsg", stackTraceToString(exception));
|
||||
|
||||
sendNotification(model, user, request);
|
||||
logError(model, user, request);
|
||||
}
|
||||
|
||||
public String stackTraceToString(@NotNull Throwable e) {
|
||||
String retValue = null;
|
||||
String retValue;
|
||||
StringWriter sw = null;
|
||||
PrintWriter pw = null;
|
||||
try {
|
||||
|
@ -1,32 +1,18 @@
|
||||
<html>
|
||||
<body>
|
||||
<ul>
|
||||
<li>User Name: ${fullName}</li>
|
||||
<li>Email: ${email}</li>
|
||||
<li>Server: ${server}</li>
|
||||
<li>RequestURI: ${requestURI}</li>
|
||||
<li>Method: ${method}</li>
|
||||
<li>User Agent: ${userAgent}</li>
|
||||
<li>Remote Address: ${remoteAddress}</li>
|
||||
|
||||
|
||||
#if($mapId)
|
||||
<li>Mindmap Id: ${mapId}</li>
|
||||
#end
|
||||
#if($mapTitle)
|
||||
<li>Mindmap Title: ${mapTitle}</li>
|
||||
#end
|
||||
</ul>
|
||||
|
||||
<pre style="border:1px dashed #a9a9a9">
|
||||
${errorMsg}
|
||||
</pre>
|
||||
User Name: ${fullName} -
|
||||
Email: ${email} -
|
||||
Server: ${server} -
|
||||
RequestURI: ${requestURI} -
|
||||
Method: ${method} -
|
||||
User Agent: ${userAgent} -
|
||||
Remote Address: ${remoteAddress} -
|
||||
#if($mapId)
|
||||
Mindmap Id: ${mapId} -
|
||||
#end
|
||||
#if($mapTitle)
|
||||
Mindmap Title: ${mapTitle} -
|
||||
#end
|
||||
${errorMsg}
|
||||
|
||||
#if($mapXML)
|
||||
<pre style="border:1px dashed #a9a9a9">
|
||||
${mapXML}
|
||||
</pre>
|
||||
${mapXML}
|
||||
#end
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,14 +0,0 @@
|
||||
<jxb:bindings version="2.0" xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||
<jxb:bindings schemaLocation="mindmap.xsd">
|
||||
<jxb:schemaBindings>
|
||||
<jxb:package name="com.wisemapping.jaxb.wisemap"/>
|
||||
</jxb:schemaBindings>
|
||||
</jxb:bindings>
|
||||
<jxb:bindings node="/xsd:schema/xsd:complexType[@name='topicType']/xsd:attribute[@name='text']" schemaLocation="mindmap.xsd">
|
||||
<jxb:property name="textAttr"/>
|
||||
</jxb:bindings>
|
||||
<jxb:bindings node="/xsd:schema/xsd:complexType[@name='note']/xsd:simpleContent/xsd:extension/xsd:attribute[@name='text']" schemaLocation="mindmap.xsd">
|
||||
<jxb:property name="textAttr"/>
|
||||
</jxb:bindings>
|
||||
</jxb:bindings>
|
@ -68,9 +68,6 @@ mail.serverSendEmail=root@localhost
|
||||
# Optional: Support account that the users could use to contact you. This address will appear in emails and in some places in the site.
|
||||
mail.supportEmail=root@localhost
|
||||
|
||||
# Optional: Unexpected errors will be reported to this address.
|
||||
mail.errorReporterEmail=
|
||||
|
||||
##################################################################################
|
||||
# Users Registration Configuration
|
||||
##################################################################################
|
||||
@ -130,14 +127,12 @@ security.ldap.server.user=cn=pveiga,dc=wisemapping,dc=com
|
||||
security.ldap.server.password=password
|
||||
security.ldap.basedn=dc=wisemapping,dc=com
|
||||
|
||||
|
||||
# This will be concatenated as part of the DN. In this case, I will be "ou=people".
|
||||
# In case this need to be changed, modify the wisemapping-security-ldap.xml.
|
||||
security.ldap.subDn=ou=people
|
||||
|
||||
# Attribute used as authentication login (Eg: in this case, the user email will be used)
|
||||
security.ldap.auth.attribute=mail
|
||||
|
||||
security.ldap.lastName.attribute=sn
|
||||
security.ldap.firstName.attribute=givenName
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
<bean id="userService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
|
||||
<property name="transactionManager" ref="transactionManager"/>
|
||||
<property name="target" ref="userServiceTarget" />
|
||||
<property name="target" ref="userServiceTarget"/>
|
||||
<property name="transactionAttributes">
|
||||
<props>
|
||||
<prop key="*">PROPAGATION_REQUIRED</prop>
|
||||
@ -66,7 +66,7 @@
|
||||
|
||||
<bean id="labelService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
|
||||
<property name="transactionManager" ref="transactionManager"/>
|
||||
<property name="target" ref="labelServiceTarget" />
|
||||
<property name="target" ref="labelServiceTarget"/>
|
||||
<property name="transactionAttributes">
|
||||
<props>
|
||||
<prop key="*">PROPAGATION_REQUIRED</prop>
|
||||
@ -95,6 +95,7 @@
|
||||
<bean id="notificationService" class="com.wisemapping.mail.NotificationService">
|
||||
<property name="baseUrl" value="${site.baseurl}"/>
|
||||
<property name="mailer" ref="mailer"/>
|
||||
<property name="velocityEngineWrapper" ref="velocityEngineWrapper"/>
|
||||
</bean>
|
||||
|
||||
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
|
||||
|
Loading…
Reference in New Issue
Block a user