1 /*******************************************************************************
2 * Copyright � Igor Barma, Alexandre Desoubeaux, Christian Martel, Eric Brun, Mathieu Amblard, Gwenael Gevet, Pierre Guillot, 2012
3 * Copyright Alexandre Desoubeaux, Christian Martel, Cedric Lecarpentier, Alexandre Lefevre, Marc Salvat 2014-2016
4 * Copyright Alexandre Desoubeaux, Christian Martel, Cedric Lecarpentier, Marc Salvat, Marc Suarez, Harifetra Ramamonjy 2017
6 * This file is part of the work and learning management system Pentila Nero.
8 * Pentila Nero is free software. You can redistribute it and/or modify since
9 * you respect the terms of either (at least one of the both license) :
10 * - under the terms of the GNU Affero General Public License as
11 * published by the Free Software Foundation, either version 3 of the
12 * License, or (at your option) any later version.
13 * - the CeCILL-C as published by CeCILL-C; either version 1 of the
14 * License, or any later version
15 * - the GNU Lesser General Public License as published by the
16 * Free Software Foundation, either version 3 of the license,
17 * or (at your option) any later version.
19 * There are special exceptions to the terms and conditions of the
20 * licenses as they are applied to this software. View the full text of
21 * the exception in file LICENSE-PROJECT.txt in the directory of this software
24 * Pentila Nero is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * Licenses for more details.
29 * You should have received a copy of the GNU Affero General Public License
30 * and the CeCILL-C and the GNU Lesser General Public License along with
31 * Pentila Nero. If not, see :
32 * <http://www.gnu.org/licenses/> and
33 * <http://www.cecill.info/licences.fr.html>.
34 ******************************************************************************/
35 package com.pentila.entSavoie.internalMessaging;
39 import com.liferay.portal.kernel.json.JSONArray;
40 import com.liferay.portal.model.User;
41 import com.liferay.portal.security.auth.PrincipalThreadLocal;
42 import com.liferay.portal.security.permission.PermissionChecker;
43 import com.liferay.portal.security.permission.PermissionCheckerFactoryUtil;
44 import com.liferay.portal.security.permission.PermissionThreadLocal;
45 import com.pentila.entSavoie.utils.ENTSendingUtil;
48 public class ThreadSendMessage extends Thread{
51 private Set<Long> destFinal;
52 private String subject;
53 private String content;
54 private JSONArray attachFiles;
56 private Boolean toCasier;
57 private String destMail;
58 private String ccMail;
59 private String cciMail;
60 private Long accountId;
61 private String accountPassword;
62 private long messageId;
64 public ThreadSendMessage(User u, Set<Long> df, String s, String c, JSONArray af, long messageId, String destMail, String ccMail, String cciMail, Long accountId, String accountPassword, Boolean toIm, Boolean toCasier) {
69 this.attachFiles = af;
71 this.toCasier = toCasier;
72 this.destMail = destMail;
74 this.messageId = messageId;
75 this.cciMail = cciMail;
76 this.accountId = accountId;
77 this.accountPassword = accountPassword;
78 this.setUncaughtExceptionHandler(new UncaughtExceptionSendMessageHandler(this.user, this.subject));
81 public ThreadSendMessage(User u, Set<Long> df, String s, String c, JSONArray af, Boolean toIm, Boolean toCasier) {
86 this.attachFiles = af;
88 this.toCasier = toCasier;
91 this.accountId = new Long(0);
92 this.accountPassword = "";
93 this.setUncaughtExceptionHandler(new UncaughtExceptionSendMessageHandler(this.user, this.subject));
99 PrincipalThreadLocal.setName(this.user.getUserId());
100 PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(this.user);
101 PermissionThreadLocal.setPermissionChecker(permissionChecker);
102 ENTSendingUtil.sendMessageToUsers(this.user, this.destFinal, this.subject, this.content, this.attachFiles, this.messageId, this.destMail, this.ccMail, this.cciMail, this.accountId, this.accountPassword, this.toIm, this.toCasier);
103 } catch (Exception e) {
104 System.out.println("ereur de thread TSM");