modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java
| 1
modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatWarComponent.java
| 33 ++++++----
modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/helper/FileContentDelegate.java
| 3
3 files changed, 24 insertions(+), 13 deletions(-)
New commits:
commit 5649eb36a46f7192aabd528d23b18c7324e2fc57
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Dec 8 16:41:19 2011 -0600
[BZ 761593] Update the code to correctly compute SHA 265 for the exploded war file.
The existing code was computing MD5 sums.
Also, removed warning supression code left behind from incorrect use of the message
digest generator.
diff --git
a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java
b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java
index aa48a20..f605e2d 100644
---
a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java
+++
b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java
@@ -228,7 +228,6 @@ public class TomcatVHostComponent extends
MBeanResourceComponent<TomcatServerCom
return report;
}
- @SuppressWarnings("static-access")
private void warCreate(CreateResourceReport report) throws Exception {
ResourcePackageDetails details = report.getPackageDetails();
PackageDetailsKey key = details.getKey();
diff --git
a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/helper/FileContentDelegate.java
b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/helper/FileContentDelegate.java
index 42dbde7..a93eddf 100644
---
a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/helper/FileContentDelegate.java
+++
b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/helper/FileContentDelegate.java
@@ -81,7 +81,6 @@ public class FileContentDelegate {
* it is written, using the package name as the base directory; if
<code>false</code> the
* content will be written to directly to a file using the package
name as the file name
*/
- @SuppressWarnings("static-access")
public void createContent(File destination, File content, boolean unzip) {
try {
if (unzip) {
@@ -101,7 +100,7 @@ public class FileContentDelegate {
}
Attributes attribs = manifest.getMainAttributes();
- String sha = new
MessageDigestGenerator(MessageDigestGenerator.SHA_256).getDigestString(content);
+ String sha = new
MessageDigestGenerator(MessageDigestGenerator.SHA_256).calcDigestString(content);
attribs.putValue("RHQ-Sha256", sha);
FileOutputStream outputStream = new FileOutputStream(manifestFile);
commit dfd95c7e1c529aea661847acc6c21432be680946
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Dec 8 16:38:17 2011 -0600
[BZ 761593] The plugin was not obtaining the SHA from the manifest file. Since the
deployment is exploded the existing code would just fail.
diff --git
a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatWarComponent.java
b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatWarComponent.java
index d865f56..933792f 100644
---
a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatWarComponent.java
+++
b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatWarComponent.java
@@ -34,6 +34,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
+import java.util.jar.Manifest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -450,8 +451,8 @@ public class TomcatWarComponent extends
MBeanResourceComponent<TomcatVHostCompon
private List<EmsBean> getVHosts() {
EmsConnection emsConnection = getEmsConnection();
String query = QUERY_TEMPLATE_HOST;
- query = query.replace("%PATH%",
getResourceContext().getPluginConfiguration().getSimpleValue(
- PROPERTY_CONTEXT_ROOT, ""));
+ query = query.replace("%PATH%",
+
getResourceContext().getPluginConfiguration().getSimpleValue(PROPERTY_CONTEXT_ROOT,
""));
ObjectNameQueryUtility queryUtil = new ObjectNameQueryUtility(query);
List<EmsBean> mBeans =
emsConnection.queryBeans(queryUtil.getTranslatedQuery());
return mBeans;
@@ -633,9 +634,15 @@ public class TomcatWarComponent extends
MBeanResourceComponent<TomcatVHostCompon
return packages;
}
- // TODO: if needed we can speed this up by looking in the ResourceContainer's
installedPackage
- // list for previously discovered packages. If there use the sha256 from that record.
We'd have to
- // get access to that info by adding access in
org.rhq.core.pluginapi.content.ContentServices
+ /**
+ * Retrieve SHA 256 for a deployed app.
+ * 1) If the app is exploded then look into the manifest file for the RHQ-Sha265
attribute.
+ * The SHA should have been computed and the attribute added during package
deployment.
+ * 2) If the app is not exploded then compute the SHA256 for the archive.
+ *
+ * @param file application file
+ * @return the SHA 256
+ */
private String getSHA256(File file) {
String sha256 = null;
@@ -644,8 +651,15 @@ public class TomcatWarComponent extends
MBeanResourceComponent<TomcatVHostCompon
//if the filesize of discovered package is null then it's an exploded and
deployed war/ear.
File app = new File(file.getPath());
if (app.isDirectory()) {
- File associatedWarFile = new File(app.getAbsolutePath() +
".war");
- sha256 = new
MessageDigestGenerator(MessageDigestGenerator.SHA_256).calcDigestString(associatedWarFile);
+ File manifestFile = new File(app.getAbsolutePath(),
"META-INF/MANIFEST.MF");
+ InputStream manifestStream = new FileInputStream(manifestFile);
+ Manifest manifest = null;
+ try {
+ manifest = new Manifest(manifestStream);
+ sha256 =
manifest.getMainAttributes().getValue("RHQ-Sha256");
+ } finally {
+ manifestStream.close();
+ }
} else {
sha256 = new
MessageDigestGenerator(MessageDigestGenerator.SHA_256).calcDigestString(app);
}
@@ -733,9 +747,8 @@ public class TomcatWarComponent extends
MBeanResourceComponent<TomcatVHostCompon
File file = new File(fileName);
if (!file.exists()) {
- log
- .warn("Could not delete web application files (perhaps removed
manually?). Proceeding with resource removal for: "
- + fileName);
+ log.warn("Could not delete web application files (perhaps removed
manually?). Proceeding with resource removal for: "
+ + fileName);
} else {
deleteApp(pluginConfiguration, file, false, true);
}
Show replies by date