Skip to content

Commit bc549af

Browse files
mmoquiEmmanuel Hugonnet
authored andcommitted
Integrating the HornetQ fix
1 parent 3dc82e6 commit bc549af

16 files changed

+166
-2
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<groupId>com.silverpeas</groupId>
1212
<artifactId>installation</artifactId>
1313
<version>5.12-SNAPSHOT</version>
14-
<name>Silverpeas Installation Package</name>
14+
<name>Silverpeas Installation Package - ${project.version}</name>
1515
<description>Builds the Silverpeas installation package</description>
1616

1717
<scm>

src/main/config/settings/jboss6/linux/JBossSettings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
<!-- secure JBoss server -->
1515
<script name="securejboss.groovy" />
16+
17+
<!-- upgrade HornetQ in JBoss if old version -->
18+
<script name="upgradeHornetq.groovy" />
1619

1720
<!-- configure HornetQ JMS -->
1821
<script name="configHornetq.groovy" />

src/main/config/settings/jboss6/windows/JBossSettings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
<!-- secure JBoss server -->
1616
<script name="securejboss.groovy" />
17+
18+
<!-- upgrade HornetQ in JBoss if old version -->
19+
<script name="upgradeHornetq.groovy" />
1720

1821
<!-- configure HornetQ JMS -->
1922
<script name="configHornetq.groovy" />

src/main/resources/assemblies/assembly-linux.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,14 @@
3737
<includes>
3838
<include>**/*.xml</include>
3939
</includes>
40-
</fileSet>
40+
</fileSet>
41+
<fileSet>
42+
<outputDirectory>bin/jar/</outputDirectory>
43+
<directory>src/main/upgrades</directory>
44+
<includes>
45+
<include>*/*</include>
46+
</includes>
47+
</fileSet>
4148
</fileSets>
4249
<files>
4350
<file>

src/main/resources/assemblies/assembly-windows.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@
7373
<include>**/*.xml</include>
7474
</includes>
7575
</fileSet>
76+
<fileSet>
77+
<outputDirectory>bin/jar/</outputDirectory>
78+
<directory>src/main/upgrades</directory>
79+
<includes>
80+
<include>*/*</include>
81+
</includes>
82+
</fileSet>
7683
</fileSets>
7784
<dependencySets>
7885
<dependencySet>
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
#!/usr/bin/groovy
2+
3+
import java.security.MessageDigest
4+
import org.apache.commons.io.FileUtils
5+
import org.apache.commons.io.FileExistsException
6+
7+
/**
8+
* Short name of the product to upgrade.
9+
*/
10+
ProductName = 'hornetq'
11+
12+
/**
13+
* Path of the directory in which the libraries of the new product version are available.
14+
*/
15+
SourceLibsPath = "${SILVERPEAS_HOME}/bin/jar/hornetq"
16+
17+
/**
18+
* Libraries of tier-party product embedded in the JBoss AS are distributed into several
19+
* locations in a JBoss installation (JBOSS_HOME): common/libs, client/, and server/<profile>/deploy
20+
* for RAs.
21+
* Below are defined the descriptors on the libraries to upgrade.
22+
*/
23+
def JBossCommonLibs = [
24+
path: "${JBOSS_HOME}/common/lib",
25+
libs: ['hornetq-core.jar', 'hornetq-bootstrap.jar', 'hornetq-jboss-as-integration.jar',
26+
'hornetq-jms.jar', 'hornetq-logging.jar', 'netty.jar'],
27+
copied: []
28+
]
29+
30+
def JBossClientLibs = [
31+
path: "${JBOSS_HOME}/client",
32+
libs: ['hornetq-core-client.jar', 'hornetq-jms-client.jar', 'netty.jar'],
33+
copied: []
34+
]
35+
36+
def JBossRAs = [
37+
path: "${JBOSS_HOME}/server/${JBOSS_SERVER_PROFILE}/deploy",
38+
libs: ['jms-ra.rar'],
39+
copied: []
40+
]
41+
42+
/**
43+
* The descriptors carrying the information about the libraries implied in the upgrade.
44+
*/
45+
JBossLibsInUpdate = [JBossCommonLibs, JBossClientLibs, JBossRAs]
46+
47+
void die(String msg) {
48+
throw new RuntimeException(msg)
49+
}
50+
51+
String md5sum(String f) {
52+
MessageDigest digest = MessageDigest.getInstance("MD5")
53+
new File(f).withInputStream() { input ->
54+
byte[] buffer = new byte[8192]
55+
int read = 0
56+
while( (read = input.read(buffer)) > 0) {
57+
digest.update(buffer, 0, read);
58+
}
59+
}
60+
byte[] md5sum = digest.digest()
61+
return new BigInteger(1, md5sum).toString(16).padLeft(32, '0')
62+
}
63+
64+
def setUpBackup() {
65+
BACKUP_DIR = new File("${FileUtils.getTempDirectoryPath()}/${ProductName}")
66+
RESTORE_ERROR = false
67+
if (BACKUP_DIR.exists())
68+
try {
69+
FileUtils.forceDelete(BACKUP_DIR)
70+
} catch(Exception ex) {
71+
die "ERROR: cannot remove a previous temporary directory: ${ex.message}. Stop the upgrade"
72+
}
73+
if (!BACKUP_DIR.mkdirs())
74+
die 'ERROR: cannot create temporary directory! Stop the upgrade'
75+
}
76+
77+
def tearDownBackup() {
78+
if (!RESTORE_ERROR)
79+
try {
80+
FileUtils.forceDelete(BACKUP_DIR)
81+
} catch(Exception ex) {
82+
println "WARNING: ${ex.message}"
83+
}
84+
}
85+
86+
def copyLibs(descriptor) {
87+
descriptor.libs.each { lib ->
88+
try {
89+
FileUtils.moveToDirectory(new File("${descriptor.path}/${lib}"), BACKUP_DIR, false)
90+
} catch(FileExistsException ex) {
91+
}
92+
descriptor.copied << lib
93+
File source = new File("${SourceLibsPath}/${lib}")
94+
if (source.isFile())
95+
FileUtils.copyFileToDirectory(source, new File("${descriptor.path}"))
96+
else if (source.isDirectory())
97+
FileUtils.copyDirectoryToDirectory(source, new File("${descriptor.path}"))
98+
}
99+
}
100+
101+
def restoreLibs(descriptor) {
102+
descriptor.copied.each { lib ->
103+
try {
104+
File source = new File("${BACKUP_DIR.path}/${lib}")
105+
if (source.isFile())
106+
FileUtils.copyFileToDirectory(source, new File("${descriptor.path}"))
107+
else (source.isDirectory)
108+
FileUtils.copyDirectoryToDirectory(source, new File("${descriptor.path}"))
109+
} catch(Exception ex) {
110+
println "WARNING: cannot restore ${lib}. ${ex.message}"
111+
RESTORE_ERROR = true
112+
}
113+
}
114+
}
115+
116+
String libToCheck = JBossLibsInUpdate[0].libs[0]
117+
String currentMD5 = md5sum "${SourceLibsPath}/${libToCheck}"
118+
String newerMD5 = md5sum "${JBossLibsInUpdate[0].path}/${libToCheck}"
119+
if (currentMD5 != newerMD5) {
120+
try {
121+
println 'Old HornetQ version detected: upgrade it...'
122+
setUpBackup()
123+
try {
124+
JBossLibsInUpdate.each { descriptor ->
125+
copyLibs descriptor
126+
}
127+
} catch(Exception ex) {
128+
println "ERROR: ${ex.message}. Restores the original ${ProductName}..."
129+
JBossLibsInUpdate.each { descriptor ->
130+
restoreLibs descriptor
131+
}
132+
if (RESTORE_ERROR)
133+
println "INFO: Some error has occured while restoring the original ${ProductName} in JBoss.\n" +
134+
"Theses libraries are in ${BACKUP_DIR.path}, please restore them by hand"
135+
die "An error occured while upgrading ${ProductName}. Stop the upgrade."
136+
} finally {
137+
tearDownBackup()
138+
}
139+
} catch(Exception ex) {
140+
println ex.message
141+
return 1
142+
}
143+
}
144+
return 0
5.69 KB
Binary file not shown.
Binary file not shown.
1.44 MB
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)