diff --git a/ENSIM/Java/tp-deezer3-squelette/.DS_Store b/ENSIM/Java/tp-deezer3-squelette/.DS_Store
new file mode 100644
index 0000000..87dd1e3
Binary files /dev/null and b/ENSIM/Java/tp-deezer3-squelette/.DS_Store differ
diff --git a/ENSIM/Java/tp-deezer3-squelette/.classpath b/ENSIM/Java/tp-deezer3-squelette/.classpath
new file mode 100644
index 0000000..6bdcd6a
--- /dev/null
+++ b/ENSIM/Java/tp-deezer3-squelette/.classpath
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ENSIM/Java/tp-deezer3-squelette/.project b/ENSIM/Java/tp-deezer3-squelette/.project
new file mode 100644
index 0000000..2a91ea7
--- /dev/null
+++ b/ENSIM/Java/tp-deezer3-squelette/.project
@@ -0,0 +1,17 @@
+
+
+ tp-deezer3-HerbronTanguy
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/ENSIM/Java/tp-deezer3-squelette/.settings/org.eclipse.jdt.core.prefs b/ENSIM/Java/tp-deezer3-squelette/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..d17b672
--- /dev/null
+++ b/ENSIM/Java/tp-deezer3-squelette/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,12 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.7
diff --git a/ENSIM/Java/tp-deezer3-squelette/.settings/org.eclipse.m2e.core.prefs b/ENSIM/Java/tp-deezer3-squelette/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..f897a7f
--- /dev/null
+++ b/ENSIM/Java/tp-deezer3-squelette/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/ENSIM/Java/tp-deezer3-squelette/47685332.html b/ENSIM/Java/tp-deezer3-squelette/47685332.html
new file mode 100644
index 0000000..51fe67d
--- /dev/null
+++ b/ENSIM/Java/tp-deezer3-squelette/47685332.html
@@ -0,0 +1,67 @@
+
\ No newline at end of file
diff --git a/ENSIM/Java/tp-deezer3-squelette/83325.html b/ENSIM/Java/tp-deezer3-squelette/83325.html
new file mode 100644
index 0000000..8a0d317
--- /dev/null
+++ b/ENSIM/Java/tp-deezer3-squelette/83325.html
@@ -0,0 +1 @@
+The Evol’
\ No newline at end of file
diff --git a/ENSIM/Java/tp-deezer3-squelette/Shaka Ponk.html b/ENSIM/Java/tp-deezer3-squelette/Shaka Ponk.html
new file mode 100644
index 0000000..c54cf63
--- /dev/null
+++ b/ENSIM/Java/tp-deezer3-squelette/Shaka Ponk.html
@@ -0,0 +1,158 @@
+
\ No newline at end of file
diff --git a/ENSIM/Java/tp-deezer3-squelette/bin/.gitignore b/ENSIM/Java/tp-deezer3-squelette/bin/.gitignore
new file mode 100644
index 0000000..e9e8828
--- /dev/null
+++ b/ENSIM/Java/tp-deezer3-squelette/bin/.gitignore
@@ -0,0 +1,2 @@
+/.DS_Store
+/fr/
diff --git a/ENSIM/Java/tp-deezer3-squelette/lib/gagawa-1.0.1.jar b/ENSIM/Java/tp-deezer3-squelette/lib/gagawa-1.0.1.jar
new file mode 100644
index 0000000..d112026
Binary files /dev/null and b/ENSIM/Java/tp-deezer3-squelette/lib/gagawa-1.0.1.jar differ
diff --git a/ENSIM/Java/tp-deezer3-squelette/lib/log4j-1.2.14.jar b/ENSIM/Java/tp-deezer3-squelette/lib/log4j-1.2.14.jar
new file mode 100644
index 0000000..6251307
Binary files /dev/null and b/ENSIM/Java/tp-deezer3-squelette/lib/log4j-1.2.14.jar differ
diff --git a/ENSIM/Java/tp-deezer3-squelette/log4J.xml b/ENSIM/Java/tp-deezer3-squelette/log4J.xml
new file mode 100644
index 0000000..01ee3cd
--- /dev/null
+++ b/ENSIM/Java/tp-deezer3-squelette/log4J.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ENSIM/Java/tp-deezer3-squelette/pom.xml b/ENSIM/Java/tp-deezer3-squelette/pom.xml
new file mode 100644
index 0000000..82ad24f
--- /dev/null
+++ b/ENSIM/Java/tp-deezer3-squelette/pom.xml
@@ -0,0 +1,28 @@
+
+ 4.0.0
+ tp-deezer3-HerbronTanguy
+ tp-deezer3-HerbronTanguy
+ 0.0.1-SNAPSHOT
+
+ src
+ test
+
+
+ test
+
+ **/*.java
+
+
+
+
+
+ maven-compiler-plugin
+ 3.7.0
+
+ 1.7
+ 1.7
+
+
+
+
+
\ No newline at end of file
diff --git a/ENSIM/Java/tp-deezer3-squelette/src/fr/ensim/xml/deezer/AbstractSearchAlbum.java b/ENSIM/Java/tp-deezer3-squelette/src/fr/ensim/xml/deezer/AbstractSearchAlbum.java
new file mode 100644
index 0000000..c02d158
--- /dev/null
+++ b/ENSIM/Java/tp-deezer3-squelette/src/fr/ensim/xml/deezer/AbstractSearchAlbum.java
@@ -0,0 +1,86 @@
+package fr.ensim.xml.deezer;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.List;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.log4j.Logger;
+import org.xml.sax.SAXException;
+
+import fr.ensim.xml.deezer.data.Album;
+
+/**
+ * @author Denis Apparicio
+ *
+ */
+public abstract class AbstractSearchAlbum {
+ private static final Logger LOG = Logger.getLogger(AbstractSearchAlbum.class);
+
+ /**
+ * Restitue la liste des albums d'un auteur.
+ *
+ * @param author
+ * l'auteur.
+ * @throws IOException
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ */
+ public List find(String author) throws IOException,
+ ParserConfigurationException,
+ SAXException {
+ LOG.debug(">>find author="+author);
+
+ // Constitution de l'URL
+ StringBuilder sUrl = new StringBuilder();
+ sUrl.append("http://api.deezer.com/2.0/search/album?q=");
+ sUrl.append(author);
+ sUrl.append("&output=xml");
+
+ URL url = new URL(sUrl.toString());
+ LOG.debug(url);
+
+ HttpURLConnection cnx = (HttpURLConnection) url.openConnection();
+
+ List albums = null;
+ try {
+
+ // recuperation du flux xml
+ cnx.setConnectTimeout(5000);
+ cnx.setReadTimeout(5000);
+ cnx.setRequestMethod("GET");
+ cnx.setDoInput(true);
+ cnx.addRequestProperty("Accept-Language", "en;q=0.6,en-us;q=0.4,sv;q=0.2");
+ if (cnx.getResponseCode() != HttpURLConnection.HTTP_OK) {
+ throw new IOException("http status code " + cnx.getResponseCode());
+ }
+
+ InputStream in = cnx.getInputStream();
+
+ // Lecture
+ albums = readAlbums(in);
+ }
+ catch(Exception e) {
+ LOG.error("", e);
+ }
+ finally {
+ cnx.disconnect();
+ }
+
+ LOG.debug("< readAlbums(InputStream in) throws Exception;
+
+}
diff --git a/ENSIM/Java/tp-deezer3-squelette/src/fr/ensim/xml/deezer/AbstractSearchAlbumTracks.java b/ENSIM/Java/tp-deezer3-squelette/src/fr/ensim/xml/deezer/AbstractSearchAlbumTracks.java
new file mode 100644
index 0000000..fcd0f85
--- /dev/null
+++ b/ENSIM/Java/tp-deezer3-squelette/src/fr/ensim/xml/deezer/AbstractSearchAlbumTracks.java
@@ -0,0 +1,70 @@
+package fr.ensim.xml.deezer;
+
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import fr.ensim.xml.deezer.data.Track;
+
+/**
+ * @author Denis Apparicio
+ *
+ */
+public abstract class AbstractSearchAlbumTracks {
+ private static Logger log = Logger.getLogger(AbstractSearchAlbumTracks.class);
+
+ /**
+ * Restitue la liste des chansons d'un album.
+ *
+ * @param id
+ * id de l'album.
+ * @return la liste des chansons.
+ * @throws Exception
+ */
+ public List find(String id) throws Exception {
+ log.debug(">>find");
+
+ // Constitution de l'URL
+ StringBuilder sUrl = new StringBuilder();
+ sUrl.append("http://api.deezer.com/2.0/album/");
+ sUrl.append(id);
+ sUrl.append("?output=xml");
+
+ URL url = new URL(sUrl.toString());
+
+ log.debug(url);
+
+ HttpURLConnection cnx = (HttpURLConnection) url.openConnection();
+ cnx.setConnectTimeout(5000);
+ cnx.setReadTimeout(5000);
+ cnx.setRequestMethod("GET");
+ cnx.setDoInput(true);
+ cnx.addRequestProperty("Accept-Language", "en;q=0.6,en-us;q=0.4,sv;q=0.2");
+
+ try {
+ if (cnx.getResponseCode() == HttpURLConnection.HTTP_OK) {
+ return readTrack(cnx.getInputStream());
+ }
+ }
+ finally {
+ cnx.disconnect();
+ }
+
+ log.debug("< readTrack(InputStream in) throws Exception;
+
+}
\ No newline at end of file
diff --git a/ENSIM/Java/tp-deezer3-squelette/src/fr/ensim/xml/deezer/Main.java b/ENSIM/Java/tp-deezer3-squelette/src/fr/ensim/xml/deezer/Main.java
new file mode 100644
index 0000000..27dc215
--- /dev/null
+++ b/ENSIM/Java/tp-deezer3-squelette/src/fr/ensim/xml/deezer/Main.java
@@ -0,0 +1,81 @@
+package fr.ensim.xml.deezer;
+
+import static org.junit.Assert.fail;
+
+import java.awt.Desktop;
+import java.awt.Desktop.Action;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.xml.DOMConfigurator;
+
+import fr.ensim.xml.deezer.data.Album;
+import fr.ensim.xml.deezer.data.Track;
+import fr.ensim.xml.deezer.dom.SearchAlbumTracks;
+import fr.ensim.xml.deezer.sax.SAXSearchAlbums;
+import fr.ensim.xml.deezer.stax.HtmlAlbum;
+
+
+/**
+ * @author Denis Apparicio
+ *
+ */
+public class Main {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ // configuration du proxy et des logs
+ DOMConfigurator.configure("log4J.xml");
+ ProxyConfiguration.configure();
+
+ Logger log = Logger.getLogger(Main.class);
+
+ FileOutputStream out = null;
+
+ try {
+ List listAlbum = new SAXSearchAlbums().find("Shaka%20Ponk");
+
+ // recuperation des titres de l album
+ for(int i = 0; i < listAlbum.size(); i++)
+ {
+ listAlbum.get(i).setTracks(SearchAlbumTracks.find(listAlbum.get(i).getId()));
+ }
+
+ // Ecriture de la page html
+ File fileHtml = new File(listAlbum.get(0).getArtist().getName() + ".html");
+ out = new FileOutputStream(fileHtml);
+ HtmlAlbum.write(listAlbum, out);
+ out.close();
+
+ // Ouverture de la page
+ if (fileHtml.isFile()) {
+ if (Desktop.isDesktopSupported()
+ && Desktop.getDesktop().isSupported(Action.BROWSE)) {
+ Desktop.getDesktop().browse(fileHtml.toURI());
+ }
+ }
+ }
+ catch (Exception e) {
+ log.error("", e);
+ fail(e.getMessage());
+ }
+ finally {
+ try {
+ if (out != null) {
+ out.close();
+ }
+ }
+ catch (IOException e) {
+ log.error("", e);
+ }
+ }
+
+ log.debug("< tracks = new ArrayList();
+
+ public Album() {
+ }
+
+ public void addTrack(Track title) {
+ tracks.add(title);
+ }
+
+ public List getTracks() {
+ return tracks;
+ }
+
+ public void setTracks(List tracks) {
+ this.tracks = tracks;
+ }
+
+ public Artist getArtist() {
+ return artist;
+ }
+
+ public void setArtist(Artist artist) {
+ this.artist = artist;
+ }
+
+ public String getCover() {
+ return cover;
+ }
+
+ public void setCover(String cover) {
+ this.cover = cover;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+}
diff --git a/ENSIM/Java/tp-deezer3-squelette/src/fr/ensim/xml/deezer/data/Artist.java b/ENSIM/Java/tp-deezer3-squelette/src/fr/ensim/xml/deezer/data/Artist.java
new file mode 100644
index 0000000..31baa0f
--- /dev/null
+++ b/ENSIM/Java/tp-deezer3-squelette/src/fr/ensim/xml/deezer/data/Artist.java
@@ -0,0 +1,48 @@
+package fr.ensim.xml.deezer.data;
+
+/**
+ * @author Denis Apparicio
+ */
+public class Artist {
+
+ private String id;
+
+ private String name;
+
+ private String link;
+
+ private String picture;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getLink() {
+ return link;
+ }
+
+ public void setLink(String link) {
+ this.link = link;
+ }
+
+ public String getPicture() {
+ return picture;
+ }
+
+ public void setPicture(String picture) {
+ this.picture = picture;
+ }
+
+}
diff --git a/ENSIM/Java/tp-deezer3-squelette/src/fr/ensim/xml/deezer/data/Track.java b/ENSIM/Java/tp-deezer3-squelette/src/fr/ensim/xml/deezer/data/Track.java
new file mode 100644
index 0000000..66f0270
--- /dev/null
+++ b/ENSIM/Java/tp-deezer3-squelette/src/fr/ensim/xml/deezer/data/Track.java
@@ -0,0 +1,40 @@
+package fr.ensim.xml.deezer.data;
+
+/**
+ *
+ * @author Denis Apparicio
+ *
+ */
+public class Track {
+
+ private String title;
+
+ private String preview;
+
+ public Track() {
+ super();
+ }
+
+ public Track(String title, String preview) {
+ super();
+ this.title = title;
+ this.preview = preview;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public String getPreview() {
+ return preview;
+ }
+
+ public void setPreview(String preview) {
+ this.preview = preview;
+ }
+
+}
diff --git a/ENSIM/Java/tp-deezer3-squelette/src/fr/ensim/xml/deezer/dom/DOMSearchAlbums.java b/ENSIM/Java/tp-deezer3-squelette/src/fr/ensim/xml/deezer/dom/DOMSearchAlbums.java
new file mode 100644
index 0000000..ffc2e08
--- /dev/null
+++ b/ENSIM/Java/tp-deezer3-squelette/src/fr/ensim/xml/deezer/dom/DOMSearchAlbums.java
@@ -0,0 +1,43 @@
+package fr.ensim.xml.deezer.dom;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.log4j.Logger;
+import org.xml.sax.SAXException;
+
+import fr.ensim.xml.deezer.AbstractSearchAlbum;
+import fr.ensim.xml.deezer.data.Album;
+
+/**
+ * @author Denis Apparicio
+ *
+ */
+public class DOMSearchAlbums extends AbstractSearchAlbum {
+ private static final Logger LOG = Logger.getLogger(DOMSearchAlbumsTest.class);
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * fr.ensim.xml.deezer.AbstractSearchAlbum#readAlbums(java.io.InputStream)
+ */
+ @Override
+ public List readAlbums(InputStream in) throws ParserConfigurationException,
+ SAXException,
+ IOException {
+ LOG.debug(">>readAlbums");
+
+ List listAlbums = new ArrayList();
+
+ //TODO Recherche les albums en DOM
+
+
+ LOG.debug("< find(String id) throws IOException,
+ ParserConfigurationException,
+ SAXException {
+ log.debug(">>albums");
+
+ // Constitution de l'URL
+ StringBuilder sUrl = new StringBuilder();
+ sUrl.append("http://api.deezer.com/2.0/album/");
+ sUrl.append(id);
+ sUrl.append("?output=xml");
+
+ URL url = new URL(sUrl.toString());
+
+ log.debug(url);
+
+ HttpURLConnection cnx = (HttpURLConnection) url.openConnection();
+ cnx.setConnectTimeout(5000);
+ cnx.setReadTimeout(5000);
+ cnx.setRequestMethod("GET");
+ cnx.setDoInput(true);
+ cnx.addRequestProperty("Accept-Language", "en;q=0.6,en-us;q=0.4,sv;q=0.2");
+
+ try {
+ if (cnx.getResponseCode() == HttpURLConnection.HTTP_OK) {
+ return find(cnx.getInputStream());
+ }
+ }
+ finally {
+ cnx.disconnect();
+ }
+
+ log.debug("< find(InputStream in) throws SAXException,
+ ParserConfigurationException,
+ IOException {
+ log.debug(">>find");
+
+ ArrayList listTracks = new ArrayList();
+
+ //TODO Recherche les pistes d'albums en DOM
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document doc = db.parse(in);
+ doc.normalize();
+
+ parseChildElements(doc.getDocumentElement(), listTracks);
+
+ log.debug(">>find");
+ return listTracks;
+ }
+
+ private static boolean isTrackBeingRead;
+
+ private static void parseChildElements(Element el, List listTracks)
+ {
+ if(el.getNodeName().equals("track"))
+ {
+ isTrackBeingRead = true;
+
+ if(isTrackBeingRead)
+ {
+ if(buildingTrack != null)
+ {
+ listTracks.add(buildingTrack);
+ }
+
+ buildingTrack = new Track();
+ }
+ }
+
+ if(isTrackBeingRead)
+ {
+ switch(el.getNodeName())
+ {
+ case "title":
+ buildingTrack.setTitle(el.getTextContent());
+ break;
+ case "preview":
+ buildingTrack.setPreview(el.getTextContent());
+ break;
+ }
+ }
+
+ NodeList nl = el.getChildNodes();
+ for(int i = 0; i < nl.getLength(); i++)
+ {
+ Node n = nl.item(i);
+ if(n instanceof Element)
+ {
+ parseChildElements((Element) n, listTracks);
+ }
+ }
+ }
+}
diff --git a/ENSIM/Java/tp-deezer3-squelette/src/fr/ensim/xml/deezer/sax/SAXSearchAlbums.java b/ENSIM/Java/tp-deezer3-squelette/src/fr/ensim/xml/deezer/sax/SAXSearchAlbums.java
new file mode 100644
index 0000000..7c1a500
--- /dev/null
+++ b/ENSIM/Java/tp-deezer3-squelette/src/fr/ensim/xml/deezer/sax/SAXSearchAlbums.java
@@ -0,0 +1,51 @@
+package fr.ensim.xml.deezer.sax;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.apache.log4j.Logger;
+import org.xml.sax.SAXException;
+
+import fr.ensim.xml.deezer.AbstractSearchAlbum;
+import fr.ensim.xml.deezer.data.Album;
+
+/**
+ * @author Denis Apparicio
+ *
+ */
+public class SAXSearchAlbums extends AbstractSearchAlbum {
+ private static final Logger LOG = Logger.getLogger(SAXSearchAlbums.class);
+
+
+ @Override
+ public List readAlbums(InputStream in) {
+ LOG.debug(">>readAlbums");
+
+ //TODO Recherche les albums en SAX
+ SAXSearchAlbumsHandler handler = new SAXSearchAlbumsHandler();
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ factory.setNamespaceAware(true);
+ try {
+ SAXParser parser = factory.newSAXParser();
+ parser.parse(in, handler);
+ } catch (ParserConfigurationException e) {
+ // TODO Auto-generated catch block
+ LOG.error("ParserConfigurationException", e);
+ } catch (SAXException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO: handle exception
+ e.printStackTrace();
+ }
+
+
+ LOG.debug("< listAlbum = new ArrayList();
+ private String val;
+ private Album buildingAlbum;
+ private Artist buildingArtist;
+ private boolean isArtist;
+
+ /**
+ * Restitue la liste des albums.
+ *
+ * @return la liste des albums.
+ */
+ public List getListAlbum() {
+ return listAlbum;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String,
+ * java.lang.String, java.lang.String, org.xml.sax.Attributes)
+ */
+ @Override
+ public void startElement(String uri,
+ String localName,
+ String qName,
+ Attributes attributes) throws SAXException {
+
+ if(localName.equals("album"))
+ {
+ buildingAlbum = new Album();
+ }
+
+ if(localName.equals("artist"))
+ {
+ buildingArtist = new Artist();
+ isArtist = true;
+ }
+ }
+
+ /*
+ * (non-Javadoc) BufferedReader
+ *
+ * @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String,
+ * java.lang.String, java.lang.String)
+ */
+ @Override
+ public void endElement(String uri, String localName, String qName) throws SAXException {
+ switch(localName)
+ {
+ case "album":
+ listAlbum.add(buildingAlbum);
+ break;
+ case "id":
+ updateId();
+ break;
+ case "title":
+ if(buildingAlbum != null) buildingAlbum.setTitle(val);
+ break;
+ case "cover":
+ if(buildingAlbum != null) buildingAlbum.setCover(val);
+ break;
+ case "name":
+ buildingArtist.setName(val);
+ break;
+ case "link":
+ updateLink();
+ break;
+ case "picture":
+ buildingArtist.setPicture(val);
+ break;
+ case "artist":
+ buildingAlbum.setArtist(buildingArtist);
+ isArtist = false;
+ break;
+ }
+ }
+
+ private void updateLink()
+ {
+ if(isArtist)
+ {
+ buildingArtist.setLink(val);
+ }
+ }
+
+ private void updateId()
+ {
+ if(isArtist)
+ {
+ buildingArtist.setId(val);
+ }
+ else
+ {
+ buildingAlbum.setId(val);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.xml.sax.helpers.DefaultHandler#characters(char[], int, int)
+ */
+ @Override
+ public void characters(char[] ch, int start, int length) throws SAXException {
+ val = new String(ch, start, length);
+ }
+}
diff --git a/ENSIM/Java/tp-deezer3-squelette/src/fr/ensim/xml/deezer/stax/HtmlAlbum.java b/ENSIM/Java/tp-deezer3-squelette/src/fr/ensim/xml/deezer/stax/HtmlAlbum.java
new file mode 100644
index 0000000..0fa9c16
--- /dev/null
+++ b/ENSIM/Java/tp-deezer3-squelette/src/fr/ensim/xml/deezer/stax/HtmlAlbum.java
@@ -0,0 +1,134 @@
+package fr.ensim.xml.deezer.stax;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.util.List;
+import java.util.NavigableMap;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.log4j.Logger;
+
+import com.hp.gagawa.java.Document;
+import com.hp.gagawa.java.DocumentType;
+import com.hp.gagawa.java.elements.A;
+import com.hp.gagawa.java.elements.Body;
+import com.hp.gagawa.java.elements.Div;
+import com.hp.gagawa.java.elements.Head;
+import com.hp.gagawa.java.elements.Img;
+import com.hp.gagawa.java.elements.Link;
+import com.hp.gagawa.java.elements.Script;
+import com.hp.gagawa.java.elements.Style;
+
+import fr.ensim.xml.deezer.data.Album;
+import fr.ensim.xml.deezer.data.Track;
+
+/**
+ * @author Denis Apparicio
+ *
+ */
+public class HtmlAlbum {
+ private static Logger log = Logger.getLogger(HtmlAlbum.class);
+
+ /**
+ * Ecriture de la page HTML avec StAX.
+ *
+ * @param album
+ * @param out
+ * @throws XMLStreamException
+ * @throws IOException
+ */
+ public static void write(List albums, OutputStream outputStream) throws XMLStreamException,
+ IOException {
+ log.debug(">>write");
+
+ Document document = new Document(DocumentType.HTMLTransitional);
+
+ Head head = new Head();
+
+ Link cssLink = new Link();
+ cssLink.setRel("stylesheet").setHref("https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css");
+ Script matScript = new Script(null);
+ matScript.setSrc("https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js");
+
+ head.appendChild(cssLink);
+ head.appendChild(matScript);
+
+ Body body = new Body();
+ Div navDiv = new Div();
+ navDiv.appendText(
+ "\r\n" +
+ " \r\n" +
+ " ");
+
+ body.appendChild(navDiv);
+
+ Div container = new Div();
+ container.setCSSClass("container");
+
+ int i = 0;
+
+ while(i < albums.size())
+ {
+ Div row = new Div();
+ row.setCSSClass("row");
+
+ row.appendChild(createAlbumCard(albums.get(i).getTitle()
+ , albums.get(i).getCover()
+ , albums.get(i).getTracks()));
+
+ if(albums.size() > i+1)
+ {
+ i++;
+
+ row.appendChild(createAlbumCard(albums.get(i).getTitle()
+ , albums.get(i).getCover()
+ , albums.get(i).getTracks()));
+ }
+
+ i++;
+
+ container.appendChild(row);
+ }
+
+ body.appendChild(container);
+
+ document.head.appendChild(head);
+ document.body.appendChild(body);
+
+ PrintWriter p = new PrintWriter(outputStream);
+ p.write(document.write());
+ p.close();
+
+ log.debug("< tracks)
+ {
+ Div div = new Div().setCSSClass("col s12 m6").appendText(
+ " \r\n" +
+ "
\r\n" +
+ "
\r\n" +
+ " \r\n");
+
+ for(int i = 0; i < tracks.size(); i++)
+ {
+ div.appendText("" + tracks.get(i).getTitle() + " "
+ + ""
+ + " "
+ + " \r\n");
+ }
+
+ div.appendText(" ");
+
+ return div;
+ }
+}
diff --git a/ENSIM/Java/tp-deezer3-squelette/src/fr/ensim/xml/deezer/stax/StAXSearchAlbums.java b/ENSIM/Java/tp-deezer3-squelette/src/fr/ensim/xml/deezer/stax/StAXSearchAlbums.java
new file mode 100644
index 0000000..b5bbc59
--- /dev/null
+++ b/ENSIM/Java/tp-deezer3-squelette/src/fr/ensim/xml/deezer/stax/StAXSearchAlbums.java
@@ -0,0 +1,55 @@
+package fr.ensim.xml.deezer.stax;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.log4j.Logger;
+
+import fr.ensim.xml.deezer.AbstractSearchAlbum;
+import fr.ensim.xml.deezer.data.Album;
+
+/**
+ * @author Denis Apparicio
+ *
+ */
+public class StAXSearchAlbums extends AbstractSearchAlbum {
+ private static final Logger LOG = Logger.getLogger(StAXSearchAlbums.class);
+
+ /**
+ * Compte le nombre d'albums.
+ *
+ * @param in
+ * le flux xml.
+ * @return le nombre d'albums.
+ * @throws XMLStreamException
+ */
+ public int count(InputStream in) throws XMLStreamException {
+ LOG.debug(">>count");
+
+ int nbAlbums = 0;
+ // recuperation d'un parser StAX
+ // @ TODO
+
+ LOG.debug("< readAlbums(InputStream in) throws XMLStreamException {
+ LOG.debug(">>readAlbums");
+
+ List listAlbums = new ArrayList();
+
+ // recuperation d'un parser StAX
+ // @ TODO
+
+ // parsing
+ // @ TODO
+
+ LOG.debug("<
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ENSIM/Java/tp-deezer3-squelette/test/fr/ensim/xml/deezer/dom/DOMSearchAlbumsTest.java b/ENSIM/Java/tp-deezer3-squelette/test/fr/ensim/xml/deezer/dom/DOMSearchAlbumsTest.java
new file mode 100644
index 0000000..bec4bec
--- /dev/null
+++ b/ENSIM/Java/tp-deezer3-squelette/test/fr/ensim/xml/deezer/dom/DOMSearchAlbumsTest.java
@@ -0,0 +1,32 @@
+package fr.ensim.xml.deezer.dom;
+
+import java.io.InputStream;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.xml.DOMConfigurator;
+import org.junit.Test;
+
+/**
+ * @author Denis Apparicio
+ *
+ */
+public class DOMSearchAlbumsTest {
+ static {
+ DOMConfigurator.configure("log4J.xml");
+ }
+
+ private static final Logger LOG = Logger
+ .getLogger(DOMSearchAlbumsTest.class);
+
+ @Test
+ public void testParse() {
+ LOG.debug(">>testParse");
+
+ // Recuperation du flux a parser
+ InputStream in = getClass().getResourceAsStream("../album-stupeflip.xml");
+
+ //TODO
+
+ LOG.debug("<>testParse");
+
+ // Recuperation du flux a parser
+ InputStream in = getClass().getResourceAsStream("../album-stupeflip.xml");
+
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ factory.setNamespaceAware(true);
+ SAXParser parser = factory.newSAXParser();
+
+ // constitution du flux xml
+ BufferedReader reader = new BufferedReader(new InputStreamReader(in));
+ InputSource source = new InputSource(reader);
+
+ // parsing
+ SAXSearchAlbumsHandler handler = new SAXSearchAlbumsHandler();
+ parser.parse(source, handler);
+
+ assertEquals(10, handler.getListAlbum().size());
+ //First album
+ assertEquals("47685332", handler.getListAlbum().get(0).getId());
+ assertEquals("The Evol", handler.getListAlbum().get(0).getTitle());
+ assertEquals("http://api.deezer.com/2.0/album/47685332/image", handler.getListAlbum().get(0).getCover());
+ assertEquals("83325", handler.getListAlbum().get(0).getArtist().getId());
+ assertEquals("Shaka Ponk", handler.getListAlbum().get(0).getArtist().getName());
+
+ //Second album
+ assertEquals("1121440", handler.getListAlbum().get(1).getId());
+ assertEquals("The Geeks And The Jerkin' Socks", handler.getListAlbum().get(1).getTitle());
+ assertEquals("http://api.deezer.com/2.0/album/1121440/image", handler.getListAlbum().get(1).getCover());
+ assertEquals("83325", handler.getListAlbum().get(1).getArtist().getId());
+ assertEquals("Shaka Ponk", handler.getListAlbum().get(1).getArtist().getName());
+
+ LOG.debug("<
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ENSIM/Java/tp-deezer3-squelette/test/fr/ensim/xml/deezer/sax/SAXSearchAlbumsTest.java b/ENSIM/Java/tp-deezer3-squelette/test/fr/ensim/xml/deezer/sax/SAXSearchAlbumsTest.java
new file mode 100644
index 0000000..1b1ec50
--- /dev/null
+++ b/ENSIM/Java/tp-deezer3-squelette/test/fr/ensim/xml/deezer/sax/SAXSearchAlbumsTest.java
@@ -0,0 +1,69 @@
+package fr.ensim.xml.deezer.sax;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.xml.DOMConfigurator;
+import org.junit.Test;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * @author Denis Apparicio
+ *
+ */
+public class SAXSearchAlbumsTest {
+ static {
+ DOMConfigurator.configure("log4J.xml");
+ }
+
+ private static final Logger LOG = Logger.getLogger(SAXSearchAlbumsTest.class);
+
+ @Test
+ public void testParse() throws ParserConfigurationException, SAXException, IOException {
+ LOG.debug(">>testParse");
+
+ // Recuperation du flux a parser
+ InputStream in = getClass().getResourceAsStream("../list-albums.xml");
+
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ factory.setNamespaceAware(true);
+ SAXParser parser = factory.newSAXParser();
+
+ // constitution du flux xml
+ BufferedReader reader = new BufferedReader(new InputStreamReader(in));
+ InputSource source = new InputSource(reader);
+
+ // parsing
+ SAXSearchAlbumsHandler handler = new SAXSearchAlbumsHandler();
+ parser.parse(source, handler);
+
+ assertEquals(10, handler.getListAlbum().size());
+ //First album
+ assertEquals("47685332", handler.getListAlbum().get(0).getId());
+ assertEquals("The Evol", handler.getListAlbum().get(0).getTitle());
+ assertEquals("http://api.deezer.com/2.0/album/47685332/image", handler.getListAlbum().get(0).getCover());
+ assertEquals("83325", handler.getListAlbum().get(0).getArtist().getId());
+ assertEquals("Shaka Ponk", handler.getListAlbum().get(0).getArtist().getName());
+
+ //Second album
+ assertEquals("1121440", handler.getListAlbum().get(1).getId());
+ assertEquals("The Geeks And The Jerkin' Socks", handler.getListAlbum().get(1).getTitle());
+ assertEquals("http://api.deezer.com/2.0/album/1121440/image", handler.getListAlbum().get(1).getCover());
+ assertEquals("83325", handler.getListAlbum().get(1).getArtist().getId());
+ assertEquals("Shaka Ponk", handler.getListAlbum().get(1).getArtist().getName());
+
+ LOG.debug("<>testCount");
+
+ // Recuperation du flux a parser
+ InputStream in = getClass().getResourceAsStream("../album-stupeflip.xml");
+
+ //TODO
+
+ LOG.debug("<>testParse");
+
+ // Recuperation du flux a parser
+ InputStream in = getClass().getResourceAsStream("album-stupeflip.xml");
+
+ //TODO
+
+ LOG.debug("<>find author=Shaka%20Ponk
+19:05:44,337 DEBUG fr.ensim.xml.deezer.AbstractSearchAlbum - http://api.deezer.com/2.0/search/album?q=Shaka%20Ponk&output=xml
+19:05:49,606 DEBUG fr.ensim.xml.deezer.sax.SAXSearchAlbums - >>readAlbums
+19:05:49,640 DEBUG fr.ensim.xml.deezer.sax.SAXSearchAlbums - <>albums
+19:05:49,641 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - http://api.deezer.com/2.0/album/47685332?output=xml
+19:05:54,764 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - >>find
+19:05:54,792 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - >>find
+19:05:54,793 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - >>albums
+19:05:54,793 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - http://api.deezer.com/2.0/album/1121440?output=xml
+19:05:59,968 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - >>find
+19:05:59,980 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - >>find
+19:05:59,981 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - >>albums
+19:05:59,981 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - http://api.deezer.com/2.0/album/7529289?output=xml
+19:06:05,117 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - >>find
+19:06:05,160 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - >>find
+19:06:05,161 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - >>albums
+19:06:05,161 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - http://api.deezer.com/2.0/album/625593?output=xml
+19:06:10,336 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - >>find
+19:06:10,366 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - >>find
+19:06:10,367 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - >>albums
+19:06:10,367 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - http://api.deezer.com/2.0/album/8910295?output=xml
+19:06:15,501 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - >>find
+19:06:15,533 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - >>find
+19:06:15,534 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - >>albums
+19:06:15,534 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - http://api.deezer.com/2.0/album/7084004?output=xml
+19:06:20,680 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - >>find
+19:06:20,728 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - >>find
+19:06:20,728 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - >>albums
+19:06:20,728 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - http://api.deezer.com/2.0/album/56633592?output=xml
+19:06:25,858 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - >>find
+19:06:25,861 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - >>find
+19:06:25,861 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - >>albums
+19:06:25,861 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - http://api.deezer.com/2.0/album/637662?output=xml
+19:06:30,979 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - >>find
+19:06:31,007 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - >>find
+19:06:31,007 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - >>albums
+19:06:31,008 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - http://api.deezer.com/2.0/album/43199651?output=xml
+19:06:36,143 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - >>find
+19:06:36,150 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - >>find
+19:06:36,150 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - >>albums
+19:06:36,150 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - http://api.deezer.com/2.0/album/7327738?output=xml
+19:06:41,280 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - >>find
+19:06:41,284 DEBUG fr.ensim.xml.deezer.dom.SearchAlbumTracks - >>find
+19:06:41,288 DEBUG fr.ensim.xml.deezer.stax.HtmlAlbum - >>write
+19:06:41,303 DEBUG fr.ensim.xml.deezer.stax.HtmlAlbum - <