Bonjour,

Je suis actuellement confronté à un problème pour lire des ear/war inclus dans des zip.
Le problème est le suivant : j'ai un zip stocké sur le réseau. Ce zip contient un ear que je dois extraire. Cet ear contient lien un war que je dois également extraire. Enfin je dois lister les fichiers contenu dans ce fameux war.

J'ai donc une architecture du type :
zip
+ dossier(s)
+ fichier(s) divers
+ ear
--+ dossier(s)
--+ fichier(s) divers
--+ war
-----+ fichier 1
-----+ fichier 2
-----+ fichier 3

J'arrive à récupérer le zip sans problème ainsi qu'à le lire... Mais je n'arrive pas à chopper l'ear ensuite :-/


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
 
/**
 * Récupère sur le nexus le fichier libelleEar.txt de la Version
 * 
 * @param libelleEar
 * @param versionFonctionnelle
 * @param libelleGroupId
 * @return
 * @throws CommonException
 */
private String getFichierVersion(String lien, String ear, String war) {
	URL url; 				// represents the location of the file we want to dl.
	URLConnection con; 		// represents a connection to the url we want to dl.
	DataInputStream dis; 	// input stream that will read data from the file.
	FileOutputStream fos; 	// used to write data from inut stream to file.
	byte[] fileDataZip; 	// byte aray used to hold data from downloaded file.
	String verMetis = null;
 
try {
		if (log.isDebugEnabled())
			log.debug("Lien: " + lien);
		url = new URL(lien);
		con = url.openConnection();
		dis = new DataInputStream(con.getInputStream());
		fileDataZip = new byte[con.getContentLength()];
		for (int x = 0; x < fileDataZip.length; x++) {
			fileDataZip[x] = dis.readByte();
		}
		dis.close();
 
		ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(fileDataZip);
		ZipInputStream zis = new ZipInputStream(byteArrayInputStream);
 
		ZipEntry entry;
		// while there are entries I process them
		while ((entry = zis.getNextEntry()) != null) {
			if (log.isDebugEnabled())
				log.debug("entryZip: " + entry.getName());
			if (entry.getName().contains(ear)) {
				log.info("Extraction ear " + ear);
				File earZip = new File(entry.getName());
 
				/* Recherche du war */
				ZipFile earFile = new ZipFile(earZip);
				Enumeration eear = earFile.entries();
				while(eear.hasMoreElements())
					{ZipEntry entryEar = (ZipEntry)eear.nextElement();
					if(entryEar.getName().equals(war))
						{log.info("Extraction war " + war);
						File warZip = new File(entryEar.getName());
 
						/* Recherche du metis-core */
						ZipFile warFile = new ZipFile(warZip);
						Enumeration ewar = warFile.entries();
						while(ewar.hasMoreElements())
							{ZipEntry entryWar = (ZipEntry)ewar.nextElement();
							if(entryWar.getName().startsWith("metis-core"))
								{verMetis=entryWar.getName().substring(11,
								entryWar.getName().indexOf('.'));
								log.info("Version de Metis :" + verMetis);
								return verMetis;}
							}
						break;}
					}
				break;}
			}
	} catch (MalformedURLException m) {
	} catch (IOException io) {
	}
	return verMetis;
}