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;
} |
Partager