diff --git a/README.md b/README.md index a24c53a..138fe85 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![Build Status](https://travis-ci.org/ApplETS/applets-java-api.svg?branch=master)](https://travis-ci.org/ApplETS/applets-java-api) [![Coverage Status](https://coveralls.io/repos/github/ApplETS/applets-java-api/badge.svg?branch=master)](https://coveralls.io/github/ApplETS/applets-java-api?branch=master) -[![Run in Postman](https://run.pstmn.io/button.svg)](https://app.getpostman.com/run-collection/ba698d57365064fe6007) + Vue d'ensemble ======== @@ -16,13 +16,9 @@ Liens rapides : Requêtes actuelles dans l'API ======== -- Afficher les partenaires : https://api3.clubapplets.ca/partners -- Cooptel : https://api3.clubapplets.ca/cooptel?phase=[1 à 4]&appt=[num] -- Event sources : https://api3.clubapplets.ca/events/sources -- Events : https://api3.clubapplets.ca/events/list/[nomsource] -- Nouvelle sources : https://api3.clubapplets.ca/news/sources -- Nouvelles : https://api3.clubapplets.ca/news/list/[nomsource] -- Version des apps : https://api3.clubapplets.ca/app_version/[ios ou android] +Disponibles dans la collection Postman suivante : +[![Run in Postman](https://run.pstmn.io/button.svg)](https://app.getpostman.com/run-collection/8bb16d836b6212da7c4f) + Outils nécessaires ========== diff --git a/build.gradle b/build.gradle index 799f95c..2f489d6 100644 --- a/build.gradle +++ b/build.gradle @@ -45,10 +45,13 @@ dependencies { compile 'log4j:log4j:1.2.17' + compile 'com.restfb:restfb:1.35.0' compile 'org.postgresql:postgresql:9.4-1206-jdbc42' + compile 'org.mnode.ical4j:ical4j:2.0.0' - testCompile 'junit:junit:4.12' + + testCompile 'junit:junit:4.12' testCompile 'org.glassfish.jersey.test-framework:project:2.23.2' testCompile 'org.glassfish.jersey.test-framework.providers:jersey-test-framework-provider-grizzly2:2.23.2' diff --git a/src/main/java/applets/etsmtl/ca/MyApplication.java b/src/main/java/applets/etsmtl/ca/MyApplication.java index 7aa8af1..b0d4326 100644 --- a/src/main/java/applets/etsmtl/ca/MyApplication.java +++ b/src/main/java/applets/etsmtl/ca/MyApplication.java @@ -31,7 +31,7 @@ public MyApplication() { .withIdentity("triggersources", "group1") .withSchedule( SimpleScheduleBuilder.simpleSchedule() - .withIntervalInSeconds(5000).repeatForever()) + .withIntervalInSeconds(60*60*10).repeatForever()) .build(); Trigger trigger_events = TriggerBuilder @@ -39,7 +39,7 @@ public MyApplication() { .withIdentity("triggerevents", "group2") .withSchedule( SimpleScheduleBuilder.simpleSchedule() - .withIntervalInSeconds(2500).repeatForever()) + .withIntervalInSeconds(60*60*2).repeatForever()) .build(); Trigger trigger_news = TriggerBuilder @@ -47,7 +47,7 @@ public MyApplication() { .withIdentity("triggernews", "group3") .withSchedule( SimpleScheduleBuilder.simpleSchedule() - .withIntervalInSeconds(2500).repeatForever()) + .withIntervalInSeconds(60*60).repeatForever()) .build(); diff --git a/src/main/java/applets/etsmtl/ca/app_version/AppVersionResource.java b/src/main/java/applets/etsmtl/ca/app_version/AppVersionResource.java index 54a4dd6..930b620 100644 --- a/src/main/java/applets/etsmtl/ca/app_version/AppVersionResource.java +++ b/src/main/java/applets/etsmtl/ca/app_version/AppVersionResource.java @@ -18,9 +18,6 @@ import javax.ws.rs.PathParam; import java.io.IOException; -/** - * Created by gnut3ll4 on 07/12/15. - */ @Path("app_version") public class AppVersionResource { diff --git a/src/main/java/applets/etsmtl/ca/calendar/CalendarResource.java b/src/main/java/applets/etsmtl/ca/calendar/CalendarResource.java new file mode 100644 index 0000000..a70bcf7 --- /dev/null +++ b/src/main/java/applets/etsmtl/ca/calendar/CalendarResource.java @@ -0,0 +1,128 @@ +package applets.etsmtl.ca.calendar; + + +import applets.etsmtl.ca.calendar.model.CalendarEvent; +import com.squareup.okhttp.OkHttpClient; +import com.squareup.okhttp.Request; +import com.squareup.okhttp.Response; +import net.fortuna.ical4j.data.CalendarBuilder; +import net.fortuna.ical4j.data.ParserException; +import net.fortuna.ical4j.model.Calendar; +import net.fortuna.ical4j.model.component.CalendarComponent; +import net.sf.ehcache.Cache; +import net.sf.ehcache.CacheManager; +import net.sf.ehcache.Element; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import java.io.IOException; +import java.io.InputStream; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + + +@Path("calendar") +public class CalendarResource { + + private static final String CALENDAR_URL = "http://www.google.com/calendar/ical/etsmtl.net_shfr1g6kdra1dcjdl0orb6jico%40group.calendar.google.com/public/basic.ics"; + private SimpleDateFormat dateUrlParser = new SimpleDateFormat("yyyy-MM-dd"); + + @GET + @Path("{id}/{start_date}/{end_date}") + @Produces({MediaType.APPLICATION_JSON}) + public List getCalendarEvents( + @PathParam("id") String id, + @PathParam("start_date") String startDateParam, + @PathParam("end_date") String endDateParam + ) { + + List calendarEvents = new ArrayList<>(); + + //At the moment, there is only one source for the calendar + if (!id.equals("ets")) + return calendarEvents; + + try { + Date startDate = dateUrlParser.parse(startDateParam); + Date endDate = dateUrlParser.parse(endDateParam); + + calendarEvents = getCalendarEvents().stream() + .filter(calendarEvent -> + calendarEvent.getStartDate().after(startDate) && + calendarEvent.getStartDate().before(endDate)) + .collect(Collectors.toList()); + + } catch (ParseException e) { + e.printStackTrace(); + } + + return calendarEvents; + } + + private ArrayList getCalendarEvents() { + ArrayList calendarEvents = new ArrayList<>(); + CacheManager cacheManager = CacheManager.getInstance(); + Cache cache = cacheManager.getCache("calendar"); + + //Return data from the cache, if available + Element element = cache.get("calendar"); + if (element != null) { + return (ArrayList) element.getObjectValue(); + } + + InputStream stream; + + //Download and parse .ics and refresh the cache + try { + + OkHttpClient client = new OkHttpClient(); + + Request request = new Request.Builder() + .url(CALENDAR_URL) + .get() + .build(); + + Response response = client.newCall(request).execute(); + + String redirect = response.header("Location"); + if (redirect != null) { + request = new Request.Builder() + .url(redirect) + .get() + .build(); + response = client.newCall(request).execute(); + } + + stream = response.body().byteStream(); + + CalendarBuilder builder = new CalendarBuilder(); + Calendar calendar = builder.build(stream); + + + SimpleDateFormat dateParser = new SimpleDateFormat("yyyyMMdd"); + + for (CalendarComponent calendarComponent : calendar.getComponents()) { + Date dtstart = dateParser.parse(calendarComponent.getProperty("DTSTART").getValue()); + String uid = calendarComponent.getProperty("UID").getValue(); + Date dtend = dateParser.parse(calendarComponent.getProperty("DTEND").getValue()); + String summary = calendarComponent.getProperty("SUMMARY").getValue(); + + calendarEvents.add(new CalendarEvent(dtstart, uid, dtend, summary)); + } + + cache.put(new Element("calendar", calendarEvents)); + + } catch (ParserException | IOException | ParseException e) { + e.printStackTrace(); + } + + return calendarEvents; + } +} \ No newline at end of file diff --git a/src/main/java/applets/etsmtl/ca/calendar/model/CalendarEvent.java b/src/main/java/applets/etsmtl/ca/calendar/model/CalendarEvent.java new file mode 100644 index 0000000..159f5ed --- /dev/null +++ b/src/main/java/applets/etsmtl/ca/calendar/model/CalendarEvent.java @@ -0,0 +1,63 @@ +package applets.etsmtl.ca.calendar.model; + +import applets.etsmtl.ca.calendar.utils.JsonDateSerializer; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import javax.xml.bind.annotation.XmlRootElement; +import java.io.Serializable; +import java.util.Date; + +@XmlRootElement +public class CalendarEvent implements Serializable { + + private String id; + private String summary; + + @JsonProperty("start_date") + private Date startDate; + @JsonProperty("end_date") + private Date endDate; + + + public CalendarEvent(Date startDate, String id, Date endDate, String summary) { + this.startDate = startDate; + this.id = id; + this.endDate = endDate; + this.summary = summary; + } + + @JsonSerialize(using = JsonDateSerializer.class) + public Date getStartDate() { + return startDate; + } + + public void setStartDate(Date startDate) { + this.startDate = startDate; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @JsonSerialize(using = JsonDateSerializer.class) + public Date getEndDate() { + return endDate; + } + + public void setEndDate(Date endDate) { + this.endDate = endDate; + } + + public String getSummary() { + return summary; + } + + public void setSummary(String summary) { + this.summary = summary; + } + +} diff --git a/src/main/java/applets/etsmtl/ca/calendar/utils/JsonDateSerializer.java b/src/main/java/applets/etsmtl/ca/calendar/utils/JsonDateSerializer.java new file mode 100644 index 0000000..44ea8cc --- /dev/null +++ b/src/main/java/applets/etsmtl/ca/calendar/utils/JsonDateSerializer.java @@ -0,0 +1,21 @@ +package applets.etsmtl.ca.calendar.utils; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; + +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Date; + + +public class JsonDateSerializer extends JsonSerializer { + private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); + + @Override + public void serialize(Date date, JsonGenerator gen, SerializerProvider provider) + throws IOException { + String formattedDate = dateFormat.format(date); + gen.writeString(formattedDate); + } +} \ No newline at end of file diff --git a/src/main/java/applets/etsmtl/ca/cooptel/model/ConsommationDate.java b/src/main/java/applets/etsmtl/ca/cooptel/model/ConsommationDate.java index 3fa4bc1..42a5111 100644 --- a/src/main/java/applets/etsmtl/ca/cooptel/model/ConsommationDate.java +++ b/src/main/java/applets/etsmtl/ca/cooptel/model/ConsommationDate.java @@ -4,10 +4,6 @@ import javax.xml.bind.annotation.XmlRootElement; import java.io.Serializable; -/** - * Created by gnut3ll4 on 08/03/16. - */ - @XmlRootElement public class ConsommationDate implements Serializable { diff --git a/src/main/java/applets/etsmtl/ca/cooptel/model/ConsommationGlobal.java b/src/main/java/applets/etsmtl/ca/cooptel/model/ConsommationGlobal.java index a84d38c..690e24d 100644 --- a/src/main/java/applets/etsmtl/ca/cooptel/model/ConsommationGlobal.java +++ b/src/main/java/applets/etsmtl/ca/cooptel/model/ConsommationGlobal.java @@ -5,10 +5,6 @@ import java.io.Serializable; import java.util.List; -/** - * Created by gnut3ll4 on 08/03/16. - */ - @XmlRootElement public class ConsommationGlobal implements Serializable { float restant; diff --git a/src/main/java/applets/etsmtl/ca/news/EventsResources.java b/src/main/java/applets/etsmtl/ca/news/EventsResources.java index 35c55e4..0d6a522 100644 --- a/src/main/java/applets/etsmtl/ca/news/EventsResources.java +++ b/src/main/java/applets/etsmtl/ca/news/EventsResources.java @@ -14,9 +14,6 @@ import java.util.ArrayList; import java.util.List; -/** - * Created by Marcantvez on 09/03/16. - */ @Path("events") public class EventsResources { diff --git a/src/main/java/applets/etsmtl/ca/news/NewsResources.java b/src/main/java/applets/etsmtl/ca/news/NewsResources.java index 64d1519..abe56dd 100644 --- a/src/main/java/applets/etsmtl/ca/news/NewsResources.java +++ b/src/main/java/applets/etsmtl/ca/news/NewsResources.java @@ -1,9 +1,5 @@ package applets.etsmtl.ca.news; -/** - * Created by gnut3ll4 on 22/01/16. - */ - import applets.etsmtl.ca.news.db.NouvellesDAO; import applets.etsmtl.ca.news.db.SourceDAO; import applets.etsmtl.ca.news.model.Nouvelle; diff --git a/src/main/java/applets/etsmtl/ca/news/db/ConnectionSingleton.java b/src/main/java/applets/etsmtl/ca/news/db/ConnectionSingleton.java index 51e7f0c..3b6867e 100644 --- a/src/main/java/applets/etsmtl/ca/news/db/ConnectionSingleton.java +++ b/src/main/java/applets/etsmtl/ca/news/db/ConnectionSingleton.java @@ -4,9 +4,6 @@ import java.sql.DriverManager; import java.sql.SQLException; -/** - * Created by gnut3ll4 on 24/01/16. - */ public class ConnectionSingleton { //Environment variables diff --git a/src/main/java/applets/etsmtl/ca/news/db/DAO.java b/src/main/java/applets/etsmtl/ca/news/db/DAO.java index 1e8e79d..a70f856 100644 --- a/src/main/java/applets/etsmtl/ca/news/db/DAO.java +++ b/src/main/java/applets/etsmtl/ca/news/db/DAO.java @@ -5,9 +5,6 @@ import java.sql.SQLException; import java.util.List; -/** - * Created by gnut3ll4 on 24/01/16. - */ public abstract class DAO { public Connection connection = ConnectionSingleton.getInstance(); diff --git a/src/main/java/applets/etsmtl/ca/news/db/EventDAO.java b/src/main/java/applets/etsmtl/ca/news/db/EventDAO.java index 48f9de5..c6f85d3 100644 --- a/src/main/java/applets/etsmtl/ca/news/db/EventDAO.java +++ b/src/main/java/applets/etsmtl/ca/news/db/EventDAO.java @@ -10,9 +10,6 @@ import java.util.Collections; import java.util.List; -/** - * Created by marcantvez on 24/01/16. - */ public class EventDAO extends DAO { @Override @@ -173,6 +170,48 @@ public void add(Event event) { } } + public void update(Event event) { + try { + + String req_insert_event = "" + + "UPDATE evenements " + + "SET nom = ?, debut = ?, fin = ?, nom_lieu = ?, ville = ?, etat = ?, pays = ?, " + + "adresse = ?, code_postal = ?, longitude = ?, latitude = ?, description = ?, " + + "image = ?, id_source = ? " + + "WHERE id = ?"; + PreparedStatement preparedStatement = ConnectionSingleton.getInstance().prepareStatement(req_insert_event); + + preparedStatement.setString(15, event.getId()); + preparedStatement.setString(1, event.getNom()); + + if(event.getDebut() != null) + preparedStatement.setTimestamp(2, new java.sql.Timestamp(event.getDebut().getTime())); + else + preparedStatement.setTimestamp(2, null); + + if(event.getFin() != null) + preparedStatement.setTimestamp(3, new java.sql.Timestamp(event.getFin().getTime())); + else + preparedStatement.setTimestamp(3, null); + + preparedStatement.setString(4, event.getNom_lieu()); + preparedStatement.setString(5, event.getVille()); + preparedStatement.setString(6, event.getEtat()); + preparedStatement.setString(7, event.getPays()); + preparedStatement.setString(8, event.getAdresse()); + preparedStatement.setString(9, event.getCode_postal()); + preparedStatement.setFloat(10, event.getLongitude()); + preparedStatement.setFloat(11, event.getLatitude()); + preparedStatement.setString(12, event.getDescription()); + preparedStatement.setString(13, event.getImage()); + preparedStatement.setString(14, event.getId_source()); + + preparedStatement.executeUpdate(); + } catch (SQLException | NullPointerException e) { + e.printStackTrace(); + } + } + @Override protected Event getDataFromResult(ResultSet result) throws SQLException { Event event = new Event(); diff --git a/src/main/java/applets/etsmtl/ca/news/db/NouvellesDAO.java b/src/main/java/applets/etsmtl/ca/news/db/NouvellesDAO.java index 5315a6f..ef2f060 100644 --- a/src/main/java/applets/etsmtl/ca/news/db/NouvellesDAO.java +++ b/src/main/java/applets/etsmtl/ca/news/db/NouvellesDAO.java @@ -9,19 +9,16 @@ import java.util.Collections; import java.util.List; -/** - * Created by gnut3ll4 on 24/01/16. - */ public class NouvellesDAO extends DAO { @Override public Nouvelle find(String id) { try { String findById = "SELECT * FROM nouvelles WHERE id = ?"; - PreparedStatement st = this.connection.prepareStatement(findById,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); + PreparedStatement st = this.connection.prepareStatement(findById, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); st.setString(1, id); ResultSet result = st.executeQuery(); - if(result.first()) { + if (result.first()) { Nouvelle nouvelle = getDataFromResult(result); result.close(); st.close(); @@ -38,10 +35,10 @@ public Nouvelle find(String id) { public boolean isExisting(String id) { try { String findById = "SELECT id FROM nouvelles WHERE id = ?"; - PreparedStatement st = this.connection.prepareStatement(findById,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); + PreparedStatement st = this.connection.prepareStatement(findById, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); st.setString(1, id); ResultSet result = st.executeQuery(); - if(result.first()) { + if (result.first()) { result.close(); st.close(); return true; @@ -65,7 +62,7 @@ public List findAll() { ).executeQuery( findAll ); - while(result.next()) { + while (result.next()) { nouvelles.add(getDataFromResult(result)); } } catch (SQLException e) { @@ -77,17 +74,18 @@ public List findAll() { /** * Cherche les nouvelles pour une source donnée. + * * @param sourceID le ID de la source. * @return La liste des 10 dernières nouvelles pour cette source */ public List findAllForSource(String sourceID) { List nouvelles = new ArrayList(); try { - String findAllforSource="SELECT * FROM nouvelles WHERE id_source = ? ORDER BY date DESC LIMIT " + FIND_ALL_NOUVELLES_MAX_SIZE; - PreparedStatement st = this.connection.prepareStatement(findAllforSource,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); + String findAllforSource = "SELECT * FROM nouvelles WHERE id_source = ? ORDER BY date DESC LIMIT " + FIND_ALL_NOUVELLES_MAX_SIZE; + PreparedStatement st = this.connection.prepareStatement(findAllforSource, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); st.setString(1, sourceID); ResultSet result = st.executeQuery(); - while(result.next()) { + while (result.next()) { nouvelles.add(getDataFromResult(result)); } result.close(); @@ -99,33 +97,60 @@ public List findAllForSource(String sourceID) { return nouvelles; } - public void add(Nouvelle nouvelle) - { - try { - String req_insert_nouvelle = "INSERT INTO nouvelles (id, titre, message, link, date, url_picture, id_source) VALUES (?,?,?,?,?,?,?)"; - - PreparedStatement preparedStatement = ConnectionSingleton.getInstance().prepareStatement(req_insert_nouvelle); - - preparedStatement.setString(1, nouvelle.getId()); - preparedStatement.setString(2, nouvelle.getTitre()); - preparedStatement.setString(3, nouvelle.getMessage()); - preparedStatement.setString(4, nouvelle.getLink()); - - if (nouvelle.getDate() != null) { - preparedStatement.setTimestamp(5, new java.sql.Timestamp(nouvelle.getDate().getTime())); - } else { - preparedStatement.setTimestamp(5, null); - } - preparedStatement.setString(6, nouvelle.getUrlPicture()); - preparedStatement.setString(7, nouvelle.getId_source()); - - preparedStatement.executeUpdate(); - } catch (SQLException e) { - e.printStackTrace(); - } catch (NullPointerException e) { - e.printStackTrace(); - } - } + public void add(Nouvelle nouvelle) { + try { + String req_insert_nouvelle = "INSERT INTO nouvelles (id, titre, message, link, date, url_picture, id_source) VALUES (?,?,?,?,?,?,?)"; + + PreparedStatement preparedStatement = ConnectionSingleton.getInstance().prepareStatement(req_insert_nouvelle); + + preparedStatement.setString(1, nouvelle.getId()); + preparedStatement.setString(2, nouvelle.getTitre()); + preparedStatement.setString(3, nouvelle.getMessage()); + preparedStatement.setString(4, nouvelle.getLink()); + + if (nouvelle.getDate() != null) { + preparedStatement.setTimestamp(5, new java.sql.Timestamp(nouvelle.getDate().getTime())); + } else { + preparedStatement.setTimestamp(5, null); + } + preparedStatement.setString(6, nouvelle.getUrlPicture()); + preparedStatement.setString(7, nouvelle.getId_source()); + + preparedStatement.executeUpdate(); + } catch (SQLException e) { + e.printStackTrace(); + } catch (NullPointerException e) { + e.printStackTrace(); + } + } + + public void update(Nouvelle nouvelle) { + try { + String req_insert_nouvelle = "" + + "UPDATE nouvelles " + + "SET titre = ?, message = ?, link = ?, date = ?, url_picture = ?, id_source = ? " + + "WHERE id = ?"; + + PreparedStatement preparedStatement = ConnectionSingleton.getInstance().prepareStatement(req_insert_nouvelle); + + preparedStatement.setString(7, nouvelle.getId()); + preparedStatement.setString(1, nouvelle.getTitre()); + preparedStatement.setString(2, nouvelle.getMessage()); + preparedStatement.setString(3, nouvelle.getLink()); + + if (nouvelle.getDate() != null) { + preparedStatement.setTimestamp(4, new java.sql.Timestamp(nouvelle.getDate().getTime())); + } else { + preparedStatement.setTimestamp(4, null); + } + preparedStatement.setString(5, nouvelle.getUrlPicture()); + preparedStatement.setString(6, nouvelle.getId_source()); + + preparedStatement.executeUpdate(); + } catch (SQLException | NullPointerException e) { + e.printStackTrace(); + } + } @Override protected Nouvelle getDataFromResult(ResultSet result) throws SQLException { diff --git a/src/main/java/applets/etsmtl/ca/news/db/SourceDAO.java b/src/main/java/applets/etsmtl/ca/news/db/SourceDAO.java index 976b866..73d4950 100644 --- a/src/main/java/applets/etsmtl/ca/news/db/SourceDAO.java +++ b/src/main/java/applets/etsmtl/ca/news/db/SourceDAO.java @@ -8,9 +8,6 @@ import java.util.ArrayList; import java.util.List; -/** - * Created by gnut3ll4 on 24/01/16. - */ public class SourceDAO extends DAO { @Override @@ -88,6 +85,27 @@ public void add(Source source) { } } + public void update(Source source) { + try { + + String req_insert_source = "" + + "UPDATE sources " + + "SET name = ?, type = ?::type_source, url_image = ?, value = ? " + + "WHERE key = ?"; + PreparedStatement preparedStatement = ConnectionSingleton.getInstance().prepareStatement(req_insert_source); + + preparedStatement.setString(5, source.getKey()); + preparedStatement.setString(1, source.getName()); + preparedStatement.setString(2, source.getType()); + preparedStatement.setString(3, source.getUrlImage()); + preparedStatement.setString(4, source.getValue()); + + preparedStatement.executeUpdate(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + public List findByType(String type){ List sources = new ArrayList(); try { @@ -118,4 +136,5 @@ protected Source getDataFromResult(ResultSet result) throws SQLException { } + } diff --git a/src/main/java/applets/etsmtl/ca/news/jobs/EventsJob.java b/src/main/java/applets/etsmtl/ca/news/jobs/EventsJob.java index 6701fba..2051558 100644 --- a/src/main/java/applets/etsmtl/ca/news/jobs/EventsJob.java +++ b/src/main/java/applets/etsmtl/ca/news/jobs/EventsJob.java @@ -11,9 +11,6 @@ import java.util.List; import java.util.Map; -/** - * Created by nicolas on 24/01/16. - */ public class EventsJob implements Job { @Override @@ -24,23 +21,24 @@ public void execute(JobExecutionContext context) throws JobExecutionException { try { SourceDAO sourceDao = new SourceDAO(); - List list_sources = sourceDao.findByType("facebook"); + List listSources = sourceDao.findByType("facebook"); // ADD parse token facebook - String accesstoken_facebook = System.getenv("FACEBOOK_ACCESS_TOKEN"); + String facebookAccessToken = System.getenv("FACEBOOK_ACCESS_TOKEN"); - for(Source source : list_sources) { + for (Source source : listSources) { String key = source.getKey(); String value = source.getValue(); - mapFetchers.put(key, new FacebookNewsFetcher(key, value, accesstoken_facebook)); + mapFetchers.put(key, new FacebookNewsFetcher(key, value, facebookAccessToken)); } for (Map.Entry entry : mapFetchers.entrySet()) entry.getValue().fetchEvenements(); + } catch (Exception e) { + System.out.println(e); } - catch(Exception e) { System.out.println(e); } } } \ No newline at end of file diff --git a/src/main/java/applets/etsmtl/ca/news/jobs/NewsJob.java b/src/main/java/applets/etsmtl/ca/news/jobs/NewsJob.java index b260c88..48e0b2d 100644 --- a/src/main/java/applets/etsmtl/ca/news/jobs/NewsJob.java +++ b/src/main/java/applets/etsmtl/ca/news/jobs/NewsJob.java @@ -14,9 +14,6 @@ import java.util.List; import java.util.Map; -/** - * Created by gnut3ll4 on 24/01/16. - */ public class NewsJob implements Job { @Override public void execute(JobExecutionContext context) throws JobExecutionException { @@ -25,28 +22,28 @@ public void execute(JobExecutionContext context) throws JobExecutionException { try { SourceDAO sourceDao = new SourceDAO(); - List list_sources_facebook = sourceDao.findByType("facebook"); - List list_sources_rss = sourceDao.findByType("rss"); - List list_sources_twitter = sourceDao.findByType("twitter"); + List listSourcesFacebook = sourceDao.findByType("facebook"); + List listSourcesRss = sourceDao.findByType("rss"); + List listSourcesTwitter = sourceDao.findByType("twitter"); // ADD parse token facebook - String accesstoken_facebook = System.getenv("FACEBOOK_ACCESS_TOKEN"); + String facebookAccessToken = System.getenv("FACEBOOK_ACCESS_TOKEN"); - for(Source source : list_sources_facebook) { + for(Source source : listSourcesFacebook) { String key = source.getKey(); String value = source.getValue(); - mapFetchers.put(key, new FacebookNewsFetcher(key, value, accesstoken_facebook)); + mapFetchers.put(key, new FacebookNewsFetcher(key, value, facebookAccessToken)); } - for(Source source : list_sources_rss) { + for(Source source : listSourcesRss) { String key = source.getKey(); String value = source.getValue(); - mapFetchers.put(key, new RssNewsFetcher(value, accesstoken_facebook)); + mapFetchers.put(key, new RssNewsFetcher(value, facebookAccessToken)); } - for(Source source : list_sources_twitter) { + for(Source source : listSourcesTwitter) { String key = source.getKey(); String value = source.getValue(); diff --git a/src/main/java/applets/etsmtl/ca/news/jobs/SourcesJob.java b/src/main/java/applets/etsmtl/ca/news/jobs/SourcesJob.java index a0e7c1a..2fca994 100644 --- a/src/main/java/applets/etsmtl/ca/news/jobs/SourcesJob.java +++ b/src/main/java/applets/etsmtl/ca/news/jobs/SourcesJob.java @@ -19,14 +19,10 @@ import java.util.HashMap; import java.util.Map; -/** - * Created by nicolas on 24/01/16. - */ public class SourcesJob implements Job { static String readFile(String path, Charset encoding) - throws IOException - { + throws IOException { byte[] encoded = Files.readAllBytes(Paths.get(path)); return new String(encoded, encoding); } @@ -40,43 +36,43 @@ public void execute(JobExecutionContext context) throws JobExecutionException { // Read sources.json file containing all the sources with their value to be accessed final String filePath = getClass().getResource("/news/sources.json").getPath(); - String sources_content = readFile(filePath, StandardCharsets.UTF_8); + String sourcesContent = readFile(filePath, StandardCharsets.UTF_8); - JSONObject typeSourceNews = new JSONObject(sources_content); + JSONObject typeSourceNews = new JSONObject(sourcesContent); // ADD parse token facebook - String accesstoken_facebook = System.getenv("FACEBOOK_ACCESS_TOKEN"); + String facebookAccessToken = System.getenv("FACEBOOK_ACCESS_TOKEN"); // Load RSS sources key value in the map - JSONArray rss_list_sources = (JSONArray) typeSourceNews.getJSONArray("rss"); - for(int i=0; i < rss_list_sources.length(); i++) { - String key = rss_list_sources.getJSONObject(i).get("key").toString(); - String value = rss_list_sources.getJSONObject(i).get("value").toString(); + JSONArray rssListSources = (JSONArray) typeSourceNews.getJSONArray("rss"); + for (int i = 0; i < rssListSources.length(); i++) { + String key = rssListSources.getJSONObject(i).get("key").toString(); + String value = rssListSources.getJSONObject(i).get("value").toString(); mapFetchers.put(key, new RssNewsFetcher(key, value)); } // Load Facebook sources key in the map - JSONArray facebook_list_sources = (JSONArray) typeSourceNews.getJSONArray("facebook"); - for(int i=0; i < facebook_list_sources.length(); i++) { - String key = facebook_list_sources.getJSONObject(i).get("key").toString(); - String value = facebook_list_sources.getJSONObject(i).get("value").toString(); + JSONArray facebookListSources = (JSONArray) typeSourceNews.getJSONArray("facebook"); + for (int i = 0; i < facebookListSources.length(); i++) { + String key = facebookListSources.getJSONObject(i).get("key").toString(); + String value = facebookListSources.getJSONObject(i).get("value").toString(); - mapFetchers.put(key, new FacebookNewsFetcher(key, value, accesstoken_facebook)); + mapFetchers.put(key, new FacebookNewsFetcher(key, value, facebookAccessToken)); } // Load Twitter sources key in the map - JSONArray twitter_list_sources = (JSONArray) typeSourceNews.getJSONArray("twitter"); - for(int i=0; i < twitter_list_sources.length(); i++) { - String key = twitter_list_sources.getJSONObject(i).get("key").toString(); + JSONArray twitterListSources = (JSONArray) typeSourceNews.getJSONArray("twitter"); + for (int i = 0; i < twitterListSources.length(); i++) { + String key = twitterListSources.getJSONObject(i).get("key").toString(); mapFetchers.put(key, new TwitterNewsFetcher(key)); } for (Map.Entry entry : mapFetchers.entrySet()) entry.getValue().fetchSources(); + } catch (IOException | JSONException e) { + System.out.println(e); } - catch(IOException e) { System.out.println(e); } - catch(JSONException e) { System.out.println(e); } } } \ No newline at end of file diff --git a/src/main/java/applets/etsmtl/ca/news/jobs/strategy/FacebookNewsFetcher.java b/src/main/java/applets/etsmtl/ca/news/jobs/strategy/FacebookNewsFetcher.java index 3bc8ccb..0582dcb 100644 --- a/src/main/java/applets/etsmtl/ca/news/jobs/strategy/FacebookNewsFetcher.java +++ b/src/main/java/applets/etsmtl/ca/news/jobs/strategy/FacebookNewsFetcher.java @@ -6,6 +6,12 @@ import applets.etsmtl.ca.news.model.Event; import applets.etsmtl.ca.news.model.Nouvelle; import applets.etsmtl.ca.news.model.Source; +import com.restfb.DefaultFacebookClient; +import com.restfb.FacebookClient; +import com.restfb.Parameter; +import com.restfb.Version; +import com.restfb.json.JsonArray; +import com.restfb.json.JsonObject; import com.squareup.okhttp.OkHttpClient; import com.squareup.okhttp.Request; import com.squareup.okhttp.Response; @@ -19,9 +25,6 @@ import java.util.Date; import java.util.Locale; -/** - * Created by nicolas on 26/01/16. - */ public class FacebookNewsFetcher implements IFetchNewsStrategy { private String key; @@ -32,7 +35,6 @@ public class FacebookNewsFetcher implements IFetchNewsStrategy { private SourceDAO sourceDao; private NouvellesDAO nouvelleDao; private EventDAO eventDao; - private OkHttpClient okhttpcli; public FacebookNewsFetcher(String key, String value, String token) { this.key = key; @@ -43,208 +45,194 @@ public FacebookNewsFetcher(String key, String value, String token) { this.sourceDao = new SourceDAO(); this.nouvelleDao = new NouvellesDAO(); this.eventDao = new EventDAO(); - - this.okhttpcli = new OkHttpClient(); } /******************************************* * Fetching sources */ - private String getDataFromUrl(String url) throws IOException { - Request request = new Request.Builder() - .url(url) - .build(); - - Response response = this.okhttpcli.newCall(request).execute(); - - return response.body().string(); - } - @Override public void fetchSources() { - String url_source = "https://graph.facebook.com/v2.5/" + this.value + "?access_token=" + this.token; - String url_picture_source = "https://graph.facebook.com/v2.5/" + this.value + "/picture?access_token=" + this.token + "&redirect=false"; - if(!this.sourceDao.isExisting(this.key)) { + FacebookClient facebookClient = + new DefaultFacebookClient(this.token, Version.VERSION_2_8); - try { + JsonObject jsonSource = facebookClient.fetchObject(this.value, JsonObject.class, + Parameter.with("fields", "" + + "picture, " + + "id, " + + "name")); - String data_name = getDataFromUrl(url_source); - String data_picture = getDataFromUrl(url_picture_source); + String name = jsonSource.getString("name"); + String imageURL = jsonSource.getJsonObject("picture") + .getJsonObject("data") + .getString("url"); - JSONObject Jobjet_data = new JSONObject(data_name); - JSONObject Jobjet_picture = new JSONObject(data_picture); + Source source = new Source(); - String name = Jobjet_data.getString("name"); - String imageURL = Jobjet_picture.getJSONObject("data").getString("url"); + source.setType("facebook"); - Source source = new Source(); - - source.setType("facebook"); - - source.setKey(this.key); - source.setName(name); - source.setValue(this.value); - source.setUrlImage(imageURL); - - this.sourceDao.add(source); - } + source.setKey(this.key); + source.setName(name); + source.setValue(this.value); + source.setUrlImage(imageURL); + if (this.sourceDao.isExisting(this.key)) { - catch(JSONException e) { System.out.println(e); } - catch(IOException e) { System.out.println(e); } + this.sourceDao.update(source); + } else { + this.sourceDao.add(source); } } public void fetchNouvelles() { - String url_news = "https://graph.facebook.com/v2.5/" + this.value + "/posts?fields=message,link,created_time,name,picture&access_token=" + this.token; - try { - String data_news = getDataFromUrl(url_news); - JSONObject Jobjet_data_news = new JSONObject(data_news); + FacebookClient facebookClient = + new DefaultFacebookClient(this.token, Version.VERSION_2_8); - JSONArray Jarray_data_news = Jobjet_data_news.getJSONArray("data"); + JsonObject jsonNewsData = + facebookClient.fetchObject(this.value + "/posts", + JsonObject.class, Parameter.with("fields", "" + + "message, " + + "link, " + + "created_time, " + + "name, " + + "picture")); - for (int i = 0; i < Jarray_data_news.length(); i++) { - JSONObject Jobjet_news = Jarray_data_news.getJSONObject(i); + JsonArray jsonNewsArray = jsonNewsData.getJsonArray("data"); - String id = Jobjet_news.getString("id"); + for (int i = 0; i < jsonNewsArray.length(); i++) { + JsonObject jsonSingleNews = jsonNewsArray.getJsonObject(i); - if (!this.nouvelleDao.isExisting(id)) { - String message = Jobjet_news.optString("message"); - String link = Jobjet_news.optString("link"); - String date = Jobjet_news.optString("created_time"); + String id = jsonSingleNews.getString("id"); - String name = Jobjet_news.optString("name"); - if ((name == null) || ((name != null) && (name.isEmpty()))) { - name = message.substring(0, Math.min(15, message.length())); - } + String message = jsonSingleNews.optString("message"); + String link = jsonSingleNews.optString("link"); + String date = jsonSingleNews.optString("created_time"); - String picture = Jobjet_news.optString("picture"); + String name = jsonSingleNews.optString("name"); + if (name == null || name.isEmpty()) { + name = message.substring(0, Math.min(15, message.length())); + } + String picture = jsonSingleNews.optString("picture"); - Nouvelle nouvelle = new Nouvelle(); + Nouvelle nouvelle = new Nouvelle(); - nouvelle.setId(id); - nouvelle.setTitre(name); - nouvelle.setMessage(message); - nouvelle.setLink(link); - nouvelle.setDate(parseDate(date)); - nouvelle.setUrlPicture(picture); + nouvelle.setId(id); + nouvelle.setTitre(name); + nouvelle.setMessage(message); + nouvelle.setLink(link); + nouvelle.setDate(parseDate(date)); + nouvelle.setUrlPicture(picture); - nouvelle.setId_source(this.key); + nouvelle.setId_source(this.key); - this.nouvelleDao.add(nouvelle); - } + if (this.nouvelleDao.isExisting(id)) { + this.nouvelleDao.update(nouvelle); + } else { + this.nouvelleDao.add(nouvelle); } - } catch (IOException e) { - e.printStackTrace(); - } catch (JSONException e) { - e.printStackTrace(); - } catch (NullPointerException e) { - e.printStackTrace(); } } public void fetchEvenements() { - String url_event = "https://graph.facebook.com/v2.5/" + this.value + "/events?fields=cover{source},name,place,description,start_time,end_time,id&access_token=" + this.token; - try { - String data_event = getDataFromUrl(url_event); - - JSONObject Jobjet_data_event = new JSONObject(data_event); - - JSONArray Jarray_data_event = Jobjet_data_event.getJSONArray("data"); - - for(int i = 0; i < Jarray_data_event.length(); i++) { - JSONObject Jobjet_event = Jarray_data_event.getJSONObject(i); - - String id = Jobjet_event.getString("id"); - - if(!this.eventDao.isExisting(id)) { - - String cover = null; - if(Jobjet_event.has("cover")) - cover = Jobjet_event.getJSONObject("cover").getString("source"); - - String name = Jobjet_event.getString("name"); - - String location_name = null; - String location_city = null; - String location_country = null; - String location_latitude = null; - String location_longitude = null; - String location_state = null; - String location_street = null; - String location_zip = null; - if(Jobjet_event.has("place")) { - location_name = Jobjet_event.getJSONObject("place").getString("name"); - - if (Jobjet_event.getJSONObject("place").has("location")) { - location_city = Jobjet_event.getJSONObject("place").getJSONObject("location").optString("city"); - location_country = Jobjet_event.getJSONObject("place").getJSONObject("location").optString("country"); - location_latitude = Jobjet_event.getJSONObject("place").getJSONObject("location").optString("latitude"); - location_longitude = Jobjet_event.getJSONObject("place").getJSONObject("location").optString("longitude"); - location_state = Jobjet_event.getJSONObject("place").getJSONObject("location").optString("state"); - location_street = Jobjet_event.getJSONObject("place").getJSONObject("location").optString("street"); - location_zip = Jobjet_event.getJSONObject("place").getJSONObject("location").optString("zip"); - } - } - - String description = Jobjet_event.optString("description"); - String start_date = Jobjet_event.optString("start_time"); - String end_date = Jobjet_event.optString("end_time"); - - // **************************************** - // ADD EVENT - - Event event = new Event(); - - event.setId(id); - event.setNom(name); - event.setDebut(parseDate(start_date)); - event.setFin(parseDate(end_date)); - event.setNom_lieu(location_name); - event.setVille(location_city); - event.setEtat(location_state); - event.setPays(location_country); - event.setAdresse(location_street); - event.setCode_postal(location_zip); - - if(location_longitude != null) - event.setLongitude(Float.valueOf(location_longitude)); - else - event.setLongitude(0); - - if(location_latitude != null) - event.setLatitude(Float.valueOf(location_latitude)); - else - event.setLatitude(0); - - event.setDescription(description); - event.setImage(cover); - event.setId_source(this.key); - - this.eventDao.add(event); + FacebookClient facebookClient = + new DefaultFacebookClient(this.token, Version.VERSION_2_8); + + JsonObject jsonEventData = + facebookClient.fetchObject(this.value + "/events", + JsonObject.class, Parameter.with("fields", "" + + "cover{source}, " + + "name, " + + "place, " + + "description, " + + "start_time, " + + "end_time, " + + "id ")); + + JsonArray jsonEventsArray = jsonEventData.getJsonArray("data"); + + for (int i = 0; i < jsonEventsArray.length(); i++) { + JsonObject jsonEvent = jsonEventsArray.getJsonObject(i); + + String id = jsonEvent.getString("id"); + + String cover = null; + if (jsonEvent.has("cover")) + cover = jsonEvent.getJsonObject("cover").getString("source"); + + String name = jsonEvent.getString("name"); + + String locationName = null; + String locationCity = null; + String locationCountry = null; + String locationLatitude = null; + String locationLongitude = null; + String locationState = null; + String locationStreet = null; + String locationZip = null; + if (jsonEvent.has("place")) { + locationName = jsonEvent.getJsonObject("place").getString("name"); + + if (jsonEvent.getJsonObject("place").has("location")) { + JsonObject jsonLocationEvent = jsonEvent.getJsonObject("place").getJsonObject("location"); + + locationCity = jsonLocationEvent.optString("city"); + locationCountry = jsonLocationEvent.optString("country"); + locationLatitude = jsonLocationEvent.optString("latitude"); + locationLongitude = jsonLocationEvent.optString("longitude"); + locationState = jsonLocationEvent.optString("state"); + locationStreet = jsonLocationEvent.optString("street"); + locationZip = jsonLocationEvent.optString("zip"); } } - - } catch (IOException e) { - e.printStackTrace(); - } catch (JSONException e) { - e.printStackTrace(); - } catch (NullPointerException e) { - e.printStackTrace(); + String description = jsonEvent.optString("description"); + String startDate = jsonEvent.optString("start_time"); + String endDate = jsonEvent.optString("end_time"); + + // **************************************** + // ADD EVENT + + Event event = new Event(); + + event.setId(id); + event.setNom(name); + event.setDebut(parseDate(startDate)); + event.setFin(parseDate(endDate)); + event.setNom_lieu(locationName); + event.setVille(locationCity); + event.setEtat(locationState); + event.setPays(locationCountry); + event.setAdresse(locationStreet); + event.setCode_postal(locationZip); + + if (locationLongitude != null) + event.setLongitude(Float.valueOf(locationLongitude)); + else + event.setLongitude(0); + + if (locationLatitude != null) + event.setLatitude(Float.valueOf(locationLatitude)); + else + event.setLatitude(0); + + event.setDescription(description); + event.setImage(cover); + event.setId_source(this.key); + + if (this.eventDao.isExisting(id)) { + this.eventDao.update(event); + } else { + this.eventDao.add(event); + } } - } - private static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss+SSSS"; - private static Date parseDate(String str) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.ENGLISH); @@ -252,7 +240,8 @@ private static Date parseDate(String str) { try { date = sdf.parse(str); - } catch(ParseException e) { + } catch (ParseException e) { + //todo fix that ugly catch } return date; } diff --git a/src/main/java/applets/etsmtl/ca/news/jobs/strategy/IFetchNewsStrategy.java b/src/main/java/applets/etsmtl/ca/news/jobs/strategy/IFetchNewsStrategy.java index 2a87699..05c9cef 100644 --- a/src/main/java/applets/etsmtl/ca/news/jobs/strategy/IFetchNewsStrategy.java +++ b/src/main/java/applets/etsmtl/ca/news/jobs/strategy/IFetchNewsStrategy.java @@ -1,9 +1,6 @@ package applets.etsmtl.ca.news.jobs.strategy; -/** - * Created by nicolas on 26/01/16. - */ public interface IFetchNewsStrategy { - public void fetchSources(); - public void fetchNouvelles(); + void fetchSources(); + void fetchNouvelles(); } diff --git a/src/main/java/applets/etsmtl/ca/news/jobs/strategy/RssNewsFetcher.java b/src/main/java/applets/etsmtl/ca/news/jobs/strategy/RssNewsFetcher.java index 73ff804..b36dfc9 100644 --- a/src/main/java/applets/etsmtl/ca/news/jobs/strategy/RssNewsFetcher.java +++ b/src/main/java/applets/etsmtl/ca/news/jobs/strategy/RssNewsFetcher.java @@ -13,23 +13,20 @@ import java.io.IOException; import java.net.URL; -/** - * Created by nicolas on 26/01/16. - */ public class RssNewsFetcher implements IFetchNewsStrategy { private String key; private String value; private SourceDAO sourceDao; - private OkHttpClient okhttpcli; + private OkHttpClient okHttpClient; public RssNewsFetcher(String key, String value) { this.key = key; this.value = value; this.sourceDao = new SourceDAO(); - this.okhttpcli = new OkHttpClient(); + this.okHttpClient = new OkHttpClient(); } /******************************************* @@ -41,7 +38,7 @@ private String getDataFromUrl(String url) throws IOException { .url(url) .build(); - Response response = this.okhttpcli.newCall(request).execute(); + Response response = this.okHttpClient.newCall(request).execute(); return response.body().string(); } @@ -49,11 +46,9 @@ private String getDataFromUrl(String url) throws IOException { @Override public void fetchSources() { - if(!this.sourceDao.isExisting(this.key)) { + if (!this.sourceDao.isExisting(this.key)) { try { - String data = getDataFromUrl(this.value); - SyndFeedInput input = new SyndFeedInput(); SyndFeed feed = input.build(new XmlReader(new URL(this.value))); @@ -70,9 +65,7 @@ public void fetchSources() { this.sourceDao.add(source); - } catch (IOException e) { - e.printStackTrace(); - } catch (FeedException e) { + } catch (IOException | FeedException e) { e.printStackTrace(); } } diff --git a/src/main/java/applets/etsmtl/ca/news/jobs/strategy/TwitterNewsFetcher.java b/src/main/java/applets/etsmtl/ca/news/jobs/strategy/TwitterNewsFetcher.java index d3cb422..6b5b0e1 100644 --- a/src/main/java/applets/etsmtl/ca/news/jobs/strategy/TwitterNewsFetcher.java +++ b/src/main/java/applets/etsmtl/ca/news/jobs/strategy/TwitterNewsFetcher.java @@ -1,8 +1,5 @@ package applets.etsmtl.ca.news.jobs.strategy; -/** - * Created by nicolas on 26/01/16. - */ public class TwitterNewsFetcher implements IFetchNewsStrategy { private String key; diff --git a/src/main/java/applets/etsmtl/ca/news/model/Event.java b/src/main/java/applets/etsmtl/ca/news/model/Event.java index 4702473..93e3e5e 100644 --- a/src/main/java/applets/etsmtl/ca/news/model/Event.java +++ b/src/main/java/applets/etsmtl/ca/news/model/Event.java @@ -3,9 +3,6 @@ import javax.xml.bind.annotation.XmlRootElement; import java.util.Date; -/** - * Created by Marcantvez on 09/03/16. - */ @XmlRootElement public class Event implements Comparable{ private String id; diff --git a/src/main/java/applets/etsmtl/ca/news/model/Nouvelle.java b/src/main/java/applets/etsmtl/ca/news/model/Nouvelle.java index e227fd6..cddeb95 100644 --- a/src/main/java/applets/etsmtl/ca/news/model/Nouvelle.java +++ b/src/main/java/applets/etsmtl/ca/news/model/Nouvelle.java @@ -3,9 +3,6 @@ import javax.xml.bind.annotation.XmlRootElement; import java.util.Date; -/** - * Created by gnut3ll4 on 22/01/16. - */ @XmlRootElement public class Nouvelle implements Comparable{ diff --git a/src/main/java/applets/etsmtl/ca/news/model/Source.java b/src/main/java/applets/etsmtl/ca/news/model/Source.java index c087dde..d5e9785 100644 --- a/src/main/java/applets/etsmtl/ca/news/model/Source.java +++ b/src/main/java/applets/etsmtl/ca/news/model/Source.java @@ -2,9 +2,6 @@ import javax.xml.bind.annotation.XmlRootElement; -/** - * Created by gnut3ll4 on 22/01/16. - */ @XmlRootElement public class Source { diff --git a/src/main/java/applets/etsmtl/ca/partners/PartnersResource.java b/src/main/java/applets/etsmtl/ca/partners/PartnersResource.java index fdc33ba..fcb0a06 100644 --- a/src/main/java/applets/etsmtl/ca/partners/PartnersResource.java +++ b/src/main/java/applets/etsmtl/ca/partners/PartnersResource.java @@ -19,9 +19,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -/** - * Created by gnut3ll4 on 04/12/15. - */ @Path("partners") public class PartnersResource { diff --git a/src/main/resources/ehcache.xml b/src/main/resources/ehcache.xml index 0ff1ccb..5b269dd 100644 --- a/src/main/resources/ehcache.xml +++ b/src/main/resources/ehcache.xml @@ -29,6 +29,11 @@ timeToIdleSeconds="0" timeToLiveSeconds="3000" memoryStoreEvictionPolicy="LRU" statistics="true"/> + + diff --git a/src/test/java/applets/etsmtl/ca/hello/EchoResourceTest.java b/src/test/java/applets/etsmtl/ca/hello/EchoResourceTest.java index 6eca8fa..3793522 100644 --- a/src/test/java/applets/etsmtl/ca/hello/EchoResourceTest.java +++ b/src/test/java/applets/etsmtl/ca/hello/EchoResourceTest.java @@ -7,9 +7,6 @@ import javax.ws.rs.core.Application; -/** - * Created by gnut3ll4 on 8/20/16. - */ public class EchoResourceTest extends JerseyTest { @Override diff --git a/src/test/java/applets/etsmtl/ca/hello/HelloWorldResourceTest.java b/src/test/java/applets/etsmtl/ca/hello/HelloWorldResourceTest.java index d277a4b..2d24f32 100644 --- a/src/test/java/applets/etsmtl/ca/hello/HelloWorldResourceTest.java +++ b/src/test/java/applets/etsmtl/ca/hello/HelloWorldResourceTest.java @@ -7,9 +7,6 @@ import javax.ws.rs.core.Application; -/** - * Created by gnut3ll4 on 8/20/16. - */ public class HelloWorldResourceTest extends JerseyTest { @Override diff --git a/src/test/java/applets/etsmtl/ca/news/EventsResourcesTest.java b/src/test/java/applets/etsmtl/ca/news/EventsResourcesTest.java index 7ecb1c0..2723008 100644 --- a/src/test/java/applets/etsmtl/ca/news/EventsResourcesTest.java +++ b/src/test/java/applets/etsmtl/ca/news/EventsResourcesTest.java @@ -19,9 +19,6 @@ import static org.mockito.Mockito.when; -/** - * Created by gnut3ll4 on 8/21/16. - */ public class EventsResourcesTest extends JerseyTest { @Mock diff --git a/src/test/java/applets/etsmtl/ca/news/NewsResourcesTest.java b/src/test/java/applets/etsmtl/ca/news/NewsResourcesTest.java index 2f4a497..5e68473 100644 --- a/src/test/java/applets/etsmtl/ca/news/NewsResourcesTest.java +++ b/src/test/java/applets/etsmtl/ca/news/NewsResourcesTest.java @@ -19,9 +19,6 @@ import static org.mockito.Mockito.when; -/** - * Created by gnut3ll4 on 8/21/16. - */ public class NewsResourcesTest extends JerseyTest { @Mock diff --git a/src/test/java/applets/etsmtl/ca/partners/PartnersResourcesTest.java b/src/test/java/applets/etsmtl/ca/partners/PartnersResourcesTest.java index d9e3fac..1d6e78e 100644 --- a/src/test/java/applets/etsmtl/ca/partners/PartnersResourcesTest.java +++ b/src/test/java/applets/etsmtl/ca/partners/PartnersResourcesTest.java @@ -1,6 +1,5 @@ package partners; -import applets.etsmtl.ca.news.model.Event; import applets.etsmtl.ca.partners.Partner; import applets.etsmtl.ca.partners.PartnersResource; import okhttp3.mockwebserver.MockResponse; @@ -19,9 +18,6 @@ import java.nio.file.Paths; import java.util.List; -/** - * Created by gnut3ll4 on 8/21/16. - */ public class PartnersResourcesTest extends JerseyTest { @Override