mirror of
https://github.com/ArenMg/aren.git
synced 2024-12-23 07:19:46 +00:00
Merge branch 'lastdev' of https://github.com/ArenMg/aren into lastdev
This commit is contained in:
commit
9ba4c7b813
14 changed files with 356 additions and 31 deletions
|
@ -99,6 +99,9 @@ public class Debate extends AbstractOwnedEntity implements Serializable {
|
||||||
@Column(name = "open_public")
|
@Column(name = "open_public")
|
||||||
private boolean openPublic = false;
|
private boolean openPublic = false;
|
||||||
|
|
||||||
|
@Column(name = "is_carto")
|
||||||
|
private boolean carto = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
|
@ -346,6 +349,22 @@ public class Debate extends AbstractOwnedEntity implements Serializable {
|
||||||
this.openPublic = openPublic;
|
this.openPublic = openPublic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isCarto() {
|
||||||
|
return carto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param carto
|
||||||
|
*/
|
||||||
|
public void setCarto(boolean carto) {
|
||||||
|
this.carto = carto;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
|
|
|
@ -59,6 +59,21 @@ public class Document extends AbstractDatedEntity implements Serializable {
|
||||||
@Column(name = "debates_count")
|
@Column(name = "debates_count")
|
||||||
private Integer debatesCount = 0;
|
private Integer debatesCount = 0;
|
||||||
|
|
||||||
|
@Column(name = "is_carto")
|
||||||
|
private boolean carto = false;
|
||||||
|
|
||||||
|
@Column(name = "mesh_line")
|
||||||
|
private int meshLine = 1;
|
||||||
|
|
||||||
|
@Column(name = "mesh_column")
|
||||||
|
private int meshColumn = 1;
|
||||||
|
|
||||||
|
@Lob
|
||||||
|
@Type(type = "org.hibernate.type.TextType")
|
||||||
|
@Column(name = "map_link")
|
||||||
|
private String mapLink;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
|
@ -165,6 +180,54 @@ public class Document extends AbstractDatedEntity implements Serializable {
|
||||||
return debates.isEmpty();
|
return debates.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isCarto() {
|
||||||
|
return carto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param carto
|
||||||
|
*/
|
||||||
|
public void setCarto(boolean carto) {
|
||||||
|
this.carto = carto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int getMeshLine() {
|
||||||
|
return meshLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param meshLine
|
||||||
|
*/
|
||||||
|
public void setMeshLine(int meshLine) {
|
||||||
|
this.meshLine = meshLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMeshColumn() {
|
||||||
|
return meshColumn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMeshColumn(int meshColumn) {
|
||||||
|
this.meshColumn = meshColumn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMapLink() {
|
||||||
|
return mapLink;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMapLink(String mapLink) {
|
||||||
|
this.mapLink = mapLink;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
|
|
|
@ -58,6 +58,10 @@ public class Team extends AbstractEntEntity implements Serializable {
|
||||||
@Column(name = "debates_count")
|
@Column(name = "debates_count")
|
||||||
private Integer debatesCount = 0;
|
private Integer debatesCount = 0;
|
||||||
|
|
||||||
|
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||||
|
@Column(name = "debates_carto_count")
|
||||||
|
private Integer debatesCartoCount = 0;
|
||||||
|
|
||||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||||
@Column(name = "users_count")
|
@Column(name = "users_count")
|
||||||
private Integer usersCount = 0;
|
private Integer usersCount = 0;
|
||||||
|
|
|
@ -290,6 +290,7 @@ public class User extends AbstractEntEntity implements Serializable {
|
||||||
this.invitedDebates = invitedDebates;
|
this.invitedDebates = invitedDebates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
|
|
38
src/main/java/fr/lirmm/aren/model/vm/VMNotification.java
Normal file
38
src/main/java/fr/lirmm/aren/model/vm/VMNotification.java
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
package fr.lirmm.aren.model.vm;
|
||||||
|
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ANDRIAMBOLAHARIMIHANTA Havana on 01/08/2021
|
||||||
|
* @project aren-1
|
||||||
|
*/
|
||||||
|
public class VMNotification {
|
||||||
|
private String link ;
|
||||||
|
private List<String>emails ;
|
||||||
|
private String expiracy ;
|
||||||
|
public String getLink() {
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLink(String link) {
|
||||||
|
this.link = link;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getEmails() {
|
||||||
|
return emails;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmails(List<String> emails) {
|
||||||
|
this.emails = emails;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getExpiracy() {
|
||||||
|
return expiracy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpiracy(String expiracy) {
|
||||||
|
this.expiracy = expiracy;
|
||||||
|
}
|
||||||
|
}
|
|
@ -58,36 +58,36 @@ public class DebateService extends AbstractService<Debate> {
|
||||||
boolean isUser = user != null && user.is(Authority.USER) && !user.is(Authority.ADMIN);
|
boolean isUser = user != null && user.is(Authority.USER) && !user.is(Authority.ADMIN);
|
||||||
boolean onlyPublic = user != null && user.getAuthority().equals(Authority.GUEST);
|
boolean onlyPublic = user != null && user.getAuthority().equals(Authority.GUEST);
|
||||||
TypedQuery<Debate> query = getEntityManager().createQuery("SELECT d "
|
TypedQuery<Debate> query = getEntityManager().createQuery("SELECT d "
|
||||||
+ "FROM Debate d "
|
+ "FROM Debate d "
|
||||||
+ (withComments
|
+ (withComments
|
||||||
? "LEFT JOIN FETCH d.comments c "
|
? "LEFT JOIN FETCH d.comments c "
|
||||||
: "")
|
: "")
|
||||||
+ (withTeams || withUsers || isUser
|
+ (withTeams || withUsers || isUser
|
||||||
? "LEFT JOIN " + (withTeams || withUsers ? "FETCH" : "") + " d.teams t "
|
? "LEFT JOIN " + (withTeams || withUsers ? "FETCH" : "") + " d.teams t "
|
||||||
: "")
|
: "")
|
||||||
+ (withUsers || isUser
|
+ (withUsers || isUser
|
||||||
? "LEFT JOIN " + (withUsers ? "FETCH" : "") + " t.users u "
|
? "LEFT JOIN " + (withUsers ? "FETCH" : "") + " t.users u "
|
||||||
: "")
|
: "")
|
||||||
+ (withGuests || isUser
|
+ (withGuests || isUser
|
||||||
? "LEFT JOIN " + (withGuests ? "FETCH" : "") + " d.guests g "
|
? "LEFT JOIN " + (withGuests ? "FETCH" : "") + " d.guests g "
|
||||||
: "")
|
: "")
|
||||||
+ (withDocument
|
+ (withDocument
|
||||||
? "LEFT JOIN FETCH d.document do "
|
? "LEFT JOIN FETCH d.document do "
|
||||||
: "")
|
: "")
|
||||||
+ (debateId != null
|
+ (debateId != null
|
||||||
? "WHERE d.id = :debateId "
|
? "WHERE d.id = :debateId "
|
||||||
: "WHERE d.id IS NOT NULL ")
|
: "WHERE d.id IS NOT NULL ")
|
||||||
+ (categoryId != null
|
+ (categoryId != null
|
||||||
? "AND d.document.category.id = :categoryId "
|
? "AND d.document.category.id = :categoryId "
|
||||||
: "")
|
: "")
|
||||||
+ (isUser
|
+ (isUser
|
||||||
? "AND (d.openPublic IS TRUE "
|
? "AND (d.openPublic IS TRUE "
|
||||||
+ "OR :user = d.owner "
|
+ "OR :user = d.owner "
|
||||||
+ "OR :user IN g "
|
+ "OR :user IN g "
|
||||||
+ "OR :user IN u) "
|
+ "OR :user IN u) "
|
||||||
: (onlyPublic
|
: (onlyPublic
|
||||||
? "AND d.openPublic IS TRUE "
|
? "AND d.openPublic IS TRUE "
|
||||||
: "")),
|
: "")),
|
||||||
Debate.class
|
Debate.class
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -122,6 +122,26 @@ public class DebateService extends AbstractService<Debate> {
|
||||||
return results.get(0);
|
return results.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void remove(Long debateId){
|
||||||
|
super.transactionBegin();
|
||||||
|
try{
|
||||||
|
getEntityManager().createNativeQuery("DELETE FROM debates_teams WHERE debate_id=:debateId")
|
||||||
|
.setParameter("debateId",debateId)
|
||||||
|
.executeUpdate() ;
|
||||||
|
getEntityManager().createNativeQuery("DELETE FROM debates_guests WHERE debate_id=:debateId")
|
||||||
|
.setParameter("debateId",debateId)
|
||||||
|
.executeUpdate() ;
|
||||||
|
getEntityManager().createNativeQuery("DELETE FROM notifications WHERE debate_id = :debateId")
|
||||||
|
.setParameter("debateId", debateId)
|
||||||
|
.executeUpdate();
|
||||||
|
super.commit();
|
||||||
|
Debate debate=super.find(debateId) ;
|
||||||
|
super.remove(debate);
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param user
|
* @param user
|
||||||
|
@ -172,15 +192,15 @@ public class DebateService extends AbstractService<Debate> {
|
||||||
public void clearComments(Long debateId) {
|
public void clearComments(Long debateId) {
|
||||||
this.transactionBegin();
|
this.transactionBegin();
|
||||||
getEntityManager().createQuery("DELETE FROM Comment c "
|
getEntityManager().createQuery("DELETE FROM Comment c "
|
||||||
+ "WHERE c.debate.id = :debateId")
|
+ "WHERE c.debate.id = :debateId")
|
||||||
.setParameter("debateId", debateId)
|
.setParameter("debateId", debateId)
|
||||||
.executeUpdate();
|
.executeUpdate();
|
||||||
getEntityManager().createQuery("UPDATE Debate d SET "
|
getEntityManager().createQuery("UPDATE Debate d SET "
|
||||||
+ "d.commentsCount = 0, "
|
+ "d.commentsCount = 0, "
|
||||||
+ "d.commentsCountFor = 0, "
|
+ "d.commentsCountFor = 0, "
|
||||||
+ "d.commentsCountAgainst = 0, "
|
+ "d.commentsCountAgainst = 0, "
|
||||||
+ "d.lastCommentDate = null "
|
+ "d.lastCommentDate = null "
|
||||||
+ "WHERE d.id = :debateId")
|
+ "WHERE d.id = :debateId")
|
||||||
.setParameter("debateId", debateId)
|
.setParameter("debateId", debateId)
|
||||||
.executeUpdate();
|
.executeUpdate();
|
||||||
this.commit();
|
this.commit();
|
||||||
|
@ -193,18 +213,18 @@ public class DebateService extends AbstractService<Debate> {
|
||||||
public void updateExternaleTables(Debate debate) {
|
public void updateExternaleTables(Debate debate) {
|
||||||
super.transactionBegin();
|
super.transactionBegin();
|
||||||
getEntityManager().createQuery("UPDATE Category c SET "
|
getEntityManager().createQuery("UPDATE Category c SET "
|
||||||
+ "c.debatesCount = (SELECT COUNT(d) FROM c.documents doc LEFT JOIN doc.debates d) "
|
+ "c.debatesCount = (SELECT COUNT(d) FROM c.documents doc LEFT JOIN doc.debates d) "
|
||||||
+ "WHERE c.id = :id")
|
+ "WHERE c.id = :id")
|
||||||
.setParameter("id", debate.getDocument().getCategory().getId())
|
.setParameter("id", debate.getDocument().getCategory().getId())
|
||||||
.executeUpdate();
|
.executeUpdate();
|
||||||
getEntityManager().createQuery("UPDATE Document doc SET "
|
getEntityManager().createQuery("UPDATE Document doc SET "
|
||||||
+ "doc.debatesCount = (SELECT COUNT(d) FROM doc.debates d) "
|
+ "doc.debatesCount = (SELECT COUNT(d) FROM doc.debates d) "
|
||||||
+ "WHERE doc.id = :id")
|
+ "WHERE doc.id = :id")
|
||||||
.setParameter("id", debate.getDocument().getId())
|
.setParameter("id", debate.getDocument().getId())
|
||||||
.executeUpdate();
|
.executeUpdate();
|
||||||
getEntityManager().createQuery("UPDATE Team t SET "
|
getEntityManager().createQuery("UPDATE Team t SET "
|
||||||
+ "t.debatesCount = (SELECT COUNT(d) from t.debates d) "
|
+ "t.debatesCount = (SELECT COUNT(d) from t.debates d) "
|
||||||
+ "WHERE t IN (SELECT t1 FROM Debate d LEFT JOIN d.teams t1 WHERE d.id = :id)")
|
+ "WHERE t IN (SELECT t1 FROM Debate d LEFT JOIN d.teams t1 WHERE d.id = :id)")
|
||||||
.setParameter("id", debate.getId())
|
.setParameter("id", debate.getId())
|
||||||
.executeUpdate();
|
.executeUpdate();
|
||||||
super.commit();
|
super.commit();
|
||||||
|
|
|
@ -0,0 +1,125 @@
|
||||||
|
package fr.lirmm.aren.service.vm;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import fr.lirmm.aren.model.User;
|
||||||
|
import fr.lirmm.aren.model.vm.VMNotification;
|
||||||
|
import fr.lirmm.aren.model.vm.VMTheme;
|
||||||
|
import fr.lirmm.aren.producer.Configurable;
|
||||||
|
import fr.lirmm.aren.service.MailingService;
|
||||||
|
|
||||||
|
import javax.enterprise.context.ApplicationScoped;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.mail.*;
|
||||||
|
import javax.mail.internet.InternetAddress;
|
||||||
|
import javax.mail.internet.MimeMessage;
|
||||||
|
import java.io.File;
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ANDRIAMBOLAHARIMIHANTA Havana on 18/07/2021
|
||||||
|
* @project aren-1
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ApplicationScoped
|
||||||
|
public class VMSendNotificationService extends Thread implements Runnable{
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@Configurable("reverse-proxy")
|
||||||
|
private String reverseProxy;
|
||||||
|
|
||||||
|
public VMSendNotificationService() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(){
|
||||||
|
int i=0 ;
|
||||||
|
try {
|
||||||
|
VMNotification notification=null ;
|
||||||
|
while(true){
|
||||||
|
File file = new File("/aren/tmp/vote_majoritaire.json");
|
||||||
|
if((file.exists() && notification==null) || notification.getEmails().size()==0){
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
Map<?, ?> map = (Map<String, Object>) mapper.readValue(file, Map.class);
|
||||||
|
notification=new VMNotification() ;
|
||||||
|
for (Map.Entry<?, ?> entry : map.entrySet()) {
|
||||||
|
switch(entry.getKey().toString()){
|
||||||
|
case "link":
|
||||||
|
notification.setLink(entry.getValue().toString());
|
||||||
|
break;
|
||||||
|
case "expiracy":
|
||||||
|
notification.setExpiracy(entry.getValue().toString());
|
||||||
|
break;
|
||||||
|
case "emails":
|
||||||
|
notification.setEmails((List<String>) entry.getValue());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(notification!=null){
|
||||||
|
final String link=notification.getLink() ;
|
||||||
|
ZonedDateTime dateTime=ZonedDateTime.now();
|
||||||
|
if(dateTime.getHour()==20 && dateTime.getMinute()==0 && dateTime.getSecond()==0) {
|
||||||
|
notification.getEmails().forEach(email->{
|
||||||
|
try {
|
||||||
|
sendNotification(link,email,"mail_vm_notification_subject","mail_vm_notification_body");
|
||||||
|
} catch (MessagingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i++ ;
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
}catch (Exception ex){
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void sendNotification(String link, String adress, String subject, String body) throws MessagingException {
|
||||||
|
Locale currentLocale = Locale.getDefault();
|
||||||
|
ResourceBundle messages = ResourceBundle.getBundle("messages", currentLocale);
|
||||||
|
ResourceBundle application_config = ResourceBundle.getBundle("application", currentLocale);
|
||||||
|
|
||||||
|
String localSubject;
|
||||||
|
String localBody;
|
||||||
|
|
||||||
|
localSubject = messages.getString(subject);
|
||||||
|
localBody = MessageFormat.format(messages.getString(body), link, link);
|
||||||
|
System.out.println(localBody) ;
|
||||||
|
|
||||||
|
Properties properties=System.getProperties() ;
|
||||||
|
properties.put("mail.smtp.host",application_config.getString("smtp.server")) ;
|
||||||
|
properties.put("mail.smtp.auth", application_config.getString("smtp.auth"));
|
||||||
|
properties.put("mail.smtp.starttls.enable", application_config.getString("smtp.tls"));
|
||||||
|
properties.put("mail.smtp.port", application_config.getString("smtp.port"));
|
||||||
|
|
||||||
|
Authenticator auth = new Authenticator() {
|
||||||
|
//override the getPasswordAuthentication method
|
||||||
|
protected PasswordAuthentication getPasswordAuthentication() {
|
||||||
|
return new PasswordAuthentication(application_config.getString("smtp.username"), application_config.getString("smtp.password"));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Session session = Session.getInstance(properties,auth) ;
|
||||||
|
|
||||||
|
// Create a default MimeMessage object.
|
||||||
|
Message message = new MimeMessage(session);
|
||||||
|
|
||||||
|
// Set From: header field of the header.
|
||||||
|
message.setFrom(new InternetAddress(application_config.getString("smtp.username")));
|
||||||
|
|
||||||
|
// Set To: header field of the header.
|
||||||
|
message.setRecipients(Message.RecipientType.TO,
|
||||||
|
InternetAddress.parse(adress));
|
||||||
|
|
||||||
|
// Set Subject: header field
|
||||||
|
message.setSubject(localSubject);
|
||||||
|
|
||||||
|
// Send the actual HTML message, as big as you like
|
||||||
|
message.setContent(localBody, "text/html");
|
||||||
|
|
||||||
|
// Send message
|
||||||
|
Transport.send(message);
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,8 @@ import fr.lirmm.aren.service.AbstractService;
|
||||||
import javax.enterprise.context.ApplicationScoped;
|
import javax.enterprise.context.ApplicationScoped;
|
||||||
import javax.persistence.TypedQuery;
|
import javax.persistence.TypedQuery;
|
||||||
import javax.ws.rs.NotFoundException;
|
import javax.ws.rs.NotFoundException;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -35,8 +37,10 @@ public class VMThemeService extends AbstractService<VMTheme> {
|
||||||
}
|
}
|
||||||
return query ;
|
return query ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<VMTheme> findAll(boolean withChoices, boolean withVotes) {
|
public Set<VMTheme> findAll(boolean withChoices, boolean withVotes) {
|
||||||
return new HashSet<VMTheme>(generateQuery(null, withChoices,withVotes).getResultList());
|
List<VMTheme> themes=generateQuery(null, withChoices,withVotes).getResultList() ;
|
||||||
|
return new HashSet<>(themes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
package fr.lirmm.aren.servlet;
|
package fr.lirmm.aren.servlet;
|
||||||
|
|
||||||
import fr.lirmm.aren.service.CommentService;
|
import fr.lirmm.aren.service.CommentService;
|
||||||
|
import fr.lirmm.aren.service.vm.VMSendNotificationService;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
@ -42,6 +44,9 @@ public class BackgroundJobManager implements ServletContextListener {
|
||||||
this.scheduler.scheduleAtFixedRate(() -> {
|
this.scheduler.scheduleAtFixedRate(() -> {
|
||||||
this.commentService.updateAllTags();
|
this.commentService.updateAllTags();
|
||||||
}, untilMidnight, millisInDay, TimeUnit.MILLISECONDS);
|
}, untilMidnight, millisInDay, TimeUnit.MILLISECONDS);
|
||||||
|
|
||||||
|
VMSendNotificationService sendNotificationService=new VMSendNotificationService() ;
|
||||||
|
sendNotificationService.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -43,6 +43,7 @@ public class Root implements Filter {
|
||||||
String path = request.getRequestURI().substring(request.getContextPath().length());
|
String path = request.getRequestURI().substring(request.getContextPath().length());
|
||||||
if (!path.startsWith("/caslogin") && !path.startsWith("/ws/") && !path.startsWith("/assets/")) {
|
if (!path.startsWith("/caslogin") && !path.startsWith("/ws/") && !path.startsWith("/assets/")) {
|
||||||
request.getRequestDispatcher("/index.jsp").forward(request, response);
|
request.getRequestDispatcher("/index.jsp").forward(request, response);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
chain.doFilter(request, response);
|
chain.doFilter(request, response);
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,9 +151,10 @@ public class DebateRESTFacade extends AbstractRESTFacade<Debate> {
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@RolesAllowed({"MODO"})
|
@RolesAllowed({"ADMIN"})
|
||||||
public void remove(Long id) {
|
public void remove(Long id) {
|
||||||
super.remove(id);
|
debateService.clearComments(id);
|
||||||
|
debateService.remove(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -211,7 +212,6 @@ public class DebateRESTFacade extends AbstractRESTFacade<Debate> {
|
||||||
@Path("{id}/comments")
|
@Path("{id}/comments")
|
||||||
@RolesAllowed({"ADMIN"})
|
@RolesAllowed({"ADMIN"})
|
||||||
public void clear(@PathParam("id") Long id) {
|
public void clear(@PathParam("id") Long id) {
|
||||||
|
|
||||||
debateService.clearComments(id);
|
debateService.clearComments(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,5 +83,4 @@ public class NotificationRESTFacade extends AbstractRESTFacade<Notification> {
|
||||||
}
|
}
|
||||||
return entityToUpdate;
|
return entityToUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
package fr.lirmm.aren.ws.rest;
|
package fr.lirmm.aren.ws.rest;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import fr.lirmm.aren.model.Team;
|
||||||
import fr.lirmm.aren.model.vm.VMChoice;
|
import fr.lirmm.aren.model.vm.VMChoice;
|
||||||
|
import fr.lirmm.aren.model.vm.VMNotification;
|
||||||
|
import fr.lirmm.aren.model.vm.VMTeam;
|
||||||
import fr.lirmm.aren.model.vm.VMTheme;
|
import fr.lirmm.aren.model.vm.VMTheme;
|
||||||
|
import fr.lirmm.aren.service.TeamService;
|
||||||
import fr.lirmm.aren.service.vm.VMChoiceService;
|
import fr.lirmm.aren.service.vm.VMChoiceService;
|
||||||
import fr.lirmm.aren.service.vm.VMThemeService;
|
import fr.lirmm.aren.service.vm.VMThemeService;
|
||||||
import fr.lirmm.aren.service.vm.VMVoteService;
|
import fr.lirmm.aren.service.vm.VMVoteService;
|
||||||
|
@ -14,6 +19,9 @@ import javax.inject.Inject;
|
||||||
import javax.ws.rs.DELETE;
|
import javax.ws.rs.DELETE;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.PathParam;
|
import javax.ws.rs.PathParam;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,6 +40,9 @@ public class VMThemeRESTFacade extends AbstractRESTFacade<VMTheme>{
|
||||||
@Inject
|
@Inject
|
||||||
VMVoteService voteService ;
|
VMVoteService voteService ;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
TeamService teamService ;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected VMThemeService getService() {
|
protected VMThemeService getService() {
|
||||||
return themeService;
|
return themeService;
|
||||||
|
@ -41,8 +52,40 @@ public class VMThemeRESTFacade extends AbstractRESTFacade<VMTheme>{
|
||||||
//@RolesAllowed({"ADMIN"})
|
//@RolesAllowed({"ADMIN"})
|
||||||
@PermitAll
|
@PermitAll
|
||||||
public VMTheme create(VMTheme theme){
|
public VMTheme create(VMTheme theme){
|
||||||
System.out.println(theme.toString());
|
VMTheme res= super.create(theme);
|
||||||
return super.create(theme);
|
try{
|
||||||
|
File file = new File("/aren/tmp/vote_majoritaire.json");
|
||||||
|
File directory = new File("/aren/tmp");
|
||||||
|
if (! directory.exists()){
|
||||||
|
directory.mkdirs() ;
|
||||||
|
}
|
||||||
|
System.out.println(file.getAbsolutePath());
|
||||||
|
if(!file.exists())
|
||||||
|
file.createNewFile() ;
|
||||||
|
VMNotification notification=new VMNotification() ;
|
||||||
|
List<String> emails=new ArrayList<>() ;
|
||||||
|
Team team=teamService.find(theme.getTeam().getId());
|
||||||
|
team.getUsers().forEach(user->{
|
||||||
|
emails.add(user.getEmail()) ;
|
||||||
|
});
|
||||||
|
notification.setExpiracy(theme.getExpiracyDate().toString());
|
||||||
|
String serverRoot = request.getRequestURL().substring(0, request.getRequestURL().length() - "/ws/vm/themes".length());
|
||||||
|
notification.setLink(serverRoot+"/votemajoritairedetails?id="+res.getId());
|
||||||
|
notification.setEmails(emails);
|
||||||
|
String []emails_array=new String[notification.getEmails().size()] ;
|
||||||
|
for(int j=0 ; j<emails_array.length ; j++){
|
||||||
|
emails_array[j]=notification.getEmails().get(j) ;
|
||||||
|
}
|
||||||
|
Map<String, Object> map = new HashMap<>() ;
|
||||||
|
map.put("link",notification.getLink()) ;
|
||||||
|
map.put("expiracy",notification.getExpiracy()) ;
|
||||||
|
map.put("emails",emails_array) ;
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
mapper.writeValue(file,map);
|
||||||
|
}catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return res ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -23,3 +23,6 @@ mail_new_user_body: <p>Bonjour,</p><p>Pour poursuivre l''activation de votre com
|
||||||
|
|
||||||
mail_reset_password_subject: Réinitialisation du mot de passe
|
mail_reset_password_subject: Réinitialisation du mot de passe
|
||||||
mail_reset_password_body: <p>Bonjour,</p><p>Une demande de réinitialisation de mot de passe à été faite en votre nom pour la plateforme AREN.</p><p>Si vous êtes l''auteur\u22c5e de cette demande, pour réinitialiser votre mot de passe, <a href="{0}">cliquer ici</a></p><p>Si le lien ne fonctionne pas, veuillez copier-coller l''url suivante dans la barre d''adresse de votre navigateur : <br><span style="color:blue">{0}</span></p><br><p><b>Attention ce lien n''est valable que pendant 24h</b>.</p><br><p>Si vous n''êtes pas l''auteur\u22c5e de cette demande, vous pouvez ignorer cet e-mail.</p><br><p>PS : Veuillez ne pas répondre à ce mail qui est envoyé automatiquement par l''application de gestion de comptes informatiques.</p>
|
mail_reset_password_body: <p>Bonjour,</p><p>Une demande de réinitialisation de mot de passe à été faite en votre nom pour la plateforme AREN.</p><p>Si vous êtes l''auteur\u22c5e de cette demande, pour réinitialiser votre mot de passe, <a href="{0}">cliquer ici</a></p><p>Si le lien ne fonctionne pas, veuillez copier-coller l''url suivante dans la barre d''adresse de votre navigateur : <br><span style="color:blue">{0}</span></p><br><p><b>Attention ce lien n''est valable que pendant 24h</b>.</p><br><p>Si vous n''êtes pas l''auteur\u22c5e de cette demande, vous pouvez ignorer cet e-mail.</p><br><p>PS : Veuillez ne pas répondre à ce mail qui est envoyé automatiquement par l''application de gestion de comptes informatiques.</p>
|
||||||
|
|
||||||
|
mail_vm_notification_subject: Notification sur le vote
|
||||||
|
mail_vm_notification_body : <p>Bonjour,</p><p>Pour poursuivre l''evolution du vote sur la plateforme AREN veuillez <a href="{0}">cliquer ici</a></p><p>Si le lien ne fonctionne pas, veuillez copier-coller l''url suivante dans la barre d''adresse de votre navigateur : <br><span style="font-size: 10px;text-decoration: underline;">{0}</span></p><br><br><p>PS : Veuillez ne pas répondre à ce mail qui est envoyé automatiquement par l''application de gestion de comptes informatiques.</p>
|
Loading…
Reference in a new issue