Skip to content
This repository was archived by the owner on Apr 22, 2025. It is now read-only.

Commit c642465

Browse files
committed
Enable error handling in MyCollab
1 parent bfe0e0c commit c642465

File tree

31 files changed

+201
-109
lines changed

31 files changed

+201
-109
lines changed

README.md

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Free, open source Project Management software
22
[![License](http://img.shields.io/badge/License-AGPLv3-orange.svg)](https://www.gnu.org/licenses/agpl-3.0.en.html) [![Project Stats](https://www.openhub.net/p/mycollab/widgets/project_thin_badge.gif)](https://www.openhub.net/p/mycollab) [![Build](https://travis-ci.org/MyCollab/mycollab.svg)](https://travis-ci.org/MyCollab/mycollab)
3-
[![Version](https://img.shields.io/badge/Version-6.0.0-brightgreen.svg)](https://community.mycollab.com/)
3+
[![Version](https://img.shields.io/badge/Version-7.0.0-brightgreen.svg)](https://community.mycollab.com/)
44
[![Github](https://img.shields.io/github/downloads/MyCollab/mycollab/total.svg)](https://github.com/MyCollab/mycollab/releases)
55

66

@@ -17,7 +17,7 @@ MyCollab is the free and open source project management software. Intuitive UI,
1717
<br />
1818
<em>Project Dashboard</em>
1919
</td>
20-
<td align="center">
20+
<td align ="center">
2121
<a href="https://community.mycollab.com/wp-content/uploads/2015/12/Bug-Dashboard.png" target="_blank" title="Bug Dashboard">
2222
<img src="https://community.mycollab.com/wp-content/uploads/2015/12/Bug-Dashboard-300x151.png" alt="Bug Dashboard">
2323
</a>
@@ -90,8 +90,6 @@ MyCollab requires a running Java Runtime Environment (8 or greater), Java comman
9090

9191
## Installation
9292

93-
The current MyCollab version is 6.0.0 released on 30th August, 2018. This branch focuses in monitoring, customize options for on-demand edition.
94-
9593
1. Download MyCollab binary - https://www.mycollab.com/self-hosted/
9694
2. Follow installation guideline at https://community.mycollab.com/docs/hosting-mycollab-on-your-own-server/installing-mycollab/
9795

@@ -112,11 +110,3 @@ Contact the MyCollab team at:
112110
* MyCollab community is licensed with Affero GPL v3. For license terms, see https://www.gnu.org/licenses/agpl-3.0.en.html
113111

114112
* You can try MyCollab on-demand edition on site https://www.mycollab.com
115-
116-
## Sponsors
117-
118-
JProfiler supports open source projects with its full-featured Java Profiler. Click the JProfiler logo below to learn more.
119-
120-
<a href="http://www.ej-technologies.com/products/jprofiler/overview.html" target="_blank" title="File Management">
121-
<img src="http://www.ej-technologies.com/images/product_banners/jprofiler_large.png" alt="File Management">
122-
</a>

mycollab-app-community/pom.xml

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,6 @@
2626
<version>${project.version}</version>
2727
</dependency>
2828

29-
<!--
30-
<dependency>
31-
<groupId>com.mycollab</groupId>
32-
<artifactId>mycollab-mobile</artifactId>
33-
<version>${project.version}</version>
34-
</dependency>
35-
-->
36-
3729
<dependency>
3830
<groupId>com.mycollab</groupId>
3931
<artifactId>mycollab-server-runner</artifactId>
@@ -69,25 +61,7 @@
6961
<artifactId>mycollab-web-community</artifactId>
7062
<version>${project.version}</version>
7163
</dependency>
72-
<!--
73-
<dependency>
74-
<groupId>com.vaadin</groupId>
75-
<artifactId>vaadin-client-compiled</artifactId>
76-
<scope>provided</scope>
77-
</dependency>
7864

79-
<dependency>
80-
<groupId>com.vaadin</groupId>
81-
<artifactId>vaadin-client</artifactId>
82-
<scope>provided</scope>
83-
<exclusions>
84-
<exclusion>
85-
<groupId>javax.validation</groupId>
86-
<artifactId>validation-api</artifactId>
87-
</exclusion>
88-
</exclusions>
89-
</dependency>
90-
-->
9165
<dependency>
9266
<groupId>com.vaadin</groupId>
9367
<artifactId>vaadin-compatibility-client</artifactId>

mycollab-app-community/src/main/config/application.properties.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ mail.ssl=${smtpSSLEnable}
4444
# want to send report automatically to our team, you can
4545
# leave this field to empty
4646
#=====================================================
47-
error.sendTo=error@mycollab.com
47+
mail.errorTo=error@mycollab.com

mycollab-app-community/src/main/docker/mysql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: '3.1'
22
services:
33
hlsoft-mysql:
4-
image: mysql:8.0.11
4+
image: mysql:8.0.15
55
restart: always
66
hostname: mysql
77
command: mysqld --default-authentication-plugin=mysql_native_password

mycollab-config/src/main/java/com/mycollab/configuration/ApplicationProperties.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ public class ApplicationProperties {
4040

4141
private static Properties properties;
4242

43-
public static final String DROPBOX_AUTH_LINK = "dropbox.callbackUrl";
44-
4543
public static final String BI_ENDECRYPT_PASSWORD = "endecryptPassword";
4644

4745
public static final String DEFAULT_LOCALE = "defaultLocale";

mycollab-config/src/main/java/com/mycollab/configuration/EmailConfiguration.kt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ import org.springframework.stereotype.Component
2828
*/
2929
@Component
3030
@ConfigurationProperties(prefix = "mail")
31-
class EmailConfiguration(var smtphost: String?, var username: String?,
32-
var password: String?, var port: Int,
31+
data class EmailConfiguration(var smtphost: String = "", var username: String = "",
32+
var password: String = "", var port: Int = -1,
3333
var startTls: Boolean = false, var ssl: Boolean = false,
34-
var notifyEmail: String) : ValuedBean() {
35-
constructor() : this("", "", "", -1, false, false, "")
36-
}
37-
38-
34+
var errorTo: String = "error@mycollab.com") : ValuedBean()

mycollab-core/src/main/java/com/mycollab/logging/ExceptionFilter.kt renamed to mycollab-config/src/main/java/com/mycollab/logging/ExceptionFilter.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import ch.qos.logback.classic.spi.ILoggingEvent
2020
import ch.qos.logback.classic.spi.ThrowableProxy
2121
import ch.qos.logback.core.filter.Filter
2222
import ch.qos.logback.core.spi.FilterReply
23+
import java.lang.IllegalStateException
2324

2425
/**
2526
* @author MyCollab Ltd
@@ -50,8 +51,7 @@ class ExceptionFilter : Filter<ILoggingEvent>() {
5051
Class.forName("org.apache.commons.mail.EmailException"),
5152
Class.forName("java.net.SocketTimeoutException"),
5253
Class.forName("java.sql.SQLTransientConnectionException"),
53-
Class.forName("com.mysql.jdbc.exceptions.jdbc4.CommunicationsException"),
54-
Class.forName("com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException"))
54+
IllegalStateException::class.java)
5555
} catch (e: Exception) {
5656
arrayOf()
5757
}

mycollab-core/src/main/java/com/mycollab/logging/LogFilter.kt renamed to mycollab-config/src/main/java/com/mycollab/logging/LogFilter.kt

File renamed without changes.
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/**
2+
* Copyright © MyCollab
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Affero General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Affero General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Affero General Public License
15+
* along with this program. If not, see <http:></http:>//www.gnu.org/licenses/>.
16+
*/
17+
package com.mycollab.logging
18+
19+
import ch.qos.logback.classic.net.SMTPAppender
20+
import ch.qos.logback.classic.spi.ILoggingEvent
21+
import ch.qos.logback.core.Layout
22+
import ch.qos.logback.core.helpers.CyclicBuffer
23+
import ch.qos.logback.core.util.OptionHelper
24+
import com.mycollab.configuration.EmailConfiguration
25+
import com.mycollab.core.Version
26+
import com.mycollab.spring.AppContextUtil
27+
import java.util.*
28+
import javax.mail.Authenticator
29+
import javax.mail.PasswordAuthentication
30+
import javax.mail.Session
31+
32+
/**
33+
* @author MyCollab Ltd
34+
* @since 5.0.5
35+
*/
36+
class MailAppender : SMTPAppender() {
37+
38+
private var isSessionCreated = false
39+
40+
override fun makeSubjectLayout(subjectStr: String?): Layout<ILoggingEvent> {
41+
var subjectStr = subjectStr
42+
if (subjectStr == null) {
43+
subjectStr = "MyCollab ${Version.getVersion()} - Error: %logger{20} - %m"
44+
}
45+
46+
return super.makeSubjectLayout(subjectStr)
47+
}
48+
49+
override fun sendBuffer(cb: CyclicBuffer<ILoggingEvent>?, lastEventObject: ILoggingEvent?) {
50+
// if (!isSessionCreated) {
51+
try {
52+
val emailConfiguration = AppContextUtil.getSpringBean(EmailConfiguration::class.java)
53+
val props = Properties(OptionHelper.getSystemProperties())
54+
isSessionCreated = true;
55+
this.from = emailConfiguration.username
56+
this.addTo(emailConfiguration.errorTo)
57+
58+
props["mail.smtp.host"] = emailConfiguration.smtphost
59+
props["mail.smtp.port"] = emailConfiguration.port
60+
61+
var loginAuthenticator: Authenticator? = null
62+
63+
if (emailConfiguration.username != null) {
64+
loginAuthenticator = object : Authenticator() {
65+
override fun getPasswordAuthentication(): PasswordAuthentication? {
66+
return PasswordAuthentication(emailConfiguration.username, emailConfiguration.password)
67+
}
68+
}
69+
props["mail.smtp.auth"] = "true"
70+
}
71+
72+
if (emailConfiguration.ssl && emailConfiguration.startTls) {
73+
addError("Both SSL and StartTLS cannot be enabled simultaneously")
74+
} else {
75+
if (emailConfiguration.startTls) {
76+
// see also http://jira.qos.ch/browse/LBCORE-225
77+
props["mail.smtp.starttls.enable"] = "true"
78+
}
79+
if (emailConfiguration.ssl) {
80+
val SSL_FACTORY = "javax.net.ssl.SSLSocketFactory"
81+
props["mail.smtp.socketFactory.port"] = emailConfiguration.port
82+
props["mail.smtp.socketFactory.class"] = SSL_FACTORY
83+
props["mail.smtp.socketFactory.fallback"] = "true"
84+
}
85+
}
86+
87+
// props.put("mail.debug", "true");
88+
89+
session = Session.getInstance(props, loginAuthenticator)
90+
} catch (e: Exception) {
91+
addError("Error to get email configuration")
92+
}
93+
94+
// }
95+
super.sendBuffer(cb, lastEventObject)
96+
}
97+
}

mycollab-server-runner/src/main/resources/logback-spring.xml renamed to mycollab-config/src/main/resources/logback-spring.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,20 @@
55
<Target>System.out</Target>
66
<encoder>
77
<pattern>%d{"HH:mm:ss,SSS"} %5p %c:%L - %m%n</pattern>
8-
<!--<pattern>%d{"HH:mm:ss,SSS"} %5p %c{1}:%L - %m%n</pattern>-->
98
</encoder>
109
</appender>
11-
<!--
10+
1211
<appender name="email" class="com.mycollab.logging.MailAppender">
1312
<layout class="ch.qos.logback.classic.PatternLayout">
1413
<pattern>%5p %c{1}:%L - %m%n</pattern>
1514
</layout>
1615
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
1716
<level>ERROR</level>
1817
</filter>
18+
<filter class="com.mycollab.logging.ExceptionFilter"/>
19+
<filter class="com.mycollab.logging.LogFilter"/>
1920
</appender>
20-
-->
21+
2122
<appender name="R" class="ch.qos.logback.core.rolling.RollingFileAppender">
2223
<file>logs/mycollab.out</file>
2324
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
@@ -40,5 +41,6 @@
4041
<root level="INFO">
4142
<appender-ref ref="stdout"/>
4243
<appender-ref ref="R"/>
44+
<appender-ref ref="email"/>
4345
</root>
4446
</configuration>

0 commit comments

Comments
 (0)