Subversion Repositories eFlore/Applications.cel

Rev

Rev 990 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 990 Rev 991
Line 2... Line 2...
2
 
2
 
3
import java.util.HashMap;
3
import java.util.HashMap;
4
import java.util.Iterator;
4
import java.util.Iterator;
Line 5... Line -...
5
import java.util.Set;
-
 
6
 
-
 
7
import com.google.appengine.api.memcache.MemcacheServicePb.MemcacheDeleteRequest.Item;
5
import java.util.Set;
8
import com.google.gwt.core.client.GWT;
6
 
9
import com.google.gwt.json.client.JSONObject;
7
import com.google.gwt.json.client.JSONObject;
10
import com.google.gwt.xml.client.Document;
8
import com.google.gwt.xml.client.Document;
11
import com.google.gwt.xml.client.Node;
9
import com.google.gwt.xml.client.Node;
Line 307... Line 305...
307
	 * Renvoie un tableau nom / valeur de toutes les metadonnées Iptc
305
	 * Renvoie un tableau nom / valeur de toutes les metadonnées Iptc
308
	 * 
306
	 * 
309
	 * @return les métadonnées iptc
307
	 * @return les métadonnées iptc
310
	 */
308
	 */
311
	public String[][] getMetadonnesIptc() {
309
	public String[][] getMetadonnesIptc() {
312
		
-
 
313
		String[][] metaIptc = {{},{}};
-
 
314
		
-
 
315
		String xml = renvoyerValeurCorrecte("meta_iptc");
310
		return getMetadonneesXml("meta_iptc");
316
		String invalidXmlPattern = "[^"
-
 
317
            + "\\u0009\\u000A\\u000D"
-
 
318
            + "\\u0020-\\uD7FF"
-
 
319
            + "\\uE000-\\uFFFD"
-
 
320
            + "\\u10000-\\u10FFFF"
-
 
321
            + "]+";
-
 
322
		xml = xml.replaceAll(invalidXmlPattern, " ");
-
 
323
		
-
 
324
		//FIXME: pq ça marche pour exif et pas pour iptc ?
-
 
325
		try {
-
 
326
			Document d = XMLParser.parse(xml);
-
 
327
			if(d.hasChildNodes()) {
-
 
328
				NodeList attributs = d.getFirstChild().getChildNodes();
-
 
329
				
-
 
330
				int taille = attributs.getLength();
-
 
331
				metaIptc = new String[taille][2];
-
 
332
				
-
 
333
				for(int i = 0; i < taille; i++)  {
-
 
334
					if(attributs.item(i) != null) {
-
 
335
						XMLParser.removeWhitespace(attributs.item(i));
-
 
336
						attributs.item(i).normalize();
-
 
337
						metaIptc[i][0] = attributs.item(i).getNodeName();
-
 
338
						if(attributs.item(i).hasChildNodes()) {
-
 
339
							Node valeur = attributs.item(i).getFirstChild();
-
 
340
							if(valeur.getNodeType() == Node.TEXT_NODE) {
-
 
341
								metaIptc[i][1] = ((Text)valeur).getData();
-
 
342
							} else {
-
 
343
								metaIptc[i][1] = "";
-
 
344
							}
-
 
345
						}
-
 
346
					}
-
 
347
				}
-
 
348
			}
-
 
349
			
-
 
350
			return metaIptc;
-
 
351
		} catch(DOMParseException e) {
-
 
352
			
-
 
353
		}	
-
 
354
		
-
 
355
		return metaIptc;
-
 
356
	}
311
	}
Line 357... Line 312...
357
 
312
 
358
	/**
313
	/**
359
	 * Renvoie un tableau nom / valeur de toutes les metadonnées Exif
314
	 * Renvoie un tableau nom / valeur de toutes les metadonnées Exif
360
	 * 
315
	 * 
361
	 * @return les métadonnées Exif
316
	 * @return les métadonnées Exif
362
	 */
317
	 */
-
 
318
	public String[][] getMetadonnesExif() {
-
 
319
		return getMetadonneesXml("meta_exif");
-
 
320
	}
-
 
321
	
Line 363... Line 322...
363
	public String[][] getMetadonnesExif() {
322
	private String[][] getMetadonneesXml(String type) {
Line 364... Line 323...
364
		
323
		
Line 365... Line 324...
365
		String[][] metaExif = {{},{}};
324
		String[][] metadonnees = {{},{}};
366
		
325
		
367
		String xml = renvoyerValeurCorrecte("meta_exif");
326
		String xml = renvoyerValeurCorrecte(type);
368
		
327
		
Line 378... Line 337...
378
			Document d = XMLParser.parse(xml);
337
			Document d = XMLParser.parse(xml);
379
			if(d.hasChildNodes()) {
338
			if(d.hasChildNodes()) {
380
				NodeList attributs = d.getFirstChild().getChildNodes();
339
				NodeList attributs = d.getFirstChild().getChildNodes();
Line 381... Line 340...
381
				
340
				
382
				int taille = attributs.getLength();
341
				int taille = attributs.getLength();
Line 383... Line 342...
383
				metaExif = new String[taille][2];
342
				metadonnees = new String[taille][2];
384
				
343
				
385
				for(int i = 0; i < taille; i++)  {
344
				for(int i = 0; i < taille; i++)  {
386
					if(attributs.item(i) != null) {
345
					if(attributs.item(i) != null) {
387
						XMLParser.removeWhitespace(attributs.item(i));
346
						XMLParser.removeWhitespace(attributs.item(i));
388
						attributs.item(i).normalize();
347
						attributs.item(i).normalize();
389
						metaExif[i][0] = attributs.item(i).getNodeName();
348
						metadonnees[i][0] = attributs.item(i).getNodeName();
390
						if(attributs.item(i).hasChildNodes()) {
349
						if(attributs.item(i).hasChildNodes()) {
391
							Node valeur = attributs.item(i).getFirstChild();
350
							Node valeur = attributs.item(i).getFirstChild();
392
							if(valeur.getNodeType() == Node.TEXT_NODE) {
351
							if(valeur.getNodeType() == Node.TEXT_NODE) {
393
								metaExif[i][1] = ((Text)valeur).getData();
352
								metadonnees[i][1] = ((Text)valeur).getData();
394
							} else {
353
							} else {
395
								metaExif[i][1] = "";
354
								metadonnees[i][1] = "";
396
							}
355
							}
397
						}
356
						}
398
					}
357
					}
399
				}
-
 
400
			}
-
 
401
			
358
				}
Line 402... Line 359...
402
			return metaExif;
359
			}
Line 403... Line 360...
403
		} catch(DOMParseException e) {
360
		} catch(DOMParseException e) {
404
			
-
 
405
		}	
361
			
Line 406... Line 362...
406
		
362
		}	
407
		return metaExif;
363
		
408
 
364
		return metadonnees;